Class: Hashira::CI::Ratchet

Inherits:
Object
  • Object
show all
Defined in:
lib/hashira/ci/ratchet.rb

Instance Method Summary collapse

Constructor Details

#initialize(graph, findings, baseline_path, io: $stdout) ⇒ Ratchet

Returns a new instance of Ratchet.



6
7
8
9
10
11
# File 'lib/hashira/ci/ratchet.rb', line 6

def initialize(graph, findings, baseline_path, io: $stdout)
  @graph = graph
  @findings = findings
  @baseline = Baseline.load(baseline_path)
  @io = io
end

Instance Method Details

#checkObject

Raises:



19
20
21
22
23
# File 'lib/hashira/ci/ratchet.rb', line 19

def check
  raise Error, "no baseline at #{@baseline.path} — run --update-baseline first" unless @baseline.exist?

  RatchetReport.new(@graph, @findings, io: @io).print(edge_diff, finding_diff)
end

#updateObject



13
14
15
16
17
# File 'lib/hashira/ci/ratchet.rb', line 13

def update
  @baseline.write(edge_signatures, finding_signatures)
  @io.puts "Baseline updated: #{edge_signatures.size} edges, #{finding_signatures.size} findings."
  0
end