summaryrefslogtreecommitdiff
path: root/spec/support/report.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/report.rb')
-rw-r--r--spec/support/report.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/support/report.rb b/spec/support/report.rb
new file mode 100644
index 0000000..d6546ae
--- /dev/null
+++ b/spec/support/report.rb
@@ -0,0 +1,37 @@
+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