Class: Bumps::ResultsPushFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/bumps/results_push_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step_mother, io, options) ⇒ ResultsPushFormatter

Returns a new instance of ResultsPushFormatter.



9
10
11
12
13
# File 'lib/bumps/results_push_formatter.rb', line 9

def initialize(step_mother, io, options)
  @step_mother = step_mother
  @io = io
  @options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



37
38
39
# File 'lib/bumps/results_push_formatter.rb', line 37

def method_missing(method, *args, &block)
  formatter.send(method, *args, &block)
end

Instance Attribute Details

#formatterObject (readonly)

Returns the value of attribute formatter.



7
8
9
# File 'lib/bumps/results_push_formatter.rb', line 7

def formatter
  @formatter
end

#resultsObject (readonly)

Returns the value of attribute results.



7
8
9
# File 'lib/bumps/results_push_formatter.rb', line 7

def results
  @results
end

Instance Method Details

#after_features(features) ⇒ Object



21
22
23
24
25
# File 'lib/bumps/results_push_formatter.rb', line 21

def after_features features
  formatter.after_features features
  results.close
  push results.string
end

#before_features(features) ⇒ Object



15
16
17
18
19
# File 'lib/bumps/results_push_formatter.rb', line 15

def before_features features
  @results = StringIO.open
  @formatter = Bumps::Configuration.results_formatter.new @step_mother, results, @options
  formatter.before_features features
end

#push(results) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/bumps/results_push_formatter.rb', line 27

def push results
  uri = URI.parse(Bumps::Configuration.push_url)
  response, body = Net::HTTP.post_form uri, {:results => results}
  if response.code_type == Net::HTTPOK
    @io << "Successfully pushed results to #{Bumps::Configuration.push_url}\n\n"
  else
    @io << "Failed to push results to #{Bumps::Configuration.push_url} - HTTP #{response.code}: \n#{response.body}\n\n"
  end
end

#respond_to?(message, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/bumps/results_push_formatter.rb', line 41

def respond_to?(message, include_private = false)
  super(message, include_private) || formatter.respond_to?(message, include_private)
end