Class: R10K::ModuleLoader::Puppetfile::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/r10k/module_loader/puppetfile/dsl.rb

Instance Method Summary collapse

Constructor Details

#initialize(librarian, metadata_only: false) ⇒ DSL

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

A barebones implementation of the Puppetfile DSL



9
10
11
12
# File 'lib/r10k/module_loader/puppetfile/dsl.rb', line 9

def initialize(librarian, metadata_only: false)
  @librarian     = librarian
  @metadata_only = 
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

Raises:

  • (NoMethodError)


36
37
38
# File 'lib/r10k/module_loader/puppetfile/dsl.rb', line 36

def method_missing(method, *args)
  raise NoMethodError, _("unrecognized declaration '%{method}'") % {method: method}
end

Instance Method Details

#forge(location) ⇒ Object



28
29
30
# File 'lib/r10k/module_loader/puppetfile/dsl.rb', line 28

def forge(location)
  @librarian.set_forge(location)
end

#mod(name, args = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/r10k/module_loader/puppetfile/dsl.rb', line 14

def mod(name, args = nil)
  if args.is_a?(Hash)
    opts = args
  else
    opts = { version: args }
  end

  if @metadata_only
    @librarian.(name, opts)
  else
    @librarian.add_module(name, opts)
  end
end

#moduledir(location) ⇒ Object



32
33
34
# File 'lib/r10k/module_loader/puppetfile/dsl.rb', line 32

def moduledir(location)
  @librarian.set_moduledir(location)
end