five_mobile_push 0.4.3 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/Gemfile +5 -0
- data/Guardfile +5 -0
- data/five_mobile_push.gemspec +4 -2
- data/lib/faraday/errors.rb +10 -15
- data/lib/five_mobile_push/client.rb +7 -1
- data/lib/five_mobile_push/version.rb +1 -1
- data/spec/five_mobile_push/client_spec.rb +12 -5
- data/spec/five_mobile_push/device_spec.rb +1 -1
- data/spec/five_mobile_push/notifier_spec.rb +1 -1
- data/spec/five_mobile_push/tags_spec.rb +1 -4
- metadata +27 -16
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Guardfile
ADDED
data/five_mobile_push.gemspec
CHANGED
@@ -19,8 +19,10 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.
|
23
|
-
s.
|
22
|
+
s.add_runtime_dependency "multi_json", ["~> 1.0.0"]
|
23
|
+
s.add_runtime_dependency "faraday", ["~> 0.7.3"]
|
24
|
+
|
25
|
+
s.add_development_dependency "rake"
|
24
26
|
s.add_development_dependency "rspec", ["~> 2.5.0"]
|
25
27
|
s.add_development_dependency "yajl-ruby"
|
26
28
|
s.add_development_dependency "webmock"
|
data/lib/faraday/errors.rb
CHANGED
@@ -4,28 +4,23 @@ require 'faraday'
|
|
4
4
|
# is currently incomplete.
|
5
5
|
module Faraday
|
6
6
|
class Response::Errors < Response::Middleware
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
env[:response].on_complete do |finished_env|
|
11
|
-
case finished_env[:status]
|
7
|
+
def call(env)
|
8
|
+
@app.call(env).on_complete do
|
9
|
+
case env[:status]
|
12
10
|
when 400
|
13
|
-
raise FiveMobilePush::GeneralError,
|
11
|
+
raise FiveMobilePush::GeneralError, response_values(env)
|
14
12
|
when 401
|
15
|
-
raise FiveMobilePush::UnauthorizedError,
|
13
|
+
raise FiveMobilePush::UnauthorizedError, response_values(env)
|
16
14
|
when 500
|
17
|
-
|
18
|
-
|
15
|
+
env[:body] = 'push.fivemobile.com is currently down'
|
16
|
+
raise FiveMobilePush::ServerError, response_values(env)
|
19
17
|
end
|
20
18
|
end
|
21
|
-
rescue LoadError, NameError => e
|
22
|
-
self.load_error = e
|
23
19
|
end
|
24
20
|
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
# Copied from Faraday
|
22
|
+
def response_values(env)
|
23
|
+
{ :status => env[:status], :headers => env[:response_headers], :body => env[:body] }
|
28
24
|
end
|
29
|
-
|
30
25
|
end
|
31
26
|
end
|
@@ -1,9 +1,10 @@
|
|
1
|
+
require 'uri'
|
1
2
|
require 'faraday/errors'
|
2
3
|
|
3
4
|
module FiveMobilePush
|
4
5
|
class Client
|
5
6
|
|
6
|
-
DEFAULT_ENDPOINT = 'https://push.fivemobile.com/rest
|
7
|
+
DEFAULT_ENDPOINT = 'https://push.fivemobile.com/rest'
|
7
8
|
|
8
9
|
attr_accessor :application_uid, :api_token, :adapter
|
9
10
|
|
@@ -41,6 +42,11 @@ module FiveMobilePush
|
|
41
42
|
FiveMobilePush::Tag.new(self, device_uid)
|
42
43
|
end
|
43
44
|
|
45
|
+
# @return [URI] a URI object for the {DEFAULT_ENDPOINT}
|
46
|
+
def self.default_endpoint
|
47
|
+
URI.parse(DEFAULT_ENDPOINT)
|
48
|
+
end
|
49
|
+
|
44
50
|
private
|
45
51
|
|
46
52
|
def perform_request(method, path, options={})
|
@@ -9,8 +9,7 @@ describe FiveMobilePush::Client do
|
|
9
9
|
|
10
10
|
it "connects using the fivemobile endpoint" do
|
11
11
|
connection = subject.send(:connection).build_url(nil).to_s
|
12
|
-
|
13
|
-
connection.should == endpoint.to_s
|
12
|
+
connection.should == described_class.default_endpoint.to_s
|
14
13
|
end
|
15
14
|
|
16
15
|
describe "#device" do
|
@@ -39,7 +38,7 @@ describe FiveMobilePush::Client do
|
|
39
38
|
|
40
39
|
context "response code is 400" do
|
41
40
|
|
42
|
-
let(:path) { "
|
41
|
+
let(:path) { (described_class.default_endpoint + "some_endpoint?api_token=#{api_token}&application_id=#{application_uid}").to_s }
|
43
42
|
|
44
43
|
it "raises a GeneralError" do
|
45
44
|
stub_request(:any, path).to_return(:body => "something broken", :status => 400)
|
@@ -50,7 +49,7 @@ describe FiveMobilePush::Client do
|
|
50
49
|
|
51
50
|
context "response code is 401" do
|
52
51
|
|
53
|
-
let(:path) { "
|
52
|
+
let(:path) { (described_class.default_endpoint + "some_endpoint?api_token=#{api_token}&application_id=#{application_uid}").to_s }
|
54
53
|
|
55
54
|
it "raises a GeneralError" do
|
56
55
|
stub_request(:any, path).to_return(:body => "something broken", :status => 401)
|
@@ -61,7 +60,7 @@ describe FiveMobilePush::Client do
|
|
61
60
|
|
62
61
|
context "response code is 500" do
|
63
62
|
|
64
|
-
let(:path) { "
|
63
|
+
let(:path) { (described_class.default_endpoint + "some_endpoint?api_token=#{api_token}&application_id=#{application_uid}").to_s }
|
65
64
|
|
66
65
|
it "raises a GeneralError" do
|
67
66
|
stub_request(:any, path).to_return(:body => "something broken", :status => 500)
|
@@ -70,4 +69,12 @@ describe FiveMobilePush::Client do
|
|
70
69
|
|
71
70
|
end
|
72
71
|
|
72
|
+
describe '.default_endpoint' do
|
73
|
+
it { described_class.default_endpoint.should be_a(URI) }
|
74
|
+
|
75
|
+
it 'acts as a URI object' do
|
76
|
+
uri = described_class.default_endpoint + 'foo'
|
77
|
+
uri.to_s.should =~ /foo\z/
|
78
|
+
end
|
79
|
+
end
|
73
80
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: five_mobile_push
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.4.
|
5
|
+
version: 0.4.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kevin Faustino
|
@@ -11,8 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-05
|
15
|
-
default_executable:
|
14
|
+
date: 2011-07-05 00:00:00 Z
|
16
15
|
dependencies:
|
17
16
|
- !ruby/object:Gem::Dependency
|
18
17
|
name: multi_json
|
@@ -33,64 +32,75 @@ dependencies:
|
|
33
32
|
requirements:
|
34
33
|
- - ~>
|
35
34
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.
|
35
|
+
version: 0.7.3
|
37
36
|
type: :runtime
|
38
37
|
version_requirements: *id002
|
39
38
|
- !ruby/object:Gem::Dependency
|
40
|
-
name:
|
39
|
+
name: rake
|
41
40
|
prerelease: false
|
42
41
|
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rspec
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
43
53
|
none: false
|
44
54
|
requirements:
|
45
55
|
- - ~>
|
46
56
|
- !ruby/object:Gem::Version
|
47
57
|
version: 2.5.0
|
48
58
|
type: :development
|
49
|
-
version_requirements: *
|
59
|
+
version_requirements: *id004
|
50
60
|
- !ruby/object:Gem::Dependency
|
51
61
|
name: yajl-ruby
|
52
62
|
prerelease: false
|
53
|
-
requirement: &
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
54
64
|
none: false
|
55
65
|
requirements:
|
56
66
|
- - ">="
|
57
67
|
- !ruby/object:Gem::Version
|
58
68
|
version: "0"
|
59
69
|
type: :development
|
60
|
-
version_requirements: *
|
70
|
+
version_requirements: *id005
|
61
71
|
- !ruby/object:Gem::Dependency
|
62
72
|
name: webmock
|
63
73
|
prerelease: false
|
64
|
-
requirement: &
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
65
75
|
none: false
|
66
76
|
requirements:
|
67
77
|
- - ">="
|
68
78
|
- !ruby/object:Gem::Version
|
69
79
|
version: "0"
|
70
80
|
type: :development
|
71
|
-
version_requirements: *
|
81
|
+
version_requirements: *id006
|
72
82
|
- !ruby/object:Gem::Dependency
|
73
83
|
name: fabrication
|
74
84
|
prerelease: false
|
75
|
-
requirement: &
|
85
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
76
86
|
none: false
|
77
87
|
requirements:
|
78
88
|
- - ~>
|
79
89
|
- !ruby/object:Gem::Version
|
80
90
|
version: 0.9.5
|
81
91
|
type: :development
|
82
|
-
version_requirements: *
|
92
|
+
version_requirements: *id007
|
83
93
|
- !ruby/object:Gem::Dependency
|
84
94
|
name: yard
|
85
95
|
prerelease: false
|
86
|
-
requirement: &
|
96
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
87
97
|
none: false
|
88
98
|
requirements:
|
89
99
|
- - ~>
|
90
100
|
- !ruby/object:Gem::Version
|
91
101
|
version: 0.6.5
|
92
102
|
type: :development
|
93
|
-
version_requirements: *
|
103
|
+
version_requirements: *id008
|
94
104
|
description: API wrapper for Five Mobile Push notification service
|
95
105
|
email:
|
96
106
|
- kevin.faustino@gmail.com
|
@@ -104,8 +114,10 @@ extra_rdoc_files: []
|
|
104
114
|
files:
|
105
115
|
- .gitignore
|
106
116
|
- .rspec
|
117
|
+
- .travis.yml
|
107
118
|
- .yardopts
|
108
119
|
- Gemfile
|
120
|
+
- Guardfile
|
109
121
|
- MIT-LICENSE
|
110
122
|
- Rakefile
|
111
123
|
- five_mobile_push.gemspec
|
@@ -132,7 +144,6 @@ files:
|
|
132
144
|
- spec/five_mobile_push_spec.rb
|
133
145
|
- spec/fixtures/register.json
|
134
146
|
- spec/spec_helper.rb
|
135
|
-
has_rdoc: true
|
136
147
|
homepage: ""
|
137
148
|
licenses: []
|
138
149
|
|
@@ -156,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
167
|
requirements: []
|
157
168
|
|
158
169
|
rubyforge_project: five_mobile_push
|
159
|
-
rubygems_version: 1.
|
170
|
+
rubygems_version: 1.8.5
|
160
171
|
signing_key:
|
161
172
|
specification_version: 3
|
162
173
|
summary: API wrapper for Five Mobile Push notification service
|