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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d89e77a8e5e36c93ab7a5eea1f84ac336f023ba
4
- data.tar.gz: b531d67c47e7878841487a5c1224a643f3a77d57
3
+ metadata.gz: 81c2e5b0f6e8a686ac293c356e80f8799d380b3d
4
+ data.tar.gz: 3d323c7cdaccbc701279a01d2875f98294233563
5
5
  SHA512:
6
- metadata.gz: 875e68b2695a243be178f77258b06d6ffbe991402ea941dfccf6ee4a24ed9d929c7766bec2614dc80dcd491e42fd48e3a280d0e817ac592f426a037a15a3bf0c
7
- data.tar.gz: 501521adc8b467ac8a5654e28e1e12914952f9842b99899114982c6c86638b85de6b743279a1286262d3bf3752dfa2e152a9012720b912c7be50b64a41cbd15e
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/terry90/user_notif.svg?branch=master)](https://travis-ci.org/terry90/user_notif)
5
- [![Coverage Status](https://coveralls.io/repos/github/terry90/user_notif/badge.svg?branch=master)](https://coveralls.io/github/terry90/user_notif?branch=master)
6
- [![Code Climate](https://codeclimate.com/github/terry90/user_notif/badges/gpa.svg)](https://codeclimate.com/github/terry90/user_notif)
7
- [![Dependency Status](https://gemnasium.com/badges/github.com/terry90/user_notif.svg)](https://gemnasium.com/github.com/terry90/user_notif)
8
- [![security](https://hakiri.io/github/terry90/user_notif/master.svg)](https://hakiri.io/github/terry90/user_notif/master)
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
@@ -1,7 +1,7 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task default: :spec
7
- task test: :spec
7
+ task test: :spec
@@ -10,4 +10,4 @@ class CreateNotifs < ActiveRecord::Migration
10
10
  t.timestamps
11
11
  end
12
12
  end
13
- end
13
+ end
@@ -5,4 +5,4 @@ UserNotif.setup do |config|
5
5
  # config.mailer_return_path = 'contact@myapp.com'
6
6
  # config.mailer_reply_to = 'contact@myapp.com'
7
7
  # config.mailer_cc = 'contact2@myapp.com'
8
- end
8
+ end
@@ -5,10 +5,9 @@ module UserNotif
5
5
 
6
6
  def read
7
7
  set_notif
8
- raise ActiveRecord::RecordNotFound.new('Not Found') unless @notif
9
- raise ActiveRecord::RecordNotFound.new('Not Found') unless @notif
8
+ raise ActiveRecord::RecordNotFound, 'Not Found' unless @notif
10
9
  @notif.update!(unread: false)
11
- render nothing: true
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.new('Not Found') unless @notif.owner == current_user
21
+ raise ActiveRecord::RecordNotFound, 'Not Found' unless @notif.owner == current_user
23
22
  end
24
23
  end
25
- end
24
+ end
@@ -14,4 +14,4 @@ class UserNotifGenerator < Rails::Generators::NamedBase
14
14
  copy_file 'small_notif_view.html.erb', "app/views/notifs/small/_#{file_name}_notif.html.erb"
15
15
  copy_file 'full_notif_view.html.erb', "app/views/notifs/full/_#{file_name}_notif.html.erb"
16
16
  end
17
- end
17
+ end
data/lib/user_notif.rb CHANGED
@@ -21,4 +21,4 @@ module UserNotif
21
21
  @@app_name = 'My App'
22
22
 
23
23
  mattr_accessor :mailer_bcc, :mailer_return_path, :mailer_from, :mailer_reply_to, :mailer_cc, :mailer_date
24
- end
24
+ end
@@ -8,7 +8,7 @@ module UserNotif
8
8
  scope :unread, -> { where(unread: true) }
9
9
 
10
10
  before_save :validate_target_and_user
11
- after_create :notify_email
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 self.target.class == target_class
41
- raise ModelExceptions::NotifOwnerNil if self.user == nil
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(self.id).deliver_later
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
- to: @user.email,
11
- template_path: 'notifs/mailer',
12
- template_name: notif.template_name
13
- }.merge(notif.email_options)
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
@@ -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(#{app.root}/app/models/notifs)
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{ user_notif.js.coffee user_notif.scss }
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
@@ -1,3 +1,3 @@
1
1
  module UserNotif
2
- VERSION = '0.1.13.2'
2
+ VERSION = '0.1.13.3'.freeze
3
3
  end
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 = %q{Notification system for your users.}
13
- spec.description = %q{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 !}
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', '~> 10.0'
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', '~> 5.0'
33
- spec.add_runtime_dependency 'coffee-rails', '~> 4.1.0'
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.2
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: 2016-06-15 00:00:00.000000000 Z
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.5.1
241
+ rubygems_version: 2.6.11
242
242
  signing_key:
243
243
  specification_version: 4
244
244
  summary: Notification system for your users.