Class: Hat::Stage

Inherits:
Object
  • Object
show all
Defined in:
lib/hat/stage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, configuration, list) ⇒ Stage

Returns a new instance of Stage.



5
6
7
8
# File 'lib/hat/stage.rb', line 5

def initialize name, configuration, list
  self.name = name.to_sym
  self.configuration = configuration
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



3
4
5
# File 'lib/hat/stage.rb', line 3

def configuration
  @configuration
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/hat/stage.rb', line 3

def name
  @name
end

Instance Method Details

#define_task(recipes) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/hat/stage.rb', line 14

def define_task(recipes)
  conf = self.configuration
  name = self.name

  task = Rake::Task.define_task(name) do
    invoke 'load:defaults'
    conf.each do  |k, v|
      set k.to_sym, v
    end
    recipes.list.each{|l| load "#{recipes.dir}/recipes/#{l}.rb" }
    set(:stage, name)
    load "capistrano/#{fetch(:scm)}.rb"
    I18n.locale = fetch(:locale, :en)
    configure_backend
  end

end

#set_defaults(defaults) ⇒ Object



10
11
12
# File 'lib/hat/stage.rb', line 10

def set_defaults(defaults)
  configuration.merge!(Hash[defaults])
end