Module: Capistrano::Mountaintop

Defined in:
lib/capistrano/mountaintop.rb

Class Method Summary collapse

Class Method Details

.extended(configuration) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/capistrano/mountaintop.rb', line 7

def self.extended(configuration)
  configuration.load do

    before 'deploy', 'mountaintop:campfire:starting'
    before 'deploy:migrations', 'mountaintop:campfire:starting'
    after 'deploy',  'mountaintop:campfire:finished'

    set :deployer do
      ENV['GIT_AUTHOR_NAME'] || `git config user.name`.chomp
    end


    namespace :mountaintop do
      namespace :campfire do
        task :starting do
          announced_deployer = fetch(:deployer)
          announced_stage = fetch(:stage, 'production')

          announcement = if fetch(:branch, nil)
                           "#{announced_deployer} is deploying #{application}'s #{branch} to #{announced_stage}"
                         else
                           "#{announced_deployer} is deploying #{application} to #{announced_stage}"
                         end
          
          campfire_room.speak announcement
        end


        task :finished do
          begin
            campfire_room.paste fetch(:full_log)
          rescue Faraday::Error::ParsingError
            # FIXME deal with crazy color output instead of rescuing
            # it's stuff like: ^[[0;33m and ^[[0m
          end
        end
      end
    end
  end
end