notifications 0.6.0 → 0.6.1

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
  SHA256:
3
- metadata.gz: cba82d59d143b6411bffc9075d57c62da33109df3bb44258b6748c4c25fe85b4
4
- data.tar.gz: 923fada5c2102c30d43f637ccd450401d6b51eae40be6a1a09ced2e70c2738d9
3
+ metadata.gz: 5c4cb0d88943eedf45ead745235a72a06b5ec3762fd1d1d30b1c7b0ea12f2ad8
4
+ data.tar.gz: 970edb7122c6a3b8a1c6d057b10c5092f1ae7a5cb0b059590567205230717768
5
5
  SHA512:
6
- metadata.gz: 916a13099e241528a0094eb57f674854edcc6dd25b140c4c1aebadbfa5dd31fd1a5a53b977018edad204b1376151c03aba6b66866fcdf9ef92235ed34a632de3
7
- data.tar.gz: e727c786778533d599303e61ad23583d8e7c2ea9255465b48ea54d664a81a9d4997eac77542c9cb1d7b9cb9d3b4239e0bbb6f7fb4a9e026cf2185a75115a0987
6
+ metadata.gz: c5988152884954fc797937c1236eba2c44b34878f722e25617232f9d61d37be3a1c1781a4624de77da8ff3c0cc371a0f07336931fb7ac2de682ff5e6d775d7da
7
+ data.tar.gz: c0cbe1c39d35c83a38c721a6bd96cf77aa93a1c4b97f5d75c43418aa91b85f242b527d604e1198b5a62349a6a4a341bc5f25dae3b1ffb21ce0aac2636f13d601
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Mountable notifications for any Rails applications.
4
4
 
5
- [![Gem Version](https://badge.fury.io/rb/notifications.svg)](https://badge.fury.io/rb/notifications) [![Build Status](https://travis-ci.org/rails-engine/notifications.svg)](https://travis-ci.org/rails-engine/notifications) [![Code Climate](https://codeclimate.com/github/rails-engine/notifications/badges/gpa.svg)](https://codeclimate.com/github/rails-engine/notifications) [![codecov.io](https://codecov.io/github/rails-engine/notifications/coverage.svg?branch=master)](https://codecov.io/github/rails-engine/notifications?branch=master) [![](http://inch-ci.org/github/rails-engine/notifications.svg?branch=master)](http://inch-ci.org/github/rails-engine/notifications?branch=master)
5
+ [![Gem Version](https://badge.fury.io/rb/notifications.svg)](https://badge.fury.io/rb/notifications) [![Build Status](https://travis-ci.org/rails-engine/notifications.svg)](https://travis-ci.org/rails-engine/notifications) [![codecov.io](https://codecov.io/github/rails-engine/notifications/coverage.svg?branch=master)](https://codecov.io/github/rails-engine/notifications?branch=master)
6
6
 
7
7
  ## Example:
8
8
 
@@ -45,7 +45,7 @@ end
45
45
 
46
46
  class Comment
47
47
  belongs_to :post
48
- belongs_user :user
48
+  belongs_to :user
49
49
 
50
50
  after_commit :create_notifications, on: [:create]
51
51
  def create_notifications
@@ -74,7 +74,7 @@ Notification.create(notify_type: 'follow' ....)
74
74
  Notification.create(notify_type: 'mention', target: @reply, second_target: @topic, ....)
75
75
  ```
76
76
 
77
- You app must have:
77
+ Your app must have:
78
78
 
79
79
  - app/views/notifications/_follow.html.erb
80
80
  - app/views/notifications/_mention.html.erb
@@ -82,21 +82,23 @@ You app must have:
82
82
  ```erb
83
83
  # app/views/notifications/_follow.html.erb
84
84
  <div class="media-heading">
85
- <%= link_to notification.actor.title, notification.actor %> just followed you.
85
+ <%= link_to notification.actor.title, main_app.user_path(notification.actor) %> just followed you.
86
86
  </div>
87
87
  ```
88
88
 
89
89
  ```erb
90
90
  # app/views/notifications/_mention.html.erb
91
91
  <div class="media-heading">
92
- <%= link_to notification.actor.title, notification.actor %> has mentioned you in
93
- <%= link_to notification.second_target.title, topic_path(notification.second_target) %>
92
+ <%= link_to notification.actor.title, main_app.user_path(notification.actor) %> has mentioned you in
93
+ <%= link_to notification.second_target.title, main_app.topic_path(notification.second_target) %>
94
94
  </div>
95
95
  <div class="media-content">
96
96
  <%= notification.target.body %>
97
97
  </div>
98
98
  ```
99
99
 
100
+ > NOTE: When you want use Rails route path name in notification views, you must use [main_app](http://api.rubyonrails.org/classes/Rails/Engine.html#class-Rails::Engine-label-Using+Engine-27s+routes+outside+Engine) prefix. etc: `main_app.user_path(user)`
101
+
100
102
  ### About Notification template N+1 performance
101
103
 
102
104
  It is recommended that you use [second_level_cache](https://github.com/hooopo/second_level_cache) for solving N+1 performance issues.
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ rescue LoadError
4
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
5
  end
6
6
 
7
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
7
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
8
8
 
9
9
  load 'rails/tasks/engine.rake'
10
10
  load 'rails/tasks/statistics.rake'
@@ -17,7 +17,7 @@ module Notifications
17
17
  private
18
18
 
19
19
  def notifications
20
- raise "You need reqiure user login for /notifications page." unless current_user
20
+ raise 'You need reqiure user login for /notifications page.' unless current_user
21
21
  Notification.where(user_id: current_user.id)
22
22
  end
23
23
  end
@@ -15,7 +15,7 @@ class CreateNotifications < ActiveRecord::Migration[5.0]
15
15
  t.timestamps null: false
16
16
  end
17
17
 
18
- add_index :notifications, [:user_id, :notify_type]
18
+ add_index :notifications, %i[user_id notify_type]
19
19
  add_index :notifications, [:user_id]
20
20
  end
21
21
  end
@@ -2,11 +2,11 @@ require 'rails/generators'
2
2
  module Notifications
3
3
  module Generators
4
4
  class ControllersGenerator < Rails::Generators::Base #:nodoc:
5
- source_root File.expand_path('../../../../app/controllers', __FILE__)
5
+ source_root File.expand_path('../../../app/controllers', __dir__)
6
6
  desc "Used to copy Notifications's controllers to your application's controllers."
7
7
 
8
8
  def copy_controllers
9
- %w(notifications).each do |fname|
9
+ %w[notifications].each do |fname|
10
10
  path = "#{Rails.root}/app/controllers/notifications/#{fname}_controller.rb"
11
11
  if File.exist?(path)
12
12
  puts "Skipping notifications/#{fname}_controller.rb creation, as file already exists!"
@@ -3,10 +3,10 @@ module Notifications
3
3
  module Generators
4
4
  class I18nGenerator < Rails::Generators::Base
5
5
  desc "Create Notifications's default I18n files"
6
- source_root File.expand_path('../../../../', __FILE__)
6
+ source_root File.expand_path('../../..', __dir__)
7
7
 
8
8
  def add_locales
9
- %w(en.yml zh-CN.yml).each do |fname|
9
+ %w[en.yml zh-CN.yml].each do |fname|
10
10
  path = "#{Rails.root}/config/locales/notifications.#{fname}"
11
11
  if File.exist?(path)
12
12
  puts "Skipping config/locales/notifications.#{fname} creation, as file already exists!"
@@ -3,7 +3,7 @@ module Notifications
3
3
  module Generators
4
4
  class InstallGenerator < Rails::Generators::Base
5
5
  desc "Create Notifications's base files"
6
- source_root File.expand_path('../../../../', __FILE__)
6
+ source_root File.expand_path('../../..', __dir__)
7
7
 
8
8
  def add_initializer
9
9
  path = "#{Rails.root}/config/initializers/notifications.rb"
@@ -2,7 +2,7 @@ require 'rails/generators'
2
2
  module Notifications
3
3
  module Generators
4
4
  class ViewsGenerator < Rails::Generators::Base #:nodoc:
5
- source_root File.expand_path('../../../../', __FILE__)
5
+ source_root File.expand_path('../../..', __dir__)
6
6
  desc "Used to copy Notifications's views to your application's views."
7
7
 
8
8
  def copy_views
@@ -1,3 +1,3 @@
1
1
  module Notifications
2
- VERSION = '0.6.0'
2
+ VERSION = '0.6.1'
3
3
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifications
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-06 00:00:00.000000000 Z
11
+ date: 2019-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: kaminari
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
19
+ version: '0.15'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5'
26
+ version: '0.15'
27
27
  - !ruby/object:Gem::Dependency
28
- name: kaminari
28
+ name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0.15'
33
+ version: '5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0.15'
40
+ version: '5'
41
41
  description: Rails mountable Notification for any applications.
42
42
  email:
43
43
  - huacnlee@gmail.com
@@ -88,8 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
- rubyforge_project:
92
- rubygems_version: 2.7.6
91
+ rubygems_version: 3.0.1
93
92
  signing_key:
94
93
  specification_version: 4
95
94
  summary: Rails mountable Notification for any applications.