notification-handler 1.0.0.beta1 → 1.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -37
- metadata +10 -43
- data/CHANGELOG.md +0 -9
- data/generators/install_generator.rb +0 -42
- data/generators/templates/install/README.md +0 -1
- data/generators/templates/install/initializer.rb +0 -6
- data/generators/templates/install/notification_model.rb +0 -9
- data/generators/templates/install/notifications_migration.rb.erb +0 -14
- data/generators/templates/type/_action_cable.html.erb +0 -0
- data/generators/templates/type/_default.html.erb +0 -0
- data/generators/templates/type/_email.html.erb +0 -0
- data/generators/templates/type/_one_signal.html.erb +0 -0
- data/generators/type_generator.rb +0 -19
- data/lib/notification_handler/configuration.rb +0 -22
- data/lib/notification_handler/engine.rb +0 -6
- data/lib/notification_handler/library.rb +0 -9
- data/lib/notification_handler/object.rb +0 -23
- data/lib/notification_handler/railtie.rb +0 -14
- data/lib/notification_handler/scopes.rb +0 -7
- data/lib/notification_handler/target.rb +0 -23
- data/lib/notification_handler.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1eeb372b1b28269baba5376d9a4c5a206d000584cf10da928ce5ccbc8124f0f1
|
4
|
+
data.tar.gz: 6e59f6f3edefd95d0c3562a71c1e039e83e9883b76f43b53196204d9082c9c55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 109e473d421d2b444691365922a8a6496c4ecf876266576088d50fda23a4aae93d9364ad074a711bd711dbf0e2b0c35e858ccc712cd0d9de6dac21d4c9ca6b36
|
7
|
+
data.tar.gz: 68f56618fa317923eaa72a746c29b9f5c3690df0970004e17df9d8674135145c1b63dfc482d296b35ef4a1e450ad0db6c5fcf4e8cae462ddaf8c1eb8afa507fc
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# NotificationsRails
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/notifications-rails.svg)](https://badge.fury.io/rb/notifications-rails) <img src="https://travis-ci.org/jonhue/notifications-rails.svg?branch=master" />
|
4
4
|
|
5
5
|
The most powerful (cross-platform) notifications handler & pusher API for Rails.
|
6
6
|
|
@@ -9,8 +9,6 @@ The most powerful (cross-platform) notifications handler & pusher API for Rails.
|
|
9
9
|
## Table of Contents
|
10
10
|
|
11
11
|
* [Installation](#installation)
|
12
|
-
* [Usage](#usage)
|
13
|
-
* [Configuration](#configuration)
|
14
12
|
* [To Do](#to-do)
|
15
13
|
* [Contributing](#contributing)
|
16
14
|
* [Contributors](#contributors)
|
@@ -21,10 +19,10 @@ The most powerful (cross-platform) notifications handler & pusher API for Rails.
|
|
21
19
|
|
22
20
|
## Installation
|
23
21
|
|
24
|
-
|
22
|
+
NotificationsRails works with Rails 5 onwards. You can add it to your `Gemfile` with:
|
25
23
|
|
26
24
|
```ruby
|
27
|
-
gem '
|
25
|
+
gem 'notifications-rails'
|
28
26
|
```
|
29
27
|
|
30
28
|
And then execute:
|
@@ -33,45 +31,19 @@ And then execute:
|
|
33
31
|
|
34
32
|
Or install it yourself as:
|
35
33
|
|
36
|
-
$ gem install
|
34
|
+
$ gem install notifications-rails
|
37
35
|
|
38
36
|
If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
|
39
37
|
|
40
38
|
```ruby
|
41
|
-
gem '
|
39
|
+
gem 'notifications-rails', github: 'jonhue/notifications-rails'
|
42
40
|
```
|
43
41
|
|
44
|
-
Now run the generator:
|
45
|
-
|
46
|
-
$ rails g notification_handler:install
|
47
|
-
|
48
|
-
To wrap things up, migrate the changes to your database:
|
49
|
-
|
50
|
-
$ rails db:migrate
|
51
|
-
|
52
|
-
---
|
53
|
-
|
54
|
-
## Usage
|
55
|
-
|
56
|
-
---
|
57
|
-
|
58
|
-
## Configuration
|
59
|
-
|
60
|
-
You can configure NotificationHandler by passing a block to `configure`. This can be done in `config/initializers/notification-handler.rb`:
|
61
|
-
|
62
|
-
```ruby
|
63
|
-
NotificationHandler.configure do |config|
|
64
|
-
config.default_type = 'notification'
|
65
|
-
end
|
66
|
-
```
|
67
|
-
|
68
|
-
**`default_type`** Choose your default notification type. Takes a string. Defaults to `'notification'`.
|
69
|
-
|
70
42
|
---
|
71
43
|
|
72
44
|
## To Do
|
73
45
|
|
74
|
-
[Here](https://github.com/jonhue/notifications-rails/projects
|
46
|
+
[Here](https://github.com/jonhue/notifications-rails/projects) is the full list of current projects.
|
75
47
|
|
76
48
|
To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/notifications-rails/issues/new).
|
77
49
|
|
@@ -79,7 +51,7 @@ To propose your ideas, initiate the discussion by adding a [new issue](https://g
|
|
79
51
|
|
80
52
|
## Contributing
|
81
53
|
|
82
|
-
We hope that you will consider contributing to
|
54
|
+
We hope that you will consider contributing to NotificationsRails. Please read this short overview for some information about how to get started:
|
83
55
|
|
84
56
|
[Learn more about contributing to this repository](https://github.com/jonhue/notifications-rails/blob/master/CONTRIBUTING.md), [Code of Conduct](https://github.com/jonhue/notifications-rails/blob/master/CODE_OF_CONDUCT.md)
|
85
57
|
|
@@ -91,7 +63,7 @@ https://github.com/jonhue/notifications-rails/graphs/contributors
|
|
91
63
|
|
92
64
|
### Semantic Versioning
|
93
65
|
|
94
|
-
|
66
|
+
NotificationsRails follows Semantic Versioning 2.0 as defined at http://semver.org.
|
95
67
|
|
96
68
|
## License
|
97
69
|
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notification-handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Hübotter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: railties
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,35 +25,21 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.16'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.16'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
31
|
+
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
type: :
|
33
|
+
version: '5.0'
|
34
|
+
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- - "
|
38
|
+
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
40
|
+
version: '5.0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
42
|
+
name: rspec
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
@@ -86,27 +72,8 @@ executables: []
|
|
86
72
|
extensions: []
|
87
73
|
extra_rdoc_files: []
|
88
74
|
files:
|
89
|
-
- CHANGELOG.md
|
90
75
|
- LICENSE
|
91
76
|
- README.md
|
92
|
-
- generators/install_generator.rb
|
93
|
-
- generators/templates/install/README.md
|
94
|
-
- generators/templates/install/initializer.rb
|
95
|
-
- generators/templates/install/notification_model.rb
|
96
|
-
- generators/templates/install/notifications_migration.rb.erb
|
97
|
-
- generators/templates/type/_action_cable.html.erb
|
98
|
-
- generators/templates/type/_default.html.erb
|
99
|
-
- generators/templates/type/_email.html.erb
|
100
|
-
- generators/templates/type/_one_signal.html.erb
|
101
|
-
- generators/type_generator.rb
|
102
|
-
- lib/notification_handler.rb
|
103
|
-
- lib/notification_handler/configuration.rb
|
104
|
-
- lib/notification_handler/engine.rb
|
105
|
-
- lib/notification_handler/library.rb
|
106
|
-
- lib/notification_handler/object.rb
|
107
|
-
- lib/notification_handler/railtie.rb
|
108
|
-
- lib/notification_handler/scopes.rb
|
109
|
-
- lib/notification_handler/target.rb
|
110
77
|
homepage: https://github.com/jonhue/notifications-rails/tree/master/notification-handler
|
111
78
|
licenses:
|
112
79
|
- MIT
|
data/CHANGELOG.md
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
require 'rails/generators/migration'
|
3
|
-
|
4
|
-
class InstallGenerator < Rails::Generators::Base
|
5
|
-
|
6
|
-
include Rails::Generators::Migration
|
7
|
-
|
8
|
-
source_root File.join File.dirname(__FILE__), 'templates/install'
|
9
|
-
desc 'Install NotificationHandler'
|
10
|
-
|
11
|
-
def self.next_migration_number dirname
|
12
|
-
if ActiveRecord::Base.timestamped_migrations
|
13
|
-
Time.now.utc.strftime '%Y%m%d%H%M%S'
|
14
|
-
else
|
15
|
-
"%.3d" % ( current_migration_number(dirname) + 1 )
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def create_initializer
|
20
|
-
template 'initializer.rb', 'config/initializers/notification-handler.rb'
|
21
|
-
end
|
22
|
-
|
23
|
-
def create_notifications_migration_file
|
24
|
-
migration_template 'notifications_migration.rb.erb', 'db/migrate/notifications_migration.rb', migration_version: migration_version
|
25
|
-
end
|
26
|
-
def create_notification_model
|
27
|
-
template 'notification_model.rb', 'app/models/notification.rb'
|
28
|
-
end
|
29
|
-
|
30
|
-
def show_readme
|
31
|
-
readme 'README.md'
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def migration_version
|
37
|
-
if Rails.version >= '5.0.0'
|
38
|
-
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
Now run `rails db:migrate` to add NotificationHandler to your database.
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class NotificationsMigration < ActiveRecord::Migration<%= migration_version %>
|
2
|
-
def change
|
3
|
-
create_table :notifications do |t|
|
4
|
-
|
5
|
-
t.references :target, polymorphic: true, index: true
|
6
|
-
t.references :object, polymorphic: true, index: true
|
7
|
-
|
8
|
-
t.string :type, default: NotificationHandler.configuration.default_type, null: false, index: true
|
9
|
-
|
10
|
-
t.timestamps
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
require 'rails/generators/migration'
|
3
|
-
|
4
|
-
class TypeGenerator < Rails::Generators::Base
|
5
|
-
|
6
|
-
include Rails::Generators::Migration
|
7
|
-
|
8
|
-
source_root File.join File.dirname(__FILE__), 'templates/type'
|
9
|
-
desc 'Create a new notification type'
|
10
|
-
class_option :type, desc: 'Specify the notification type', type: :string, default: NotificationHandler.configuration.default_type, aliases: '-t'
|
11
|
-
|
12
|
-
def create_templates
|
13
|
-
template '_default.html.erb', "app/views/notifications/#{options[:type]}/_default.html.erb"
|
14
|
-
template '_action_cable.html.erb', "app/views/notifications/#{options[:type]}/_action_cable.html.erb" if defined?(NotificationPusher::ActionCable)
|
15
|
-
template '_email.html.erb', "app/views/notifications/#{options[:type]}/_email.html.erb" if defined?(NotificationPusher::Email)
|
16
|
-
template '_one_signal.html.erb', "app/views/notifications/#{options[:type]}/_one_signal.html.erb" if defined?(NotificationPusher::OneSignal)
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module NotificationHandler
|
2
|
-
|
3
|
-
class << self
|
4
|
-
attr_accessor :configuration
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.configure
|
8
|
-
self.configuration ||= Configuration.new
|
9
|
-
yield configuration
|
10
|
-
end
|
11
|
-
|
12
|
-
class Configuration
|
13
|
-
|
14
|
-
attr_accessor :default_type
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
@default_type = 'notification'
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module NotificationHandler
|
2
|
-
module Object
|
3
|
-
|
4
|
-
def self.included base
|
5
|
-
base.extend ClassMethods
|
6
|
-
end
|
7
|
-
|
8
|
-
module ClassMethods
|
9
|
-
def notification_object
|
10
|
-
has_many :notifications, as: :object, dependent: :destroy
|
11
|
-
include NotificationHandler::Object::InstanceMethods
|
12
|
-
include NotificationHandler::Library
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module InstanceMethods
|
17
|
-
|
18
|
-
# ...
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'rails'
|
2
|
-
|
3
|
-
module NotificationHandler
|
4
|
-
class Railtie < Rails::Railtie
|
5
|
-
|
6
|
-
initializer 'notification-handler.active_record' do
|
7
|
-
ActiveSupport.on_load :active_record do
|
8
|
-
include NotificationHandler::Target
|
9
|
-
include NotificationHandler::Object
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module NotificationHandler
|
2
|
-
module Target
|
3
|
-
|
4
|
-
def self.included base
|
5
|
-
base.extend ClassMethods
|
6
|
-
end
|
7
|
-
|
8
|
-
module ClassMethods
|
9
|
-
def notification_target
|
10
|
-
has_many :notifications, as: :target, dependent: :destroy
|
11
|
-
include NotificationHandler::Target::InstanceMethods
|
12
|
-
include NotificationHandler::Library
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module InstanceMethods
|
17
|
-
|
18
|
-
# ...
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
data/lib/notification_handler.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
module NotificationHandler
|
2
|
-
|
3
|
-
require 'notification_handler/configuration'
|
4
|
-
|
5
|
-
# require 'notification_handler/engine'
|
6
|
-
|
7
|
-
autoload :Target, 'notification_handler/target'
|
8
|
-
autoload :Object, 'notification_handler/object'
|
9
|
-
autoload :Library, 'notification_handler/library'
|
10
|
-
autoload :Scopes, 'notification_handler/scopes'
|
11
|
-
|
12
|
-
require 'notification_handler/railtie'
|
13
|
-
|
14
|
-
end
|