Class: Bolt::ModuleInstaller::Specs::ForgeSpec
- Inherits:
-
Object
- Object
- Bolt::ModuleInstaller::Specs::ForgeSpec
- Defined in:
- lib/bolt/module_installer/specs/forge_spec.rb
Constant Summary collapse
- NAME_REGEX =
%r{\A[a-z][a-z0-9_]*[-/](?<name>[a-z][a-z0-9_]*)\z}.freeze
- REQUIRED_KEYS =
Set.new(%w[name]).freeze
- KNOWN_KEYS =
Set.new(%w[name version_requirement]).freeze
Instance Attribute Summary collapse
-
#full_name ⇒ Object
readonly
Returns the value of attribute full_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#semantic_version ⇒ Object
readonly
Returns the value of attribute semantic_version.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(init_hash) ⇒ ForgeSpec
constructor
A new instance of ForgeSpec.
-
#satisfied_by?(mod) ⇒ Boolean
Returns true if the specification is satisfied by the module.
-
#to_hash ⇒ Object
Returns a hash matching the module spec in bolt-project.yaml.
-
#to_resolver_module ⇒ Object
Creates a PuppetfileResolver::Puppetfile::ForgeModule object, which is used to generate a graph of resolved modules.
Constructor Details
#initialize(init_hash) ⇒ ForgeSpec
Returns a new instance of ForgeSpec.
20 21 22 23 24 |
# File 'lib/bolt/module_installer/specs/forge_spec.rb', line 20 def initialize(init_hash) @full_name, @name = parse_name(init_hash['name']) @version_requirement, @semantic_version = parse_version_requirement(init_hash['version_requirement']) @type = :forge end |
Instance Attribute Details
#full_name ⇒ Object (readonly)
Returns the value of attribute full_name.
18 19 20 |
# File 'lib/bolt/module_installer/specs/forge_spec.rb', line 18 def full_name @full_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/bolt/module_installer/specs/forge_spec.rb', line 18 def name @name end |
#semantic_version ⇒ Object (readonly)
Returns the value of attribute semantic_version.
18 19 20 |
# File 'lib/bolt/module_installer/specs/forge_spec.rb', line 18 def semantic_version @semantic_version end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
18 19 20 |
# File 'lib/bolt/module_installer/specs/forge_spec.rb', line 18 def type @type end |
Class Method Details
.implements?(hash) ⇒ Boolean
26 27 28 |
# File 'lib/bolt/module_installer/specs/forge_spec.rb', line 26 def self.implements?(hash) KNOWN_KEYS.superset?(hash.keys.to_set) && REQUIRED_KEYS.subset?(hash.keys.to_set) end |
Instance Method Details
#satisfied_by?(mod) ⇒ Boolean
Returns true if the specification is satisfied by the module.
55 56 57 58 59 60 |
# File 'lib/bolt/module_installer/specs/forge_spec.rb', line 55 def satisfied_by?(mod) @type == mod.type && @full_name == mod.full_name && !mod.version.nil? && @semantic_version.cover?(mod.version) end |
#to_hash ⇒ Object
Returns a hash matching the module spec in bolt-project.yaml
64 65 66 67 68 69 |
# File 'lib/bolt/module_installer/specs/forge_spec.rb', line 64 def to_hash { 'name' => @full_name, 'version_requirement' => @version_requirement }.compact end |
#to_resolver_module ⇒ Object
Creates a PuppetfileResolver::Puppetfile::ForgeModule object, which is used to generate a graph of resolved modules.
74 75 76 77 78 79 80 |
# File 'lib/bolt/module_installer/specs/forge_spec.rb', line 74 def to_resolver_module require 'puppetfile-resolver' PuppetfileResolver::Puppetfile::ForgeModule.new(@full_name).tap do |mod| mod.version = @version_requirement end end |