hey_listen 0.0.4 → 0.0.5
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 +4 -4
- data/app/assets/images/hey_listen/alert.png +0 -0
- data/app/models/hey_listen/notification.rb +3 -1
- data/lib/generators/hey_listen/install_generator.rb +9 -0
- data/lib/generators/templates/example_notification.rb +24 -0
- data/lib/generators/templates/initializer.rb +1 -0
- data/lib/generators/templates/notifications.rb +4 -0
- data/lib/hey_listen/acts_as_notification_receiver.rb +21 -0
- data/lib/hey_listen/notifications/base.rb +48 -0
- data/lib/hey_listen/version.rb +1 -1
- data/lib/hey_listen.rb +2 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59f431f5b684c1862fab29b3bb4320876712b5c6
|
4
|
+
data.tar.gz: 81d38c266e6e2b274a71e9f16b458ce673181f2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c56c52cbec5caad02aaf130c1d2ec75dc9aaa1095e4c1ce3c3265b6653a46146ccbb2ddafd96e7cb97fbbf1eb7cb25651f0c4b52daebe657d5b57081ceb807db
|
7
|
+
data.tar.gz: 80f99daea7134a05f9ff0d1b768a231863deb036438e011059ded57202451e6bdfbf678773c12083d35587f75d83ab4e7e6c2c60e80bc72eeab13c446d42dcd1
|
Binary file
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module HeyListen
|
2
2
|
class Notification < ActiveRecord::Base
|
3
|
+
self.table_name = 'notifications'
|
4
|
+
|
3
5
|
belongs_to :user
|
4
6
|
belongs_to :notifiable, polymorphic: true
|
5
7
|
|
@@ -8,7 +10,7 @@ module HeyListen
|
|
8
10
|
def notification
|
9
11
|
"Notifications::#{label}".constantize.new(notifiable, user)
|
10
12
|
end
|
11
|
-
delegate :accepted?, :requires_action?, :image, :text, :content, to: :notification
|
13
|
+
delegate :accepted?, :requires_action?, :image, :text, :content, :accepted, :requires_action?, :actions, to: :notification
|
12
14
|
|
13
15
|
def date
|
14
16
|
-> (d) {
|
@@ -5,10 +5,19 @@ module HeyListen
|
|
5
5
|
|
6
6
|
desc 'Creates a Hey! Listen! migration for the Notifications table.'
|
7
7
|
|
8
|
+
def copy_initializer
|
9
|
+
template 'initializer.rb', 'config/initializers/hey_listen.rb'
|
10
|
+
end
|
11
|
+
|
8
12
|
def copy_migration
|
9
13
|
migration_template 'create_notifications.rb', 'db/migrate/create_notifications.rb'
|
10
14
|
end
|
11
15
|
|
16
|
+
def copy_notifications_module
|
17
|
+
template 'notifications.rb', 'lib/notifications.rb'
|
18
|
+
template 'example_notification.rb', 'lib/notifications/example.rb'
|
19
|
+
end
|
20
|
+
|
12
21
|
def self.next_migration_number(path)
|
13
22
|
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
14
23
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Notifications
|
2
|
+
class Example < HeyListen::Notifications::Base
|
3
|
+
include Rails.application.routes.url_helpers
|
4
|
+
|
5
|
+
def path
|
6
|
+
polymorphic_path(@notifiable)
|
7
|
+
end
|
8
|
+
|
9
|
+
def image_src
|
10
|
+
asset_path('hey_listen/alert.png')
|
11
|
+
end
|
12
|
+
|
13
|
+
def content
|
14
|
+
[{
|
15
|
+
type: 'text',
|
16
|
+
text: 'Someone just went and did'
|
17
|
+
}, {
|
18
|
+
type: 'link',
|
19
|
+
text: 'something',
|
20
|
+
path: path
|
21
|
+
}]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'notifications'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module HeyListen
|
2
|
+
module ActsAsNotificationReceiver
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def acts_as_notification_receiver
|
7
|
+
has_many :notifications, class_name: 'HeyListen::Notification', dependent: :destroy
|
8
|
+
|
9
|
+
include HeyListen::ActsAsNotificationReceiver::InstanceMethods
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module InstanceMethods
|
14
|
+
def notify(label, notifiable)
|
15
|
+
notifications.create(label: label, notifiable: notifiable)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
ActiveRecord::Base.send :include, HeyListen::ActsAsNotificationReceiver
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module HeyListen
|
2
|
+
module Notifications
|
3
|
+
class Base
|
4
|
+
include ActionView::Helpers::AssetUrlHelper
|
5
|
+
include ActionDispatch::Routing::PolymorphicRoutes
|
6
|
+
|
7
|
+
def initialize(user, notifiable)
|
8
|
+
@user = user
|
9
|
+
@notifiable = notifiable
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
polymorphic_path(@notifiable)
|
14
|
+
end
|
15
|
+
|
16
|
+
def image_src
|
17
|
+
asset_path('hey_listen/alert.png')
|
18
|
+
end
|
19
|
+
|
20
|
+
def image
|
21
|
+
{
|
22
|
+
src: image_src,
|
23
|
+
path: path
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def content
|
28
|
+
[]
|
29
|
+
end
|
30
|
+
|
31
|
+
def text
|
32
|
+
content.map { |e| e[:text] }.join(' ') + '.'
|
33
|
+
end
|
34
|
+
|
35
|
+
def requires_action?
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
39
|
+
def accepted?
|
40
|
+
false
|
41
|
+
end
|
42
|
+
|
43
|
+
def actions
|
44
|
+
{}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/hey_listen/version.rb
CHANGED
data/lib/hey_listen.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hey_listen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Escobedo
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.
|
19
|
+
version: 4.0.0
|
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: 4.
|
26
|
+
version: 4.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sqlite3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- MIT-LICENSE
|
49
49
|
- README.rdoc
|
50
50
|
- Rakefile
|
51
|
+
- app/assets/images/hey_listen/alert.png
|
51
52
|
- app/assets/javascripts/hey_listen/application.js
|
52
53
|
- app/assets/stylesheets/hey_listen/application.css
|
53
54
|
- app/controllers/hey_listen/application_controller.rb
|
@@ -57,8 +58,13 @@ files:
|
|
57
58
|
- config/routes.rb
|
58
59
|
- lib/generators/hey_listen/install_generator.rb
|
59
60
|
- lib/generators/templates/create_notifications.rb
|
61
|
+
- lib/generators/templates/example_notification.rb
|
62
|
+
- lib/generators/templates/initializer.rb
|
63
|
+
- lib/generators/templates/notifications.rb
|
60
64
|
- lib/hey_listen.rb
|
65
|
+
- lib/hey_listen/acts_as_notification_receiver.rb
|
61
66
|
- lib/hey_listen/engine.rb
|
67
|
+
- lib/hey_listen/notifications/base.rb
|
62
68
|
- lib/hey_listen/version.rb
|
63
69
|
- lib/tasks/hey_listen_tasks.rake
|
64
70
|
homepage: http://github.com/codigojade/hey_listen
|