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