Module: Capistrano::Mountaintop

Defined in:
lib/capistrano/mountaintop.rb

Class Method Summary collapse

Class Method Details

.load_into(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
# File 'lib/capistrano/mountaintop.rb', line 7

def self.load_into(configuration)

  configuration.load do

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

    namespace :mountaintop do
      namespace :campfire do
        task :starting do
          announced_deployer = fetch(:deployer,  `git config user.name`.chomp)
          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
            # nah, it's cool. happens particularly when color is involved
            # TODO sanitze full_log instead
          end
        end
      end
    end
  end
end