Class: Capistrano::Campfire::RoomCollection

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

Instance Method Summary collapse

Constructor Details

#initialize(campfire_options) ⇒ RoomCollection

Returns a new instance of RoomCollection.



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

def initialize(campfire_options)
  rooms_options = campfire_options[:rooms]

  # if no rooms specified, let's assume the campfire_options has everything
  # so let's fake it
  unless rooms_options
    rooms_options = [{}]
  end

  @rooms = rooms_options.map do |room_options|
     = room_options[:account] || campfire_options[:account]
    token = room_options[:token] || campfire_options[:token]
    ssl = room_options[:ssl] || campfire_options[:ssl]
    ssl_verify = room_options[:ssl_verify] || campfire_options[:ssl_verify]
    room_name = room_options[:room] || campfire_options[:room]
    room_id = room_options[:room] || campfire_options[:room_id]


    campfire = ::Tinder::Campfire.new ,
      :token => token,
      :ssl => ssl,
      :ssl_verify => ssl_verify

    if room_name
      campfire.find_room_by_name(room_name)
    elsif room_id
      campfire.find_room_by_id(room_id)
    else
      raise "Please, specify room name or room_id for your Campfire room"
    end
  end
end

Instance Method Details

#paste(message) ⇒ Object



46
47
48
49
50
# File 'lib/capistrano/campfire.rb', line 46

def paste(message)
  @rooms.each do |room|
    room.paste message
  end
end

#play(message) ⇒ Object



52
53
54
55
56
# File 'lib/capistrano/campfire.rb', line 52

def play(message)
  @rooms.each do |room|
    room.play message
  end
end

#speak(message) ⇒ Object



40
41
42
43
44
# File 'lib/capistrano/campfire.rb', line 40

def speak(message)
  @rooms.each do |room|
    room.speak message
  end
end