Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Custom origin is now available for sub and pub. Added test for the same.

  • Loading branch information...
commit 98fc4070ecd3ff03800ff9c5d51bd66e76a8301e 1 parent 4caa7a6
geremy authored
View
1  ruby/3.3/CHANGELOG
@@ -2,6 +2,7 @@
. errors logged to /tmp/pubnubError.log by default
. selectively retry based on operation type
. adjust request timeouts based on operation type
+. publish and subscribe both take origin argument
02-25-13
. graceful recover on bad json
View
2  ruby/3.3/Gemfile
@@ -11,7 +11,7 @@ gem 'sqlite3'
gem 'em-http-request'
gem "uuid", "~> 2.3.5"
gem 'yajl-ruby'
-gem 'pubnub'
+gem 'pubnub', "3.3.0.5"
gem 'linecache19'
gem 'ruby_core_source'
gem 'ruby-debug19'
View
4 ruby/3.3/Gemfile.lock
@@ -73,7 +73,7 @@ GEM
rack
rake (>= 0.8.1)
polyglot (0.3.3)
- pubnub (3.3.0.4)
+ pubnub (3.3.0.5)
activesupport
em-http-request
eventmachine
@@ -156,7 +156,7 @@ DEPENDENCIES
httparty
linecache19
passenger
- pubnub
+ pubnub (= 3.3.0.5)
rails (= 3.2.6)
rr (= 1.0.4)
rspec-rails (~> 2.0)
View
44 ruby/3.3/fixtures/vcr_cassettes/integration_publish_10.yml
@@ -0,0 +1,44 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: http://a.pubnub.com/publish/demo/demo/0/hello_world/0/%22hi%22
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers: {}
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ !binary "RGF0ZQ==":
+ - !binary |-
+ VHVlLCAyNiBGZWIgMjAxMyAyMjoyMzo1NiBHTVQ=
+ !binary "Q29udGVudC1UeXBl":
+ - !binary |-
+ dGV4dC9qYXZhc2NyaXB0OyBjaGFyc2V0PSJVVEYtOCI=
+ !binary "Q29udGVudC1MZW5ndGg=":
+ - !binary |-
+ MzA=
+ !binary "Q29ubmVjdGlvbg==":
+ - !binary |-
+ Y2xvc2U=
+ !binary "Q2FjaGUtQ29udHJvbA==":
+ - !binary |-
+ bm8tY2FjaGU=
+ !binary "QWNjZXNzLUNvbnRyb2wtQWxsb3ctT3JpZ2lu":
+ - !binary |-
+ Kg==
+ !binary "QWNjZXNzLUNvbnRyb2wtQWxsb3ctTWV0aG9kcw==":
+ - !binary |-
+ R0VU
+ !binary "UG4tVHQ=":
+ - !binary |-
+ MTM2MTkxNzQzNjAyNDc1Nzc=
+ body:
+ encoding: US-ASCII
+ string: ! '[1,"Sent","13619174360247577"]'
+ http_version:
+ recorded_at: Tue, 26 Feb 2013 22:23:56 GMT
+recorded_with: VCR 2.2.4
View
41 ruby/3.3/fixtures/vcr_cassettes/integration_subscribe_6.yml
@@ -0,0 +1,41 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: http://myorigin.pubnub.com/subscribe/demo/hello_world/0/0
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers: {}
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ !binary "RGF0ZQ==":
+ - !binary |-
+ VHVlLCAyNiBGZWIgMjAxMyAyMTo1ODo0NSBHTVQ=
+ !binary "Q29udGVudC1UeXBl":
+ - !binary |-
+ dGV4dC9qYXZhc2NyaXB0OyBjaGFyc2V0PSJVVEYtOCI=
+ !binary "VHJhbnNmZXItRW5jb2Rpbmc=":
+ - !binary |-
+ Y2h1bmtlZA==
+ !binary "Q29ubmVjdGlvbg==":
+ - !binary |-
+ Y2xvc2U=
+ !binary "Q2FjaGUtQ29udHJvbA==":
+ - !binary |-
+ bm8tY2FjaGU=
+ !binary "QWNjZXNzLUNvbnRyb2wtQWxsb3ctT3JpZ2lu":
+ - !binary |-
+ Kg==
+ !binary "QWNjZXNzLUNvbnRyb2wtQWxsb3ctTWV0aG9kcw==":
+ - !binary |-
+ R0VU
+ body:
+ encoding: US-ASCII
+ string: ! '[[],"13619080213373042"]'
+ http_version:
+ recorded_at: Tue, 26 Feb 2013 21:58:45 GMT
+recorded_with: VCR 2.2.4
View
79 ruby/3.3/fixtures/vcr_cassettes/integration_subscribe_7.yml
@@ -0,0 +1,79 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: http://myorigin.pubnub.com/subscribe/demo/hello_world/0/0
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers: {}
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ !binary "RGF0ZQ==":
+ - !binary |-
+ VHVlLCAyNiBGZWIgMjAxMyAyMjoxMTowNyBHTVQ=
+ !binary "Q29udGVudC1UeXBl":
+ - !binary |-
+ dGV4dC9qYXZhc2NyaXB0OyBjaGFyc2V0PSJVVEYtOCI=
+ !binary "VHJhbnNmZXItRW5jb2Rpbmc=":
+ - !binary |-
+ Y2h1bmtlZA==
+ !binary "Q29ubmVjdGlvbg==":
+ - !binary |-
+ Y2xvc2U=
+ !binary "Q2FjaGUtQ29udHJvbA==":
+ - !binary |-
+ bm8tY2FjaGU=
+ !binary "QWNjZXNzLUNvbnRyb2wtQWxsb3ctT3JpZ2lu":
+ - !binary |-
+ Kg==
+ !binary "QWNjZXNzLUNvbnRyb2wtQWxsb3ctTWV0aG9kcw==":
+ - !binary |-
+ R0VU
+ body:
+ encoding: US-ASCII
+ string: ! '[[],"13619080213373042"]'
+ http_version:
+ recorded_at: Tue, 26 Feb 2013 22:11:07 GMT
+- request:
+ method: get
+ uri: http://myorigin.pubnub.com/subscribe/demo/hello_world/0/13619080213373042
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers: {}
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ !binary "RGF0ZQ==":
+ - !binary |-
+ VHVlLCAyNiBGZWIgMjAxMyAyMjoxNTo0NyBHTVQ=
+ !binary "Q29udGVudC1UeXBl":
+ - !binary |-
+ dGV4dC9qYXZhc2NyaXB0OyBjaGFyc2V0PSJVVEYtOCI=
+ !binary "VHJhbnNmZXItRW5jb2Rpbmc=":
+ - !binary |-
+ Y2h1bmtlZA==
+ !binary "Q29ubmVjdGlvbg==":
+ - !binary |-
+ Y2xvc2U=
+ !binary "Q2FjaGUtQ29udHJvbA==":
+ - !binary |-
+ bm8tY2FjaGU=
+ !binary "QWNjZXNzLUNvbnRyb2wtQWxsb3ctT3JpZ2lu":
+ - !binary |-
+ Kg==
+ !binary "QWNjZXNzLUNvbnRyb2wtQWxsb3ctTWV0aG9kcw==":
+ - !binary |-
+ R0VU
+ body:
+ encoding: US-ASCII
+ string: ! '[[],"13619080213373042"]'
+ http_version:
+ recorded_at: Tue, 26 Feb 2013 22:15:47 GMT
+recorded_with: VCR 2.2.4
View
1  ruby/3.3/lib/pubnub.rb
@@ -118,6 +118,7 @@ def subscribe(options)
#TODO: refactor into initializer code on request instantiation
subscribe_request.ssl = @ssl
+ subscribe_request.set_origin(options)
subscribe_request.set_channel(options)
subscribe_request.set_callback(options)
subscribe_request.set_cipher_key(options, self.cipher_key) unless subscribe_request.operation == "presence"
View
BIN  ruby/3.3/pubnub-3.3.0.4.gem
Binary file not shown
View
BIN  ruby/3.3/pubnub-3.3.0.5.gem
Binary file not shown
View
2  ruby/3.3/pubnub.gemspec
@@ -5,7 +5,7 @@
Gem::Specification.new do |s|
s.name = "pubnub"
- s.version = "3.3.0.4"
+ s.version = "3.3.0.5"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["PubNub"]
View
9 ruby/3.3/spec/lib/publish_integration_spec.rb
@@ -22,6 +22,15 @@
end
end
+ it "should publish without ssl with custom origin" do
+ my_response = [1, "Sent", "13619174360247577"]
+ mock(@my_callback).call(my_response) {}
+
+ VCR.use_cassette("integration_publish_10", :record => :none) do
+ @pn.publish(:origin => "a.pubnub.com", :channel => :hello_world, :message => "hi", :callback => @my_callback)
+ end
+ end
+
it "should publish with ssl" do
my_response = [1, "Sent", "13451428018571368"]
View
27 ruby/3.3/spec/lib/subscribe_integration_spec.rb
@@ -29,6 +29,18 @@
end
+ it "should allow a custom origin at subscribe time" do
+ my_response = [[], "13619080213373042"]
+ mock(@my_callback).call(my_response) {EM.stop}
+
+ VCR.use_cassette("integration_subscribe_6", :record => :none) do
+ @pn.subscribe(:origin => "myorigin.pubnub.com", :channel => :hello_world, :callback => @my_callback)
+ end
+
+ # Test will fail if origin breaks per VCR tape
+
+ end
+
it "should retry on a non 200 server response" do
my_response = [[], "13617798873598999"]
mock(@my_callback).call(my_response) {EM.stop}
@@ -70,6 +82,21 @@
context "with basic subscribe config" do
+
+ it "should continue with a custom origin" do
+ my_response = [[], "13619080213373042"]
+ mock(@my_callback).call(my_response) {}
+ mock(@my_callback).call(my_response) {EM.stop}
+
+ VCR.use_cassette("integration_subscribe_7", :record => :none) do
+ @pn.subscribe(:origin => "myorigin.pubnub.com", :channel => :hello_world, :callback => @my_callback)
+ end
+
+ # Test will fail if origin breaks per VCR tape
+
+ end
+
+
it "should sub without ssl" do
my_response = [[{"text" => "bo"}], "13455067954018816"]
mock(@my_callback).call(my_response) { EM.stop}
Please sign in to comment.
Something went wrong with that request. Please try again.