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.



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

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

Class Method Details

.load(path) ⇒ Object



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

def self.load(path)
  return new([]) unless path && File.exist?(path)
  new(JSON.parse(File.read(path)).fetch("accepted", []))
end

Instance Method Details

#entriesObject



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

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

#screen(findings) ⇒ Object



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

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