X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=lib%2Fmcollective%2Fgenerators%2Fagent_generator.rb;fp=lib%2Fmcollective%2Fgenerators%2Fagent_generator.rb;h=577125ed0c4a930404e26469a79a69872e360890;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/lib/mcollective/generators/agent_generator.rb b/lib/mcollective/generators/agent_generator.rb new file mode 100644 index 0000000..577125e --- /dev/null +++ b/lib/mcollective/generators/agent_generator.rb @@ -0,0 +1,51 @@ +module MCollective + module Generators + class AgentGenerator \"%ACTIONDESCRIPTION%\" do\n" + action_text += action_help if i == 0 + action_text += "end\n" + action_text += "\n" unless @actions.size == (i + 1) + end + # Use inherited method to create metadata part of the ddl + create_metadata_string + action_text + end + + def create_plugin_content + content_text = "" + + # Add actions to agent file + @actions.each_with_index do |action, i| + content_text += "%6s%s" % [" ", "action \"#{action}\" do\n"] + content_text += "%6s%s" % [" ", "end\n"] + content_text += "\n" unless @actions.size == (i + 1) + end + content_text + end + + def action_help + action_snippet = File.read(File.join(File.dirname(__FILE__), "templates", "action_snippet.erb")) + ERB.new(action_snippet).result + end + end + end +end