Class: Bolt::ModuleInstaller::Specs

Inherits:
Object
  • Object
show all
Defined in:
lib/bolt/module_installer/specs.rb,
lib/bolt/module_installer/specs/id/base.rb,
lib/bolt/module_installer/specs/git_spec.rb,
lib/bolt/module_installer/specs/id/github.rb,
lib/bolt/module_installer/specs/id/gitlab.rb,
lib/bolt/module_installer/specs/forge_spec.rb,
lib/bolt/module_installer/specs/id/gitclone.rb

Defined Under Namespace

Classes: ForgeSpec, GitSpec, ID

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(specs = [], config = {}) ⇒ Specs

Returns a new instance of Specs.



10
11
12
13
14
15
16
# File 'lib/bolt/module_installer/specs.rb', line 10

def initialize(specs = [], config = {})
  @specs  = []
  @config = config

  add_specs(specs)
  assert_unique_names
end

Class Method Details

.from_puppetfile(puppetfile) ⇒ Object

Creates a list of specs from the modules in a Puppetfile object.



20
21
22
# File 'lib/bolt/module_installer/specs.rb', line 20

def self.from_puppetfile(puppetfile)
  new(puppetfile.modules.map(&:to_hash))
end

Instance Method Details

#add_specs(*specs) ⇒ Object

Adds a spec.



39
40
41
42
43
44
45
46
47
48
# File 'lib/bolt/module_installer/specs.rb', line 39

def add_specs(*specs)
  specs.flatten.map do |spec|
    case spec
    when Hash
      @specs.unshift spec_from_hash(spec)
    else
      @specs.unshift spec
    end
  end
end

#include?(name) ⇒ Boolean

Returns true if the specs includes the given name.

Returns:

  • (Boolean)


32
33
34
35
# File 'lib/bolt/module_installer/specs.rb', line 32

def include?(name)
  _owner, name = name.tr('-', '/').split('/', 2)
  @specs.any? { |spec| spec.name == name }
end

#satisfied_by?(puppetfile) ⇒ Boolean

Returns true if all specs are satisfied by the modules in a Puppetfile.

Returns:

  • (Boolean)


66
67
68
69
70
71
72
# File 'lib/bolt/module_installer/specs.rb', line 66

def satisfied_by?(puppetfile)
  @specs.all? do |spec|
    puppetfile.modules.any? do |mod|
      spec.satisfied_by?(mod)
    end
  end
end

#specsObject

Returns a list of specs.



26
27
28
# File 'lib/bolt/module_installer/specs.rb', line 26

def specs
  @specs.uniq(&:name)
end