firering 1.0.7 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -84,6 +84,7 @@ For more details take a look at spec/fixtures/load_server.rb file.
84
84
  * indirect (Andre Arko), https://github.com/EmmanuelOga/firering/pull/1 ,
85
85
  https://github.com/EmmanuelOga/firering/pull/2 ,
86
86
  https://github.com/EmmanuelOga/firering/pull/3
87
+ * caius (Caius Durling), https://github.com/EmmanuelOga/firering/pull/5
87
88
 
88
89
  == Copyright
89
90
 
data/bin/campf-notify CHANGED
@@ -19,7 +19,7 @@ if subdomain.to_s =~ /^\s*$/ || token.to_s =~ /^\s*$/ || room_name.to_s =~ /^\s*
19
19
  puts
20
20
  exit 1
21
21
  else
22
- host = "http://#{subdomain}.campfirenow.com"
22
+ host = "https://#{subdomain}.campfirenow.com"
23
23
  puts "connecting to #{host}"
24
24
  end
25
25
 
@@ -27,22 +27,26 @@ conn = Firering::Connection.new(host) {|c| c.token = token }
27
27
 
28
28
  EM.run do
29
29
  conn.rooms do |rooms|
30
- room = rooms.detect { |r| r.name == room_name }
30
+ room = rooms.detect { |r| room_name =~ /#{r.name}|#{r.id}/i }
31
31
 
32
- unless room
33
- puts "Could not find that room. Found rooms:"
34
- rooms.each { |room| puts " * #{room}" }
35
- exit 1
36
- end
37
-
38
- puts "Streaming #{room}"
32
+ if room
33
+ puts "Streaming #{room}"
39
34
 
40
- room.stream do |message|
41
- if message.from_user?
42
- message.user { |user| system("notify-send -i #{icon_path.shellescape} -t 10000 Campfire #{ "( #{user} ) #{message}".shellescape }") }
35
+ room.stream do |message|
36
+ if message.from_user?
37
+ message.user { |user| system("notify-send -i #{icon_path.shellescape} -t 10000 Campfire #{ "( #{user} ) #{message}".shellescape }") }
38
+ else
39
+ system("notify-send -i #{icon_path.shellescape} -t 10000 Campfire #{message.to_s.shellescape}") if message.to_s =~ /\S/
40
+ end
41
+ end
42
+ else
43
+ if rooms.empty?
44
+ puts "Could not find any rooms on #{host}. Check your host/credentials?"
43
45
  else
44
- system("notify-send -i #{icon_path.shellescape} -t 10000 Campfire #{message.to_s.shellescape}") if message.to_s =~ /\S/
46
+ puts "Could not find #{room_name.inspect} room on #{host}, but found: "
47
+ rooms.each { |room| puts " * #{room}" }
45
48
  end
49
+ EM.stop
46
50
  end
47
51
  end
48
52
 
data/firering.gemspec CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.5'
5
5
 
6
6
  s.name = 'firering'
7
- s.version = '1.0.7'
8
- s.date = '2011-03-03'
7
+ s.version = '1.1.0'
8
+ s.date = '2011-05-04'
9
9
  s.rubyforge_project = 'firering'
10
10
 
11
11
  s.summary = "Campfire API interface powered by eventmachine em-http-request and yajl-ruby."
@@ -1,5 +1,5 @@
1
1
  module Firering
2
- User = Struct.new(:connection, :id, :name, :email_address, :admin, :created_at, :type, :api_auth_token)
2
+ User = Struct.new(:connection, :id, :name, :email_address, :admin, :created_at, :type, :api_auth_token, :avatar_url)
3
3
 
4
4
  class User
5
5
  extend Instantiator
@@ -10,8 +10,19 @@ module Firering
10
10
  attributes ||= Hash.new
11
11
 
12
12
  attributes.each do |key, val|
13
+ setter = "#{key}="
13
14
  value = ( key.to_s =~ /(_at|_on)$/ ) ? (Time.parse(val) rescue val) : val
14
- instance.send("#{key}=", value)
15
+ if instance.respond_to?(setter)
16
+ instance.send(setter, value)
17
+ else
18
+ warning = "WARNING: Tried to set #{setter} #{value.inspect} on a #{instance.class} instance but it didn't respond. Probably the API got updated, please report this! (https://github.com/EmmanuelOga/firering/issues)"
19
+
20
+ if conn && conn.logger
21
+ conn.logger.warn warning
22
+ else
23
+ Kernel.warn warning
24
+ end
25
+ end
15
26
  end
16
27
 
17
28
  callback.call(instance) if callback
@@ -27,7 +27,12 @@ module Firering
27
27
  # multi: if true, gets all the users from each room as Firering::User objects
28
28
  def rooms(&callback)
29
29
  http(:get, "/rooms.json") do |data, http|
30
- callback.call(data[:rooms].map{|room| Firering::Room.instantiate(self, room)}) if callback
30
+ if data[:rooms]
31
+ callback.call(data[:rooms].map{|room| Firering::Room.instantiate(self, room)}) if callback
32
+ else
33
+ logger.error(http.response)
34
+ callback.call([])
35
+ end
31
36
  end
32
37
  end
33
38
 
data/lib/firering.rb CHANGED
@@ -5,7 +5,7 @@ require 'yajl'
5
5
  require 'em-http'
6
6
 
7
7
  module Firering
8
- VERSION = '1.0.7'
8
+ VERSION = '1.1.0'
9
9
 
10
10
  Error = Class.new(StandardError)
11
11
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firering
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
4
+ hash: 19
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 7
10
- version: 1.0.7
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Emmanuel Oga
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-03 00:00:00 -03:00
18
+ date: 2011-05-04 00:00:00 -03:00
19
19
  default_executable: campf-notify
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  requirements: []
202
202
 
203
203
  rubyforge_project: firering
204
- rubygems_version: 1.3.7
204
+ rubygems_version: 1.6.0
205
205
  signing_key:
206
206
  specification_version: 2
207
207
  summary: Campfire API interface powered by eventmachine em-http-request and yajl-ruby.