Commit 1e28b3c

mo khan <mo.khan@gmail.com>
2019-10-05 04:35:07
Parse the other fields in the license hash tag: v0.1.0
1 parent 713022c
Changed files (2)
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)
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