Class: Hashira::CI::Baseline
- Inherits:
-
Object
- Object
- Hashira::CI::Baseline
- Defined in:
- lib/hashira/ci/baseline.rb
Constant Summary collapse
- SCHEMA_VERSION =
2
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #edges ⇒ Object
- #exist? ⇒ Boolean
- #findings ⇒ Object
-
#initialize(path, recorded) ⇒ Baseline
constructor
A new instance of Baseline.
- #ratchets_findings? ⇒ Boolean
- #write(edges, findings) ⇒ Object
Constructor Details
#initialize(path, recorded) ⇒ Baseline
Returns a new instance of Baseline.
12 13 14 15 |
# File 'lib/hashira/ci/baseline.rb', line 12 def initialize(path, recorded) @path = path @recorded = recorded end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
17 18 19 |
# File 'lib/hashira/ci/baseline.rb', line 17 def path @path end |
Class Method Details
.load(path) ⇒ Object
10 |
# File 'lib/hashira/ci/baseline.rb', line 10 def self.load(path) = new(path, File.exist?(path) ? JSON.parse(File.read(path)) : {}) |
Instance Method Details
#edges ⇒ Object
21 |
# File 'lib/hashira/ci/baseline.rb', line 21 def edges = @recorded.fetch("edges", []) |
#exist? ⇒ Boolean
19 |
# File 'lib/hashira/ci/baseline.rb', line 19 def exist? = File.exist?(@path) |
#findings ⇒ Object
23 |
# File 'lib/hashira/ci/baseline.rb', line 23 def findings = @recorded.fetch("findings", []) |
#ratchets_findings? ⇒ Boolean
25 |
# File 'lib/hashira/ci/baseline.rb', line 25 def ratchets_findings? = @recorded.key?("findings") |
#write(edges, findings) ⇒ Object
27 28 29 |
# File 'lib/hashira/ci/baseline.rb', line 27 def write(edges, findings) File.write(@path, JSON.pretty_generate(payload(edges, findings)) << "\n") end |