Module: Capistrano::Blaze

Extended by:
Blaze
Included in:
Blaze
Defined in:
lib/capistrano/blaze.rb,
lib/capistrano/blaze/version.rb

Constant Summary collapse

VERSION =
'0.0.1'

Instance Method Summary collapse

Instance Method Details

#commandObject



45
46
47
# File 'lib/capistrano/blaze.rb', line 45

def command
  [ 'cap', *$* ] * ' '
end

#configure(opts = {}) {|@config| ... } ⇒ Object

Yields:

  • (@config)


11
12
13
14
# File 'lib/capistrano/blaze.rb', line 11

def configure(opts = {})
  @config = OpenStruct.new(opts)
  yield @config if block_given?
end

#failure(context, exception) ⇒ Object



29
30
31
# File 'lib/capistrano/blaze.rb', line 29

def failure(context, exception)
  speak ":warning: #{user} failed to deploy to the #{context.stage} stage of #{context.application}, via `#{command}`: #{exception.to_s} (#{exception.class.inspect})"
end

#speak(message) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/capistrano/blaze.rb', line 16

def speak(message)
  port = @config.ssl ? 443 : 80

  req = Net::HTTP::Post.new("/room/#{@config.room_id}/speak.json")
  req.basic_auth @config.token, 'X'
  req.body = { :message => { :body => message } }.to_json
  req.content_type = "application/json"

  res = Net::HTTP.start("#{@config.}.campfirenow.com", port, :use_ssl => @config.ssl) do |http|
    http.request(req)
  end
end

#success(context) ⇒ Object



33
34
35
# File 'lib/capistrano/blaze.rb', line 33

def success(context)
  speak "#{user} succesfully deployed to the #{context.stage} stage of #{context.application}, via `#{command}`"
end

#test(context) ⇒ Object



41
42
43
# File 'lib/capistrano/blaze.rb', line 41

def test(context)
  speak ":heart: #{context.application}!"
end

#userObject



37
38
39
# File 'lib/capistrano/blaze.rb', line 37

def user
  `whoami`.strip
end