Class: R10K::Puppetfile
- Inherits:
-
Object
- Object
- R10K::Puppetfile
- Includes:
- Logging, Util::Purgeable
- Defined in:
- lib/r10k/puppetfile.rb
Defined Under Namespace
Classes: DSL
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
-
#basedir ⇒ Object
readonly
Returns the value of attribute basedir.
-
#forge ⇒ Object
readonly
Returns the value of attribute forge.
-
#moduledir ⇒ Object
readonly
Returns the value of attribute moduledir.
-
#modules ⇒ Object
readonly
Returns the value of attribute modules.
-
#puppetfile_path ⇒ Object
readonly
Returns the value of attribute puppetfile_path.
Instance Method Summary collapse
- #add_module(name, args) ⇒ Object
-
#desired_contents ⇒ Array<String>
List all modules that should exist in the module directory.
-
#initialize(basedir, moduledir = nil, puppetfile = nil) ⇒ Puppetfile
constructor
A new instance of Puppetfile.
- #load ⇒ Object
- #load! ⇒ Object
- #managed_directory ⇒ Object
- #set_forge(forge) ⇒ Object
- #set_moduledir(moduledir) ⇒ Object
Methods included from Util::Purgeable
#current_contents, #pending_contents, #purge!, #stale_contents
Methods included from Logging
formatter, included, level, level=, levels, #logger, #logger_name, outputter, parse_level
Constructor Details
#initialize(basedir, moduledir = nil, puppetfile = nil) ⇒ Puppetfile
Returns a new instance of Puppetfile.
33 34 35 36 37 38 39 40 |
# File 'lib/r10k/puppetfile.rb', line 33 def initialize(basedir, moduledir = nil, puppetfile = nil) @basedir = basedir @moduledir = moduledir || File.join(basedir, 'modules') @puppetfile_path = puppetfile || File.join(basedir, 'Puppetfile') @modules = [] @forge = 'forge.puppetlabs.com' end |
Instance Attribute Details
#basedir ⇒ Object (readonly)
Returns the value of attribute basedir.
21 22 23 |
# File 'lib/r10k/puppetfile.rb', line 21 def basedir @basedir end |
#forge ⇒ Object (readonly)
Returns the value of attribute forge.
13 14 15 |
# File 'lib/r10k/puppetfile.rb', line 13 def forge @forge end |
#moduledir ⇒ Object (readonly)
Returns the value of attribute moduledir.
25 26 27 |
# File 'lib/r10k/puppetfile.rb', line 25 def moduledir @moduledir end |
#modules ⇒ Object (readonly)
Returns the value of attribute modules.
17 18 19 |
# File 'lib/r10k/puppetfile.rb', line 17 def modules @modules end |
#puppetfile_path ⇒ Object (readonly)
Returns the value of attribute puppetfile_path.
29 30 31 |
# File 'lib/r10k/puppetfile.rb', line 29 def puppetfile_path @puppetfile_path end |
Instance Method Details
#add_module(name, args) ⇒ Object
67 68 69 |
# File 'lib/r10k/puppetfile.rb', line 67 def add_module(name, args) @modules << R10K::Module.new(name, @moduledir, args) end |
#desired_contents ⇒ Array<String>
This implements a required method for the Purgeable mixin
List all modules that should exist in the module directory
80 81 82 |
# File 'lib/r10k/puppetfile.rb', line 80 def desired_contents @modules.map { |mod| mod.name } end |
#load ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/r10k/puppetfile.rb', line 42 def load if File.readable? @puppetfile_path self.load! else logger.debug "Puppetfile #{@puppetfile_path.inspect} missing or unreadable" end end |
#load! ⇒ Object
50 51 52 53 |
# File 'lib/r10k/puppetfile.rb', line 50 def load! dsl = R10K::Puppetfile::DSL.new(self) dsl.instance_eval(puppetfile_contents, @puppetfile_path) end |
#managed_directory ⇒ Object
73 74 75 |
# File 'lib/r10k/puppetfile.rb', line 73 def managed_directory @moduledir end |
#set_forge(forge) ⇒ Object
56 57 58 |
# File 'lib/r10k/puppetfile.rb', line 56 def set_forge(forge) @forge = forge end |
#set_moduledir(moduledir) ⇒ Object
61 62 63 |
# File 'lib/r10k/puppetfile.rb', line 61 def set_moduledir(moduledir) @moduledir = moduledir end |