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.



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

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

Instance Method Details

#blockerObject



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

def blocker
  return "no baseline at #{@baseline.path} — run --update-baseline first" unless @baseline.exist?
  mismatch unless @baseline.packaging == packaging
end

#checkObject



17
# File 'lib/hashira/ci/ratchet.rb', line 17

def check = Hashira::CI::RatchetReport.new(@graph, @findings, io: @io).print(drift, delta)

#updateObject



11
12
13
14
15
# File 'lib/hashira/ci/ratchet.rb', line 11

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