Class: Flombe::Dsl
- Inherits:
-
Object
- Object
- Flombe::Dsl
- Defined in:
- lib/flombe/dsl.rb
Constant Summary collapse
- CHEF_METHODS =
%w(cookbook_path sandbox_path file_cache_path file_backup_path json_attribs log_level log_location verbose_logging node_name node_path solo ssl_verify_mode umask recipe_url cache_type cache_options)
- BASE_COOKBOOKS =
[File.('../../../cookbooks', __FILE__)]
- FLOMBE_BASE =
"#{ENV['HOME']}/.flombe"
Class Method Summary collapse
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize ⇒ Dsl
constructor
A new instance of Dsl.
- #recipe(name, *args) ⇒ Object
- #rubies(rubies, *args) ⇒ Object
- #to_dna ⇒ Object
- #to_solo_config ⇒ Object
Constructor Details
#initialize ⇒ Dsl
Returns a new instance of Dsl.
15 16 17 18 |
# File 'lib/flombe/dsl.rb', line 15 def initialize @config = {} @recipes = {} end |
Class Method Details
.evaluate(flombefile) ⇒ Object
9 10 11 12 13 |
# File 'lib/flombe/dsl.rb', line 9 def self.evaluate(flombefile) builder = new builder.instance_eval(File.open(flombefile, "rb") { |f| f.read }, flombefile.to_s, 1) builder end |
Instance Method Details
#config ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/flombe/dsl.rb', line 20 def config cookbooks = @config.delete(:cookbook_path) cookbooks = [cookbooks] if cookbooks.kind_of? String { :file_cache_path => "#{FLOMBE_BASE}/cache", :file_backup_path => "#{FLOMBE_BASE}/backup", :sandbox_path => "#{FLOMBE_BASE}/sandbox", :log_level => :info, :log_location => STDOUT, :cookbook_path => BASE_COOKBOOKS + (cookbooks || []), :cache_options => {:path => "#{FLOMBE_BASE}/cache/checksums", :skip_expires => true} }.merge!(@config) end |
#recipe(name, *args) ⇒ Object
51 52 53 54 |
# File 'lib/flombe/dsl.rb', line 51 def recipe(name, *args) = Hash === args.last ? args.pop : {} @recipes[name.to_sym] = end |
#rubies(rubies, *args) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/flombe/dsl.rb', line 56 def rubies(rubies, *args) @recipes[:rvm] = {} unless @recipes.has_key?(:rvm) rubies = [rubies] if rubies.is_a? String @recipes[:rvm][:rubies] = rubies = Hash === args.last ? args.pop : {} @recipes[:rvm][:default_ruby] = [:default] unless [:default].nil? end |
#to_dna ⇒ Object
34 35 36 37 38 |
# File 'lib/flombe/dsl.rb', line 34 def to_dna { :recipes => @recipes.keys }.merge!(@recipes).to_json end |
#to_solo_config ⇒ Object
40 41 42 43 |
# File 'lib/flombe/dsl.rb', line 40 def to_solo_config template = File.open(File.('../../../templates/chef_solo.erb', __FILE__), "r") { |f| f.read } Erubis::Eruby.new(template).result(:config => config) end |