Class: Scout::Command::Test
- Inherits:
-
Scout::Command
- Object
- Scout::Command
- Scout::Command::Test
- Defined in:
- lib/es-scout/command/test.rb
Constant Summary
Constants inherited from Scout::Command
Instance Attribute Summary
Attributes inherited from Scout::Command
#config_dir, #history, #log_path, #server
Instance Method Summary collapse
Methods inherited from Scout::Command
#create_pid_file_or_exit, dispatch, #initialize, #level, #log, program_name, #program_name, program_path, #program_path, usage, #usage, user, #user, #verbose?
Constructor Details
This class inherits a constructor from Scout::Command
Instance Method Details
#run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/es-scout/command/test.rb', line 8 def run create_pid_file_or_exit plugin, * = @args # read the plugin_code from the file specified plugin_code = File.read(plugin) = {} # deal with embedded options yaml if = Scout::Plugin.(plugin_code) =Scout::PluginOptions.from_yaml() if .error puts "Problem parsing option definition in the plugin code (ignoring and continuing):" puts else puts "== Plugin options: " puts .to_s .select{|o|o.has_default?}.each{|o|[o.name]=o.default} end else puts "== This plugin doesn't have option metadata." end # provided_options are what the user gave us in the command line. Here, we merge them into # the defaults we've already established (if any) for this run. .each do |e| if e.include?('=') k,v=e.split('=',2) [k]=v else puts "ERROR: Option '#{e}' is no good -- provided options should be in the format name=value." end end if .any? puts "== Running plugin with: #{.to_a.map{|a| "#{a.first}=#{a.last}"}.join('; ') }" else puts "== You haven't provided any options for running this plugin." end Scout::Server.new(nil, nil, history, log) do |scout| scout.prepare_checkin scout.process_plugin( 'interval' => 0, 'plugin_id' => 1, 'name' => "Local Plugin", 'code' => plugin_code, 'options' => , 'path' => plugin ) puts "== Output:" scout.show_checkin(:pp) end end |