Class: Hashira::CI::Ratchet

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

Constant Summary collapse

SCHEMA_VERSION =
1

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Ratchet.



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

def initialize(graph, baseline_path, io: $stdout)
  @graph = graph
  @baseline_path = baseline_path
  @io = io
end

Instance Method Details

#checkObject



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

def check
  added, removed = diff(@graph.edge_list)
  EdgeDiffReport.new(@graph, io: @io).print(added, removed)
end

#updateObject



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

def update
  edges = @graph.edge_list.map(&:to_s)
  File.write(@baseline_path, JSON.pretty_generate(payload(edges)) << "\n")
  @io.puts "Baseline updated: #{edges.size} edges."
  0
end