pusher 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/VERSION +1 -1
- data/lib/pusher.rb +33 -7
- data/lib/pusher/channel.rb +3 -6
- data/lib/pusher/request.rb +1 -1
- data/pusher.gemspec +3 -2
- data/spec/pusher_spec.rb +21 -1
- metadata +4 -3
data/CHANGELOG
ADDED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
data/lib/pusher.rb
CHANGED
@@ -20,18 +20,44 @@ module Pusher
|
|
20
20
|
def authentication_token
|
21
21
|
Signature::Token.new(@key, @secret)
|
22
22
|
end
|
23
|
+
|
24
|
+
# Builds a connection url for Pusherapp
|
25
|
+
def url
|
26
|
+
@url ||= URI::HTTP.build({
|
27
|
+
:host => self.host,
|
28
|
+
:port => self.port,
|
29
|
+
:path => "/apps/#{self.app_id}"
|
30
|
+
})
|
31
|
+
end
|
32
|
+
|
33
|
+
# Allows configuration from a url
|
34
|
+
def url=(url)
|
35
|
+
uri = URI.parse(url)
|
36
|
+
self.app_id = uri.path.split('/').last
|
37
|
+
self.key = uri.user
|
38
|
+
self.secret = uri.password
|
39
|
+
self.host = uri.host
|
40
|
+
self.port = uri.port
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def configured?
|
46
|
+
host && port && key && secret && app_id
|
47
|
+
end
|
23
48
|
end
|
24
49
|
|
25
|
-
self.
|
26
|
-
self.
|
27
|
-
|
28
|
-
|
29
|
-
|
50
|
+
self.host = 'api.pusherapp.com'
|
51
|
+
self.port = 80
|
52
|
+
|
53
|
+
if ENV['PUSHER_URL']
|
54
|
+
self.url = ENV['PUSHER_URL']
|
55
|
+
end
|
30
56
|
|
31
57
|
def self.[](channel_name)
|
32
|
-
raise ArgumentError, 'Missing configuration: please check that Pusher.
|
58
|
+
raise ArgumentError, 'Missing configuration: please check that Pusher.url is configured' unless configured?
|
33
59
|
@channels ||= {}
|
34
|
-
@channels[channel_name.to_s] = Channel.new(
|
60
|
+
@channels[channel_name.to_s] = Channel.new(url, channel_name)
|
35
61
|
end
|
36
62
|
end
|
37
63
|
|
data/lib/pusher/channel.rb
CHANGED
@@ -10,13 +10,10 @@ module Pusher
|
|
10
10
|
class Channel
|
11
11
|
attr_reader :name
|
12
12
|
|
13
|
-
def initialize(
|
13
|
+
def initialize(base_url, name)
|
14
|
+
@uri = base_url.dup
|
15
|
+
@uri.path = @uri.path + "/channels/#{name}/events"
|
14
16
|
@name = name
|
15
|
-
@uri = URI::HTTP.build({
|
16
|
-
:host => Pusher.host,
|
17
|
-
:port => Pusher.port,
|
18
|
-
:path => "/apps/#{app_id}/channels/#{name}/events"
|
19
|
-
})
|
20
17
|
end
|
21
18
|
|
22
19
|
def trigger_async(event_name, data, socket_id = nil, &block)
|
data/lib/pusher/request.rb
CHANGED
data/pusher.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{pusher}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["New Bamboo"]
|
12
|
-
s.date = %q{2010-05-
|
12
|
+
s.date = %q{2010-05-20}
|
13
13
|
s.description = %q{Wrapper for pusherapp.com REST api}
|
14
14
|
s.email = %q{support@pusherapp.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".gitignore",
|
22
|
+
"CHANGELOG",
|
22
23
|
"LICENSE",
|
23
24
|
"README.md",
|
24
25
|
"Rakefile",
|
data/spec/pusher_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe Pusher do
|
|
10
10
|
Pusher.host.should == 'api.pusherapp.com'
|
11
11
|
end
|
12
12
|
|
13
|
-
it 'should be preconfigured for
|
13
|
+
it 'should be preconfigured for port 80' do
|
14
14
|
Pusher.port.should == 80
|
15
15
|
end
|
16
16
|
|
@@ -28,6 +28,26 @@ describe Pusher do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
describe "configuration using url" do
|
32
|
+
after do
|
33
|
+
Pusher.app_id = nil
|
34
|
+
Pusher.key = nil
|
35
|
+
Pusher.secret = nil
|
36
|
+
Pusher.host = 'api.pusherapp.com'
|
37
|
+
Pusher.port = 80
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should be possible to configure everything by setting the url" do
|
41
|
+
Pusher.url = "http://somekey:somesecret@api.staging.pusherapp.com:8080/apps/87"
|
42
|
+
|
43
|
+
Pusher.host.should == 'api.staging.pusherapp.com'
|
44
|
+
Pusher.port.should == 8080
|
45
|
+
Pusher.key.should == 'somekey'
|
46
|
+
Pusher.secret.should == 'somesecret'
|
47
|
+
Pusher.app_id.should == '87'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
31
51
|
describe 'configured' do
|
32
52
|
before do
|
33
53
|
Pusher.app_id = '20'
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 0.5.
|
8
|
+
- 1
|
9
|
+
version: 0.5.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- New Bamboo
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-20 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -103,6 +103,7 @@ extra_rdoc_files:
|
|
103
103
|
files:
|
104
104
|
- .document
|
105
105
|
- .gitignore
|
106
|
+
- CHANGELOG
|
106
107
|
- LICENSE
|
107
108
|
- README.md
|
108
109
|
- Rakefile
|