Class: Bolt::ModuleInstaller::Puppetfile::ForgeModule

Inherits:
Module
  • Object
show all
Defined in:
lib/bolt/module_installer/puppetfile/forge_module.rb

Instance Attribute Summary collapse

Attributes inherited from Module

#full_name, #name, #type

Instance Method Summary collapse

Constructor Details

#initialize(name, version) ⇒ ForgeModule

Returns a new instance of ForgeModule.


14
15
16
17
18
# File 'lib/bolt/module_installer/puppetfile/forge_module.rb', line 14

def initialize(name, version)
  super(name)
  @version = parse_version(version)
  @type    = :forge
end

Instance Attribute Details

#versionObject (readonly)

Returns the value of attribute version.


12
13
14
# File 'lib/bolt/module_installer/puppetfile/forge_module.rb', line 12

def version
  @version
end

Instance Method Details

#to_hashObject

Returns a hash that can be used to create a module specification.


45
46
47
48
49
50
# File 'lib/bolt/module_installer/puppetfile/forge_module.rb', line 45

def to_hash
  {
    'name'                => @full_name,
    'version_requirement' => @version ? @version.to_s : nil
  }.compact
end

#to_specObject

Returns a Puppetfile module specification.


35
36
37
38
39
40
41
# File 'lib/bolt/module_installer/puppetfile/forge_module.rb', line 35

def to_spec
  if @version
    "mod '#{@full_name}', '#{@version}'"
  else
    "mod '#{@full_name}'"
  end
end