Class: MCollective::Generators::AgentGenerator
- Defined in:
- lib/mcollective/generators/agent_generator.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#ddl ⇒ Object
Returns the value of attribute ddl.
Attributes inherited from Base
#meta, #mod_name, #plugin_name
Instance Method Summary collapse
- #action_help ⇒ Object
- #create_ddl ⇒ Object
- #create_plugin_content ⇒ Object
-
#initialize(plugin_name, actions = [], name = nil, description = nil, author = nil, license = nil, version = nil, url = nil, timeout = nil) ⇒ AgentGenerator
constructor
A new instance of AgentGenerator.
Methods inherited from Base
#create_metadata_string, #create_plugin_string, #write_plugins
Constructor Details
#initialize(plugin_name, actions = [], name = nil, description = nil, author = nil, license = nil, version = nil, url = nil, timeout = nil) ⇒ AgentGenerator
Returns a new instance of AgentGenerator.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mcollective/generators/agent_generator.rb', line 6 def initialize(plugin_name, actions=[], name=nil, description=nil, =nil, license=nil, version=nil, url=nil, timeout=nil) super(name, description, , license, version, url, timeout) @plugin_name = plugin_name @actions = actions || [] @ddl = create_ddl @mod_name = "Agent" @pclass = "RPC::Agent" @content = create_plugin_content @plugin = create_plugin_string write_plugins end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
4 5 6 |
# File 'lib/mcollective/generators/agent_generator.rb', line 4 def content @content end |
#ddl ⇒ Object
Returns the value of attribute ddl.
4 5 6 |
# File 'lib/mcollective/generators/agent_generator.rb', line 4 def ddl @ddl end |
Instance Method Details
#action_help ⇒ Object
44 45 46 47 |
# File 'lib/mcollective/generators/agent_generator.rb', line 44 def action_help action_snippet = File.read(File.join(File.dirname(__FILE__), "templates", "action_snippet.erb")) ERB.new(action_snippet).result end |
#create_ddl ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mcollective/generators/agent_generator.rb', line 20 def create_ddl action_text = "" @actions.each_with_index do |action, i| action_text += "action \"#{action}\", :description => \"%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 + action_text end |
#create_plugin_content ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mcollective/generators/agent_generator.rb', line 32 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 |