Class: Salt::Saltfile
- Inherits:
-
Object
- Object
- Salt::Saltfile
- Defined in:
- lib/salt/saltfile.rb
Defined Under Namespace
Classes: DSL
Instance Attribute Summary collapse
-
#basedir ⇒ Object
readonly
Returns the value of attribute basedir.
-
#formuladir ⇒ Object
readonly
Returns the value of attribute formuladir.
-
#formulas ⇒ Object
readonly
Returns the value of attribute formulas.
-
#saltfile ⇒ Object
readonly
Returns the value of attribute saltfile.
Instance Method Summary collapse
- #add_formula(name, args) ⇒ Object
-
#initialize(basedir = '.', formuladir = nil, saltfile = nil) ⇒ Saltfile
constructor
A new instance of Saltfile.
- #load ⇒ Object
- #load! ⇒ Object
- #saltfile_contents ⇒ File
Constructor Details
#initialize(basedir = '.', formuladir = nil, saltfile = nil) ⇒ Saltfile
Returns a new instance of Saltfile.
16 17 18 19 20 21 22 |
# File 'lib/salt/saltfile.rb', line 16 def initialize(basedir='.', formuladir=nil, saltfile=nil) @basedir = basedir @formuladir = formuladir || @basedir @saltfile = saltfile || File.join(@basedir, 'Saltfile') @formulas = [] end |
Instance Attribute Details
#basedir ⇒ Object (readonly)
Returns the value of attribute basedir.
8 9 10 |
# File 'lib/salt/saltfile.rb', line 8 def basedir @basedir end |
#formuladir ⇒ Object (readonly)
Returns the value of attribute formuladir.
9 10 11 |
# File 'lib/salt/saltfile.rb', line 9 def formuladir @formuladir end |
#formulas ⇒ Object (readonly)
Returns the value of attribute formulas.
10 11 12 |
# File 'lib/salt/saltfile.rb', line 10 def formulas @formulas end |
#saltfile ⇒ Object (readonly)
Returns the value of attribute saltfile.
11 12 13 |
# File 'lib/salt/saltfile.rb', line 11 def saltfile @saltfile end |
Instance Method Details
#add_formula(name, args) ⇒ Object
45 46 47 |
# File 'lib/salt/saltfile.rb', line 45 def add_formula(name, args) @formulas << Salt::Formula.new(name, @formuladir, args) end |
#load ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/salt/saltfile.rb', line 25 def load if File.readable? @saltfile self.load! else $stderr.puts "Saltfile (#{@saltfile}) missing or unreadable" end end |
#load! ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/salt/saltfile.rb', line 34 def load! dsl = DSL.new(self) dsl.instance_eval(saltfile_contents, @saltfile) rescue SyntaxError, LoadError => e puts e.inspect.magenta raise Salt::Matrix::Error.wrap(e, "Failed to process #{@saltfile}") end |
#saltfile_contents ⇒ File
50 51 52 |
# File 'lib/salt/saltfile.rb', line 50 def saltfile_contents File.read(@saltfile) end |