bmo 0.8.7 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c4d72c31c7bd2a3ec83e27806b6a40b2f7c3664a
4
- data.tar.gz: dbca42a10a817f492a6ca357415015cf7d44bf53
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NmM2NWMzOTM5MDFkZmZkNzVjODQ2NWM0NWQ2ODE5NWZhMTI0OGZkYw==
5
+ data.tar.gz: !binary |-
6
+ MTE0Y2NmMzMyOGU5NDE4ZThhN2M1Zjk5YThkNTY4OWI0YTI2NWFjMA==
5
7
  SHA512:
6
- metadata.gz: 60f95aa5be2336adc688bba51b8969ba9284f2eabdcfd0bed93d0aa72e0160bef559cd9bc4e034cf4ce26d7f26c6ab50ddffbcd3f92e1cc408236d6bed3c1c36
7
- data.tar.gz: adb4edba935e088a19b9f139b6d52ce6056b53d55b9d0fbb03b384277fa830c7ccbee8913dcb75fd7e401b938d4b279fe91db06ac06adca0ff55075c38d2a6da
8
+ metadata.gz: !binary |-
9
+ NjZkN2I2NzI4YzIyZjkyNjFlZmNlOTMwNjhkNjkzNmVhNDY5OWI5Y2YxNTBh
10
+ MTRkN2M2MWNlMDM5ODQyZDVmNmU1N2NjMWM3MmUwNGZjYTAyOWJkN2Q4NzE3
11
+ NmQxNjUyOTA5OWYwMDRjZmIyZDI2NjY3OTRkM2E4Y2Q2YjY0MjQ=
12
+ data.tar.gz: !binary |-
13
+ OGE1NDQ4ZjdmZDNjMDBkNjNmMjM0NDU4OWY3ZTIxNGE5MzMwZTA1YmM3YWRh
14
+ YjllMGEzODkyNWViYTkwMmY4MWJjMGQ3OWRkNmRkYjc3ZDg1NTgwNTc5MGU2
15
+ NjkyOTk1ODRjNjQwMTY1YWY5ODMxMjRhNmM1NmRjMGFlYTBjNTU=
data/Gemfile.lock CHANGED
@@ -26,7 +26,7 @@ GIT
26
26
  PATH
27
27
  remote: .
28
28
  specs:
29
- bmo (0.8.6)
29
+ bmo (0.8.7)
30
30
  equalizer (~> 0.0.0)
31
31
  faraday (> 0.8.0)
32
32
 
data/README.md CHANGED
@@ -56,11 +56,11 @@ Default Params :
56
56
  ```ruby
57
57
  BMO.configuration do |config|
58
58
  config.apns.gateway_host = 'gateway.push.apple.com'
59
- config.apns.gateway_port = 2195
60
- config.apns.feedback_host = 'feedback.push.apple.com'
61
- config.apns.feedback_port = 2196
62
- config.apns.cert_path = nil
63
- config.apns.cert_pass = nil
59
+ config.apns.gateway_port = 2195
60
+ config.apns.feedback_host = 'feedback.push.apple.com'
61
+ config.apns.feedback_port = 2196
62
+ config.apns.cert_path = nil
63
+ config.apns.cert_pass = nil
64
64
  end
65
65
  ```
66
66
 
@@ -92,7 +92,7 @@ BMO.configuration do |config|
92
92
  end
93
93
  ```
94
94
 
95
- You should set the api_key.
95
+ You should set the api_key. It uses Faraday internally, so just set your regular http_proxy environment variable if need to configure a proxy.
96
96
 
97
97
  ## License
98
98
 
@@ -64,8 +64,6 @@ module BMO
64
64
  end
65
65
  end
66
66
 
67
- private
68
-
69
67
  # Handle the Feedback Object
70
68
  #
71
69
  # @!attribute time [Time] Time when the device was notified
@@ -16,7 +16,7 @@ module BMO
16
16
  # a pure TCPSocket. It then yields the socket and handles the closing
17
17
  #
18
18
  # @return The yielded return
19
- def connect(&block)
19
+ def connect
20
20
  socket = cert_path ? ssl_socket : tcp_socket
21
21
 
22
22
  yielded = yield socket
@@ -31,8 +31,6 @@ module BMO
31
31
  payload.validate!
32
32
  end
33
33
 
34
- private
35
-
36
34
  # The Payload contains the data sent to Apple
37
35
  class Payload
38
36
  class PayloadTooLarge < Exception; end
@@ -53,10 +51,9 @@ module BMO
53
51
  end
54
52
 
55
53
  def validate!
56
- if to_package.size > MAX_BYTE_SIZE
57
- str = <<-EOS
58
- Payload size should be less than #{Payload::MAX_BYTE_SIZE} bytes
59
- EOS
54
+ if to_package.bytesize > MAX_BYTE_SIZE
55
+ str = "Payload byte size (#{to_package.bytesize})" \
56
+ " should be less than #{Payload::MAX_BYTE_SIZE} bytes"
60
57
  fail PayloadTooLarge, str
61
58
  end
62
59
  true
@@ -82,7 +79,7 @@ module BMO
82
79
 
83
80
  def validate!
84
81
  unless token =~ /^[a-z0-9]{64}$/i
85
- fail(MalformedDeviceToken, 'Malformed Device Token')
82
+ fail(MalformedDeviceToken, "Malformed Device Token : #{token}")
86
83
  end
87
84
  true
88
85
  end
@@ -9,7 +9,7 @@ module BMO
9
9
  @api_key = api_key
10
10
  end
11
11
 
12
- def connect(&block)
12
+ def connect
13
13
  faraday_connection.post(gateway_url) do |request|
14
14
  request.headers.merge!(content_type: 'application/json',
15
15
  authorization: "key=#{api_key}")
@@ -24,8 +24,6 @@ module BMO
24
24
  payload.validate!
25
25
  end
26
26
 
27
- private
28
-
29
27
  # The Payload contains the data sent to Apple
30
28
  class Payload
31
29
  # Error Raised when the payload packaged > MAX_BYTE_SIZE
@@ -47,7 +45,7 @@ module BMO
47
45
  end
48
46
 
49
47
  def validate!
50
- if to_package.size > MAX_BYTE_SIZE
48
+ if to_package.bytesize > MAX_BYTE_SIZE
51
49
  str = <<-EOS
52
50
  Payload size should be less than #{Payload::MAX_BYTE_SIZE} bytes
53
51
  EOS
data/lib/bmo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # Main BMO module, version get right here
3
3
  module BMO
4
- VERSION = '0.8.7'.freeze
4
+ VERSION = '0.8.8'.freeze
5
5
  end
@@ -3,52 +3,19 @@
3
3
  require File.dirname(__FILE__) + '../../../spec_helper'
4
4
 
5
5
  describe BMO::APNS::Notification::DeviceToken do
6
- describe '#token' do
7
- it 'returns the token' do
8
- device_token = described_class.new('abc')
9
- expect(device_token.token).to eq('abc')
10
- end
11
- end
12
-
13
- describe '#==' do
14
- it 'returns true for equal device token' do
15
- device_token = described_class.new('abc')
16
- device_token_bis = described_class.new('abc')
17
- expect(device_token == device_token_bis).to be_true
18
- end
19
-
20
- it 'returns true for equal device token' do
21
- device_token = described_class.new('abc')
22
- device_token_bis = described_class.new('abc')
23
- expect(device_token).to eq(device_token_bis)
24
- end
25
-
26
- it 'returns false for equal device token' do
27
- device_token = described_class.new('abc')
28
- device_token_bis = described_class.new('def')
29
- expect(device_token).to_not eq(device_token_bis)
30
- end
31
-
32
- it 'returns true for equal device token' do
33
- device_token = described_class.new('abc')
34
- device_token_bis = described_class.new('def')
35
- expect(device_token == device_token_bis).to be_false
36
- end
37
- end
38
-
39
6
  describe '#validate!' do
40
7
  it 'returns true if the token is 64 chars' do
41
8
  device_token = described_class.new('a' * 64)
42
9
  expect(device_token.validate!).to be_true
43
10
  end
44
11
 
45
- it 'returns false if the token is not 64 chars' do
12
+ it 'raises an error if the token is not 64 chars' do
46
13
  device_token = described_class.new('a' * 63)
47
14
  expect { device_token.validate! }.to raise_error(
48
15
  BMO::APNS::Notification::DeviceToken::MalformedDeviceToken)
49
16
  end
50
17
 
51
- it 'returns false if the token contains a special char' do
18
+ it 'raises an error if the token contains a special char' do
52
19
  device_token = described_class.new(('a' * 63) + '"')
53
20
  expect { device_token.validate! }.to raise_error(
54
21
  BMO::APNS::Notification::DeviceToken::MalformedDeviceToken)
@@ -78,4 +45,16 @@ describe BMO::APNS::Notification::Payload do
78
45
  payload = described_class.new('Jake' => 'The Dog')
79
46
  expect(payload).to eq(described_class.new(Jake: 'The Dog'))
80
47
  end
48
+
49
+ describe '#validate!' do
50
+ it 'returns true if the payload is valid' do
51
+ payload = described_class.new(apns: 'a' * 200)
52
+ expect(payload.validate!).to be_true
53
+ end
54
+ it 'raises an error if the payload is too large' do
55
+ payload = described_class.new(apns: 'a' * 256)
56
+ expect { payload.validate! }.to raise_error(
57
+ BMO::APNS::Notification::Payload::PayloadTooLarge)
58
+ end
59
+ end
81
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bmo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.7
4
+ version: 0.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antoine Lyset
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-24 00:00:00.000000000 Z
11
+ date: 2014-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equalizer
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>'
31
+ - - ! '>'
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.8.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>'
38
+ - - ! '>'
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.8.0
41
41
  - !ruby/object:Gem::Dependency
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Push notifications to iOS and Android devices
@@ -106,17 +106,17 @@ require_paths:
106
106
  - lib
107
107
  required_ruby_version: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - '>='
109
+ - - ! '>='
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - '>='
114
+ - - ! '>='
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
118
  rubyforge_project:
119
- rubygems_version: 2.1.11
119
+ rubygems_version: 2.2.2
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Push notifications to iOS and Android devices