Class: Debci::Status
- Inherits:
-
Object
- Object
- Debci::Status
- Defined in:
- lib/debci/status.rb
Overview
This class represents one test execution.
Instance Attribute Summary (collapse)
-
- (Object) architecture
Returns the value of attribute architecture.
-
- (Object) blame
Returns the value of attribute blame.
-
- (Object) date
Returns the value of attribute date.
-
- (Object) duration_human
Returns the value of attribute duration_human.
-
- (Object) duration_seconds
Returns the value of attribute duration_seconds.
-
- (Object) message
Returns the value of attribute message.
-
- (Object) package
Returns the value of attribute package.
-
- (Object) previous_status
Returns the value of attribute previous_status.
-
- (Object) run_id
Returns the value of attribute run_id.
-
- (Object) status
Returns the value of attribute status.
-
- (Object) suite
Returns the value of attribute suite.
-
- (Object) version
Returns the value of attribute version.
Class Method Summary (collapse)
-
+ (Object) from_file(file)
Constructs a new object by reading the JSON status
file
.
Instance Method Summary (collapse)
-
- (Object) description
A longer version of the headline.
-
- (Object) headline
Returns a headline for this status object, to be used as a short description of the event it represents.
-
- (Boolean) newsworthy?
Returns
true
if this status object represents an important event, such as a package that used to pass started failing, of vice versa.
Instance Attribute Details
- (Object) architecture
Returns the value of attribute architecture
10 11 12 |
# File 'lib/debci/status.rb', line 10 def architecture @architecture end |
- (Object) blame
Returns the value of attribute blame
10 11 12 |
# File 'lib/debci/status.rb', line 10 def blame @blame end |
- (Object) date
Returns the value of attribute date
10 11 12 |
# File 'lib/debci/status.rb', line 10 def date @date end |
- (Object) duration_human
Returns the value of attribute duration_human
10 11 12 |
# File 'lib/debci/status.rb', line 10 def duration_human @duration_human end |
- (Object) duration_seconds
Returns the value of attribute duration_seconds
10 11 12 |
# File 'lib/debci/status.rb', line 10 def duration_seconds @duration_seconds end |
- (Object) message
Returns the value of attribute message
10 11 12 |
# File 'lib/debci/status.rb', line 10 def @message end |
- (Object) package
Returns the value of attribute package
10 11 12 |
# File 'lib/debci/status.rb', line 10 def package @package end |
- (Object) previous_status
Returns the value of attribute previous_status
10 11 12 |
# File 'lib/debci/status.rb', line 10 def previous_status @previous_status end |
- (Object) run_id
Returns the value of attribute run_id
10 11 12 |
# File 'lib/debci/status.rb', line 10 def run_id @run_id end |
- (Object) status
Returns the value of attribute status
10 11 12 |
# File 'lib/debci/status.rb', line 10 def status @status end |
- (Object) suite
Returns the value of attribute suite
10 11 12 |
# File 'lib/debci/status.rb', line 10 def suite @suite end |
- (Object) version
Returns the value of attribute version
10 11 12 |
# File 'lib/debci/status.rb', line 10 def version @version end |
Class Method Details
+ (Object) from_file(file)
Constructs a new object by reading the JSON status file
.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/debci/status.rb', line 33 def self.from_file(file) status = new return status unless File.exists?(file) data = nil begin File.open(file, 'r') do |f| data = JSON.load(f) end rescue JSON::ParserError true # nothing really end return status unless data status.run_id = data['run_id'] status.package = data['package'] status.version = data['version'] status.date = begin Time.parse(data.fetch('date', 'unknown') + ' UTC') rescue ArgumentError nil end status.status = data.fetch('status', :unknown).to_sym status.previous_status = data.fetch('previous_status', :unknown).to_sym status.blame = data['blame'] status.duration_seconds = begin Integer(data.fetch('duration_seconds', 0)) rescue ArgumentError nil end status.duration_human = data['duration_human'] status. = data['message'] status end |
Instance Method Details
- (Object) description
A longer version of the headline
28 29 30 |
# File 'lib/debci/status.rb', line 28 def description "The tests for #{package} #{status.upcase}ED on #{suite}/#{architecture} but have previosly #{previous_status.upcase}ED." end |
- (Object) headline
Returns a headline for this status object, to be used as a short description of the event it represents
23 24 25 |
# File 'lib/debci/status.rb', line 23 def headline "#{package} tests #{status.upcase}ED on #{suite}/#{architecture}" end |
- (Boolean) newsworthy?
Returns true
if this status object represents an important
event, such as a package that used to pass started failing, of vice versa.
14 15 16 17 18 19 |
# File 'lib/debci/status.rb', line 14 def newsworthy? [ [:fail, :pass], [:pass, :fail], ].include?([status, previous_status]) end |