notification-renderer 1.2.4 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 712f319a90e8085272bd6e7e2064a1b1f5e736a9235703640ccc9f7dcad23335
4
- data.tar.gz: fff7dc09ad9e69bfc29ccdf8c85a6fb60dae9c18dbfc6d82ee84648ea44c4beb
3
+ metadata.gz: 36bf41fe2085e87d8719b4bf164cfd9620b65a048f3c784274f912abafb86853
4
+ data.tar.gz: cf6006fb927acdea8edaf91fc3b0c1c65efc9d60b3ac24cb643f0b4e23a5af3b
5
5
  SHA512:
6
- metadata.gz: 84df50521bd7d113bd023ac9b1f58603f87ae0c2378d89e7250742043fb8506cc593acf030ecd287dac39bf0b5500b25c502b0349f4991fb8aba9a2b7646cac1
7
- data.tar.gz: e52ea677458828dcd1fb9d0a812e2b6d10fc7e5ba166f41afbb588f82937b4d5c467bd57f8eccd74bc8745a8ee99db04c63f04c5ae015f76c2f5e533fb545641
6
+ metadata.gz: 3b91805d98abf2485e2d41548196f1aa7244d627b238a4935833b6a0365ed7625062fd0752c6892f9b5bfe14af73c6c688735c1690182016bccc3c4003c6e998
7
+ data.tar.gz: c0d168c97b8570c04a56c8bc6e8a47aecff54ca051c47da3472128251aec578aee32387c1136076043d6bdff42a509dbac87a3875e7b6f10c185e258165082d4
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2017 Jonas Hübotter
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 all
13
- 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 THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Jonas Hübotter
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,328 +1,84 @@
1
- # NotificationRenderer
2
-
3
- [![Gem Version](https://badge.fury.io/rb/notification-renderer.svg)](https://badge.fury.io/rb/notification-renderer) <img src="https://travis-ci.org/jonhue/notifications-rails.svg?branch=master" />
4
-
5
- Render your notifications on multiple platforms by specifying notification types.
6
-
7
- ---
8
-
9
- ## Table of Contents
10
-
11
- * [Installation](#installation)
12
- * [Usage](#usage)
13
- * [Types](#types)
14
- * [Generating a new type](#generating-a-new-type)
15
- * [Using a type](#using-a-type)
16
- * [Renderers](#renderers)
17
- * [View helpers](#view-helpers)
18
- * [`render_notification`](#render_notification)
19
- * [`render_notifications`](#render_notifications)
20
- * [Grouping](#grouping)
21
- * [Grouping by notification types](#grouping-by-notification-types)
22
- * [Grouping by notification dates](#grouping-by-notification-dates)
23
- * [Configuration](#configuration)
24
- * [To Do](#to-do)
25
- * [Contributing](#contributing)
26
- * [Contributors](#contributors)
27
- * [Semantic versioning](#semantic-versioning)
28
- * [License](#license)
29
-
30
- ---
31
-
32
- ## Installation
33
-
34
- NotificationRenderer works with Rails 5 onwards. You can add it to your `Gemfile` with:
35
-
36
- ```ruby
37
- gem 'notification-renderer'
38
- ```
39
-
40
- And then execute:
41
-
42
- $ bundle
43
-
44
- Or install it yourself as:
45
-
46
- $ gem install notification-renderer
47
-
48
- If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
49
-
50
- ```ruby
51
- gem 'notification-renderer', github: 'jonhue/notifications-rails'
52
- ```
53
-
54
- Now run the generator:
55
-
56
- $ rails g notification_renderer:install
57
-
58
- To wrap things up, migrate the changes to your database:
59
-
60
- $ rails db:migrate
61
-
62
- ---
63
-
64
- ## Usage
65
-
66
- ### Types
67
-
68
- NotificationRenderer uses templates to render your notifications.
69
-
70
- The `type` of a notification determines which template gets utilized for rendering. Each notification type has multiple templates each of which responsible for rendering a notification in another scenario. The default template for a given type is `index`.
71
-
72
- #### Generating a new type
73
-
74
- This gem comes with a generator to make adding new types a whole lot easier. Run in your terminal:
75
-
76
- $ rails g notification_renderer:type -t notification
77
-
78
- This will create the following structure in your application:
79
-
80
- * `views`
81
- * `notifications`
82
- * `notification`
83
- * `_index.html.erb`
84
-
85
- You can also customize the generated templates (renderers):
86
-
87
- $ rails g notification_renderer:type -t notification -r index feed
88
-
89
- This command will also create a custom renderer called `feed` for the notification type `notification`:
90
-
91
- * `views`
92
- * `notifications`
93
- * `notification`
94
- * `_feed.html.erb`
95
- * `_index.html.erb`
96
-
97
- #### Using a type
98
-
99
- You are able to specify the `type` of a `Notification` record:
100
-
101
- ```ruby
102
- notification = Notification.create target: User.first, object: Recipe.first, type: 'notification'
103
- ```
104
-
105
- **Note:** The `type` attribute of any new `Notification` record will default to the [`default_type` configuration](#configuration).
106
-
107
- You can also scope records by their type:
108
-
109
- ```ruby
110
- # Return records with `'notification'` as type
111
- Notification.notification_type
112
-
113
- # Return records with `'follow'` as type
114
- Notification.follow_type
115
- ```
116
-
117
- ### Renderers
118
-
119
- In your renderers you can access the `Notification` record through the `notification` variable. This is how a renderer could look like:
120
-
121
- ```erb
122
- <%= notification.target.name %> commented on <%= notification.object.article.title %>.
123
- ```
124
-
125
- ### View helpers
126
-
127
- NotificationRenderer introduces some view helpers to assist you in embedding notifications.
128
-
129
- #### `render_notification`
130
-
131
- `render_notification` renders a single `Notification` record:
132
-
133
- ```erb
134
- <%= render_notification Notification.first %>
135
- ```
136
-
137
- Rendering a notification will set its `read` attribute to `true`. This behavior can be [configured](#configuration).
138
-
139
- You can also specify a renderer. It defaults to `'index'`.
140
-
141
- ```erb
142
- <%= render_notification Notification.first, 'feed' %>
143
- ```
144
-
145
- #### `render_notifications`
146
-
147
- `render_notifications` takes an ActiveRecord array of `Notification` records and renders each of them in order:
148
-
149
- ```erb
150
- <%= render_notifications Notification.all %>
151
- ```
152
-
153
- You can also specify a renderer. It defaults to `'index'`.
154
-
155
- ```erb
156
- <%= render_notifications Notification.all, 'feed' %>
157
- ```
158
-
159
- It wraps the rendered notifications in a `div`:
160
-
161
- ```html
162
- <div class="notification-renderer notifications">
163
- <!-- ... -->
164
- </div>
165
- ```
166
-
167
- ### Grouping
168
-
169
- You can group any ActiveRecord array of `Notification` records by an attribute value:
170
-
171
- ```ruby
172
- Notification.all.grouping(['object.article'])
173
- Notification.all.grouping(['object.article', 'metadata[:title]'])
174
- ```
175
-
176
- **Note:** Notifications will be grouped in order.
177
-
178
- When rendering notifications you often want to group them by the object they belong to. This is how to group notifications by the associated object:
179
-
180
- ```erb
181
- <%= render_notifications_grouped Notification.all, ['object'], renderer: 'feed' %>
182
- ```
183
-
184
- You can also group notifications by nested attributes:
185
-
186
- ```erb
187
- <%= render_notifications_grouped Notification.all, ['object.article'] %>
188
- <%= render_notifications_grouped Notification.all, ['metadata[:title]'] %>
189
- ```
190
-
191
- It is also possible to group notifications for just one object:
192
-
193
- ```erb
194
- <%= render_notifications_grouped Notification.where(object_id: 1, object_type: 'Comment'), ['object'] %>
195
- ```
196
-
197
- This will render the last notification for every group and pass the attributes value grouped by to your renderer:
198
-
199
- ```erb
200
- <!-- View -->
201
-
202
- <%= render_notifications_grouped Notification.notification_type, ['object.article'] %>
203
- ```
204
-
205
- ```erb
206
- <!-- Renderer -->
207
-
208
- <% if notification_grouped? %>
209
- <%= notification.target.name %> and <%= (notifications.count - 1).to_s %> others commented on <%= attributes['object.article'].title %>.
210
- <% else %>
211
- <%= notification.target.name %> commented on <%= notification.object.article.title %>.
212
- <% end %>
213
- ```
214
-
215
- Grouping makes the following two methods available in your renderer:
216
-
217
- **`attributes`** Hash of attributes grouped by and their values.
218
-
219
- **`notifications`** The ActiveRecord array of notifications including the currently rendered notification.
220
-
221
- You may check whether a template is being used for grouping by using the `notification_grouped?` helper method.
222
-
223
- #### Grouping by notification types
224
-
225
- It is common, if rendering multiple notification types at once, to group the notifications by their type:
226
-
227
- ```erb
228
- <%= render_notifications_grouped Notification.all, ['object.article'], group_by_type: true %>
229
- ```
230
-
231
- This is identical to the following:
232
-
233
- ```erb
234
- <%= render_notifications_grouped Notification.all, [:type, 'object.article'] %>
235
- ```
236
-
237
- #### Grouping by notification dates
238
-
239
- It is also often required to group notifications by their date of creation:
240
-
241
- ```erb
242
- <%= render_notifications_grouped Notification.all, ['object.article'], group_by_date: :month %>
243
- ```
244
-
245
- This is identical to the following:
246
-
247
- ```erb
248
- <%= render_notifications_grouped Notification.all, ['created_at.beginning_of_month', 'object.article'] %>
249
- ```
250
-
251
- Accepted values are:
252
-
253
- * `:minute`
254
- * `:hour`
255
- * `:day`
256
- * `:week`
257
- * `:month`
258
- * `:year`
259
-
260
- **Note:** If used together with `group_by_type`, notifications will be grouped first by creation date and then by `:type`.
261
-
262
- ---
263
-
264
- ## Configuration
265
-
266
- You can configure NotificationRenderer by passing a block to `configure`. This can be done in `config/initializers/notification-renderer.rb`:
267
-
268
- ```ruby
269
- NotificationRenderer.configure do |config|
270
- config.default_type = 'notification'
271
- end
272
- ```
273
-
274
- **`default_type`** Choose your default notification type. Takes a string. Defaults to `'notification'`.
275
-
276
- **`default_renderer`** Choose your default renderer. Takes a string. Defaults to `'index'`.
277
-
278
- **`auto_read`** Automatically mark rendered notifications as read. Takes a boolean. Defaults to `true`.
279
-
280
- ---
281
-
282
- ## To Do
283
-
284
- [Here](https://github.com/jonhue/notifications-rails/projects/7) is the full list of current projects.
285
-
286
- To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/notifications-rails/issues/new).
287
-
288
- ---
289
-
290
- ## Contributing
291
-
292
- We hope that you will consider contributing to NotificationRenderer. Please read this short overview for some information about how to get started:
293
-
294
- [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)
295
-
296
- ### Contributors
297
-
298
- Give the people some :heart: who are working on this project. See them all at:
299
-
300
- https://github.com/jonhue/notifications-rails/graphs/contributors
301
-
302
- ### Semantic Versioning
303
-
304
- NotificationRenderer follows Semantic Versioning 2.0 as defined at http://semver.org.
305
-
306
- ## License
307
-
308
- MIT License
309
-
310
- Copyright (c) 2017 Jonas Hübotter
311
-
312
- Permission is hereby granted, free of charge, to any person obtaining a copy
313
- of this software and associated documentation files (the "Software"), to deal
314
- in the Software without restriction, including without limitation the rights
315
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
316
- copies of the Software, and to permit persons to whom the Software is
317
- furnished to do so, subject to the following conditions:
318
-
319
- The above copyright notice and this permission notice shall be included in all
320
- copies or substantial portions of the Software.
321
-
322
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
323
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
324
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
325
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
326
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
327
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
328
- SOFTWARE.
1
+ # notifications-rails
2
+
3
+ notifications-rails is the most powerful notification library for Rails. It offers not only simple APIs to create and render notifications but also supports user-integration and cross-platform delivery of notifications.
4
+
5
+ ## Philosophy
6
+
7
+ notifications-rails has been built with modularity in mind. It currently consists of four components each of which bringing one essential functionality to the integration of notifications in your Rails app.
8
+
9
+ **[notification-handler](notification-handler):** Create and modify your notifications through a simple API.
10
+
11
+ **[notification-renderer](notification-renderer):** Render your notifications in various contexts.
12
+
13
+ **[notification-pusher](notification-pusher):** Deliver your notifications to various services, including [Email](notification-pusher/notification-pusher-actionmailer) and [OneSignal](notification-pusher/notification-pusher-onesignal).
14
+
15
+ **[notification-settings](notification-settings):** Integrates with your authentication solution to craft a personalized user notification platform.
16
+
17
+ You may just use the components you actually need, or instead use this gem to bundle everything for a complete notification solution.
18
+
19
+ ## Installation
20
+
21
+ You can add notifications-rails to your `Gemfile` with:
22
+
23
+ ```ruby
24
+ gem 'notifications-rails'
25
+ ```
26
+
27
+ And then run:
28
+
29
+ $ bundle install
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install notifications-rails
34
+
35
+ If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
36
+
37
+ ```ruby
38
+ gem 'notifications-rails', github: 'jonhue/notifications-rails'
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ Details on usage are provided in the [documentation](#philosophy) of the specific modules.
44
+
45
+ ## Development
46
+
47
+ To start development you first have to fork this repository and locally clone your fork.
48
+
49
+ Install the projects dependencies by running:
50
+
51
+ $ bundle install
52
+
53
+ ### Testing
54
+
55
+ Tests are written with RSpec. Integration tests are located in `/spec`, unit tests can be found in `<module>/spec`.
56
+
57
+ To run all tests:
58
+
59
+ $ ./rspec
60
+
61
+ To run RuboCop:
62
+
63
+ $ bundle exec rubocop
64
+
65
+ You can find all commands run by the CI workflow in `.github/workflows/ci.yml`.
66
+
67
+ ## Contributing
68
+
69
+ We warmly welcome everyone who is intersted in contributing. Please reference our [contributing guidelines](CONTRIBUTING.md) and our [Code of Conduct](CODE_OF_CONDUCT.md).
70
+
71
+ ## Releases
72
+
73
+ [Here](https://github.com/jonhue/notifications-rails/releases) you can find details on all past releases. Unreleased breaking changes that are on the current master can be found [here](CHANGELOG.md).
74
+
75
+ notifications-rails follows Semantic Versioning 2.0 as defined at http://semver.org. Reference our [security policy](SECURITY.md).
76
+
77
+ ### Publishing
78
+
79
+ 1. Review breaking changes and deprecations in `CHANGELOG.md`.
80
+ 1. Change the gem version in `VERSION`.
81
+ 1. Reset `CHANGELOG.md`.
82
+ 1. Create a pull request to merge the changes into `master`.
83
+ 1. After the pull request was merged, create a new release listing the breaking changes and commits on `master` since the last release.
84
+ 1. The release workflow will publish the gems to RubyGems.
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'notification-handler'
4
+ require 'notification-renderer'
5
+ require 'notification-pusher'
6
+ require 'notification-settings'
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notification-renderer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 3.0.3
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: 2018-03-17 00:00:00.000000000 Z
11
+ date: 2020-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: railties
14
+ name: actionview
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: actionview
28
+ name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,21 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: activesupport
42
+ name: notification-handler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.3
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: railties
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -53,73 +67,117 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '5.0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: notification-handler
70
+ name: factory_bot
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: 1.2.4
62
- type: :runtime
75
+ version: '0'
76
+ type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - '='
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: 1.2.4
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rspec
84
+ name: pry
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - "~>"
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
- version: '3.7'
89
+ version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "~>"
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
- version: '3.7'
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
83
125
  - !ruby/object:Gem::Dependency
84
126
  name: rubocop
85
127
  requirement: !ruby/object:Gem::Requirement
86
128
  requirements:
87
- - - "~>"
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: sqlite3
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
88
158
  - !ruby/object:Gem::Version
89
- version: '0.52'
159
+ version: '0'
90
160
  type: :development
91
161
  prerelease: false
92
162
  version_requirements: !ruby/object:Gem::Requirement
93
163
  requirements:
94
- - - "~>"
164
+ - - ">="
95
165
  - !ruby/object:Gem::Version
96
- version: '0.52'
97
- description: Render your notifications on multiple platforms by specifying notification
98
- types.
99
- email: me@jonhue.me
166
+ version: '0'
167
+ description: Render your notifications in various contexts.
168
+ email: jonas.huebotter@gmail.com
100
169
  executables: []
101
170
  extensions: []
102
171
  extra_rdoc_files: []
103
172
  files:
104
- - CHANGELOG.md
105
173
  - LICENSE
106
174
  - README.md
107
- - app/helpers/notification_renderer_helper.rb
108
- - lib/generators/notification_renderer/install_generator.rb
109
- - lib/generators/notification_renderer/type_generator.rb
110
- - lib/generators/templates/install/README.md
111
- - lib/generators/templates/install/initializer.rb
112
- - lib/generators/templates/install/notifications_migration.rb.erb
113
- - lib/generators/templates/type/_template.html
114
- - lib/notification-renderer.rb
115
- - lib/notification_renderer/configuration.rb
116
- - lib/notification_renderer/engine.rb
117
- - lib/notification_renderer/notification_library.rb
118
- - lib/notification_renderer/notification_scopes.rb
175
+ - lib/notifications-rails.rb
119
176
  homepage: https://github.com/jonhue/notifications-rails/tree/master/notification-renderer
120
177
  licenses:
121
178
  - MIT
122
- metadata: {}
179
+ metadata:
180
+ github_repo: ssh://github.com/jonhue/notifications-rails
123
181
  post_install_message:
124
182
  rdoc_options: []
125
183
  require_paths:
@@ -128,17 +186,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
186
  requirements:
129
187
  - - ">="
130
188
  - !ruby/object:Gem::Version
131
- version: '2.3'
189
+ version: 2.2.2
132
190
  required_rubygems_version: !ruby/object:Gem::Requirement
133
191
  requirements:
134
192
  - - ">="
135
193
  - !ruby/object:Gem::Version
136
194
  version: '0'
137
195
  requirements: []
138
- rubyforge_project:
139
- rubygems_version: 2.7.4
196
+ rubygems_version: 3.1.4
140
197
  signing_key:
141
198
  specification_version: 4
142
- summary: Render your notifications on multiple platforms by specifying notification
143
- types
199
+ summary: Render your notifications in various contexts
144
200
  test_files: []
@@ -1,46 +0,0 @@
1
- # Changelog
2
-
3
- ### master
4
-
5
- * nothing yet
6
-
7
- ### 1.2.3 - 2018/01/23
8
-
9
- * enhancements
10
- * made `attribute` & `notifications_count` parameters optional for `render_notification` method
11
- * bugfixes
12
- * fixed magic type scopes
13
-
14
- ### 1.0.0 - 2017/12/28
15
-
16
- * bugfixes
17
-
18
- ### 1.0.0.beta6 - 2017/12/28
19
-
20
- * bugfixes
21
- * fix lib loading problems
22
-
23
- ### 1.0.0.beta5 - 2017/12/28
24
-
25
- * bugfixes
26
- * fix generators
27
- * fix lib loading problems
28
- * fix syntax errors
29
-
30
- ### 1.0.0.beta4 - 2017/12/27
31
-
32
- * features
33
- * add helpers
34
- * add `default_renderer` and `auto_read` configuration options
35
- * add grouping functionality
36
- * enhancements
37
- * allow defining renderers for `type` generator
38
-
39
- ### 1.0.0.beta3 - 2017/12/25
40
-
41
- * features
42
- * introduce `type` generator
43
-
44
- ### 1.0.0.beta2 - 2017/12/23
45
-
46
- * initial release
@@ -1,63 +0,0 @@
1
- module NotificationRendererHelper
2
-
3
- def render_notification notification, options = {}
4
- defaults = {
5
- renderer: NotificationRenderer.configuration.default_renderer,
6
- attributes: nil,
7
- notifications: nil
8
- }
9
- options = defaults.merge options
10
-
11
- notification.update_attributes read: true if NotificationRenderer.configuration.auto_read
12
- render "notifications/#{notification.type}/#{options[:renderer]}", notification: notification, attributes: options[:attributes], notifications: options[:notifications]
13
- end
14
-
15
- def render_notifications notifications, options = {}
16
- defaults = {
17
- renderer: NotificationRenderer.configuration.default_renderer
18
- }
19
- options = defaults.merge options
20
-
21
- content_tag :div, class: 'notification-renderer notifications' do
22
- notifications.each do |notification|
23
- render_notification notification, renderer: options[:renderer]
24
- end
25
- end
26
- end
27
-
28
- def render_notifications_grouped notifications, group_by, options = {}
29
- defaults = {
30
- renderer: NotificationRenderer.configuration.default_renderer,
31
- group_by_date: false,
32
- group_by_type: false
33
- }
34
- options = defaults.merge options
35
-
36
- group_by.unshift :type if options[:group_by_type]
37
- group_by.unshift "created_at.beginning_of_#{options[:group_by_date]}" if options[:group_by_date]
38
-
39
- content_tag :div, class: 'notification-renderer notifications' do
40
- recursive_render_notifications_grouped notifications.grouping(options[:group_by]), options
41
- end
42
- end
43
-
44
- def notification_grouped?
45
- local_assigns[:attributes] && local_assigns[:notifications]
46
- end
47
-
48
- private
49
-
50
- def recursive_render_notifications_grouped notifications, i = 0, options = {}
51
- options[:attributes] = {} unless options.has_key? :attributes
52
- notifications.each_pair do |k, v|
53
- options[:attributes][options[:group_by][i]] = k
54
- i += 1
55
- if v.is_a? Hash
56
- recursive_render_notifications_grouped v, options
57
- else
58
- render_notification v.last, renderer: options[:renderer], attributes: options[:attributes], notifications: v
59
- end
60
- end
61
- end
62
-
63
- end
@@ -1,47 +0,0 @@
1
- require 'rails/generators'
2
- require 'rails/generators/migration'
3
-
4
- module NotificationRenderer
5
-
6
- class InstallGenerator < Rails::Generators::Base
7
-
8
- include Rails::Generators::Migration
9
-
10
- source_root File.join File.dirname(__FILE__), '../templates/install'
11
- desc 'Install NotificationRenderer'
12
-
13
- def self.next_migration_number dirname
14
- if ActiveRecord::Base.timestamped_migrations
15
- Time.now.utc.strftime '%Y%m%d%H%M%S'
16
- else
17
- "%.3d" % ( current_migration_number(dirname) + 1 )
18
- end
19
- end
20
-
21
- def create_initializer
22
- template 'initializer.rb', 'config/initializers/notification-renderer.rb'
23
- end
24
-
25
- def create_notifications_migration_file
26
- migration_template 'notifications_migration.rb.erb', 'db/migrate/notification_renderer_migration.rb', migration_version: migration_version
27
- end
28
-
29
- def create_templates
30
- system 'rails g notification_renderer:type -t notification'
31
- end
32
-
33
- def show_readme
34
- readme 'README.md'
35
- end
36
-
37
- private
38
-
39
- def migration_version
40
- if Rails.version >= '5.0.0'
41
- "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
42
- end
43
- end
44
-
45
- end
46
-
47
- end
@@ -1,21 +0,0 @@
1
- require 'rails/generators'
2
- require 'rails/generators/migration'
3
-
4
- module NotificationRenderer
5
-
6
- class TypeGenerator < Rails::Generators::Base
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: NotificationRenderer.configuration.default_type, aliases: '-t'
11
- class_option :renderers, desc: 'Specify the renderer templates', type: :string, default: NotificationRenderer.configuration.default_renderer, aliases: '-r'
12
-
13
- def create_templates
14
- options[:renderers].split(' ')&.each do |template|
15
- template '_template.html', "app/views/notifications/#{options[:type]}/_#{template}.html.erb"
16
- end
17
- end
18
-
19
- end
20
-
21
- end
@@ -1 +0,0 @@
1
- Now run `rails db:migrate` to add NotificationRenderer to your database.
@@ -1,12 +0,0 @@
1
- NotificationRenderer.configure do |config|
2
-
3
- # Choose your default notification type. Takes a string.
4
- # config.default_type = 'notification'
5
-
6
- # Choose your default renderer. Takes a string.
7
- # config.default_renderer = 'index'
8
-
9
- # Automatically mark rendered notifications as read. Takes a boolean.
10
- # config.auto_read = true
11
-
12
- end
@@ -1,5 +0,0 @@
1
- class NotificationRendererMigration < ActiveRecord::Migration<%= migration_version %>
2
- def change
3
- add_column :notifications, :type, :string, index: true
4
- end
5
- end
@@ -1,7 +0,0 @@
1
- <!--
2
- In your renderers you can access the `Notification` record through the `notification` variable. This is how a renderer could look like:
3
-
4
- <%#= notification.target.name %> commented on <%#= notification.object.article.title %>
5
-
6
- Learn more: https://github.com/jonhue/notifications-rails/tree/master/notification-renderer#renderers
7
- -->
@@ -1,10 +0,0 @@
1
- module NotificationRenderer
2
-
3
- require 'notification_renderer/configuration'
4
-
5
- require 'notification_renderer/engine'
6
-
7
- autoload :NotificationLibrary, 'notification_renderer/notification_library'
8
- autoload :NotificationScopes, 'notification_renderer/notification_scopes'
9
-
10
- end
@@ -1,26 +0,0 @@
1
- module NotificationRenderer
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
- attr_accessor :default_renderer
16
- attr_accessor :auto_read
17
-
18
- def initialize
19
- @default_type = 'notification'
20
- @default_renderer = 'index'
21
- @auto_read = true
22
- end
23
-
24
- end
25
-
26
- end
@@ -1,7 +0,0 @@
1
- require 'rails/railtie'
2
- require 'action_view'
3
-
4
- module NotificationRenderer
5
- class Engine < ::Rails::Engine
6
- end
7
- end
@@ -1,45 +0,0 @@
1
- require 'notification-handler'
2
- require 'active_support'
3
-
4
- module NotificationRenderer
5
- module NotificationLibrary
6
-
7
- extend ActiveSupport::Concern
8
-
9
- module ClassMethods
10
-
11
- def grouping group_by
12
- notifications = all
13
- group_by.each do |method|
14
- notifications = recursive_grouping notifications, method
15
- end
16
- notifications
17
- end
18
-
19
- def grouping_by group_by
20
- all.group_by{ |notification| notification.send(group_by) }
21
- end
22
-
23
- def recursive_grouping notifications, group_by
24
- if notifications.is_a? Hash
25
- notifications.each_pair do |k, v|
26
- if v.is_a? Hash
27
- recursive_grouping v, group_by
28
- else
29
- k = v.grouping_by group_by
30
- end
31
- end
32
- else
33
- notifications.grouping_by group_by
34
- end
35
- notifications
36
- end
37
-
38
- end
39
-
40
- def type
41
- self[:type] || NotificationRenderer.configuration.default_type
42
- end
43
-
44
- end
45
- end
@@ -1,26 +0,0 @@
1
- require 'notification-handler'
2
- require 'active_support'
3
-
4
- module NotificationRenderer
5
- module NotificationScopes
6
-
7
- extend ActiveSupport::Concern
8
-
9
- module ClassMethods
10
-
11
- def method_missing m, *args
12
- if m.to_s[/(.+)_type/]
13
- where type: $1.singularize.classify
14
- else
15
- super
16
- end
17
- end
18
-
19
- def respond_to? m, include_private = false
20
- super || m.to_s[/(.+)_type/]
21
- end
22
-
23
- end
24
-
25
- end
26
- end