activity_feed 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -1
- data/CHANGELOG.markdown +8 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/README.markdown +2 -1
- data/Rakefile +1 -0
- data/lib/activity_feed/item.rb +12 -0
- data/lib/activity_feed/version.rb +1 -1
- data/spec/activity_feed/feed_spec.rb +20 -20
- data/spec/activity_feed/item_spec.rb +26 -6
- data/spec/spec_helper.rb +6 -5
- data/spec/support/mongoid.rb +12 -4
- data/spec/support/mongoid.yml +6 -0
- data/spec/version_spec.rb +1 -1
- metadata +7 -5
data/.rspec
CHANGED
data/CHANGELOG.markdown
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 2.3.0 (2013-05-03)
|
4
|
+
|
5
|
+
* Added `check_item?(user_id, item_id, aggregate = ActivityFeed.aggregate)` to see if an item is in an activity feed.
|
6
|
+
|
7
|
+
## 2.2.2 (2012-09-12)
|
8
|
+
|
9
|
+
* Added `add_item(...)` as an alias for `update_item(...)`.
|
10
|
+
|
3
11
|
## 2.2.1 (2012-08-27)
|
4
12
|
|
5
13
|
* Added `total_pages` and `total_items` as aliases for `total_pages_in_feed` and `total_items_in_feed`, respectively.
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.markdown
CHANGED
@@ -287,6 +287,7 @@ ActivityFeed.add_item(user_id, item_id, timestamp, aggregate = ActivityFeed.aggr
|
|
287
287
|
|
288
288
|
ActivityFeed.aggregate_item(user_id, item_id, timestamp)
|
289
289
|
ActivityFeed.remove_item(user_id, item_id)
|
290
|
+
ActivityFeed.check_item?(user_id, item_id, aggregate = ActivityFeed.aggregate)
|
290
291
|
|
291
292
|
# Feed-related
|
292
293
|
|
@@ -315,4 +316,4 @@ ActivityFeed.remove_feeds(user_id)
|
|
315
316
|
|
316
317
|
## Copyright
|
317
318
|
|
318
|
-
Copyright (c) 2011-
|
319
|
+
Copyright (c) 2011-2013 David Czarnecki. See LICENSE.txt for further details.
|
data/Rakefile
CHANGED
data/lib/activity_feed/item.rb
CHANGED
@@ -42,5 +42,17 @@ module ActivityFeed
|
|
42
42
|
feederboard = ActivityFeed.feederboard_for(user_id, true)
|
43
43
|
feederboard.remove_member(item_id)
|
44
44
|
end
|
45
|
+
|
46
|
+
# Check to see if an item is in the activity feed for a given +user_id+.
|
47
|
+
#
|
48
|
+
# @param user_id [String] User ID.
|
49
|
+
# @param item_id [String] Item ID.
|
50
|
+
# @param aggregate [boolean, false] Whether or not to check the aggregate activity feed.
|
51
|
+
def check_item?(user_id, item_id, aggregate = ActivityFeed.aggregate)
|
52
|
+
feederboard_individual = ActivityFeed.feederboard_for(user_id, false)
|
53
|
+
feederboard_aggregate = ActivityFeed.feederboard_for(user_id, true)
|
54
|
+
|
55
|
+
aggregate ? feederboard_aggregate.check_member?(item_id) : feederboard_individual.check_member?(item_id)
|
56
|
+
end
|
45
57
|
end
|
46
58
|
end
|
@@ -53,15 +53,15 @@ describe ActivityFeed::Feed do
|
|
53
53
|
describe 'without aggregation' do
|
54
54
|
it 'should return activity feed items between the starting and ending timestamps' do
|
55
55
|
Timecop.travel(Time.local(2012, 6, 19, 4, 0, 0))
|
56
|
-
ActivityFeed.update_item('david', 1,
|
56
|
+
ActivityFeed.update_item('david', 1, Time.now.to_i)
|
57
57
|
Timecop.travel(Time.local(2012, 6, 19, 4, 30, 0))
|
58
|
-
ActivityFeed.update_item('david', 2,
|
58
|
+
ActivityFeed.update_item('david', 2, Time.now.to_i)
|
59
59
|
Timecop.travel(Time.local(2012, 6, 19, 5, 30, 0))
|
60
|
-
ActivityFeed.update_item('david', 3,
|
60
|
+
ActivityFeed.update_item('david', 3, Time.now.to_i)
|
61
61
|
Timecop.travel(Time.local(2012, 6, 19, 6, 37, 0))
|
62
|
-
ActivityFeed.update_item('david', 4,
|
62
|
+
ActivityFeed.update_item('david', 4, Time.now.to_i)
|
63
63
|
Timecop.travel(Time.local(2012, 6, 19, 8, 17, 0))
|
64
|
-
ActivityFeed.update_item('david', 5,
|
64
|
+
ActivityFeed.update_item('david', 5, Time.now.to_i)
|
65
65
|
Timecop.return
|
66
66
|
|
67
67
|
feed = ActivityFeed.feed_between_timestamps('david', Time.local(2012, 6, 19, 4, 43, 0).to_i, Time.local(2012, 6, 19, 8, 16, 0).to_i)
|
@@ -74,15 +74,15 @@ describe ActivityFeed::Feed do
|
|
74
74
|
describe 'with aggregation' do
|
75
75
|
it 'should return activity feed items between the starting and ending timestamps' do
|
76
76
|
Timecop.travel(Time.local(2012, 6, 19, 4, 0, 0))
|
77
|
-
ActivityFeed.update_item('david', 1,
|
77
|
+
ActivityFeed.update_item('david', 1, Time.now.to_i, true)
|
78
78
|
Timecop.travel(Time.local(2012, 6, 19, 4, 30, 0))
|
79
|
-
ActivityFeed.update_item('david', 2,
|
79
|
+
ActivityFeed.update_item('david', 2, Time.now.to_i, true)
|
80
80
|
Timecop.travel(Time.local(2012, 6, 19, 5, 30, 0))
|
81
|
-
ActivityFeed.update_item('david', 3,
|
81
|
+
ActivityFeed.update_item('david', 3, Time.now.to_i, true)
|
82
82
|
Timecop.travel(Time.local(2012, 6, 19, 6, 37, 0))
|
83
|
-
ActivityFeed.update_item('david', 4,
|
83
|
+
ActivityFeed.update_item('david', 4, Time.now.to_i, true)
|
84
84
|
Timecop.travel(Time.local(2012, 6, 19, 8, 17, 0))
|
85
|
-
ActivityFeed.update_item('david', 5,
|
85
|
+
ActivityFeed.update_item('david', 5, Time.now.to_i, true)
|
86
86
|
Timecop.return
|
87
87
|
|
88
88
|
feed = ActivityFeed.feed_between_timestamps('david', Time.local(2012, 6, 19, 4, 43, 0).to_i, Time.local(2012, 6, 19, 8, 16, 0).to_i, true)
|
@@ -160,15 +160,15 @@ describe ActivityFeed::Feed do
|
|
160
160
|
describe 'without aggregation' do
|
161
161
|
it 'should trim activity feed items between the starting and ending timestamps' do
|
162
162
|
Timecop.travel(Time.local(2012, 6, 19, 4, 0, 0))
|
163
|
-
ActivityFeed.update_item('david', 1,
|
163
|
+
ActivityFeed.update_item('david', 1, Time.now.to_i)
|
164
164
|
Timecop.travel(Time.local(2012, 6, 19, 4, 30, 0))
|
165
|
-
ActivityFeed.update_item('david', 2,
|
165
|
+
ActivityFeed.update_item('david', 2, Time.now.to_i)
|
166
166
|
Timecop.travel(Time.local(2012, 6, 19, 5, 30, 0))
|
167
|
-
ActivityFeed.update_item('david', 3,
|
167
|
+
ActivityFeed.update_item('david', 3, Time.now.to_i)
|
168
168
|
Timecop.travel(Time.local(2012, 6, 19, 6, 37, 0))
|
169
|
-
ActivityFeed.update_item('david', 4,
|
169
|
+
ActivityFeed.update_item('david', 4, Time.now.to_i)
|
170
170
|
Timecop.travel(Time.local(2012, 6, 19, 8, 17, 0))
|
171
|
-
ActivityFeed.update_item('david', 5,
|
171
|
+
ActivityFeed.update_item('david', 5, Time.now.to_i)
|
172
172
|
Timecop.return
|
173
173
|
|
174
174
|
ActivityFeed.trim_feed('david', Time.local(2012, 6, 19, 4, 29, 0).to_i, Time.local(2012, 6, 19, 8, 16, 0).to_i)
|
@@ -182,15 +182,15 @@ describe ActivityFeed::Feed do
|
|
182
182
|
describe 'with aggregation' do
|
183
183
|
it 'should trim activity feed items between the starting and ending timestamps' do
|
184
184
|
Timecop.travel(Time.local(2012, 6, 19, 4, 0, 0))
|
185
|
-
ActivityFeed.update_item('david', 1,
|
185
|
+
ActivityFeed.update_item('david', 1, Time.now.to_i, true)
|
186
186
|
Timecop.travel(Time.local(2012, 6, 19, 4, 30, 0))
|
187
|
-
ActivityFeed.update_item('david', 2,
|
187
|
+
ActivityFeed.update_item('david', 2, Time.now.to_i, true)
|
188
188
|
Timecop.travel(Time.local(2012, 6, 19, 5, 30, 0))
|
189
|
-
ActivityFeed.update_item('david', 3,
|
189
|
+
ActivityFeed.update_item('david', 3, Time.now.to_i, true)
|
190
190
|
Timecop.travel(Time.local(2012, 6, 19, 6, 37, 0))
|
191
|
-
ActivityFeed.update_item('david', 4,
|
191
|
+
ActivityFeed.update_item('david', 4, Time.now.to_i, true)
|
192
192
|
Timecop.travel(Time.local(2012, 6, 19, 8, 17, 0))
|
193
|
-
ActivityFeed.update_item('david', 5,
|
193
|
+
ActivityFeed.update_item('david', 5, Time.now.to_i, true)
|
194
194
|
Timecop.return
|
195
195
|
|
196
196
|
ActivityFeed.trim_feed('david', Time.local(2012, 6, 19, 4, 29, 0).to_i, Time.local(2012, 6, 19, 8, 16, 0).to_i, true)
|
@@ -6,7 +6,7 @@ describe ActivityFeed::Item do
|
|
6
6
|
describe 'without aggregation' do
|
7
7
|
it 'should correctly build an activity feed' do
|
8
8
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david')).should be_false
|
9
|
-
ActivityFeed.update_item('david', 1,
|
9
|
+
ActivityFeed.update_item('david', 1, Time.now.to_i)
|
10
10
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david')).should be_true
|
11
11
|
end
|
12
12
|
end
|
@@ -15,7 +15,7 @@ describe ActivityFeed::Item do
|
|
15
15
|
it 'should correctly build an activity feed with an aggregate activity_feed' do
|
16
16
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david')).should be_false
|
17
17
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david', true)).should be_false
|
18
|
-
ActivityFeed.update_item('david', 1,
|
18
|
+
ActivityFeed.update_item('david', 1, Time.now.to_i, true)
|
19
19
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david')).should be_true
|
20
20
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david', true)).should be_true
|
21
21
|
end
|
@@ -26,7 +26,7 @@ describe ActivityFeed::Item do
|
|
26
26
|
describe 'without aggregation' do
|
27
27
|
it 'should correctly build an activity feed' do
|
28
28
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david')).should be_false
|
29
|
-
ActivityFeed.add_item('david', 1,
|
29
|
+
ActivityFeed.add_item('david', 1, Time.now.to_i)
|
30
30
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david')).should be_true
|
31
31
|
end
|
32
32
|
end
|
@@ -36,7 +36,7 @@ describe ActivityFeed::Item do
|
|
36
36
|
it 'should correctly add an item into an aggregate activity feed' do
|
37
37
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david')).should be_false
|
38
38
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david', true)).should be_false
|
39
|
-
ActivityFeed.aggregate_item('david', 1,
|
39
|
+
ActivityFeed.aggregate_item('david', 1, Time.now.to_i)
|
40
40
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david')).should be_false
|
41
41
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david', true)).should be_true
|
42
42
|
end
|
@@ -47,7 +47,7 @@ describe ActivityFeed::Item do
|
|
47
47
|
it 'should remove an item from an activity feed' do
|
48
48
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david')).should be_false
|
49
49
|
ActivityFeed.redis.zcard(ActivityFeed.feed_key('david')).should eql(0)
|
50
|
-
ActivityFeed.update_item('david', 1,
|
50
|
+
ActivityFeed.update_item('david', 1, Time.now.to_i)
|
51
51
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david')).should be_true
|
52
52
|
ActivityFeed.redis.zcard(ActivityFeed.feed_key('david')).should eql(1)
|
53
53
|
ActivityFeed.remove_item('david', 1)
|
@@ -61,7 +61,7 @@ describe ActivityFeed::Item do
|
|
61
61
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david', true)).should be_false
|
62
62
|
ActivityFeed.redis.zcard(ActivityFeed.feed_key('david')).should eql(0)
|
63
63
|
ActivityFeed.redis.zcard(ActivityFeed.feed_key('david', true)).should eql(0)
|
64
|
-
ActivityFeed.update_item('david', 1,
|
64
|
+
ActivityFeed.update_item('david', 1, Time.now.to_i, true)
|
65
65
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david')).should be_true
|
66
66
|
ActivityFeed.redis.exists(ActivityFeed.feed_key('david', true)).should be_true
|
67
67
|
ActivityFeed.redis.zcard(ActivityFeed.feed_key('david')).should eql(1)
|
@@ -72,4 +72,24 @@ describe ActivityFeed::Item do
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
describe '#check_item?' do
|
77
|
+
describe 'without aggregation' do
|
78
|
+
it 'should return whether or not an item exists in the feed' do
|
79
|
+
ActivityFeed.aggregate = false
|
80
|
+
ActivityFeed.check_item?('david', 1).should be_false
|
81
|
+
ActivityFeed.add_item('david', 1, Time.now.to_i)
|
82
|
+
ActivityFeed.check_item?('david', 1).should be_true
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe 'with aggregation' do
|
87
|
+
it 'should return whether or not an item exists in the feed' do
|
88
|
+
ActivityFeed.aggregate = true
|
89
|
+
ActivityFeed.check_item?('david', 1, true).should be_false
|
90
|
+
ActivityFeed.add_item('david', 1, Time.now.to_i)
|
91
|
+
ActivityFeed.check_item?('david', 1, true).should be_true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
75
95
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,7 +6,7 @@ require 'support/active_record'
|
|
6
6
|
|
7
7
|
RSpec.configure do |config|
|
8
8
|
config.mock_with :rspec
|
9
|
-
|
9
|
+
|
10
10
|
config.before(:all) do
|
11
11
|
DatabaseCleaner.strategy = :truncation
|
12
12
|
DatabaseCleaner.clean_with(:truncation)
|
@@ -18,6 +18,7 @@ RSpec.configure do |config|
|
|
18
18
|
|
19
19
|
ActivityFeed.configure do |configuration|
|
20
20
|
configuration.item_loader = nil
|
21
|
+
configuration.aggregate = false
|
21
22
|
configuration.redis = Redis.new(:db => 15)
|
22
23
|
end
|
23
24
|
|
@@ -25,18 +26,18 @@ RSpec.configure do |config|
|
|
25
26
|
end
|
26
27
|
|
27
28
|
config.after(:each) do
|
28
|
-
DatabaseCleaner.clean
|
29
|
+
DatabaseCleaner.clean
|
29
30
|
|
30
31
|
ActivityFeed.redis.quit
|
31
32
|
end
|
32
33
|
|
33
34
|
# Helper method to add items to a given feed.
|
34
|
-
#
|
35
|
+
#
|
35
36
|
# @param items_to_add [int] Number of items to add to the feed.
|
36
37
|
def add_items_to_feed(user_id, items_to_add = 5, aggregate = ActivityFeed.aggregate)
|
37
38
|
1.upto(items_to_add) do |index|
|
38
|
-
ActivityFeed.update_item(user_id, index,
|
39
|
-
Timecop.travel(
|
39
|
+
ActivityFeed.update_item(user_id, index, Time.now.to_i, aggregate)
|
40
|
+
Timecop.travel(Time.now + 10)
|
40
41
|
end
|
41
42
|
|
42
43
|
Timecop.return
|
data/spec/support/mongoid.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
require 'mongoid'
|
2
2
|
|
3
|
-
Mongoid.
|
4
|
-
|
5
|
-
|
3
|
+
# If using Mongoid 2.x
|
4
|
+
# Mongoid.configure do |config|
|
5
|
+
# config.master = Mongo::Connection.new.db("activity_feed_gem_test")
|
6
|
+
# end
|
7
|
+
|
8
|
+
# If using Mongoid 3.x
|
9
|
+
Mongoid.load!("#{File.dirname(__FILE__)}/mongoid.yml", :test)
|
6
10
|
|
7
11
|
DatabaseCleaner[:mongoid].strategy = :truncation
|
8
12
|
|
@@ -23,7 +27,11 @@ module ActivityFeed
|
|
23
27
|
field :icon, :type=> String
|
24
28
|
field :sticky, :type=> Boolean
|
25
29
|
|
26
|
-
|
30
|
+
# If using Mongoid 2.x
|
31
|
+
# index :user_id
|
32
|
+
|
33
|
+
# If using Mongoid 3.x
|
34
|
+
index({ user_id: 1})
|
27
35
|
|
28
36
|
after_save :update_activity_feed
|
29
37
|
|
data/spec/version_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activity_feed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-05-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -200,6 +200,7 @@ files:
|
|
200
200
|
- spec/spec_helper.rb
|
201
201
|
- spec/support/active_record.rb
|
202
202
|
- spec/support/mongoid.rb
|
203
|
+
- spec/support/mongoid.yml
|
203
204
|
- spec/version_spec.rb
|
204
205
|
homepage: https://github.com/agoragames/activity_feed
|
205
206
|
licenses: []
|
@@ -215,7 +216,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
216
|
version: '0'
|
216
217
|
segments:
|
217
218
|
- 0
|
218
|
-
hash:
|
219
|
+
hash: 4479539862674226365
|
219
220
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
221
|
none: false
|
221
222
|
requirements:
|
@@ -224,10 +225,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
225
|
version: '0'
|
225
226
|
segments:
|
226
227
|
- 0
|
227
|
-
hash:
|
228
|
+
hash: 4479539862674226365
|
228
229
|
requirements: []
|
229
230
|
rubyforge_project: activity_feed
|
230
|
-
rubygems_version: 1.8.
|
231
|
+
rubygems_version: 1.8.25
|
231
232
|
signing_key:
|
232
233
|
specification_version: 3
|
233
234
|
summary: Activity feeds backed by Redis
|
@@ -239,4 +240,5 @@ test_files:
|
|
239
240
|
- spec/spec_helper.rb
|
240
241
|
- spec/support/active_record.rb
|
241
242
|
- spec/support/mongoid.rb
|
243
|
+
- spec/support/mongoid.yml
|
242
244
|
- spec/version_spec.rb
|