firering 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/firering.gemspec +4 -4
- data/lib/firering/connection.rb +4 -4
- data/lib/firering/data/room.rb +1 -1
- data/lib/firering/data.rb +1 -1
- data/lib/firering.rb +1 -1
- data/spec/firering/connection_spec.rb +3 -3
- metadata +6 -6
data/README.rdoc
CHANGED
data/firering.gemspec
CHANGED
@@ -4,12 +4,12 @@ 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.
|
8
|
-
s.date = '2010-10-
|
7
|
+
s.version = '1.0.3'
|
8
|
+
s.date = '2010-10-12'
|
9
9
|
s.rubyforge_project = 'firering'
|
10
10
|
|
11
|
-
s.summary = "Campfire API interface powered by
|
12
|
-
s.description = "Campfire API interface powered by
|
11
|
+
s.summary = "Campfire API interface powered by eventmachine em-http-request and yajl-ruby."
|
12
|
+
s.description = "Campfire API interface powered by eventmachine em-http-request and yajl-ruby."
|
13
13
|
|
14
14
|
s.authors = ["Emmanuel Oga"]
|
15
15
|
s.email = 'EmmanuelOga@gmail.com'
|
data/lib/firering/connection.rb
CHANGED
@@ -77,14 +77,14 @@ module Firering
|
|
77
77
|
# The Streaming API allows you to monitor a room in real time. The
|
78
78
|
# authenticated user must already have joined the room in order to use this
|
79
79
|
# API.
|
80
|
-
def stream(
|
80
|
+
def stream(room, &callback)
|
81
81
|
parser = Yajl::Parser.new(:symbolize_keys => true)
|
82
82
|
|
83
83
|
parser.on_parse_complete = proc do |data|
|
84
84
|
callback.call(Firering::Message.instantiate(self, data)) if callback
|
85
85
|
end
|
86
86
|
|
87
|
-
uri = streaming_host.join("/room/#{
|
87
|
+
uri = streaming_host.join("/room/#{room.id}/live.json")
|
88
88
|
logger.info("performing streaming request to #{uri.to_s}")
|
89
89
|
http = EventMachine::HttpRequest.new(uri).get(parameters)
|
90
90
|
|
@@ -93,7 +93,7 @@ module Firering
|
|
93
93
|
parser << chunk; reset_retries_counter
|
94
94
|
rescue Yajl::ParseError
|
95
95
|
perform_retry(http) do
|
96
|
-
stream(
|
96
|
+
room.stream(&callback)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
@@ -104,7 +104,7 @@ module Firering
|
|
104
104
|
# few seconds before trying to reconnect. Formats
|
105
105
|
http.errback do
|
106
106
|
perform_retry(http) do
|
107
|
-
stream(
|
107
|
+
room.stream(&callback)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
data/lib/firering/data/room.rb
CHANGED
@@ -8,7 +8,7 @@ class Firering::Room < Firering::Data
|
|
8
8
|
alias_method :open_to_guests?, :open_to_guests
|
9
9
|
|
10
10
|
def stream(&callback)
|
11
|
-
join { |data, http| connection.stream(
|
11
|
+
join { |data, http| connection.stream(self, &callback) }
|
12
12
|
end
|
13
13
|
|
14
14
|
# we perform a request each time so
|
data/lib/firering/data.rb
CHANGED
@@ -29,7 +29,7 @@ module Firering
|
|
29
29
|
def initialize_attributes(data, base_key = nil)
|
30
30
|
@_attributes = data.is_a?(Hash) ? data : Yajl::Parser.parse(data, :symbolize_keys => true)
|
31
31
|
@_attributes = @_attributes[base_key] if base_key
|
32
|
-
|
32
|
+
@_attributes ||= Hash.new
|
33
33
|
@_attributes.each do |key, val|
|
34
34
|
@_attributes[key] = Date.parse(val) rescue val if key.to_s =~ /(_at|_on)$/
|
35
35
|
end
|
data/lib/firering.rb
CHANGED
@@ -13,7 +13,7 @@ describe Firering::Connection do
|
|
13
13
|
|
14
14
|
it "stream messages" do
|
15
15
|
EM.run {
|
16
|
-
conn.stream(304355) do |message|
|
16
|
+
conn.stream(Firering::Room.instantiate(conn, :id => 304355)) do |message|
|
17
17
|
message.should be_an_instance_of(Firering::Message)
|
18
18
|
end
|
19
19
|
|
@@ -29,7 +29,7 @@ describe Firering::Connection do
|
|
29
29
|
messages = []
|
30
30
|
|
31
31
|
EM.run {
|
32
|
-
conn.stream(304355) do |message|
|
32
|
+
conn.stream(Firering::Room.instantiate(conn, :id => 304355)) do |message|
|
33
33
|
messages << message
|
34
34
|
end
|
35
35
|
EM.add_timer(conn.max_retries * conn.retry_delay + 1) do
|
@@ -47,7 +47,7 @@ describe Firering::Connection do
|
|
47
47
|
|
48
48
|
begin
|
49
49
|
EM.run {
|
50
|
-
conn.stream(304355) { |message| messages << message }
|
50
|
+
conn.stream(Firering::Room.instantiate(conn, :id => 304355)) { |message| messages << message }
|
51
51
|
|
52
52
|
EM.add_timer(conn.max_retries * conn.retry_delay + 1) { EM.stop }
|
53
53
|
}
|
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:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
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: 2010-10-
|
18
|
+
date: 2010-10-12 00:00:00 -03:00
|
19
19
|
default_executable: campf-notify
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: 1.0.0
|
99
99
|
type: :development
|
100
100
|
version_requirements: *id005
|
101
|
-
description: Campfire API interface powered by
|
101
|
+
description: Campfire API interface powered by eventmachine em-http-request and yajl-ruby.
|
102
102
|
email: EmmanuelOga@gmail.com
|
103
103
|
executables:
|
104
104
|
- campf-notify
|
@@ -204,7 +204,7 @@ rubyforge_project: firering
|
|
204
204
|
rubygems_version: 1.3.7
|
205
205
|
signing_key:
|
206
206
|
specification_version: 2
|
207
|
-
summary: Campfire API interface powered by
|
207
|
+
summary: Campfire API interface powered by eventmachine em-http-request and yajl-ruby.
|
208
208
|
test_files:
|
209
209
|
- spec/firering/connection_spec.rb
|
210
210
|
- spec/firering/data/message_spec.rb
|