user_notif 0.1.13.2 → 0.1.13.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -5
- data/Rakefile +3 -3
- data/lib/generators/user_notif/install_templates/create_notifs.rb +1 -1
- data/lib/generators/user_notif/install_templates/initializer.rb +1 -1
- data/lib/generators/user_notif/install_templates/notifs_controller.rb +4 -5
- data/lib/generators/user_notif/user_notif_generator.rb +1 -1
- data/lib/user_notif.rb +1 -1
- data/lib/user_notif/notif.rb +6 -6
- data/lib/user_notif/notif_mailer.rb +4 -5
- data/lib/user_notif/railtie.rb +2 -2
- data/lib/user_notif/version.rb +1 -1
- data/user_notif.gemspec +6 -5
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81c2e5b0f6e8a686ac293c356e80f8799d380b3d
|
4
|
+
data.tar.gz: 3d323c7cdaccbc701279a01d2875f98294233563
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c82fd63175d78c7db9b9018bf64a258b5ad8e842ff4f7bb7838f848e645d4e7cf90b74ecd90b8cd560637338482f78d4303d18bbb0a06dd18801191beb0ff79c
|
7
|
+
data.tar.gz: 44a781b7932e5f9fa72312420cbd22d84f9750cc9525a34fc31345b9e8e0119aba21107fa30d6c2ca009d65c3ce6623d88db85afaebcfb3023d7083b409340c8
|
data/README.md
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
# UserNotif
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/user_notif.svg)](https://badge.fury.io/rb/user_notif)
|
4
|
-
[![Build Status](https://travis-ci.org/
|
5
|
-
[![Coverage Status](https://coveralls.io/repos/github/
|
6
|
-
[![Code Climate](https://codeclimate.com/github/
|
7
|
-
[![Dependency Status](https://gemnasium.com/badges/github.com/
|
8
|
-
[![security](https://hakiri.io/github/
|
4
|
+
[![Build Status](https://travis-ci.org/Insynia/user_notif.svg?branch=master)](https://travis-ci.org/Insynia/user_notif)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/github/Insynia/user_notif/badge.svg?branch=master)](https://coveralls.io/github/Insynia/user_notif?branch=master)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/Insynia/user_notif/badges/gpa.svg)](https://codeclimate.com/github/Insynia/user_notif)
|
7
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/Insynia/user_notif.svg)](https://gemnasium.com/github.com/Insynia/user_notif)
|
8
|
+
[![security](https://hakiri.io/github/Insynia/user_notif/master.svg)](https://hakiri.io/github/Insynia/user_notif/master)
|
9
|
+
|
10
|
+
## TODO
|
11
|
+
|
12
|
+
Add belongs_to custom model (add this in initializer and load it like this belongs_to UserNotif.model_name... in notif.rb)
|
9
13
|
|
10
14
|
## Installation
|
11
15
|
|
@@ -51,6 +55,8 @@ In your `app/assets/javascripts/application.js`
|
|
51
55
|
//
|
52
56
|
```
|
53
57
|
|
58
|
+
Do not forget to restart your server to load the new assets.
|
59
|
+
|
54
60
|
## Usage
|
55
61
|
|
56
62
|
Now you can create your first notification !
|
@@ -100,6 +106,12 @@ To display your notifications, you can use some helpers:
|
|
100
106
|
|
101
107
|
The `small` parameter will take care of rendering the partial located in `app/views/notifs/[small,full]`
|
102
108
|
|
109
|
+
You can also use the `notif_badge` helper to display a badge with the number of unread notifications.
|
110
|
+
|
111
|
+
```erb
|
112
|
+
<%= notif_badge(UserNotif.unread) %>
|
113
|
+
```
|
114
|
+
|
103
115
|
|
104
116
|
#### Cutomizing your views
|
105
117
|
|
data/Rakefile
CHANGED
@@ -5,10 +5,9 @@ module UserNotif
|
|
5
5
|
|
6
6
|
def read
|
7
7
|
set_notif
|
8
|
-
raise ActiveRecord::RecordNotFound
|
9
|
-
raise ActiveRecord::RecordNotFound.new('Not Found') unless @notif
|
8
|
+
raise ActiveRecord::RecordNotFound, 'Not Found' unless @notif
|
10
9
|
@notif.update!(unread: false)
|
11
|
-
|
10
|
+
head :ok
|
12
11
|
end
|
13
12
|
|
14
13
|
private
|
@@ -19,7 +18,7 @@ module UserNotif
|
|
19
18
|
|
20
19
|
def authorized?
|
21
20
|
# This method assumes you are using Devise. You can change it to use your custom logic.
|
22
|
-
raise ActiveRecord::RecordNotFound
|
21
|
+
raise ActiveRecord::RecordNotFound, 'Not Found' unless @notif.owner == current_user
|
23
22
|
end
|
24
23
|
end
|
25
|
-
end
|
24
|
+
end
|
data/lib/user_notif.rb
CHANGED
data/lib/user_notif/notif.rb
CHANGED
@@ -8,7 +8,7 @@ module UserNotif
|
|
8
8
|
scope :unread, -> { where(unread: true) }
|
9
9
|
|
10
10
|
before_save :validate_target_and_user
|
11
|
-
|
11
|
+
after_commit :notify_email, on: :create
|
12
12
|
|
13
13
|
def email?
|
14
14
|
true
|
@@ -26,7 +26,7 @@ module UserNotif
|
|
26
26
|
from: UserNotif.mailer_sender,
|
27
27
|
reply_to: UserNotif.mailer_reply_to,
|
28
28
|
cc: UserNotif.mailer_cc,
|
29
|
-
date: Time.current
|
29
|
+
date: Time.current
|
30
30
|
}.merge(opts)
|
31
31
|
end
|
32
32
|
|
@@ -37,13 +37,13 @@ module UserNotif
|
|
37
37
|
private
|
38
38
|
|
39
39
|
def validate_target_and_user
|
40
|
-
raise ModelExceptions::BadTypeNotification unless
|
41
|
-
raise ModelExceptions::NotifOwnerNil if
|
40
|
+
raise ModelExceptions::BadTypeNotification unless target.class == target_class
|
41
|
+
raise ModelExceptions::NotifOwnerNil if user.nil?
|
42
42
|
end
|
43
43
|
|
44
44
|
def notify_email
|
45
45
|
return unless email?
|
46
|
-
NotifMailer.notif_email(
|
46
|
+
NotifMailer.notif_email(id).deliver_later
|
47
47
|
end
|
48
48
|
end
|
49
|
-
end
|
49
|
+
end
|
@@ -7,11 +7,10 @@ module UserNotif
|
|
7
7
|
@target = notif.target
|
8
8
|
@user = notif.user
|
9
9
|
send_email({
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
)
|
10
|
+
to: @user.email,
|
11
|
+
template_path: 'notifs/mailer',
|
12
|
+
template_name: notif.template_name
|
13
|
+
}.merge(notif.email_options))
|
15
14
|
end
|
16
15
|
|
17
16
|
private
|
data/lib/user_notif/railtie.rb
CHANGED
@@ -3,7 +3,7 @@ require 'rails/railtie'
|
|
3
3
|
module UserNotif
|
4
4
|
class Railtie < Rails::Railtie
|
5
5
|
config.before_configuration do |app|
|
6
|
-
ActiveSupport::Dependencies.autoload_paths += %W
|
6
|
+
ActiveSupport::Dependencies.autoload_paths += %W[#{app.root}/app/models/notifs]
|
7
7
|
end
|
8
8
|
|
9
9
|
initializer 'user_notif.view_helpers' do
|
@@ -11,7 +11,7 @@ module UserNotif
|
|
11
11
|
end
|
12
12
|
|
13
13
|
initializer :assets do
|
14
|
-
Rails.application.config.assets.precompile += %w
|
14
|
+
Rails.application.config.assets.precompile += %w[user_notif.js.coffee user_notif.scss]
|
15
15
|
Rails.application.config.assets.paths << UserNotif.root + '/vendor/assets/javascripts'
|
16
16
|
Rails.application.config.assets.paths << UserNotif.root + '/vendor/assets/stylesheets'
|
17
17
|
end
|
data/lib/user_notif/version.rb
CHANGED
data/user_notif.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'user_notif/version'
|
@@ -9,8 +10,8 @@ Gem::Specification.new do |spec|
|
|
9
10
|
spec.authors = ['Terry Raimondo']
|
10
11
|
spec.email = ['terry.raimondo@gmail.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
13
|
+
spec.summary = 'Notification system for your users.'
|
14
|
+
spec.description = 'This gem adds notifications to your app, you can display the notifications where you want, add a dropdown on your header for example. Add views, mailer views and go !'
|
14
15
|
spec.homepage = 'https://github.com/terry90/user_notif'
|
15
16
|
spec.license = 'MIT'
|
16
17
|
|
@@ -20,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
20
21
|
spec.require_paths = ['lib']
|
21
22
|
|
22
23
|
spec.add_development_dependency 'bundler', '~> 1.11'
|
23
|
-
spec.add_development_dependency 'rake', '
|
24
|
+
spec.add_development_dependency 'rake', '>= 10.0'
|
24
25
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
25
26
|
spec.add_development_dependency 'rspec-rails', '~> 3.0'
|
26
27
|
spec.add_development_dependency 'combustion', '~> 0.5.4'
|
@@ -29,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
29
30
|
spec.add_runtime_dependency 'activerecord', '>= 4.0'
|
30
31
|
spec.add_runtime_dependency 'actionmailer', '>= 4.0'
|
31
32
|
spec.add_runtime_dependency 'railties', '>= 4.0'
|
32
|
-
spec.add_runtime_dependency 'sass-rails', '
|
33
|
-
spec.add_runtime_dependency 'coffee-rails', '
|
33
|
+
spec.add_runtime_dependency 'sass-rails', '>= 5.0'
|
34
|
+
spec.add_runtime_dependency 'coffee-rails', '>= 4.1.0'
|
34
35
|
spec.add_runtime_dependency 'jquery-rails', '>= 4.0.4'
|
35
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: user_notif
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.13.
|
4
|
+
version: 0.1.13.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Terry Raimondo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -140,28 +140,28 @@ dependencies:
|
|
140
140
|
name: sass-rails
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - "
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '5.0'
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - "
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '5.0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: coffee-rails
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: 4.1.0
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - "
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: 4.1.0
|
167
167
|
- !ruby/object:Gem::Dependency
|
@@ -238,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
238
|
version: '0'
|
239
239
|
requirements: []
|
240
240
|
rubyforge_project:
|
241
|
-
rubygems_version: 2.
|
241
|
+
rubygems_version: 2.6.11
|
242
242
|
signing_key:
|
243
243
|
specification_version: 4
|
244
244
|
summary: Notification system for your users.
|