lib/fiveruns/dash/configuration.rb in fiveruns-dash-ruby-0.8.0 vs lib/fiveruns/dash/configuration.rb in fiveruns-dash-ruby-0.8.1

- old
+ new

@@ -64,16 +64,17 @@ # Merge in an existing recipe # call-seq: # add_recipe :ruby def add_recipe(name, options = {}, &block) Fiveruns::Dash.register_recipe(name, options, &block) if block_given? - if Fiveruns::Dash.recipes[name] Fiveruns::Dash.recipes[name].each do |recipe| if !recipes.include?(recipe) && recipe.matches?(options) recipes << recipe - recipe.add_to(self) + with_recipe_settings(options.reject { |k, _| k == :url }) do + recipe.add_to(self) + end end end else raise ArgumentError, "No such recipe: #{name}" end @@ -88,15 +89,29 @@ end end # Optionally fired by recipes when included def added - yield + yield current_recipe_settings end ####### private ####### + + def with_recipe_settings(settings = {}) + recipe_settings_stack << settings + yield + recipe_settings_stack.pop + end + + def current_recipe_settings + recipe_settings_stack.last + end + + def recipe_settings_stack + @recipe_settings_stack ||= [] + end def normalize_version_comparator(comparator) comparator.to_s == '=' ? '==' : comparator end \ No newline at end of file