Class: Garlic::Configurator

Inherits:
Object
  • Object
show all
Defined in:
lib/garlic/configurator.rb

Overview

Configures the garlic runner in a decalarative style

Defined Under Namespace

Classes: BlockParser

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#garlicObject (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, options = {})
  options[:name] = name
  options[:path] ||= "#{garlic.repo_path}/#{name}"
  garlic.repos << Repo.new(options)
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (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, options = {}, &block)
  options[:name] = name
  options[:path] = "#{garlic.work_path}/#{name_to_path(name)}"
  BlockParser.new(options, [:prepare, :run], &block) if block_given?
  garlic.targets << Target.new(garlic, options)
end