Class: Hashira::CI::Accepted

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

Defined Under Namespace

Classes: Entry, Screened

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entries) ⇒ Accepted

Returns a new instance of Accepted.



30
31
32
# File 'lib/hashira/ci/accepted.rb', line 30

def initialize(entries)
  @entries = entries.map { Entry.from(it) }
end

Class Method Details

.load(path) ⇒ Object



24
25
26
27
28
# File 'lib/hashira/ci/accepted.rb', line 24

def self.load(path)
  return new([]) unless path && File.exist?(path)

  new(JSON.parse(File.read(path)).fetch("accepted", []))
end

Instance Method Details

#entriesObject



34
# File 'lib/hashira/ci/accepted.rb', line 34

def entries = @entries.map(&:to_h)

#screen(findings) ⇒ Object



36
37
38
39
# File 'lib/hashira/ci/accepted.rb', line 36

def screen(findings)
  accepted, live = findings.map { [it, reason_for(it)] }.partition(&:last)
  Screened.new(all: live.map(&:first), accepted:)
end