Module: Sigstore::TUF::MetaFile
- Included in:
- Snapshot::Meta
- Defined in:
- lib/sigstore/tuf/file.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(version: 1, length: nil, hashes: nil, unrecognized_fields: {}) ⇒ Object
- #verify_length_and_hashes(data) ⇒ Object
Class Method Details
.included(base) ⇒ Object
62 63 64 65 66 |
# File 'lib/sigstore/tuf/file.rb', line 62 def self.included(base) base.include(BaseFile) base.extend(ClassMethods) super end |
Instance Method Details
#initialize(version: 1, length: nil, hashes: nil, unrecognized_fields: {}) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/sigstore/tuf/file.rb', line 68 def initialize(version: 1, length: nil, hashes: nil, unrecognized_fields: {}) @version = version @length = length @hashes = hashes @unrecognized_fields = unrecognized_fields raise ArgumentError, "Metafile version must be positive, got #{@version}" if @version <= 0 self.class.validate_length(@length) unless @length.nil? self.class.validate_hashes(@hashes) unless @hashes.nil? end |
#verify_length_and_hashes(data) ⇒ Object
80 81 82 83 |
# File 'lib/sigstore/tuf/file.rb', line 80 def verify_length_and_hashes(data) self.class.verify_length(data, @length) if @length self.class.verify_hashes(data, @hashes) if @hashes end |