Sha256: 1c0ae303d97436546826d5dc30a0ce8760272742bc2604683ab4403c940342f9

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

#!/usr/bin/env ruby -wKU

require "pp"

module Scout
  class Command
    class Test < Command
      def run
        plugin, options = @args
        
        # read the plugin_code from the file specified
        plugin_code    = File.read(plugin)
        plugin_options = if options.to_s[0, 1] == "{"
          eval(options)  # options from command-line
        elsif options
          # 
          # read the plugin_options from the YAML file specified,
          # parse each option and use the default value specified
          # in the options as the value to be passed to the test plugin
          # 
          Hash[ *File.open(options) { |f| YAML.load(f) }["options"].
                 map { |name, details| [name, details["default"]] }.flatten ]
        else
          Hash.new
        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'   => plugin_options,
                                'path'      => plugin )
          scout.show_checkin(:pp)
        end  
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scout-4.0.2 lib/scout/command/test.rb
scout-4.0.1 lib/scout/command/test.rb
scout-4.0.0 lib/scout/command/test.rb