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



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

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
36
37
38
# File 'lib/bumps/results_push_formatter.rb', line 27

def push results
  uri = URI.parse(Bumps::Configuration.push_url)
  begin
    response, body = Net::HTTP.post_form uri, {:results => results}
  rescue Exception => e
    @io << failure_message(e.message)
    return
  end
  
  response_ok = response.code_type == Net::HTTPOK 
  @io << (response_ok ? success_message : failure_message("HTTP #{response.code}: \n#{response.body}"))
end

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

Returns:

  • (Boolean)


44
45
46
# File 'lib/bumps/results_push_formatter.rb', line 44

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