hertz-fcm 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2f23a971a52ef98c21f7fdaf4bf5415dd86bdfc9b31cb44e5d0c1f18fced5bfd
4
+ data.tar.gz: caeafe44b2d5f6f8fc5197bc937584077ad7cc59c94c7e157819125164e86a0e
5
+ SHA512:
6
+ metadata.gz: f51935c6fa1dbbe483c4d0388a444070da237cd0e3fb550f054da546ef401672fbe85ebfc7d9136b1ee3e8bdbb210f08ffcbde4de2a644eb1f6f6d76f1339ba1
7
+ data.tar.gz: 23aaf627786373bbe01fe62786a6dc835f1253551e37012b9a42dfc20b82ae1ac964f437e1a73dfb85e7bc9a76f9518109a76f8ce1fbd2447dc0e591eb4100c4
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/dummy/log/*.log
9
+ /spec/dummy/tmp/
10
+ /spec/dummy/.sass-cache
11
+ /spec/dummy/config/database.yml
12
+ /spec/examples.txt
13
+ /tmp/
14
+ /.idea/
15
+
16
+ # rspec failure tracking
17
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,17 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.5.1
5
+ Exclude:
6
+ - 'spec/spec_helper.rb'
7
+ - 'spec/rails_helper.rb'
8
+ - 'spec/dummy/**/*'
9
+
10
+ Rails:
11
+ Enabled: true
12
+
13
+ Style/Documentation:
14
+ Enabled: false
15
+
16
+ RSpec/NamedSubject:
17
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,20 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 1.16.4
8
+
9
+ env:
10
+ - DB=pgsql
11
+
12
+ services:
13
+ - postgresql
14
+
15
+ before_script:
16
+ - cp spec/dummy/config/database.travis.yml spec/dummy/config/database.yml
17
+
18
+ script:
19
+ - cd spec/dummy && RAILS_ENV=test bundle exec rake db:create db:schema:load && cd ../..
20
+ - bundle exec rspec
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at igor.petkovic@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in hertz-fcm.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,206 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hertz-fcm (1.0.0)
5
+ fcm (>= 0.0.2, < 1)
6
+ hertz (~> 1.0)
7
+ rails (>= 4.0.0, < 6)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actioncable (5.2.1)
13
+ actionpack (= 5.2.1)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (>= 0.6.1)
16
+ actionmailer (5.2.1)
17
+ actionpack (= 5.2.1)
18
+ actionview (= 5.2.1)
19
+ activejob (= 5.2.1)
20
+ mail (~> 2.5, >= 2.5.4)
21
+ rails-dom-testing (~> 2.0)
22
+ actionpack (5.2.1)
23
+ actionview (= 5.2.1)
24
+ activesupport (= 5.2.1)
25
+ rack (~> 2.0)
26
+ rack-test (>= 0.6.3)
27
+ rails-dom-testing (~> 2.0)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ actionview (5.2.1)
30
+ activesupport (= 5.2.1)
31
+ builder (~> 3.1)
32
+ erubi (~> 1.4)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
35
+ activejob (5.2.1)
36
+ activesupport (= 5.2.1)
37
+ globalid (>= 0.3.6)
38
+ activemodel (5.2.1)
39
+ activesupport (= 5.2.1)
40
+ activerecord (5.2.1)
41
+ activemodel (= 5.2.1)
42
+ activesupport (= 5.2.1)
43
+ arel (>= 9.0)
44
+ activestorage (5.2.1)
45
+ actionpack (= 5.2.1)
46
+ activerecord (= 5.2.1)
47
+ marcel (~> 0.3.1)
48
+ activesupport (5.2.1)
49
+ concurrent-ruby (~> 1.0, >= 1.0.2)
50
+ i18n (>= 0.7, < 2)
51
+ minitest (~> 5.1)
52
+ tzinfo (~> 1.1)
53
+ arel (9.0.0)
54
+ ast (2.4.0)
55
+ builder (3.2.3)
56
+ concurrent-ruby (1.0.5)
57
+ coveralls (0.8.22)
58
+ json (>= 1.8, < 3)
59
+ simplecov (~> 0.16.1)
60
+ term-ansicolor (~> 1.3)
61
+ thor (~> 0.19.4)
62
+ tins (~> 1.6)
63
+ crass (1.0.4)
64
+ diff-lcs (1.3)
65
+ docile (1.3.1)
66
+ erubi (1.7.1)
67
+ factory_bot (4.11.1)
68
+ activesupport (>= 3.0.0)
69
+ factory_bot_rails (4.11.1)
70
+ factory_bot (~> 4.11.1)
71
+ railties (>= 3.0.0)
72
+ fcm (0.0.2)
73
+ httparty
74
+ json
75
+ globalid (0.4.1)
76
+ activesupport (>= 4.2.0)
77
+ hertz (1.0.2)
78
+ rails (>= 4.0.0, < 6.0.0)
79
+ httparty (0.16.2)
80
+ multi_xml (>= 0.5.2)
81
+ i18n (1.1.0)
82
+ concurrent-ruby (~> 1.0)
83
+ jaro_winkler (1.5.1)
84
+ json (2.1.0)
85
+ loofah (2.2.2)
86
+ crass (~> 1.0.2)
87
+ nokogiri (>= 1.5.9)
88
+ mail (2.7.0)
89
+ mini_mime (>= 0.1.1)
90
+ marcel (0.3.2)
91
+ mimemagic (~> 0.3.2)
92
+ method_source (0.9.0)
93
+ mimemagic (0.3.2)
94
+ mini_mime (1.0.1)
95
+ mini_portile2 (2.3.0)
96
+ minitest (5.11.3)
97
+ multi_xml (0.6.0)
98
+ nio4r (2.3.1)
99
+ nokogiri (1.8.4)
100
+ mini_portile2 (~> 2.3.0)
101
+ parallel (1.12.1)
102
+ parser (2.5.1.2)
103
+ ast (~> 2.4.0)
104
+ pg (1.1.3)
105
+ powerpack (0.1.2)
106
+ rack (2.0.5)
107
+ rack-test (1.1.0)
108
+ rack (>= 1.0, < 3)
109
+ rails (5.2.1)
110
+ actioncable (= 5.2.1)
111
+ actionmailer (= 5.2.1)
112
+ actionpack (= 5.2.1)
113
+ actionview (= 5.2.1)
114
+ activejob (= 5.2.1)
115
+ activemodel (= 5.2.1)
116
+ activerecord (= 5.2.1)
117
+ activestorage (= 5.2.1)
118
+ activesupport (= 5.2.1)
119
+ bundler (>= 1.3.0)
120
+ railties (= 5.2.1)
121
+ sprockets-rails (>= 2.0.0)
122
+ rails-dom-testing (2.0.3)
123
+ activesupport (>= 4.2.0)
124
+ nokogiri (>= 1.6)
125
+ rails-html-sanitizer (1.0.4)
126
+ loofah (~> 2.2, >= 2.2.2)
127
+ railties (5.2.1)
128
+ actionpack (= 5.2.1)
129
+ activesupport (= 5.2.1)
130
+ method_source
131
+ rake (>= 0.8.7)
132
+ thor (>= 0.19.0, < 2.0)
133
+ rainbow (3.0.0)
134
+ rake (12.3.1)
135
+ rspec-activejob (0.6.1)
136
+ activejob (>= 4.2)
137
+ rspec-mocks
138
+ rspec-core (3.8.0)
139
+ rspec-support (~> 3.8.0)
140
+ rspec-expectations (3.8.1)
141
+ diff-lcs (>= 1.2.0, < 2.0)
142
+ rspec-support (~> 3.8.0)
143
+ rspec-mocks (3.8.0)
144
+ diff-lcs (>= 1.2.0, < 2.0)
145
+ rspec-support (~> 3.8.0)
146
+ rspec-rails (3.8.0)
147
+ actionpack (>= 3.0)
148
+ activesupport (>= 3.0)
149
+ railties (>= 3.0)
150
+ rspec-core (~> 3.8.0)
151
+ rspec-expectations (~> 3.8.0)
152
+ rspec-mocks (~> 3.8.0)
153
+ rspec-support (~> 3.8.0)
154
+ rspec-support (3.8.0)
155
+ rubocop (0.59.0)
156
+ jaro_winkler (~> 1.5.1)
157
+ parallel (~> 1.10)
158
+ parser (>= 2.5, != 2.5.1.1)
159
+ powerpack (~> 0.1)
160
+ rainbow (>= 2.2.2, < 4.0)
161
+ ruby-progressbar (~> 1.7)
162
+ unicode-display_width (~> 1.0, >= 1.0.1)
163
+ rubocop-rspec (1.29.1)
164
+ rubocop (>= 0.58.0)
165
+ ruby-progressbar (1.10.0)
166
+ simplecov (0.16.1)
167
+ docile (~> 1.1)
168
+ json (>= 1.8, < 3)
169
+ simplecov-html (~> 0.10.0)
170
+ simplecov-html (0.10.2)
171
+ sprockets (3.7.2)
172
+ concurrent-ruby (~> 1.0)
173
+ rack (> 1, < 3)
174
+ sprockets-rails (3.2.1)
175
+ actionpack (>= 4.0)
176
+ activesupport (>= 4.0)
177
+ sprockets (>= 3.0.0)
178
+ term-ansicolor (1.6.0)
179
+ tins (~> 1.0)
180
+ thor (0.19.4)
181
+ thread_safe (0.3.6)
182
+ tins (1.16.3)
183
+ tzinfo (1.2.5)
184
+ thread_safe (~> 0.1)
185
+ unicode-display_width (1.4.0)
186
+ websocket-driver (0.7.0)
187
+ websocket-extensions (>= 0.1.0)
188
+ websocket-extensions (0.1.3)
189
+
190
+ PLATFORMS
191
+ ruby
192
+
193
+ DEPENDENCIES
194
+ bundler
195
+ coveralls
196
+ factory_bot_rails
197
+ hertz-fcm!
198
+ pg
199
+ rake
200
+ rspec-activejob
201
+ rspec-rails
202
+ rubocop
203
+ rubocop-rspec
204
+
205
+ BUNDLED WITH
206
+ 1.16.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Igor Petkovic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # Hertz::Fcm
2
+
3
+ [![Build Status](https://travis-ci.org/IgorPetkovic/hertz-fcm.svg?branch=master)](https://travis-ci.org/IgorPetkovic/hertz-fcm)
4
+ [![Coverage Status](https://coveralls.io/repos/github/IgorPetkovic/hertz-fcm/badge.svg?branch=master)](https://coveralls.io/github/IgorPetkovic/hertz-fcm?branch=master)
5
+
6
+ This is a [Hertz](https://github.com/aldesantis/hertz) courier for sending
7
+ notifications to your users via [Firebase Cloud Messaging](https://firebase.google.com/).
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'hertz-fcm'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install hertz-fcm
24
+
25
+ Then, run the installer generator:
26
+
27
+ ```console
28
+ $ rails g hertz:fcm:install
29
+ ```
30
+
31
+ The courier will use ActiveJob to asynchronously deliver the text messages, so make sure that you're
32
+ executing background jobs with some adapter (`inline` will work, even though it's not recommended).
33
+ Jobs are pushed to the `default` queue.
34
+
35
+ ## Usage
36
+
37
+ You need to expose a `#device_ids` method in your receiver class:
38
+
39
+ ```ruby
40
+ class User
41
+ include Hertz::Notifiable
42
+
43
+ def device_ids
44
+ mobile_devices.pluck(:token)
45
+ end
46
+ end
47
+ ```
48
+
49
+ The method should return an array of Firebase Cloud Messaging tokens (see the [FCM documentation](https://firebase.google.com/docs/cloud-messaging/android/client#sample-register) on how to acquire these).
50
+ If `#device_ids` returns an empty value (i.e. `false`, `nil` or an empty array) at the time
51
+ the job is executed, the notification will not be delivered. This allows you to programmatically
52
+ enable/disable FCM notifications for a user:
53
+
54
+ ```ruby
55
+ class User
56
+ include Hertz::Notifiable
57
+
58
+ def device_ids
59
+ mobile_devices.pluck(:token) if push_enabled?
60
+ end
61
+ end
62
+ ```
63
+
64
+ All you need to do in order to start delivering notifications via FCM is add `fcm` to the
65
+ notification's `#deliver_by` statement and provide `body` and `title` methods:
66
+
67
+ ```ruby
68
+ class CommentNotification < Hertz::Notification
69
+ deliver_by :fcm
70
+
71
+ def body
72
+ 'You received a new comment!'
73
+ end
74
+
75
+ def title
76
+ 'New comment'
77
+ end
78
+ end
79
+ ```
80
+
81
+ All `CommentNotification`s will now be delivered via FCM! :)
82
+
83
+ **NOTE:** This courier uses the [deliveries API](https://github.com/aldesantis/hertz#tracking-delivery-status)
84
+ to prevent double deliveries.
85
+
86
+ ## Development
87
+
88
+ After checking out the repo, run `bundle install` to install dependencies.
89
+ Then, to run the tests:
90
+ ```
91
+ cp spec/dummy/config/database.example.yml spec/dummy/config/database.yml
92
+ cd spec/dummy && RAILS_ENV=test bundle exec rake db:create db:schema:load && cd ../..
93
+ bundle exec rspec
94
+ ```
95
+
96
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
97
+
98
+ ## Contributing
99
+
100
+ Bug reports and pull requests are welcome on GitHub at https://github.com/IgorPetkovic/hertz-fcm. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
101
+
102
+ ## License
103
+
104
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
105
+
106
+ ## Code of Conduct
107
+
108
+ Everyone interacting in the Hertz::Fcm project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/hertz-fcm/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hertz
4
+ module Fcm
5
+ class NotificationDeliveryJob < ActiveJob::Base
6
+ queue_as :default
7
+
8
+ def perform(notification)
9
+ PushNotificationSender.new(notification).run
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ class PushNotificationSender
4
+ attr_reader :notification
5
+
6
+ REQUIRED_KEYS = %i[title body].freeze
7
+
8
+ def initialize(notification)
9
+ @notification = notification
10
+ end
11
+
12
+ def run
13
+ return if notification.receiver.device_ids.blank?
14
+ return if notification.delivered_with?(:fcm)
15
+ return unless REQUIRED_KEYS.all? { |key| notification.respond_to?(key) }
16
+
17
+ fcm_client.send(
18
+ notification.receiver.device_ids,
19
+ options
20
+ )
21
+
22
+ notification.mark_delivered_with(:fcm)
23
+ end
24
+
25
+ private
26
+
27
+ def fcm_client
28
+ @fcm_client ||= ::FCM.new(
29
+ Hertz::Fcm.server_key
30
+ )
31
+ end
32
+
33
+ def options
34
+ {
35
+ notification: REQUIRED_KEYS.map { |key| [key, notification.send(key)] }.to_h
36
+ }
37
+ end
38
+ end
data/bin/rails ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ ENGINE_ROOT = File.expand_path('..', __dir__)
5
+ ENGINE_PATH = File.expand_path('../lib/hertz/fcm/engine', __dir__)
6
+
7
+ # Set up gems listed in the Gemfile.
8
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
9
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
10
+
11
+ require 'rails/all'
12
+ require 'rails/engine/commands'
data/hertz-fcm.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+
5
+ require 'hertz/fcm/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'hertz-fcm'
9
+ spec.version = Hertz::Fcm::VERSION
10
+ spec.authors = ['Igor Petkovic']
11
+ spec.email = ['igor.petkovic@gmail.com']
12
+
13
+ spec.summary = 'A Hertz courier for sending push notifications with Firebase Cloud Messaging.'
14
+ spec.homepage = 'https://github.com/IgorPetkovic/hertz-fcm'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'fcm', '>= 0.0.2', '< 1'
25
+ spec.add_dependency 'hertz', '~> 1.0'
26
+ spec.add_dependency 'rails', '>= 4.0.0', '< 6'
27
+
28
+ spec.add_development_dependency 'bundler'
29
+ spec.add_development_dependency 'coveralls'
30
+ spec.add_development_dependency 'factory_bot_rails'
31
+ spec.add_development_dependency 'pg'
32
+ spec.add_development_dependency 'rake'
33
+ spec.add_development_dependency 'rspec-activejob'
34
+ spec.add_development_dependency 'rspec-rails'
35
+ spec.add_development_dependency 'rubocop'
36
+ spec.add_development_dependency 'rubocop-rspec'
37
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hertz
4
+ module Fcm
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('templates', __dir__)
7
+
8
+ def copy_initializer_file
9
+ copy_file 'initializer.rb', 'config/initializers/hertz_fcm.rb'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ Hertz::Fcm.configure do |config|
4
+ # Your Firebase Cloud Messaging server key.
5
+ config.server_key = 'my_server_key'
6
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hertz
4
+ module Fcm
5
+ class Engine < ::Rails::Engine
6
+ isolate_namespace Hertz::Fcm
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hertz
4
+ module Fcm
5
+ VERSION = '1.0.0'
6
+ end
7
+ end
data/lib/hertz/fcm.rb ADDED
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fcm'
4
+ require 'hertz'
5
+
6
+ require 'hertz/fcm/engine'
7
+ require 'hertz/fcm/version'
8
+
9
+ module Hertz
10
+ module Fcm
11
+ mattr_accessor :server_key
12
+
13
+ class << self
14
+ def configure
15
+ yield(self)
16
+ end
17
+
18
+ def deliver_notification(notification)
19
+ Hertz::Fcm::NotificationDeliveryJob.perform_later(notification)
20
+ end
21
+ end
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,243 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hertz-fcm
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Igor Petkovic
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-09-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fcm
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.2
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.0.2
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '1'
33
+ - !ruby/object:Gem::Dependency
34
+ name: hertz
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rails
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 4.0.0
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: '6'
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 4.0.0
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '6'
67
+ - !ruby/object:Gem::Dependency
68
+ name: bundler
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ - !ruby/object:Gem::Dependency
82
+ name: coveralls
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: factory_bot_rails
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ - !ruby/object:Gem::Dependency
110
+ name: pg
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ - !ruby/object:Gem::Dependency
124
+ name: rake
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ type: :development
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ - !ruby/object:Gem::Dependency
138
+ name: rspec-activejob
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ type: :development
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ - !ruby/object:Gem::Dependency
152
+ name: rspec-rails
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ type: :development
159
+ prerelease: false
160
+ version_requirements: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ - !ruby/object:Gem::Dependency
166
+ name: rubocop
167
+ requirement: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ type: :development
173
+ prerelease: false
174
+ version_requirements: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ - !ruby/object:Gem::Dependency
180
+ name: rubocop-rspec
181
+ requirement: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ type: :development
187
+ prerelease: false
188
+ version_requirements: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ description:
194
+ email:
195
+ - igor.petkovic@gmail.com
196
+ executables: []
197
+ extensions: []
198
+ extra_rdoc_files: []
199
+ files:
200
+ - ".gitignore"
201
+ - ".rspec"
202
+ - ".rubocop.yml"
203
+ - ".travis.yml"
204
+ - CODE_OF_CONDUCT.md
205
+ - Gemfile
206
+ - Gemfile.lock
207
+ - LICENSE.txt
208
+ - README.md
209
+ - Rakefile
210
+ - app/jobs/hertz/fcm/notification_delivery_job.rb
211
+ - app/services/push_notification_sender.rb
212
+ - bin/rails
213
+ - hertz-fcm.gemspec
214
+ - lib/generators/hertz/fcm/install_generator.rb
215
+ - lib/generators/hertz/fcm/templates/initializer.rb
216
+ - lib/hertz/fcm.rb
217
+ - lib/hertz/fcm/engine.rb
218
+ - lib/hertz/fcm/version.rb
219
+ homepage: https://github.com/IgorPetkovic/hertz-fcm
220
+ licenses:
221
+ - MIT
222
+ metadata: {}
223
+ post_install_message:
224
+ rdoc_options: []
225
+ require_paths:
226
+ - lib
227
+ required_ruby_version: !ruby/object:Gem::Requirement
228
+ requirements:
229
+ - - ">="
230
+ - !ruby/object:Gem::Version
231
+ version: '0'
232
+ required_rubygems_version: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ requirements: []
238
+ rubyforge_project:
239
+ rubygems_version: 2.7.6
240
+ signing_key:
241
+ specification_version: 4
242
+ summary: A Hertz courier for sending push notifications with Firebase Cloud Messaging.
243
+ test_files: []