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.
32 33 34 35 36 37 38 39 |
# File 'lib/r10k/puppetfile.rb', line 32 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.
20 21 22 |
# File 'lib/r10k/puppetfile.rb', line 20 def basedir @basedir end |
#forge ⇒ Object (readonly)
Returns the value of attribute forge.
12 13 14 |
# File 'lib/r10k/puppetfile.rb', line 12 def forge @forge end |
#moduledir ⇒ Object (readonly)
Returns the value of attribute moduledir.
24 25 26 |
# File 'lib/r10k/puppetfile.rb', line 24 def moduledir @moduledir end |
#modules ⇒ Object (readonly)
Returns the value of attribute modules.
16 17 18 |
# File 'lib/r10k/puppetfile.rb', line 16 def modules @modules end |
#puppetfile_path ⇒ Object (readonly)
Returns the value of attribute puppetfile_path.
28 29 30 |
# File 'lib/r10k/puppetfile.rb', line 28 def puppetfile_path @puppetfile_path end |
Instance Method Details
#add_module(name, args) ⇒ Object
66 67 68 |
# File 'lib/r10k/puppetfile.rb', line 66 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
79 80 81 |
# File 'lib/r10k/puppetfile.rb', line 79 def desired_contents @modules.map { |mod| mod.name } end |
#load ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/r10k/puppetfile.rb', line 41 def load if File.readable? @puppetfile_path self.load! else logger.debug "Puppetfile #{@puppetfile_path.inspect} missing or unreadable" end end |
#load! ⇒ Object
49 50 51 52 |
# File 'lib/r10k/puppetfile.rb', line 49 def load! dsl = R10K::Puppetfile::DSL.new(self) dsl.instance_eval(puppetfile_contents, @puppetfile_path) end |
#managed_directory ⇒ Object
72 73 74 |
# File 'lib/r10k/puppetfile.rb', line 72 def managed_directory @moduledir end |
#set_forge(forge) ⇒ Object
55 56 57 |
# File 'lib/r10k/puppetfile.rb', line 55 def set_forge(forge) @forge = forge end |
#set_moduledir(moduledir) ⇒ Object
60 61 62 |
# File 'lib/r10k/puppetfile.rb', line 60 def set_moduledir(moduledir) @moduledir = moduledir end |