summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2019-10-04 22:35:07 -0600
committermo khan <mo.khan@gmail.com>2019-10-04 22:35:07 -0600
commit1e28b3c92fdd39e6db6aaef0c97b4f2ac818ce14 (patch)
treef040288c7fe7278b553c3cde93edbb2844865f69
parent713022c1951c0a2b63da3d498f3f63c3c1444e91 (diff)
Parse the other fields in the license hashv0.1.0
-rw-r--r--lib/spandx/catalogue.rb2
-rw-r--r--lib/spandx/license.rb40
2 files changed, 40 insertions, 2 deletions
diff --git a/lib/spandx/catalogue.rb b/lib/spandx/catalogue.rb
index 2028766..1da6302 100644
--- a/lib/spandx/catalogue.rb
+++ b/lib/spandx/catalogue.rb
@@ -31,7 +31,7 @@ module Spandx
end
def map_from(license_hash)
- License.new(id: license_hash[:licenseId], name: license_hash[:name])
+ License.new(license_hash)
end
def present?(item)
diff --git a/lib/spandx/license.rb b/lib/spandx/license.rb
index 74358b8..410677c 100644
--- a/lib/spandx/license.rb
+++ b/lib/spandx/license.rb
@@ -1,5 +1,43 @@
# frozen_string_literal: true
module Spandx
- License = Struct.new(:id, :name, keyword_init: true)
+ class License
+ attr_reader :attributes
+
+ def initialize(attributes = {})
+ @attributes = attributes
+ end
+
+ def id
+ attributes[:licenseId]
+ end
+
+ def name
+ attributes[:name]
+ end
+
+ def reference
+ attributes[:reference]
+ end
+
+ def deprecated_license_id?
+ attributes[:isDeprecatedLicenseId]
+ end
+
+ def url
+ attributes[:detailsUrl]
+ end
+
+ def osi_approved?
+ attributes[:isOsiApproved]
+ end
+
+ def see_also
+ attributes[:seeAlso]
+ end
+
+ def reference_number
+ attributes[:referenceNumber]
+ end
+ end
end