Class: Hashira::CI::Baseline
- Inherits:
-
Object
- Object
- Hashira::CI::Baseline
- Defined in:
- lib/hashira/ci/baseline.rb
Constant Summary collapse
- SCHEMA_VERSION =
4
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #accepted ⇒ Object
- #analyzers ⇒ Object
- #edges ⇒ Object
- #exist? ⇒ Boolean
- #findings ⇒ Object
- #findings? ⇒ Boolean
-
#initialize(path, analyzers: [], targets: []) ⇒ Baseline
constructor
A new instance of Baseline.
- #packaging ⇒ Object
- #targets ⇒ Object
- #trouble ⇒ Object
- #wanted ⇒ Object
- #write(edges, findings, packaging:) ⇒ Object
Constructor Details
#initialize(path, analyzers: [], targets: []) ⇒ Baseline
Returns a new instance of Baseline.
8 9 10 11 12 |
# File 'lib/hashira/ci/baseline.rb', line 8 def initialize(path, analyzers: [], targets: []) @path = path @analyzers = analyzers @targets = targets end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
14 15 16 |
# File 'lib/hashira/ci/baseline.rb', line 14 def path @path end |
Instance Method Details
#accepted ⇒ Object
30 |
# File 'lib/hashira/ci/baseline.rb', line 30 def accepted = recorded.fetch("accepted", []) |
#analyzers ⇒ Object
34 |
# File 'lib/hashira/ci/baseline.rb', line 34 def analyzers = recorded.fetch("analyzers", wanted[:analyzers]) |
#edges ⇒ Object
24 |
# File 'lib/hashira/ci/baseline.rb', line 24 def edges = recorded.fetch("edges", []) |
#exist? ⇒ Boolean
16 |
# File 'lib/hashira/ci/baseline.rb', line 16 def exist? = File.exist?(@path) |
#findings ⇒ Object
26 |
# File 'lib/hashira/ci/baseline.rb', line 26 def findings = keyed(recorded.fetch("findings", {})) |
#findings? ⇒ Boolean
28 |
# File 'lib/hashira/ci/baseline.rb', line 28 def findings? = recorded.key?("findings") |
#packaging ⇒ Object
32 |
# File 'lib/hashira/ci/baseline.rb', line 32 def packaging = recorded.fetch("packaging", "folder") |
#targets ⇒ Object
36 |
# File 'lib/hashira/ci/baseline.rb', line 36 def targets = recorded.fetch("targets", wanted[:targets]) |
#trouble ⇒ Object
18 19 20 21 22 |
# File 'lib/hashira/ci/baseline.rb', line 18 def trouble recorded && nil rescue JSON::ParserError, SystemCallError => error "#{@path} is not a usable baseline — #{error..lines.first.strip}. Re-record it with --update-baseline" end |
#wanted ⇒ Object
38 |
# File 'lib/hashira/ci/baseline.rb', line 38 def wanted = scope.to_h |
#write(edges, findings, packaging:) ⇒ Object
40 41 42 |
# File 'lib/hashira/ci/baseline.rb', line 40 def write(edges, findings, packaging:) File.write(@path, JSON.pretty_generate(payload(edges, findings, packaging)) << "\n") end |