Permalink
Browse files

+ method renaming to avoid funky problems when loading config files

  • Loading branch information...
1 parent ded0dbd commit ad716f97d967a8cb569e4bec9b332f8699638ffb @floere floere committed Jun 28, 2012
Showing with 14 additions and 14 deletions.
  1. +1 −1 bin/bocuse
  2. +8 −8 lib/bocuse/file.rb
  3. +2 −2 lib/bocuse/loader.rb
  4. +1 −1 lib/bocuse/templates.rb
  5. +1 −1 spec/integration/complex_spec.rb
  6. +1 −1 spec/integration/loader_spec.rb
View
2 bin/bocuse
@@ -8,6 +8,6 @@ puts %Q{Loading configuration for node "#{node}"}
require File.expand_path '../../lib/bocuse', __FILE__
loader = Bocuse::Loader.new
-configuration = loader.load node
+configuration = loader.evaluate node
STDOUT.write configuration.to_h # TODO to_json
View
16 lib/bocuse/file.rb
@@ -11,7 +11,7 @@ module Bocuse
#
class File
- def configuration
+ def __configuration__
@configuration ||= Configuration.new
end
@@ -24,11 +24,11 @@ def configuration
# to speak of inside the file. Use "node" or
# "template" to define a configuration.
#
- def load filename
+ def evaluate filename
::File.open filename, 'r' do |file|
self.instance_eval file.read, file.path
end
- configuration
+ __configuration__
end
# Include the given template name.
@@ -37,23 +37,23 @@ def load filename
#
def include_template identifier
template = Templates.get identifier.to_sym
- configuration.merge! template
+ __configuration__.merge! template
end
- # The files read by #load will trigger these methods.
+ # The files read by #evaluate will trigger these methods.
#
# TODO Do something with the name?
#
def node name = nil
- yield configuration
- configuration
+ yield __configuration__
+ __configuration__
end
alias template node
# Cook adds to the toplevel recipes of this file's configuration.
#
def cook recipe
- configuration.recipes << recipe
+ __configuration__.recipes << recipe
end
end
View
4 lib/bocuse/loader.rb
@@ -8,10 +8,10 @@ class Loader
#
# TODO It should load all nodes, presumably?
#
- def load name
+ def evaluate name
filename = ::File.expand_path "config/nodes/#{name}.rb", Dir.pwd
file = Bocuse::File.new
- file.load filename
+ file.evaluate filename
end
end
View
2 lib/bocuse/templates.rb
@@ -21,7 +21,7 @@ def put identifier, configuration
#
def load_template identifier
file = Bocuse::File.new
- configuration = file.load ::File.expand_path("config/templates/#{identifier}.rb", Dir.pwd)
+ configuration = file.evaluate ::File.expand_path("config/templates/#{identifier}.rb", Dir.pwd)
put identifier, configuration
end
end
View
2 spec/integration/complex_spec.rb
@@ -11,7 +11,7 @@
Dir.chdir File.expand_path '../../files/complex/', __FILE__
filename = File.expand_path '../../files/complex/config/nodes/staging/complex.rb', __FILE__
- configuration = Bocuse::File.new.load filename
+ configuration = Bocuse::File.new.evaluate filename
configuration.to_h.should == {
:user => "root",
View
2 spec/integration/loader_spec.rb
@@ -10,7 +10,7 @@
it 'loads the configuration' do
Dir.chdir File.expand_path('../../files/complex', __FILE__)
- loader.load('staging/complex').to_h.should == {
+ loader.evaluate('staging/complex').to_h.should == {
:user => "root",
:users => [
{

0 comments on commit ad716f9

Please sign in to comment.