Class: Debci::HTML::JSON
Instance Attribute Summary collapse
-
#arch ⇒ Object
Returns the value of attribute arch.
-
#suite ⇒ Object
Returns the value of attribute suite.
Attributes inherited from Rooted
Instance Method Summary collapse
- #history ⇒ Object
-
#initialize(suite, arch) ⇒ JSON
constructor
A new instance of JSON.
- #packages ⇒ Object
- #status ⇒ Object
- #status_packages_data ⇒ Object
Constructor Details
#initialize(suite, arch) ⇒ JSON
Returns a new instance of JSON.
56 57 58 59 60 61 |
# File 'lib/debci/html.rb', line 56 def initialize(suite, arch) @datadir = 'status' super() self.suite = suite self.arch = arch end |
Instance Attribute Details
#arch ⇒ Object
Returns the value of attribute arch.
54 55 56 |
# File 'lib/debci/html.rb', line 54 def arch @arch end |
#suite ⇒ Object
Returns the value of attribute suite.
54 55 56 |
# File 'lib/debci/html.rb', line 54 def suite @suite end |
Instance Method Details
#history ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/debci/html.rb', line 93 def history status_history = (root / suite / arch).glob('[0-9]*/[0-9]*/[0-9]*.json') status_history_data = status_history.sort.map { |f| ::JSON.parse(f.read) } h = root / suite / arch / 'history.json' h.write(::JSON.pretty_generate(status_history_data)) end |
#packages ⇒ Object
101 102 103 104 |
# File 'lib/debci/html.rb', line 101 def packages p = root / suite / arch / 'packages.json' p.write(::JSON.pretty_generate(status_packages_data.map(&:job).as_json)) end |
#status ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/debci/html.rb', line 68 def status data = { pass: 0, fail: 0, neutral: 0, tmpfail: 0, total: 0, } status_packages_data.each do |package_status| status = package_status.job.status data[status.to_sym] += 1 data[:total] += 1 end data[:date] = Time.now.strftime('%Y-%m-%dT%H:%M:%S') output = ::JSON.pretty_generate(data) today = root / suite / arch / Time.now.strftime('%Y/%m/%d.json') today.parent.mkpath today.write(output) current = root / suite / arch / 'status.json' current.write(output) end |
#status_packages_data ⇒ Object
63 64 65 66 |
# File 'lib/debci/html.rb', line 63 def status_packages_data @status_packages_data ||= Debci::PackageStatus.where(suite: suite, arch: arch).includes(:job) end |