Class: Debci::Graph
- Inherits:
-
Object
- Object
- Debci::Graph
- Defined in:
- lib/debci/graph.rb
Overview
This class represents different data charts for a specific suite and architecture.
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#fail ⇒ Object
Returns the value of attribute fail.
-
#pass ⇒ Object
Returns the value of attribute pass.
-
#pass_percentage ⇒ Object
Returns the value of attribute pass_percentage.
-
#tmpfail ⇒ Object
Returns the value of attribute tmpfail.
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
-
#current_value(field) ⇒ Object
Returns the value of the last data entry for the specified field.
-
#get_data ⇒ Object
Read the status data.
-
#initialize(repository, suite, architecture) ⇒ Graph
constructor
A new instance of Graph.
-
#previous_value(field) ⇒ Object
Returns the value of the second to last data entry for the specified field.
Constructor Details
#initialize(repository, suite, architecture) ⇒ Graph
Returns a new instance of Graph
13 14 15 16 17 18 |
# File 'lib/debci/graph.rb', line 13 def initialize(repository, suite, architecture) @repository = repository @suite = suite @architecture = architecture @data = get_data end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date
11 12 13 |
# File 'lib/debci/graph.rb', line 11 def date @date end |
#fail ⇒ Object
Returns the value of attribute fail
11 12 13 |
# File 'lib/debci/graph.rb', line 11 def fail @fail end |
#pass ⇒ Object
Returns the value of attribute pass
11 12 13 |
# File 'lib/debci/graph.rb', line 11 def pass @pass end |
#pass_percentage ⇒ Object
Returns the value of attribute pass_percentage
11 12 13 |
# File 'lib/debci/graph.rb', line 11 def pass_percentage @pass_percentage end |
#tmpfail ⇒ Object
Returns the value of attribute tmpfail
11 12 13 |
# File 'lib/debci/graph.rb', line 11 def tmpfail @tmpfail end |
#total ⇒ Object
Returns the value of attribute total
11 12 13 |
# File 'lib/debci/graph.rb', line 11 def total @total end |
Instance Method Details
#current_value(field) ⇒ Object
Returns the value of the last data entry for the specified field
21 22 23 24 |
# File 'lib/debci/graph.rb', line 21 def current_value(field) data = @data.send(field) data[-1] || 0 end |
#get_data ⇒ Object
Read the status data
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/debci/graph.rb', line 34 def get_data data = @repository.status_history(@suite, @architecture) return unless data entries = self entries.date = data.map { |entry| Time.parse(entry['date'] + ' UTC') } entries.pass = data.map { |entry| entry['pass'] } entries.fail = data.map { |entry| entry['fail'] } entries.tmpfail = data.map { |entry| entry['tmpfail'] ? entry['tmpfail'] : 0 } entries.total = data.map { |entry| entry['total'] } entries.pass_percentage = data.map { |entry| entry['pass'].to_f / entry['total'].to_f } entries end |
#previous_value(field) ⇒ Object
Returns the value of the second to last data entry for the specified field
28 29 30 31 |
# File 'lib/debci/graph.rb', line 28 def previous_value(field) data = @data.send(field) data[-2] || 0 end |