acts_as_notificable 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b9c1882e2649acb16e430ca3c94050f49a8dc95f
4
+ data.tar.gz: 06867250eb5d051193091af855631292bb6130ab
5
+ SHA512:
6
+ metadata.gz: 7ed58ba47a78a68945fc85540ef6b215f738ba753aeec84e0ba62065c690d18a8dc867806d1089f39115a83ba410b61ec27867d59223c70cb3e11ff4241da5de
7
+ data.tar.gz: af16b9381ddd13487df74630d2d3774ae9ca8499b9bf62de532b847cfd77b1d6ce8efa9e8f4e060f7d8878d8847d7440339e4e27b4ec88a5fda33cb7cd0d399d
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'ActsAsNotificable'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
@@ -0,0 +1,11 @@
1
+ module ActsAsNotificable
2
+ extend ActiveSupport::Concern
3
+
4
+ module ClassMethods
5
+ def acts_as_notificable
6
+ has_many :notifications, inverse_of: :owner, dependent: :destroy
7
+ end
8
+ end
9
+ end
10
+
11
+ ActiveRecord::Base.send :include, ActsAsNotificable
@@ -0,0 +1,3 @@
1
+ module ActsAsNotificable
2
+ VERSION = "0.0.7"
3
+ end
@@ -0,0 +1 @@
1
+ Type something
@@ -0,0 +1,18 @@
1
+ require "rails/generators/active_record/migration"
2
+
3
+ module ActsAsNotificable
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ include ActiveRecord::Generators::Migration
7
+ source_root File.expand_path("../templates", __FILE__)
8
+
9
+ def copy_notification_model
10
+ copy_file "notification.rb", "app/models/notification.rb"
11
+ end
12
+
13
+ def copy_notification_migration
14
+ migration_template "migration.rb", "db/migrate/create_notifications_table.rb"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ class CreateNotificationsTable < ActiveRecord::Migration
2
+ def change
3
+ create_table :notifications do |t|
4
+ t.text :locals
5
+ t.string :template_name
6
+ t.references :owner, index: true
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,26 @@
1
+ class Notification < ActiveRecord::Base
2
+ belongs_to :owner, polymorphic: true
3
+
4
+ validates :template_name, presence: true
5
+
6
+ serialize :locals, Hash
7
+
8
+ def render(options = {})
9
+ locals.merge!(notification: self)
10
+ render_options = { file: "notifications/#{template_name}", locals: locals }
11
+ render_options[:layout] = "layouts/" + options[:layout] if options.has_key?(:layout)
12
+ view.render(render_options)
13
+ end
14
+
15
+ def self.create_notification(template_name, locals = {})
16
+ Notification.create(template_name: template_name, locals: locals)
17
+ end
18
+
19
+ private
20
+ def view
21
+ view_paths = ActionController::Base.view_paths
22
+ @_view ||= Class.new(ActionView::Base) do
23
+ include Rails.application.routes.url_helpers
24
+ end.new(view_paths, {})
25
+ end
26
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :acts_as_notificable do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: acts_as_notificable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ platform: ruby
6
+ authors:
7
+ - Marcio Junior
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.1.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.1.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.1.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: ammeter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.1.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.1.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: shoulda-matchers
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.7.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.7.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: database_cleaner
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
+ description: Add notifications for ActiveRecord objects
112
+ email:
113
+ - marciojunior1991@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - MIT-LICENSE
119
+ - Rakefile
120
+ - lib/acts_as_notificable.rb
121
+ - lib/acts_as_notificable/version.rb
122
+ - lib/generators/acts_as_notificable/USAGE
123
+ - lib/generators/acts_as_notificable/install_generator.rb
124
+ - lib/generators/acts_as_notificable/templates/migration.rb
125
+ - lib/generators/acts_as_notificable/templates/notification.rb
126
+ - lib/tasks/acts_as_notificable_tasks.rake
127
+ homepage: https://github.com/marcioj/acts_as_notificable
128
+ licenses:
129
+ - MIT
130
+ metadata: {}
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 2.4.3
148
+ signing_key:
149
+ specification_version: 4
150
+ summary: Add notifications for ActiveRecord objects
151
+ test_files: []