Class: Garlic::Configurator
- Inherits:
-
Object
- Object
- Garlic::Configurator
- Defined in:
- lib/garlic/configurator.rb
Overview
Configures the garlic runner in a decalarative style
Defined Under Namespace
Classes: BlockParser
Instance Attribute Summary collapse
-
#garlic ⇒ Object
readonly
Returns the value of attribute garlic.
Instance Method Summary collapse
-
#initialize(garlic, &block) ⇒ Configurator
constructor
A new instance of Configurator.
- #repo(name, options = {}) ⇒ Object
- #respond_to?(method) ⇒ Boolean
- #target(name, options = {}, &block) ⇒ Object
Constructor Details
#initialize(garlic, &block) ⇒ Configurator
Returns a new instance of Configurator.
6 7 8 9 |
# File 'lib/garlic/configurator.rb', line 6 def initialize(garlic, &block) @garlic = garlic instance_eval(&block) if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(attribute, value) ⇒ Object (protected)
33 34 35 36 37 38 39 |
# File 'lib/garlic/configurator.rb', line 33 def method_missing(attribute, value) if garlic.respond_to?("#{attribute}=") garlic.send("#{attribute}=", value) else super end end |
Instance Attribute Details
#garlic ⇒ Object (readonly)
Returns the value of attribute garlic.
4 5 6 |
# File 'lib/garlic/configurator.rb', line 4 def garlic @garlic end |
Instance Method Details
#repo(name, options = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/garlic/configurator.rb', line 11 def repo(name, = {}) [:name] = name [:path] ||= "#{garlic.repo_path}/#{name}" garlic.repos << Repo.new() end |
#respond_to?(method) ⇒ Boolean
24 25 26 |
# File 'lib/garlic/configurator.rb', line 24 def respond_to?(method) super || garlic.respond_to?("#{method}=") end |
#target(name, options = {}, &block) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/garlic/configurator.rb', line 17 def target(name, = {}, &block) [:name] = name [:path] = "#{garlic.work_path}/#{name_to_path(name)}" BlockParser.new(, [:prepare, :run], &block) if block_given? garlic.targets << Target.new(garlic, ) end |