Class: Blazing::Config

Inherits:
Object
  • Object
show all
Extended by:
DSLSetter
Includes:
Logger
Defined in:
lib/blazing/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DSLSetter

dsl_setter

Constructor Details

#initialize(configuration_file = nil) ⇒ Config

Returns a new instance of Config.



25
26
27
28
29
# File 'lib/blazing/config.rb', line 25

def initialize(configuration_file = nil)
  @file = configuration_file || Blazing::DEFAULT_CONFIG_LOCATION
  @targets = []
  @recipes = []
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



10
11
12
# File 'lib/blazing/config.rb', line 10

def file
  @file
end

#recipesObject

Returns the value of attribute recipes.



11
12
13
# File 'lib/blazing/config.rb', line 11

def recipes
  @recipes
end

#targetsObject

Returns the value of attribute targets.



11
12
13
# File 'lib/blazing/config.rb', line 11

def targets
  @targets
end

Class Method Details

.parse(configuration_file = nil) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/blazing/config.rb', line 16

def parse(configuration_file = nil)
  Blazing::Recipe.load_recipes!
  config = self.new(configuration_file)
  config.instance_eval(File.read(config.file))

  config
end

Instance Method Details

#default_targetObject



49
50
51
52
53
# File 'lib/blazing/config.rb', line 49

def default_target
  if @targets.size == 1
    @targets.first
  end
end

#find_target(target_name) ⇒ Object

TODO: Spec it!



56
57
58
# File 'lib/blazing/config.rb', line 56

def find_target(target_name)
  targets.find { |t| t.name.to_s == target_name.to_s }
end

#rake(task_name, env = nil) ⇒ Object



40
41
42
43
# File 'lib/blazing/config.rb', line 40

def rake(task_name, env = nil)
  @rake = { :task => task_name }
  @rake[:env] = env if env
end

#recipe(name, options = {}) ⇒ Object



36
37
38
# File 'lib/blazing/config.rb', line 36

def recipe(name, options = {})
  @recipes << Blazing::Recipe.init_by_name(name, options)
end

#repository(*args) ⇒ Object



45
46
47
# File 'lib/blazing/config.rb', line 45

def repository(*args)
  warn 'Ther repository DSL method has been deprecated and is no longer used. This method will be removed in Version 0.3'
end

#target(name, location, options = {}) ⇒ Object



31
32
33
34
# File 'lib/blazing/config.rb', line 31

def target(name, location, options = {})
  raise "Name already taken" if targets.find { |t| t.name == name }
  targets << Blazing::Target.new(name, location, self, options)
end