notifiable-gcm-spacialdb 0.8.0 → 0.9.0

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: e7da221865614e3397cfb5a5d70ec546c6e47364
4
- data.tar.gz: e184c03554ae384b3777a379a3845093e1df1bdc
3
+ metadata.gz: a1f15251a237ef16e25ecaa65fe48602e225a139
4
+ data.tar.gz: eb2737d7853ec2df977625cecfae70a9788ff9ea
5
5
  SHA512:
6
- metadata.gz: 7cd2403d53fb87f6c237c9334387748bc3ec80ab8ed416431bd3acc83b91241969a92e6de537bb5c334cf0ed364c4867023392c37f9d1c30b9aab9b642711e92
7
- data.tar.gz: 24f93bdf60fcd2bf268be58110652eb9833d1a2fb4f392b36d3a51b5a9e7740f5ba1c9d37082ce76a994c9bce1bdfc07d8fbc96240f4a2b4bb3cab1c45a19896
6
+ metadata.gz: d67af3e91b582015475f9034d3904f719f04a68089be72b425dcfa964ef270fd86457a008cf4f7bc8c26f06393c3685239a0d5c1f6267ae52aaf3a4deb083931
7
+ data.tar.gz: a0bf883223f62ee049272639782a9cf927886951b29eb24a73c79ea93fc0bae9e35eb92a6eedd887eba485f187b6fef445467b4085b43a52379901f4fec8e6e8
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile.lock CHANGED
@@ -3,32 +3,32 @@ PATH
3
3
  specs:
4
4
  notifiable-gcm-spacialdb (0.8.0)
5
5
  gcm (~> 0.0.6)
6
- notifiable-rails (>= 0.21.1)
6
+ notifiable-rails (>= 0.24.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionmailer (4.1.12)
12
- actionpack (= 4.1.12)
13
- actionview (= 4.1.12)
11
+ actionmailer (4.1.15)
12
+ actionpack (= 4.1.15)
13
+ actionview (= 4.1.15)
14
14
  mail (~> 2.5, >= 2.5.4)
15
- actionpack (4.1.12)
16
- actionview (= 4.1.12)
17
- activesupport (= 4.1.12)
15
+ actionpack (4.1.15)
16
+ actionview (= 4.1.15)
17
+ activesupport (= 4.1.15)
18
18
  rack (~> 1.5.2)
19
19
  rack-test (~> 0.6.2)
20
- actionview (4.1.12)
21
- activesupport (= 4.1.12)
20
+ actionview (4.1.15)
21
+ activesupport (= 4.1.15)
22
22
  builder (~> 3.1)
23
23
  erubis (~> 2.7.0)
24
- activemodel (4.1.12)
25
- activesupport (= 4.1.12)
24
+ activemodel (4.1.15)
25
+ activesupport (= 4.1.15)
26
26
  builder (~> 3.1)
27
- activerecord (4.1.12)
28
- activemodel (= 4.1.12)
29
- activesupport (= 4.1.12)
27
+ activerecord (4.1.15)
28
+ activemodel (= 4.1.15)
29
+ activesupport (= 4.1.15)
30
30
  arel (~> 5.0.0)
31
- activesupport (4.1.12)
31
+ activesupport (4.1.15)
32
32
  i18n (~> 0.6, >= 0.6.9)
33
33
  json (~> 1.7, >= 1.7.7)
34
34
  minitest (~> 5.1)
@@ -40,6 +40,7 @@ GEM
40
40
  byebug (5.0.0)
41
41
  columnize (= 0.9.0)
42
42
  columnize (0.9.0)
43
+ concurrent-ruby (1.0.1)
43
44
  crack (0.4.1)
44
45
  safe_yaml (~> 0.9.0)
45
46
  database_cleaner (1.2.0)
@@ -49,35 +50,37 @@ GEM
49
50
  gcm (0.0.9)
50
51
  httparty
51
52
  json
52
- httparty (0.13.5)
53
+ httparty (0.13.7)
53
54
  json (~> 1.8)
54
55
  multi_xml (>= 0.5.2)
55
56
  i18n (0.7.0)
56
57
  json (1.8.3)
57
- mail (2.6.3)
58
- mime-types (>= 1.16, < 3)
59
- mime-types (2.6.1)
60
- minitest (5.7.0)
58
+ mail (2.6.4)
59
+ mime-types (>= 1.16, < 4)
60
+ mime-types (3.0)
61
+ mime-types-data (~> 3.2015)
62
+ mime-types-data (3.2016.0221)
63
+ minitest (5.8.4)
61
64
  multi_json (1.8.4)
62
65
  multi_xml (0.5.5)
63
- notifiable-rails (0.21.1)
66
+ notifiable-rails (0.24.1)
64
67
  rails (~> 4.1.0)
65
68
  rack (1.5.5)
66
69
  rack-test (0.6.3)
67
70
  rack (>= 1.0)
68
- rails (4.1.12)
69
- actionmailer (= 4.1.12)
70
- actionpack (= 4.1.12)
71
- actionview (= 4.1.12)
72
- activemodel (= 4.1.12)
73
- activerecord (= 4.1.12)
74
- activesupport (= 4.1.12)
71
+ rails (4.1.15)
72
+ actionmailer (= 4.1.15)
73
+ actionpack (= 4.1.15)
74
+ actionview (= 4.1.15)
75
+ activemodel (= 4.1.15)
76
+ activerecord (= 4.1.15)
77
+ activesupport (= 4.1.15)
75
78
  bundler (>= 1.3.0, < 2.0)
76
- railties (= 4.1.12)
79
+ railties (= 4.1.15)
77
80
  sprockets-rails (~> 2.0)
78
- railties (4.1.12)
79
- actionpack (= 4.1.12)
80
- activesupport (= 4.1.12)
81
+ railties (4.1.15)
82
+ actionpack (= 4.1.15)
83
+ activesupport (= 4.1.15)
81
84
  rake (>= 0.8.7)
82
85
  thor (>= 0.18.1, < 2.0)
83
86
  rake (10.1.1)
@@ -97,9 +100,10 @@ GEM
97
100
  simplecov-html (0.8.0)
98
101
  simplecov-rcov (0.2.3)
99
102
  simplecov (>= 0.4.1)
100
- sprockets (3.2.0)
101
- rack (~> 1.0)
102
- sprockets-rails (2.3.2)
103
+ sprockets (3.5.2)
104
+ concurrent-ruby (~> 1.0)
105
+ rack (> 1, < 3)
106
+ sprockets-rails (2.3.3)
103
107
  actionpack (>= 3.0)
104
108
  activesupport (>= 3.0)
105
109
  sprockets (>= 2.8, < 4.0)
@@ -6,18 +6,23 @@ module Notifiable
6
6
  module Spacialdb
7
7
  class Batch < Notifiable::NotifierBase
8
8
 
9
- attr_accessor :api_key, :batch_size
9
+ notifier_attribute :api_key, :batch_size
10
+
11
+ def batch_size
12
+ @batch_size || 1000
13
+ end
10
14
 
11
15
  def initialize(env, notification)
12
16
  super(env, notification)
13
17
  @batch = []
14
- @batch_size = 1000
15
18
  end
16
19
 
17
20
  protected
18
21
  def enqueue(device_token, localized_notification)
22
+ raise "API Key missing" if @api_key.nil?
23
+
19
24
  @batch << device_token
20
- send_batch(localized_notification) if @batch.count >= @batch_size
25
+ send_batch(localized_notification) if @batch.count >= batch_size
21
26
  end
22
27
 
23
28
  def flush
@@ -29,7 +34,7 @@ module Notifiable
29
34
  if Notifiable.delivery_method == :test
30
35
  @batch.each {|d| processed(d, 0)}
31
36
  else
32
- gcm = ::GCM.new(self.api_key)
37
+ gcm = ::GCM.new(@api_key)
33
38
 
34
39
  data = {:message => notification.message}.merge(notification.send_params)
35
40
  response = gcm.send_notification(@batch.collect{|dt| dt.token}, {:data => data})
@@ -1,7 +1,7 @@
1
1
  module Notifiable
2
2
  module Gcm
3
3
  module Spacialdb
4
- VERSION = "0.8.0"
4
+ VERSION = "0.9.0"
5
5
  end
6
6
  end
7
7
  end
@@ -8,5 +8,3 @@ module Notifiable
8
8
  end
9
9
  end
10
10
  end
11
-
12
- Notifiable.notifier_classes[:gcm] = Notifiable::Gcm::Spacialdb::Batch
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "notifiable-rails", ">=0.21.1"
21
+ spec.add_dependency "notifiable-rails", ">=0.24.1"
22
22
  spec.add_dependency "gcm", "~> 0.0.6"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
data/spec/batch_spec.rb CHANGED
@@ -4,8 +4,12 @@ describe Notifiable::Gcm::Spacialdb::Batch do
4
4
 
5
5
  let(:a) { Notifiable::App.create }
6
6
  let(:n1) { Notifiable::Notification.create(:app => a) }
7
- let!(:ln) { Notifiable::LocalizedNotification.create(:message => "Test message", :params => {:flag => true}, :notification => n1, :locale => :en) }
8
- let(:d) { Notifiable::DeviceToken.create(:token => "ABC123", :provider => :gcm, :app => a, :locale => :en) }
7
+ let!(:ln) { Notifiable::LocalizedNotification.create(:message => "Test message", :params => {:flag => true}, :notification => n1, :locale => 'en') }
8
+ let(:d) { Notifiable::DeviceToken.create(:token => "ABC123", :provider => :gcm, :app => a, :locale => 'en') }
9
+
10
+ before(:each) do
11
+ a.gcm_api_key = "abc123"
12
+ end
9
13
 
10
14
  it "sends a single gcm notification" do
11
15
  stub_request(:post, "https://android.googleapis.com/gcm/send").to_return(:body => '{ "multicast_id": 108, "success": 1, "failure": 0, "canonical_ids": 0, "results": [{ "message_id": "1:08" }]}')
data/spec/spec_helper.rb CHANGED
@@ -28,6 +28,9 @@ RSpec.configure do |config|
28
28
 
29
29
  config.before(:all) {
30
30
 
31
+ Notifiable.notifier_classes[:gcm] = Notifiable::Gcm::Spacialdb::Batch
32
+ Notifiable::App.define_configuration_accessors(Notifiable.notifier_classes)
33
+
31
34
  # DB setup
32
35
  ActiveRecord::Base.establish_connection(
33
36
  { :adapter => 'sqlite3',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifiable-gcm-spacialdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kamil Kocemba
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-29 00:00:00.000000000 Z
12
+ date: 2016-03-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: notifiable-rails
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 0.21.1
20
+ version: 0.24.1
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 0.21.1
27
+ version: 0.24.1
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: gcm
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -174,6 +174,7 @@ extensions: []
174
174
  extra_rdoc_files: []
175
175
  files:
176
176
  - ".gitignore"
177
+ - ".rspec"
177
178
  - ".ruby-gemset"
178
179
  - ".ruby-version"
179
180
  - Gemfile