blob: dca3c96729c13b4f82933099846883b026810bcb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# frozen_string_literal: true
class Report
attr_reader :report
def initialize(raw)
@report = JSON.parse(raw, symbolize_names: true)
end
def [](key)
report[key]
end
def dependency_names
report[:dependencies].map { |x| x[:name] }
end
def licenses_for(name)
(find(name) || {}).fetch(:licenses, [])
end
def find(name)
report[:dependencies].find do |dependency|
dependency[:name] == name
end
end
def nil?
report.nil?
end
def to_hash
to_h
end
def to_h
report
end
end
|