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.



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

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

Class Method Details

.load(path) ⇒ Object



20
21
22
23
24
# File 'lib/hashira/ci/accepted.rb', line 20

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

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

Instance Method Details

#entriesObject



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

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

#screen(findings) ⇒ Object



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

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