class Omnibus::Package
Attributes
@return [String]
Public Class Methods
Create a new package from the given path.
@param [String] path
the path to the package on disk
# File lib/omnibus/package.rb, line 34 def initialize(path) @path = File.expand_path(path) end
Public Instance Methods
The actual contents of the package.
@return [String]
# File lib/omnibus/package.rb, line 88 def content @content ||= IO.read(path) rescue Errno::ENOENT raise NoPackageFile.new(path) end
The MD5 checksum for this file.
@return [String]
# File lib/omnibus/package.rb, line 52 def md5 @md5 ||= digest(path, :md5) end
The parsed contents of the metadata.
@raise [NoPackageMetadataFile] if the {#metadata} does not exist @raise [FFI_Yajl::ParseError] if the JSON is not valid
@return [Hash<Symbol, String>]
# File lib/omnibus/package.rb, line 102 def metadata @metadata ||= Metadata.for_package(self) end
Set the metadata for this package
@param [Metadata] metadata
# File lib/omnibus/package.rb, line 111 def metadata=(metadata) @metadata = metadata end
The shortname of this package (the basename of the file).
@return [String]
# File lib/omnibus/package.rb, line 43 def name @name ||= File.basename(path) end
The SHA1 checksum for this file.
@return [String]
# File lib/omnibus/package.rb, line 61 def sha1 @sha1 ||= digest(path, :sha1) end
The SHA256 checksum for this file.
@return [String]
# File lib/omnibus/package.rb, line 70 def sha256 @sha256 ||= digest(path, :sha256) end
The SHA512 checksum for this file.
@return [String]
# File lib/omnibus/package.rb, line 79 def sha512 @sha512 ||= digest(path, :sha512) end
Validate the presence of the required components for the package.
@raise [NoPackageFile] if the package is not present @raise [NoPackageMetadataFile] if the metadata file is not present
@return [true]
# File lib/omnibus/package.rb, line 123 def validate! unless File.exist?(path) raise NoPackageFile.new(path) end unless File.exist?(metadata.path) raise NoPackageMetadataFile.new(metadata.path) end true end