Class: Gem::Guardian::LockfileParser::LockfileData
- Inherits:
-
Data
- Object
- Data
- Gem::Guardian::LockfileParser::LockfileData
- Defined in:
- lib/gem/guardian/lockfile_parser.rb
Overview
Parsed lockfile data for the verify command.
Instance Attribute Summary collapse
-
#checksums ⇒ Object
readonly
Returns the value of attribute checksums.
-
#checksums_section_present ⇒ Object
readonly
Returns the value of attribute checksums_section_present.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
Instance Method Summary collapse
-
#checksum_for(dependency, algorithm = "sha256") ⇒ Object
Returns the checksum for +dependency+ and +algorithm+, if present.
-
#checksums_present? ⇒ Boolean
Returns true if the lockfile contained a CHECKSUMS section.
-
#missing_checksum_dependencies ⇒ Object
Returns dependencies that do not have a sha256 checksum.
-
#sha256_checksums ⇒ Object
Returns a dependency => sha256 checksum map.
Instance Attribute Details
#checksums ⇒ Object (readonly)
Returns the value of attribute checksums
14 15 16 |
# File 'lib/gem/guardian/lockfile_parser.rb', line 14 def checksums @checksums end |
#checksums_section_present ⇒ Object (readonly)
Returns the value of attribute checksums_section_present
14 15 16 |
# File 'lib/gem/guardian/lockfile_parser.rb', line 14 def checksums_section_present @checksums_section_present end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies
14 15 16 |
# File 'lib/gem/guardian/lockfile_parser.rb', line 14 def dependencies @dependencies end |
Instance Method Details
#checksum_for(dependency, algorithm = "sha256") ⇒ Object
Returns the checksum for +dependency+ and +algorithm+, if present.
16 17 18 |
# File 'lib/gem/guardian/lockfile_parser.rb', line 16 def checksum_for(dependency, algorithm = "sha256") checksums.fetch(dependency, {}).fetch(algorithm, nil) end |
#checksums_present? ⇒ Boolean
Returns true if the lockfile contained a CHECKSUMS section.
34 35 36 |
# File 'lib/gem/guardian/lockfile_parser.rb', line 34 def checksums_present? checksums_section_present end |
#missing_checksum_dependencies ⇒ Object
Returns dependencies that do not have a sha256 checksum.
29 30 31 |
# File 'lib/gem/guardian/lockfile_parser.rb', line 29 def missing_checksum_dependencies dependencies.reject { |dependency| sha256_checksums.key?(dependency) } end |
#sha256_checksums ⇒ Object
Returns a dependency => sha256 checksum map.
21 22 23 24 25 26 |
# File 'lib/gem/guardian/lockfile_parser.rb', line 21 def sha256_checksums checksums.each_with_object({}) do |(dependency, algorithms), memo| digest = algorithms["sha256"] memo[dependency] = digest if digest end end |