new_data_notifier 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/mailers/new_data_notifier/notifier.rb +7 -7
- data/app/views/new_data_notifier/notifier/notify.text.erb +0 -1
- data/new_data_notifier.gemspec +6 -2
- data/test/dummy/app/models/job.rb +2 -0
- data/test/dummy/config/initializers/new_data_notifier.rb +1 -1
- data/test/dummy/db/migrate/20110317065149_create_jobs.rb +13 -0
- data/test/dummy/db/schema.rb +7 -1
- data/test/integration/new_data_notifier_test.rb +2 -1
- metadata +8 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
@@ -48,8 +48,9 @@ module NewDataNotifier
|
|
48
48
|
def get_latest_added_data
|
49
49
|
# find data
|
50
50
|
data_hash = {}
|
51
|
+
last_sent_at = get_last_sent_at
|
51
52
|
NewDataNotifier::Notifier.be_monitored_models.each do |model|
|
52
|
-
data_hash[model.downcase.to_sym] = model.constantize.where("created_at >= ?",
|
53
|
+
data_hash[model.downcase.to_sym] = model.constantize.where("created_at >= ?", last_sent_at).order("created_at DESC")
|
53
54
|
end
|
54
55
|
data_hash.delete_if { |key, value| value.count == 0 }
|
55
56
|
data_hash
|
@@ -85,13 +86,12 @@ module NewDataNotifier
|
|
85
86
|
|
86
87
|
helper_method :object_name
|
87
88
|
def object_name(obj)
|
88
|
-
|
89
|
-
obj.
|
90
|
-
|
91
|
-
|
92
|
-
else
|
93
|
-
"#{obj.class}##{obj.id}"
|
89
|
+
%w{name title subject email}.each do |col|
|
90
|
+
if obj.respond_to?(col.to_sym) and obj.try(col.to_sym).present?
|
91
|
+
return "#{obj.class}##{obj.send(col)}"
|
92
|
+
end
|
94
93
|
end
|
94
|
+
"#{obj.class}##{obj.id}"
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
data/new_data_notifier.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{new_data_notifier}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["michael he"]
|
12
|
-
s.date = %q{2011-03-
|
12
|
+
s.date = %q{2011-03-18}
|
13
13
|
s.description = %q{If there is some new users signed up on your site or some new articles been added by some other user, If you hope been notified, please execute "gem install new_data_notifier}
|
14
14
|
s.email = %q{hlxwell@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
"test/dummy/Rakefile",
|
36
36
|
"test/dummy/app/controllers/application_controller.rb",
|
37
37
|
"test/dummy/app/helpers/application_helper.rb",
|
38
|
+
"test/dummy/app/models/job.rb",
|
38
39
|
"test/dummy/app/models/user.rb",
|
39
40
|
"test/dummy/app/views/layouts/application.html.erb",
|
40
41
|
"test/dummy/config.ru",
|
@@ -54,6 +55,7 @@ Gem::Specification.new do |s|
|
|
54
55
|
"test/dummy/config/locales/en.yml",
|
55
56
|
"test/dummy/config/routes.rb",
|
56
57
|
"test/dummy/db/migrate/20110317034437_create_users.rb",
|
58
|
+
"test/dummy/db/migrate/20110317065149_create_jobs.rb",
|
57
59
|
"test/dummy/db/schema.rb",
|
58
60
|
"test/dummy/public/404.html",
|
59
61
|
"test/dummy/public/422.html",
|
@@ -79,6 +81,7 @@ Gem::Specification.new do |s|
|
|
79
81
|
s.test_files = [
|
80
82
|
"test/dummy/app/controllers/application_controller.rb",
|
81
83
|
"test/dummy/app/helpers/application_helper.rb",
|
84
|
+
"test/dummy/app/models/job.rb",
|
82
85
|
"test/dummy/app/models/user.rb",
|
83
86
|
"test/dummy/config/application.rb",
|
84
87
|
"test/dummy/config/boot.rb",
|
@@ -94,6 +97,7 @@ Gem::Specification.new do |s|
|
|
94
97
|
"test/dummy/config/initializers/session_store.rb",
|
95
98
|
"test/dummy/config/routes.rb",
|
96
99
|
"test/dummy/db/migrate/20110317034437_create_users.rb",
|
100
|
+
"test/dummy/db/migrate/20110317065149_create_jobs.rb",
|
97
101
|
"test/dummy/db/schema.rb",
|
98
102
|
"test/integration/new_data_notifier_test.rb",
|
99
103
|
"test/support/integration_case.rb",
|
data/test/dummy/db/schema.rb
CHANGED
@@ -10,7 +10,13 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended to check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(:version =>
|
13
|
+
ActiveRecord::Schema.define(:version => 20110317065149) do
|
14
|
+
|
15
|
+
create_table "jobs", :force => true do |t|
|
16
|
+
t.string "name"
|
17
|
+
t.datetime "created_at"
|
18
|
+
t.datetime "updated_at"
|
19
|
+
end
|
14
20
|
|
15
21
|
create_table "users", :force => true do |t|
|
16
22
|
t.string "email"
|
@@ -6,7 +6,8 @@ class NewDataNotifierTest < ActiveSupport::IntegrationCase
|
|
6
6
|
assert NewDataNotifier::Notifier.get_latest_added_data.blank?
|
7
7
|
assert NewDataNotifier::Notifier.send_all_notification.blank?
|
8
8
|
User.create :email => "a@a.com"
|
9
|
-
|
9
|
+
Job.create :name => "rails job"
|
10
|
+
assert_equal 2, NewDataNotifier::Notifier.get_latest_added_data.size
|
10
11
|
assert !NewDataNotifier::Notifier.send_all_notification.blank?
|
11
12
|
end
|
12
13
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: new_data_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- michael he
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-18 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- test/dummy/Rakefile
|
133
133
|
- test/dummy/app/controllers/application_controller.rb
|
134
134
|
- test/dummy/app/helpers/application_helper.rb
|
135
|
+
- test/dummy/app/models/job.rb
|
135
136
|
- test/dummy/app/models/user.rb
|
136
137
|
- test/dummy/app/views/layouts/application.html.erb
|
137
138
|
- test/dummy/config.ru
|
@@ -151,6 +152,7 @@ files:
|
|
151
152
|
- test/dummy/config/locales/en.yml
|
152
153
|
- test/dummy/config/routes.rb
|
153
154
|
- test/dummy/db/migrate/20110317034437_create_users.rb
|
155
|
+
- test/dummy/db/migrate/20110317065149_create_jobs.rb
|
154
156
|
- test/dummy/db/schema.rb
|
155
157
|
- test/dummy/public/404.html
|
156
158
|
- test/dummy/public/422.html
|
@@ -204,6 +206,7 @@ summary: If there is some new users signed up on your site or some new articles
|
|
204
206
|
test_files:
|
205
207
|
- test/dummy/app/controllers/application_controller.rb
|
206
208
|
- test/dummy/app/helpers/application_helper.rb
|
209
|
+
- test/dummy/app/models/job.rb
|
207
210
|
- test/dummy/app/models/user.rb
|
208
211
|
- test/dummy/config/application.rb
|
209
212
|
- test/dummy/config/boot.rb
|
@@ -219,6 +222,7 @@ test_files:
|
|
219
222
|
- test/dummy/config/initializers/session_store.rb
|
220
223
|
- test/dummy/config/routes.rb
|
221
224
|
- test/dummy/db/migrate/20110317034437_create_users.rb
|
225
|
+
- test/dummy/db/migrate/20110317065149_create_jobs.rb
|
222
226
|
- test/dummy/db/schema.rb
|
223
227
|
- test/integration/new_data_notifier_test.rb
|
224
228
|
- test/support/integration_case.rb
|