3 class AgentGenerator<Base
5 attr_accessor :ddl, :content
7 def initialize(plugin_name, actions = [], name = nil, description = nil, author = nil ,
8 license = nil, version = nil, url = nil, timeout = nil)
10 super(name, description, author, license, version, url, timeout)
11 @plugin_name = plugin_name
12 @actions = actions || []
15 @pclass = "RPC::Agent"
16 @content = create_plugin_content
17 @plugin = create_plugin_string
23 @actions.each_with_index do |action, i|
24 action_text += "action \"#{action}\", :description => \"%ACTIONDESCRIPTION%\" do\n"
25 action_text += action_help if i == 0
26 action_text += "end\n"
27 action_text += "\n" unless @actions.size == (i + 1)
29 # Use inherited method to create metadata part of the ddl
30 create_metadata_string + action_text
33 def create_plugin_content
36 # Add actions to agent file
37 @actions.each_with_index do |action, i|
38 content_text += "%6s%s" % [" ", "action \"#{action}\" do\n"]
39 content_text += "%6s%s" % [" ", "end\n"]
40 content_text += "\n" unless @actions.size == (i + 1)
46 action_snippet = File.read(File.join(File.dirname(__FILE__), "templates", "action_snippet.erb"))
47 ERB.new(action_snippet).result