pntfr 0.3.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5cf720813ce033ef80813fd133fc74ef8db6b2b
4
- data.tar.gz: 38e3393d5950af33c10bd82e01e5eec01cc01345
3
+ metadata.gz: bc9ce43d0b5be354b83dc3016f76ea72f40f1866
4
+ data.tar.gz: 5f3a937bcb675fd5d6a94ab6c3b88d814c6ce639
5
5
  SHA512:
6
- metadata.gz: c73fce1055940fec086f8a242deae2ab71ec09d950e269c1bfbc6ae6203b14d36dc5a8476b803d6660ca8f11053f1b914f01d305d17537dccd95b803e9c596f7
7
- data.tar.gz: 43d6a4e89c141f6025418a24351bfd967b09f54656b1981cefde5f1c4e3be4545d4e11e2b230194f8ba139a8fbf79201e52a7da98e3869a479adad51bde20958
6
+ metadata.gz: b5f2f8fdffc88fbf0dd442a552e83c9c67fe8b13875f8d572e7edc7c4d003680c68f6024cb2cd46ebdbd49442de709af02f0a06641fc1758fc0b644913bf00d1
7
+ data.tar.gz: d32daa6100a28971816169e966bb80acc8be28176c55536fd096fb861a2133dfdc29ec02bd233dbaab051af7e60c0e9ccf7285bcd6a8191f05f9dabcb1d1d464
data/README.md CHANGED
@@ -5,7 +5,7 @@ Push Notifier is a simple adapter for APNS (Apple Push Notification Service) and
5
5
  ## Installation
6
6
  Add it to your Gemfile:
7
7
 
8
- gem 'pntfr', '~>0.3.0'
8
+ gem 'pntfr', '0.4.1'
9
9
 
10
10
  ## Configuration
11
11
  Pntfr can be configured in two ways.
@@ -103,16 +103,16 @@ notifier.msg(
103
103
  notifier.notify
104
104
 
105
105
 
106
- # Supose you have this configuration for
107
106
  # SETTING ANPS AND GCN CREDENTIALS ON EACH NOTIFICATION
108
107
  # using different configuration on each call
109
- credentials= {ios: {
110
- host: 'test-host',
108
+ credentials= {
109
+ # for ios you select what you override, in this case host and port will be
110
+ # kept from the general configuration
111
+ ios: {
111
112
  pem: 'test-pem',
112
- port: 'test-port',
113
113
  pass: 'test-password',
114
114
  },
115
- andr: 'notification key'
115
+ andr: 'notification key'
116
116
  }
117
117
  notifier= Pntfr::Notifier.new( credentials )
118
118
  # this Notifier instance overrides the global credentials configuration (if any)
@@ -9,11 +9,7 @@ module Pntfr
9
9
  attr_reader :apns
10
10
 
11
11
  def initialize apns_config=nil
12
- if apns_config.nil?
13
- configure_apns(Pntfr.config.apns)
14
- else
15
- configure_apns(apns_config)
16
- end
12
+ configure_apns(apns_config)
17
13
  end
18
14
 
19
15
  def notify devices, notification
@@ -46,7 +42,11 @@ module Pntfr
46
42
  device.methods.include?(:num_notifs)
47
43
  end
48
44
 
49
- def configure_apns config
45
+ def configure_apns config_override
46
+ config= Pntfr.config.apns
47
+ unless config_override.nil?
48
+ config= config.clone.merge(config_override)
49
+ end
50
50
  APNS.host = config[:host]
51
51
  APNS.pem = config[:pem]
52
52
  APNS.port = config[:port]
data/lib/pntfr/version.rb CHANGED
@@ -1,12 +1,16 @@
1
1
  module Pntfr
2
2
  #
3
+ # PATCH v0.4.1
4
+ # - Republish gem after gem yanking it.
5
+ #
6
+ # MINOR v0.4.0
7
+ # - [FEATURE] When overriding ios credentials, merge over general configuration.
8
+ #
9
+ # MINOR v0.3.0
3
10
  # - Performance improvement: Allow sending one message to many devices in one
4
11
  # single call (on both platforms).
5
12
  # - Allow overriding general configuration credentials when instantiating each
6
13
  # Notifier (on both platforms).
7
14
  # - Internal refactoring.
8
- #
9
- # As this change don't break the gem's API (it extends it), lets change only
10
- # minor version.
11
- VERSION = '0.3.0'
15
+ VERSION = '0.4.1'
12
16
  end
@@ -1,6 +1,12 @@
1
1
  require 'pntfr/device'
2
2
  module Pntfr
3
3
  class IosTest < Minitest::Test
4
+ TEST_GENERAL_IOS_CONFIG= {
5
+ host: 'test-general_host',
6
+ pem: 'test-general_pem',
7
+ port: 'test-general_port',
8
+ pass: 'test-general_password',
9
+ }
4
10
  def setup
5
11
  @push_id= 'IOSiosIOSiosIOSiosIOSiosIOSiosIOSiosIOSiosIOSiosIOSiosIOSios'
6
12
  end
@@ -61,7 +67,22 @@ module Pntfr
61
67
  assert_equal({lastkey: 'last value'}, custom[:'last-extra'])
62
68
  end
63
69
 
64
- def test_when_overriding_ios_credentials_should_use_new_ones
70
+ def test_when_not_overriding_ios_credentials_should_use_general_config_credentials
71
+ Pntfr.configure do |config|
72
+ config.apns= TEST_GENERAL_IOS_CONFIG
73
+ end
74
+ ios_session= Pntfr::Session::Ios.new
75
+ apns= ios_session.apns
76
+ assert_equal TEST_GENERAL_IOS_CONFIG[:host], apns.host
77
+ assert_equal TEST_GENERAL_IOS_CONFIG[:pem], apns.pem
78
+ assert_equal TEST_GENERAL_IOS_CONFIG[:port], apns.port
79
+ assert_equal TEST_GENERAL_IOS_CONFIG[:pass], apns.pass
80
+ end
81
+
82
+ def test_when_overriding_all_ios_credentials_should_use_new_ones
83
+ Pntfr.configure do |config|
84
+ config.apns= TEST_GENERAL_IOS_CONFIG
85
+ end
65
86
  apns_config= {
66
87
  host: 'test-host',
67
88
  pem: 'test-pem',
@@ -76,6 +97,22 @@ module Pntfr
76
97
  assert_equal 'test-password', apns.pass
77
98
  end
78
99
 
100
+ def test_when_overriding_some_ios_credentials_should_use_new_ones_but_keep_others
101
+ Pntfr.configure do |config|
102
+ config.apns= TEST_GENERAL_IOS_CONFIG
103
+ end
104
+ apns_config= {
105
+ pem: 'some-test-pem',
106
+ pass: 'some-test-password',
107
+ }
108
+ ios_session= Pntfr::Session::Ios.new(apns_config)
109
+ apns= ios_session.apns
110
+ assert_equal TEST_GENERAL_IOS_CONFIG[:host], apns.host
111
+ assert_equal 'some-test-pem', apns.pem
112
+ assert_equal TEST_GENERAL_IOS_CONFIG[:port], apns.port
113
+ assert_equal 'some-test-password', apns.pass
114
+ end
115
+
79
116
  #-----------------------------------------------------------
80
117
  private
81
118
  #-----------------------------------------------------------
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pntfr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - oliver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-01 00:00:00.000000000 Z
11
+ date: 2015-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apns