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_data(data, suite, architecture)
Populates an object by reading from a data hash.
-
+ (Object) from_file(file, suite, architecture)
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. -
- (Object) time
Returns the amount of time since the date for this status object.
- - (Object) title
Instance Attribute Details
- (Object) architecture
Returns the value of attribute architecture
11 12 13 |
# File 'lib/debci/status.rb', line 11 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
11 12 13 |
# File 'lib/debci/status.rb', line 11 def date @date end |
- (Object) duration_human
Returns the value of attribute duration_human
11 12 13 |
# File 'lib/debci/status.rb', line 11 def duration_human @duration_human end |
- (Object) duration_seconds
Returns the value of attribute duration_seconds
11 12 13 |
# File 'lib/debci/status.rb', line 11 def duration_seconds @duration_seconds end |
- (Object) message
Returns the value of attribute message
11 12 13 |
# File 'lib/debci/status.rb', line 11 def @message end |
- (Object) package
Returns the value of attribute package
11 12 13 |
# File 'lib/debci/status.rb', line 11 def package @package end |
- (Object) previous_status
Returns the value of attribute previous_status
11 12 13 |
# File 'lib/debci/status.rb', line 11 def previous_status @previous_status end |
- (Object) run_id
Returns the value of attribute run_id
11 12 13 |
# File 'lib/debci/status.rb', line 11 def run_id @run_id end |
- (Object) status
Returns the value of attribute status
11 12 13 |
# File 'lib/debci/status.rb', line 11 def status @status end |
- (Object) suite
Returns the value of attribute suite
11 12 13 |
# File 'lib/debci/status.rb', line 11 def suite @suite end |
- (Object) version
Returns the value of attribute version
11 12 13 |
# File 'lib/debci/status.rb', line 11 def version @version end |
Class Method Details
+ (Object) from_data(data, suite, architecture)
Populates an object by reading from a data hash
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/debci/status.rb', line 88 def self.from_data(data, suite, architecture) status = Debci::Status.new status.suite = suite status.architecture = architecture status.run_id = data['run_id'] || data['date'] 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 |
+ (Object) from_file(file, suite, architecture)
Constructs a new object by reading the JSON status file
.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/debci/status.rb', line 62 def self.from_file(file, suite, architecture) status = new status.suite = suite status.architecture = architecture unless File.exists?(file) status.status = :no_test_data return status end 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 from_data(data, suite, architecture) end |
Instance Method Details
- (Object) description
A longer version of the headline
38 39 40 |
# File 'lib/debci/status.rb', line 38 def description "The tests for #{package} #{status.upcase}ED on #{suite}/#{architecture} but have previously #{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
33 34 35 |
# File 'lib/debci/status.rb', line 33 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.
15 16 17 18 19 20 |
# File 'lib/debci/status.rb', line 15 def newsworthy? [ [:fail, :pass], [:pass, :fail], ].include?([status, previous_status]) end |
- (Object) time
Returns the amount of time since the date for this status object
51 52 53 54 55 56 57 58 59 |
# File 'lib/debci/status.rb', line 51 def time days = (Time.now - date)/86400 if days >= 1 || days <= -1 "#{days.floor} day(s) ago" else "#{Time.at(Time.now - date).gmtime.strftime('%H')} hour(s) ago" end end |
- (Object) title
22 23 24 25 26 27 28 29 |
# File 'lib/debci/status.rb', line 22 def title { :pass => "Pass", :fail => "Fail", :tmpfail => "Temporary failure", :no_test_data => "No test data", }.fetch(status, "Unknown") end |