Class: Hashira::CI::Gate

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

Instance Method Summary collapse

Constructor Details

#initialize(findings, kinds, io: $stdout) ⇒ Gate

Returns a new instance of Gate.



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

def initialize(findings, kinds, io: $stdout)
  @findings = findings
  @kinds = kinds
  @io = io
end

Instance Method Details

#checkObject



12
13
14
15
16
17
18
19
# File 'lib/hashira/ci/gate.rb', line 12

def check
  offending = @findings.all.select { @kinds.include?(_1.kind) }
  return report_clean if offending.empty?

  offending.each { Report::FindingLines.new(_1, io: @io).print }
  @io.puts "\nGate FAILED: #{offending.size} finding(s) of kind #{@kinds.join(", ")}."
  1
end