Class: Pray::PackageSpec
- Inherits:
-
Struct
- Object
- Struct
- Pray::PackageSpec
- Defined in:
- lib/pray/package_spec.rb
Instance Attribute Summary collapse
-
#adapters ⇒ Object
Returns the value of attribute adapters.
-
#authors ⇒ Object
Returns the value of attribute authors.
-
#changelog_uri ⇒ Object
Returns the value of attribute changelog_uri.
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#description ⇒ Object
Returns the value of attribute description.
-
#exports ⇒ Object
Returns the value of attribute exports.
-
#files ⇒ Object
Returns the value of attribute files.
-
#homepage ⇒ Object
Returns the value of attribute homepage.
-
#license ⇒ Object
Returns the value of attribute license.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#prayfile_version ⇒ Object
Returns the value of attribute prayfile_version.
-
#skills ⇒ Object
Returns the value of attribute skills.
-
#source_code_uri ⇒ Object
Returns the value of attribute source_code_uri.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#targets ⇒ Object
Returns the value of attribute targets.
-
#templates ⇒ Object
Returns the value of attribute templates.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #canonicalized ⇒ Object
-
#initialize(name: "", version: "", summary: nil, description: nil, authors: [], license: nil, homepage: nil, source_code_uri: nil, changelog_uri: nil, prayfile_version: nil, files: [], exports: {}, skills: {}, templates: {}, adapters: {}, targets: [], dependencies: [], metadata: {}) ⇒ PackageSpec
constructor
A new instance of PackageSpec.
- #tree_hash_for_root(root) ⇒ Object
Constructor Details
#initialize(name: "", version: "", summary: nil, description: nil, authors: [], license: nil, homepage: nil, source_code_uri: nil, changelog_uri: nil, prayfile_version: nil, files: [], exports: {}, skills: {}, templates: {}, adapters: {}, targets: [], dependencies: [], metadata: {}) ⇒ PackageSpec
Returns a new instance of PackageSpec.
18 19 20 21 22 23 24 25 |
# File 'lib/pray/package_spec.rb', line 18 def initialize( name: "", version: "", summary: nil, description: nil, authors: [], license: nil, homepage: nil, source_code_uri: nil, changelog_uri: nil, prayfile_version: nil, files: [], exports: {}, skills: {}, templates: {}, adapters: {}, targets: [], dependencies: [], metadata: {} ) super end |
Instance Attribute Details
#adapters ⇒ Object
Returns the value of attribute adapters
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def adapters @adapters end |
#authors ⇒ Object
Returns the value of attribute authors
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def @authors end |
#changelog_uri ⇒ Object
Returns the value of attribute changelog_uri
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def changelog_uri @changelog_uri end |
#dependencies ⇒ Object
Returns the value of attribute dependencies
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def dependencies @dependencies end |
#description ⇒ Object
Returns the value of attribute description
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def description @description end |
#exports ⇒ Object
Returns the value of attribute exports
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def exports @exports end |
#files ⇒ Object
Returns the value of attribute files
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def files @files end |
#homepage ⇒ Object
Returns the value of attribute homepage
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def homepage @homepage end |
#license ⇒ Object
Returns the value of attribute license
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def license @license end |
#metadata ⇒ Object
Returns the value of attribute metadata
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def @metadata end |
#name ⇒ Object
Returns the value of attribute name
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def name @name end |
#prayfile_version ⇒ Object
Returns the value of attribute prayfile_version
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def prayfile_version @prayfile_version end |
#skills ⇒ Object
Returns the value of attribute skills
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def skills @skills end |
#source_code_uri ⇒ Object
Returns the value of attribute source_code_uri
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def source_code_uri @source_code_uri end |
#summary ⇒ Object
Returns the value of attribute summary
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def summary @summary end |
#targets ⇒ Object
Returns the value of attribute targets
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def targets @targets end |
#templates ⇒ Object
Returns the value of attribute templates
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def templates @templates end |
#version ⇒ Object
Returns the value of attribute version
13 14 15 |
# File 'lib/pray/package_spec.rb', line 13 def version @version end |
Class Method Details
.tree_hash_from_file_bytes(file_bytes) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/pray/package_spec.rb', line 48 def self.tree_hash_from_file_bytes(file_bytes) entries = file_bytes.map { |path, bytes| [path, Hashing.sha256_prefixed(bytes)] }.sort_by(&:first) serialized = entries.map do |path, hash| "file\0regular\0#{path}\0#{hash}\n" end.join Hashing.sha256_prefixed(serialized) end |
Instance Method Details
#canonicalized ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/pray/package_spec.rb', line 27 def canonicalized dup.tap do |copy| copy.files = files.sort copy. = .sort copy.targets = targets.sort copy.dependencies = dependencies.sort_by { |dependency| [dependency.name, dependency.constraint, dependency.optional] } end end |
#tree_hash_for_root(root) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pray/package_spec.rb', line 36 def tree_hash_for_root(root) file_bytes = {} files.each do |file| path = File.join(root, file) raise Error.integrity("package file missing: #{file}") unless File.exist?(path) raise Error.integrity("package file is a directory: #{file}") if File.directory?(path) file_bytes[file] = File.binread(path) end self.class.tree_hash_from_file_bytes(file_bytes) end |