class MDQT::Client::MetadataFile

Public Class Methods

new(filename, options = {}) click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 8
def initialize(filename, options = {})
  @filename = filename
  @identifier = nil
  @data = nil
  @expires = nil
  @etag = nil
  @last_modified = nil
  @explanation = {}
end

Public Instance Methods

canonical_filename() click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 73
def canonical_filename
  if identifier.empty?
    @filename = "aggregate-#{Digest::SHA1.hexdigest(@service)}.xml"
  else
    @filename ||= identifier.start_with?("{sha1}") ?
                      "#{@identifier.gsub("{sha1}","")}.xml" :
                      "#{Digest::SHA1.hexdigest(@identifier)}.xml"
  end
end
data() click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 26
def data
  @data ||= File.read(filename)
end
etag() click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 42
def etag
  @etag
end
expires() click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 38
def expires
  @expires
end
filename() click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 18
def filename
  @filename
end
identifier() click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 22
def identifier
  @identifier
end
last_modified() click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 46
def last_modified
  @last_modified
end
ok?() click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 50
def ok?
  @ok
end
readable?() click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 30
def readable?
  File.readable?(filename)
end
signed?() click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 54
def signed?
  @data.include? "Signature" # This is... not great
end
type() click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 34
def type
  @type
end
valid?() click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 63
def valid?
  validator = MetadataValidator.new
  validator.valid?(self)
end
validation_error() click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 68
def validation_error
  validator = MetadataValidator.new
  validator.validation_error(self)
end
verified_signature?(certs = [], _ = {}) click to toggle source
# File lib/mdqt/client/metadata_file.rb, line 58
def verified_signature?(certs = [], _ = {})
  validator = MetadataValidator.new(certs: [certs].flatten)
  validator.verified_signature?(self)
end