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
12 13 14 |
# File 'lib/gem/guardian/lockfile_parser.rb', line 12 def checksums @checksums end |
#checksums_section_present ⇒ Object (readonly)
Returns the value of attribute checksums_section_present
12 13 14 |
# File 'lib/gem/guardian/lockfile_parser.rb', line 12 def checksums_section_present @checksums_section_present end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies
12 13 14 |
# File 'lib/gem/guardian/lockfile_parser.rb', line 12 def dependencies @dependencies end |
Instance Method Details
#checksum_for(dependency, algorithm = "sha256") ⇒ Object
Returns the checksum for +dependency+ and +algorithm+, if present.
14 15 16 |
# File 'lib/gem/guardian/lockfile_parser.rb', line 14 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.
32 33 34 |
# File 'lib/gem/guardian/lockfile_parser.rb', line 32 def checksums_present? checksums_section_present end |
#missing_checksum_dependencies ⇒ Object
Returns dependencies that do not have a sha256 checksum.
27 28 29 |
# File 'lib/gem/guardian/lockfile_parser.rb', line 27 def missing_checksum_dependencies dependencies.reject { |dependency| sha256_checksums.key?(dependency) } end |
#sha256_checksums ⇒ Object
Returns a dependency => sha256 checksum map.
19 20 21 22 23 24 |
# File 'lib/gem/guardian/lockfile_parser.rb', line 19 def sha256_checksums checksums.each_with_object({}) do |(dependency, algorithms), memo| digest = algorithms["sha256"] memo[dependency] = digest if digest end end |