Class: MCollective::Generators::DataGenerator
- Defined in:
- lib/mcollective/generators/data_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
- #create_ddl ⇒ Object
- #create_plugin_content ⇒ Object
-
#initialize(plugin_name, outputs = [], name = nil, description = nil, author = nil, license = nil, version = nil, url = nil, timeout = nil) ⇒ DataGenerator
constructor
A new instance of DataGenerator.
Methods inherited from Base
#create_metadata_string, #create_plugin_string, #write_plugins
Constructor Details
#initialize(plugin_name, outputs = [], name = nil, description = nil, author = nil, license = nil, version = nil, url = nil, timeout = nil) ⇒ DataGenerator
Returns a new instance of DataGenerator.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mcollective/generators/data_generator.rb', line 7 def initialize(plugin_name, outputs = [], name = nil, description = nil, = nil , license = nil, version = nil, url = nil, timeout = nil) super(name, description, , license, version, url, timeout) @mod_name = "Data" @pclass = "Base" @plugin_name = plugin_name @outputs = outputs @ddl = create_ddl @content = create_plugin_content @plugin = create_plugin_string write_plugins end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
5 6 7 |
# File 'lib/mcollective/generators/data_generator.rb', line 5 def content @content end |
#ddl ⇒ Object
Returns the value of attribute ddl.
5 6 7 |
# File 'lib/mcollective/generators/data_generator.rb', line 5 def ddl @ddl end |
Instance Method Details
#create_ddl ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mcollective/generators/data_generator.rb', line 21 def create_ddl query_text = "dataquery :description => \"Query information\" do\n" query_text += ERB.new(File.read(File.join(File.dirname(__FILE__), "templates", "data_input_snippet.erb"))).result @outputs.each_with_index do |output,i| query_text += "%2s%s" % [" ", "output :#{output},\n"] query_text += "%9s%s" % [" ", ":description => \"%DESCRIPTION%\",\n"] query_text += "%9s%s" % [" ", ":display_as => \"%DESCRIPTION%\"\n"] query_text += "\n" unless @outputs.size == (i + 1) end query_text += "end" # Use inherited method to create metadata part of the ddl + query_text end |
#create_plugin_content ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/mcollective/generators/data_generator.rb', line 38 def create_plugin_content content_text = "%6s%s" % [" ", "query do |what|\n"] @outputs.each do |output| content_text += "%8s%s" % [" ", "result[:#{output}] = nil\n"] end content_text += "%6s%s" % [" ", "end\n"] # Add actions to agent file content_text end |