Class: Claws::Capistrano

Inherits:
Object
  • Object
show all
Defined in:
lib/claws/capistrano.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(home = nil) ⇒ Capistrano

Returns a new instance of Capistrano.



5
6
7
# File 'lib/claws/capistrano.rb', line 5

def initialize(home = nil)
  self.home = home || File.join('config', 'deploy')
end

Instance Attribute Details

#homeObject

Returns the value of attribute home.



3
4
5
# File 'lib/claws/capistrano.rb', line 3

def home
  @home
end

Instance Method Details

#all_host_rolesObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/claws/capistrano.rb', line 9

def all_host_roles
  @all_roles ||= begin
    roles = Hash.new

    Dir.glob(File.join(self.home, '**/*.rb')).each do |f|
      environment = File.basename(f)[0..-4]
      roles[environment.to_sym] = get_roles(environment)
    end

    roles
  end
end

#roles(host) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/claws/capistrano.rb', line 22

def roles(host)
  self.all_host_roles.each do |env, hh|
    hh.each do |k,v|
      return v if k == host
    end
  end
end