Module: Capistrano::Blaze

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

Defined Under Namespace

Classes: Configuration, Message

Constant Summary collapse

VERSION =
'0.2.0'

Instance Method Summary collapse

Instance Method Details

#configurationObject


16
17
18
# File 'lib/capistrano/blaze.rb', line 16

def configuration
  @configuration ||= Configuration.new
end

#configure {|configuration| ... } ⇒ Object

Yields:


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

def configure
  yield configuration
end

#speak(message) ⇒ Object


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/blaze.rb', line 20

def speak(message)
  configuration.validate!
  port = configuration.ssl ? 443 : 80

  req = Net::HTTP::Post.new("/room/#{configuration.room_id}/speak.json")
  req.basic_auth configuration.token, 'X'
  req.body = { :message => { :body => message } }.to_json
  req.content_type = "application/json"
  req["User-Agent"] = "Capistrano::Blaze"

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

  if res.is_a?(Net::HTTPSuccess)
    warn "Campfire message sent!"
  else
    warn "Campfire communication failed!"
    warn res.inspect
    warn res.body.inspect
  end
end