digest_notifier 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -10,5 +10,4 @@ group :development do
10
10
  gem "rdoc", "~> 3.12"
11
11
  gem "bundler", ">= 1.0.0"
12
12
  gem "jeweler", "~> 1.8.4"
13
- gem "rcov", ">= 0"
14
13
  end
@@ -14,7 +14,6 @@ GEM
14
14
  json (1.7.5)
15
15
  multi_json (1.3.7)
16
16
  rake (10.0.2)
17
- rcov (1.0.0)
18
17
  rdoc (3.12)
19
18
  json (~> 1.4)
20
19
  shoulda (3.3.2)
@@ -35,7 +34,6 @@ PLATFORMS
35
34
  DEPENDENCIES
36
35
  bundler (>= 1.0.0)
37
36
  jeweler (~> 1.8.4)
38
- rcov
39
37
  rdoc (~> 3.12)
40
38
  shoulda
41
39
  slim (>= 1.0.4)
data/Rakefile CHANGED
@@ -32,14 +32,6 @@ Rake::TestTask.new(:test) do |test|
32
32
  test.verbose = true
33
33
  end
34
34
 
35
- require 'rcov/rcovtask'
36
- Rcov::RcovTask.new do |test|
37
- test.libs << 'test'
38
- test.pattern = 'test/**/test_*.rb'
39
- test.verbose = true
40
- test.rcov_opts << '--exclude "gems/*"'
41
- end
42
-
43
35
  task :default => :test
44
36
 
45
37
  require 'rdoc/task'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "digest_notifier"
8
- s.version = "0.0.7"
8
+ s.version = "0.0.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Naveed Ahmad"]
12
- s.date = "2013-02-12"
12
+ s.date = "2013-04-18"
13
13
  s.description = "pending"
14
14
  s.email = "naveedahmada036@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -37,8 +37,10 @@ Gem::Specification.new do |s|
37
37
  "lib/digest_notifier/performable_digest.rb",
38
38
  "lib/digest_notifier/railtie.rb",
39
39
  "lib/digest_notifier/tasks.rb",
40
+ "lib/generators/digest_notifier/add_digest_resource_generator.rb",
40
41
  "lib/generators/digest_notifier/install_generator.rb",
41
42
  "lib/generators/digest_notifier/templates/README",
43
+ "lib/generators/digest_notifier/templates/add_digest_resource_in_digest_email_items.rb",
42
44
  "lib/generators/digest_notifier/templates/create_digest_email_deliveries.rb",
43
45
  "lib/generators/digest_notifier/templates/create_digest_email_groups.rb",
44
46
  "lib/generators/digest_notifier/templates/create_digest_email_items.rb",
@@ -59,14 +61,12 @@ Gem::Specification.new do |s|
59
61
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
60
62
  s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
61
63
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
62
- s.add_development_dependency(%q<rcov>, [">= 0"])
63
64
  else
64
65
  s.add_dependency(%q<slim>, [">= 1.0.4"])
65
66
  s.add_dependency(%q<shoulda>, [">= 0"])
66
67
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
67
68
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
68
69
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
69
- s.add_dependency(%q<rcov>, [">= 0"])
70
70
  end
71
71
  else
72
72
  s.add_dependency(%q<slim>, [">= 1.0.4"])
@@ -74,7 +74,6 @@ Gem::Specification.new do |s|
74
74
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
75
75
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
76
76
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
77
- s.add_dependency(%q<rcov>, [">= 0"])
78
77
  end
79
78
  end
80
79
 
@@ -20,7 +20,7 @@ class DigestEmailGroup < ActiveRecord::Base
20
20
  end
21
21
 
22
22
  def create_digest_items(performable)
23
- digest_item = digest_email_items.build :payload => performable.payload
23
+ digest_item = digest_email_items.build :payload => performable.payload, :digest_resource => performable.digest_resource
24
24
  digest_recipients.each do |recipient|
25
25
  digest_item.digest_email_deliveries.build :receiver_email => recipient.gsub(' ', '')
26
26
  end
@@ -47,6 +47,6 @@ class DigestEmailGroup < ActiveRecord::Base
47
47
 
48
48
  protected
49
49
  def default_recipients
50
- recipients || I18n::t("digest_notifier.digest_mailer.recipient")
50
+ I18n::t("digest_notifier.digest_mailer.recipient")
51
51
  end
52
52
  end
@@ -2,6 +2,7 @@ class DigestEmailItem < ActiveRecord::Base
2
2
  serialize :payload, Array
3
3
 
4
4
  belongs_to :digest_email_group
5
+ belongs_to :digest_resource, :polymorphic => true
5
6
  has_many :digest_email_deliveries, :dependent => :destroy
6
7
 
7
8
  class << self
@@ -1,16 +1,17 @@
1
1
  module DigestNotifier
2
2
  class PerformableDigest
3
- attr_accessor :mailer, :method_name, :args, :options, :digest_group
3
+ attr_accessor :mailer, :method_name, :args, :options, :digest_group, :digest_resource
4
4
 
5
5
  delegate :method, :to => :object
6
6
 
7
7
  def initialize(mailer, method_name, method_args, options)
8
8
  #raise NoMethodError, "undefined method `#{method_name}' for #{mailer.inspect}" unless mailer.respond_to?(method_name, true)
9
9
 
10
- self.mailer = mailer.to_s
11
- self.args = method_args
12
- self.method_name = method_name.to_sym
13
- self.options = options
10
+ self.digest_resource = method_args.shift
11
+ self.mailer = mailer.to_s
12
+ self.args = method_args
13
+ self.method_name = method_name.to_sym
14
+ self.options = options
14
15
  end
15
16
 
16
17
  def payload
@@ -2,6 +2,11 @@ require 'digest_notifier'
2
2
  require 'app/mailer/digest_mailer'
3
3
 
4
4
  namespace :digest_notifier do
5
+ desc "Cleanup digest items"
6
+ task :clear => :environment do
7
+ [DigestEmailDelivery, DigestEmailGroup, DigestEmailItem].map(&:delete_all)
8
+ end
9
+
5
10
  desc "Send notification in one big digest email"
6
11
  task :send_notification_digest => :environment do
7
12
  receivers = DigestEmailDelivery.where(:sent_at => nil).group(:receiver_email).map &:receiver_email
@@ -0,0 +1,28 @@
1
+ module DigestNotifier
2
+ module Generators
3
+ class AddDigestResourceGenerator < Rails::Generators::Base
4
+ include Rails::Generators::Migration
5
+
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ desc "Add digest_resource( polymorphic column) in digest_email_item table"
9
+
10
+ def self.next_migration_number(dirname)
11
+ if ActiveRecord::Base.timestamped_migrations
12
+ unless @prev_migration_nr
13
+ @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
14
+ else
15
+ @prev_migration_nr += 1
16
+ end
17
+ @prev_migration_nr.to_s
18
+ else
19
+ (current_migration_number(dirname) + 1)
20
+ end
21
+ end
22
+
23
+ def copy_migration
24
+ migration_template "add_digest_resource_in_digest_email_items.rb", File.join("db", "migrate", "add_digest_resource_in_digest_email_items.rb")
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,11 @@
1
+ class AddDigestResourceInDigestEmailItems < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :digest_email_items, :digest_resource_type, :string
4
+ add_column :digest_email_items, :digest_resource_id, :integer
5
+ end
6
+
7
+ def self.down
8
+ remove_column :digest_email_items, :digest_resource_type
9
+ remove_column :digest_email_items, :digest_resource_id
10
+ end
11
+ end
metadata CHANGED
@@ -1,124 +1,105 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: digest_notifier
3
- version: !ruby/object:Gem::Version
4
- hash: 17
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 7
10
- version: 0.0.7
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Naveed Ahmad
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-02-12 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- prerelease: false
12
+ date: 2013-04-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: slim
23
- version_requirements: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 31
29
- segments:
30
- - 1
31
- - 0
32
- - 4
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 1.0.4
34
22
  type: :runtime
35
- requirement: *id001
36
- - !ruby/object:Gem::Dependency
37
23
  prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.4
30
+ - !ruby/object:Gem::Dependency
38
31
  name: shoulda
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
40
33
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
48
38
  type: :development
49
- requirement: *id002
50
- - !ruby/object:Gem::Dependency
51
39
  prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
52
47
  name: rdoc
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
54
49
  none: false
55
- requirements:
50
+ requirements:
56
51
  - - ~>
57
- - !ruby/object:Gem::Version
58
- hash: 31
59
- segments:
60
- - 3
61
- - 12
62
- version: "3.12"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.12'
63
54
  type: :development
64
- requirement: *id003
65
- - !ruby/object:Gem::Dependency
66
55
  prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.12'
62
+ - !ruby/object:Gem::Dependency
67
63
  name: bundler
68
- version_requirements: &id004 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
69
65
  none: false
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- hash: 23
74
- segments:
75
- - 1
76
- - 0
77
- - 0
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
78
69
  version: 1.0.0
79
70
  type: :development
80
- requirement: *id004
81
- - !ruby/object:Gem::Dependency
82
71
  prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.0.0
78
+ - !ruby/object:Gem::Dependency
83
79
  name: jeweler
84
- version_requirements: &id005 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
85
81
  none: false
86
- requirements:
82
+ requirements:
87
83
  - - ~>
88
- - !ruby/object:Gem::Version
89
- hash: 63
90
- segments:
91
- - 1
92
- - 8
93
- - 4
84
+ - !ruby/object:Gem::Version
94
85
  version: 1.8.4
95
86
  type: :development
96
- requirement: *id005
97
- - !ruby/object:Gem::Dependency
98
87
  prerelease: false
99
- name: rcov
100
- version_requirements: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
101
89
  none: false
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- hash: 3
106
- segments:
107
- - 0
108
- version: "0"
109
- type: :development
110
- requirement: *id006
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.8.4
111
94
  description: pending
112
95
  email: naveedahmada036@gmail.com
113
96
  executables: []
114
-
115
97
  extensions: []
116
-
117
- extra_rdoc_files:
98
+ extra_rdoc_files:
118
99
  - LICENSE.txt
119
100
  - README.md
120
101
  - README.rdoc
121
- files:
102
+ files:
122
103
  - .document
123
104
  - Gemfile
124
105
  - Gemfile.lock
@@ -138,44 +119,40 @@ files:
138
119
  - lib/digest_notifier/performable_digest.rb
139
120
  - lib/digest_notifier/railtie.rb
140
121
  - lib/digest_notifier/tasks.rb
122
+ - lib/generators/digest_notifier/add_digest_resource_generator.rb
141
123
  - lib/generators/digest_notifier/install_generator.rb
142
124
  - lib/generators/digest_notifier/templates/README
125
+ - lib/generators/digest_notifier/templates/add_digest_resource_in_digest_email_items.rb
143
126
  - lib/generators/digest_notifier/templates/create_digest_email_deliveries.rb
144
127
  - lib/generators/digest_notifier/templates/create_digest_email_groups.rb
145
128
  - lib/generators/digest_notifier/templates/create_digest_email_items.rb
146
129
  - lib/generators/digest_notifier/templates/digest_notifier_config.rb
147
130
  homepage: http://github.com/naveed-ahmad/digest_notifier
148
- licenses:
131
+ licenses:
149
132
  - MIT
150
133
  post_install_message:
151
134
  rdoc_options: []
152
-
153
- require_paths:
135
+ require_paths:
154
136
  - lib
155
- required_ruby_version: !ruby/object:Gem::Requirement
137
+ required_ruby_version: !ruby/object:Gem::Requirement
156
138
  none: false
157
- requirements:
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- hash: 3
161
- segments:
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ segments:
162
144
  - 0
163
- version: "0"
164
- required_rubygems_version: !ruby/object:Gem::Requirement
145
+ hash: 939570369
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
147
  none: false
166
- requirements:
167
- - - ">="
168
- - !ruby/object:Gem::Version
169
- hash: 3
170
- segments:
171
- - 0
172
- version: "0"
148
+ requirements:
149
+ - - ! '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
173
152
  requirements: []
174
-
175
153
  rubyforge_project:
176
154
  rubygems_version: 1.8.25
177
155
  signing_key:
178
156
  specification_version: 3
179
157
  summary: Send notifications to user via one digest email.
180
158
  test_files: []
181
-