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 ADDED
@@ -0,0 +1,3 @@
1
+ rvm:
2
+ - 1.9.2
3
+ script: bundle exec rspec spec
data/Gemfile CHANGED
@@ -1,2 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
  gemspec
3
+
4
+ group :test do
5
+ gem "guard"
6
+ gem "guard-rspec"
7
+ end
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard 'rspec', :version => 2 do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
@@ -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.add_dependency "multi_json", ["~> 1.0.0"]
23
- s.add_dependency "faraday", ["~> 0.5.7"]
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"
@@ -4,28 +4,23 @@ require 'faraday'
4
4
  # is currently incomplete.
5
5
  module Faraday
6
6
  class Response::Errors < Response::Middleware
7
-
8
- begin
9
- def self.register_on_complete(env)
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, finished_env[:body]
11
+ raise FiveMobilePush::GeneralError, response_values(env)
14
12
  when 401
15
- raise FiveMobilePush::UnauthorizedError, finished_env[:body]
13
+ raise FiveMobilePush::UnauthorizedError, response_values(env)
16
14
  when 500
17
- raise FiveMobilePush::ServerError, 'push.fivemobile.com is currently down'
18
- end
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
- def initialize(app)
26
- super
27
- @parser = nil
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={})
@@ -1,3 +1,3 @@
1
1
  module FiveMobilePush
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.5"
3
3
  end
@@ -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
- endpoint = URI.parse(described_class::DEFAULT_ENDPOINT)
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) { "https://push.fivemobile.com/rest/some_endpoint?api_token=#{api_token}&application_id=#{application_uid}" }
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) { "https://push.fivemobile.com/rest/some_endpoint?api_token=#{api_token}&application_id=#{application_uid}" }
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) { "https://push.fivemobile.com/rest/some_endpoint?api_token=#{api_token}&application_id=#{application_uid}" }
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
@@ -98,7 +98,7 @@ describe FiveMobilePush::Device do
98
98
  end
99
99
 
100
100
  def device_endpoint(name)
101
- "https://push.fivemobile.com/rest/device/#{name}"
101
+ (FiveMobilePush::Client.default_endpoint + "device/#{name}").to_s
102
102
  end
103
103
 
104
104
  end
@@ -52,6 +52,6 @@ describe FiveMobilePush::Notifier do
52
52
  end
53
53
 
54
54
  def notifier_endpoint(name)
55
- "https://push.fivemobile.com/rest/notify/#{name}"
55
+ (FiveMobilePush::Client.default_endpoint + "notify/#{name}").to_s
56
56
  end
57
57
  end
@@ -49,11 +49,8 @@ describe FiveMobilePush::Tag do
49
49
 
50
50
  end
51
51
 
52
- describe "#get" do
53
- end
54
-
55
52
  def tag_endpoint(name)
56
- "https://push.fivemobile.com/rest/device/tags/#{name}"
53
+ (FiveMobilePush::Client.default_endpoint + "tags/#{name}").to_s
57
54
  end
58
55
 
59
56
  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.3
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-16 00:00:00 -04:00
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.5.7
35
+ version: 0.7.3
37
36
  type: :runtime
38
37
  version_requirements: *id002
39
38
  - !ruby/object:Gem::Dependency
40
- name: rspec
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: *id003
59
+ version_requirements: *id004
50
60
  - !ruby/object:Gem::Dependency
51
61
  name: yajl-ruby
52
62
  prerelease: false
53
- requirement: &id004 !ruby/object:Gem::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: *id004
70
+ version_requirements: *id005
61
71
  - !ruby/object:Gem::Dependency
62
72
  name: webmock
63
73
  prerelease: false
64
- requirement: &id005 !ruby/object:Gem::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: *id005
81
+ version_requirements: *id006
72
82
  - !ruby/object:Gem::Dependency
73
83
  name: fabrication
74
84
  prerelease: false
75
- requirement: &id006 !ruby/object:Gem::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: *id006
92
+ version_requirements: *id007
83
93
  - !ruby/object:Gem::Dependency
84
94
  name: yard
85
95
  prerelease: false
86
- requirement: &id007 !ruby/object:Gem::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: *id007
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.6.2
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