Skip to content

Commit 1abd389

Browse files
authored
Merge pull request #116 from dmcnally/master
Helper to load the configuration from a URL
2 parents a509b38 + 30c3011 commit 1abd389

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/pusher/client.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ class Client
1212
# Loads the configuration from an url in the environment
1313
def self.from_env(key = 'PUSHER_URL')
1414
url = ENV[key] || raise(ConfigurationError, key)
15+
from_url(url)
16+
end
17+
18+
# Loads the configuration from a url
19+
def self.from_url(url)
1520
client = new
1621
client.url = url
1722
client

spec/client_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@
125125
end
126126
end
127127

128+
describe 'configuring from url' do
129+
it "works" do
130+
url = "http://somekey:somesecret@api.staging.pusherapp.com:8080/apps/87"
131+
132+
client = Pusher::Client.from_url(url)
133+
expect(client.key).to eq("somekey")
134+
expect(client.secret).to eq("somesecret")
135+
expect(client.app_id).to eq("87")
136+
expect(client.url.to_s).to eq("http://api.staging.pusherapp.com:8080/apps/87")
137+
end
138+
end
139+
128140
describe 'when configured' do
129141
before :each do
130142
@client.app_id = '20'

0 commit comments

Comments
 (0)