Class: StatsdTestHarness::Tool

Inherits:
Object
  • Object
show all
Defined in:
lib/statsd_test_harness/tool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Tool

Returns a new instance of Tool.



7
8
9
10
11
12
13
14
# File 'lib/statsd_test_harness/tool.rb', line 7

def initialize(attrs={})
  @name = attrs[:name]
  @command = attrs[:command]
  @options = attrs[:options]
  @label = attrs[:label]
  @postprocessor = attrs[:postprocessor]
  @ignore_return_value = attrs[:ignore_return_value]
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



5
6
7
# File 'lib/statsd_test_harness/tool.rb', line 5

def command
  @command
end

#ignore_return_valueObject (readonly)

Returns the value of attribute ignore_return_value.



5
6
7
# File 'lib/statsd_test_harness/tool.rb', line 5

def ignore_return_value
  @ignore_return_value
end

#labelObject (readonly)

Returns the value of attribute label.



5
6
7
# File 'lib/statsd_test_harness/tool.rb', line 5

def label
  @label
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/statsd_test_harness/tool.rb', line 5

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/statsd_test_harness/tool.rb', line 5

def options
  @options
end

#postprocessorObject (readonly)

Returns the value of attribute postprocessor.



5
6
7
# File 'lib/statsd_test_harness/tool.rb', line 5

def postprocessor
  @postprocessor
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
# File 'lib/statsd_test_harness/tool.rb', line 16

def run
  output = `#{self.command} #{self.options}`
  puts output
  data = self.postprocessor.new(output)
  if $?.to_i > 0 && ! ignore_return_value
    raise "Test run returned non-zero status, results not submitted."
  end
  data
end