Class: Licensed::DependencyRecord::License
- Inherits:
-
Object
- Object
- Licensed::DependencyRecord::License
- Defined in:
- lib/licensed/dependency_record.rb
Instance Attribute Summary collapse
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(content) ⇒ License
constructor
A new instance of License.
- #key ⇒ Object
- #to_cache ⇒ Object
Constructor Details
#initialize(content) ⇒ License
Returns a new instance of License.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/licensed/dependency_record.rb', line 12 def initialize(content) @sources = [] if content.is_a?(String) @text = content.to_s elsif content.respond_to?(:[]) @sources.concat content["sources"].to_s.split(", ") @text = content["text"] end end |
Instance Attribute Details
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
11 12 13 |
# File 'lib/licensed/dependency_record.rb', line 11 def sources @sources end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
11 12 13 |
# File 'lib/licensed/dependency_record.rb', line 11 def text @text end |
Instance Method Details
#key ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/licensed/dependency_record.rb', line 31 def key @key ||= begin # rubocop:disable GitHub/InsecureHashAlgorithm sources.join("") + ":" + Digest::XXHash64.digest(text).to_s # rubocop:enable GitHub/InsecureHashAlgorithm end end |
#to_cache ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/licensed/dependency_record.rb', line 23 def to_cache return text if sources.empty? { "sources" => sources.join(", "), "text" => text } end |