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, 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, io: $stdout)
  @graph = graph
  @findings = findings
  @baseline = baseline
  @io = io
end

Instance Method Details

#blockerObject



23
24
25
26
# File 'lib/hashira/ci/ratchet.rb', line 23

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

#check(focus) ⇒ Object



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

def check(focus)
  compared = focus.narrowing? ? Hashira::CI::Slice.new(@baseline) : Hashira::CI::Sweep.new(@baseline)
  Hashira::CI::RatchetReport.new(@graph, @findings, io: @io)
    .print(compared.edges(drift), delta(compared), tally(compared))
end

#updateObject



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

def update
  @baseline.write(edges, scored, packaging:)
  @io.puts("Baseline updated: #{edges.size} edges, #{recorded}.")
  Hashira::CI::Status::CLEAN
end