activity_feed 1.2 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use ruby-1.9.2-p290@activity_feed_gem --create
1
+ rvm use ruby-1.9.3-p0@activity_feed_gem --create
data/CHANGELOG.markdown CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.2.1
4
+
5
+ * ActivityFeed.feed(user_id) will now return an instance of ActivityFeed::Feed
6
+ * ActivityFeed::Ohm::Item will now return all of its attributes when calling to_json
7
+
3
8
  ## 1.2
4
9
 
5
10
  * Support aggregate feeds
data/README.markdown CHANGED
@@ -4,7 +4,7 @@ Activity feeds backed by Redis
4
4
 
5
5
  ## Compatibility
6
6
 
7
- The gem has been built and tested under Ruby 1.9.2-p290
7
+ The gem has been built and tested under Ruby 1.9.2-p290 and Ruby 1.9.3-p0
8
8
 
9
9
  ## Installation
10
10
 
@@ -220,6 +220,18 @@ Consult the specs to see this working if you have questions.
220
220
 
221
221
  ### Feeds and Aggregation Feeds
222
222
 
223
+ You can access an activity feed in a couple of ways.
224
+
225
+ ```ruby
226
+ ActivityFeed.feed(user_id) # return an instance of ActivityFeed::Feed
227
+ ```
228
+
229
+ or
230
+
231
+ ```ruby
232
+ ActivityFeed::Feed.new(user_id)
233
+ ```
234
+
223
235
  activity_feed uses the following key in adding the item to Redis: `ActivityFeed.namespace:ActivityFeed.key:self.user_id`. By default, activity_feed in the `create_item` call will
224
236
  also add the item in Redis to an aggregate feed using the key: `ActivityFeed.namespace:ActivityFeed.key:ActivityFeed.aggregate_key:self.user_id`.
225
237
 
@@ -18,6 +18,19 @@ module ActivityFeed
18
18
 
19
19
  after :save, :update_redis
20
20
 
21
+ def to_hash
22
+ super.merge(
23
+ :user_id => user_id,
24
+ :nickname => nickname,
25
+ :type => type,
26
+ :title => title,
27
+ :text => text,
28
+ :url => url,
29
+ :icon => icon,
30
+ :sticky => sticky
31
+ )
32
+ end
33
+
21
34
  private
22
35
 
23
36
  def update_redis
@@ -1,3 +1,3 @@
1
1
  module ActivityFeed
2
- VERSION = "1.2"
2
+ VERSION = "1.2.1"
3
3
  end
data/lib/activity_feed.rb CHANGED
@@ -78,6 +78,10 @@ module ActivityFeed
78
78
  end
79
79
  end
80
80
 
81
+ def self.feed(user_id)
82
+ ActivityFeed::Feed.new(user_id)
83
+ end
84
+
81
85
  self.namespace = 'activity'
82
86
  self.key = 'feed'
83
87
  self.aggregate_key = 'aggregate'
@@ -133,4 +133,16 @@ describe ActivityFeed do
133
133
  loaded_item.should == JSON.parse(item.to_json)
134
134
  end
135
135
  end
136
+
137
+ describe 'feed' do
138
+ it 'should allow you to create a new ActivityFeed::Feed instance' do
139
+ user_id = 1
140
+ ActivityFeed.persistence = :ohm
141
+
142
+ item = ActivityFeed.create_item(:user_id => user_id, :text => 'This is text for my activity feed')
143
+ feed = ActivityFeed.feed(user_id)
144
+
145
+ feed.total_items.should be(1)
146
+ end
147
+ end
136
148
  end
data/spec/item_spec.rb CHANGED
@@ -45,4 +45,11 @@ describe 'ActivityFeed::Item' do
45
45
  ActivityFeed.aggregate_item(item)
46
46
  ActivityFeed.redis.zcard(ActivityFeed.feed_key(item.user_id, true)).should be(1)
47
47
  end
48
+
49
+ it 'should output all the attributes for an item for Ohm' do
50
+ item = Fabricate.build(ActivityFeed::Ohm::Item)
51
+
52
+ hash = JSON.parse(JSON.generate(item))
53
+ hash.keys.size.should be(8)
54
+ end
48
55
  end
data/spec/version_spec.rb CHANGED
@@ -2,6 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe ActivityFeed do
4
4
  it "should be the correct version" do
5
- ActivityFeed::VERSION.should == '1.2'
5
+ ActivityFeed::VERSION.should == '1.2.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,203 +1,199 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: activity_feed
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.1
4
5
  prerelease:
5
- version: "1.2"
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - David Czarnecki
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-11-30 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2011-12-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: rake
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2160989100 !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
23
22
  type: :development
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *2160989100
25
+ - !ruby/object:Gem::Dependency
27
26
  name: rspec
28
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &2160988660 !ruby/object:Gem::Requirement
29
28
  none: false
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
34
33
  type: :development
35
34
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *2160988660
36
+ - !ruby/object:Gem::Dependency
38
37
  name: database_cleaner
39
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &2160988200 !ruby/object:Gem::Requirement
40
39
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
45
44
  type: :development
46
45
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *2160988200
47
+ - !ruby/object:Gem::Dependency
49
48
  name: fabrication
50
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ requirement: &2160987760 !ruby/object:Gem::Requirement
51
50
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
56
55
  type: :development
57
56
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
57
+ version_requirements: *2160987760
58
+ - !ruby/object:Gem::Dependency
60
59
  name: mongo_mapper
61
- requirement: &id005 !ruby/object:Gem::Requirement
60
+ requirement: &2160987340 !ruby/object:Gem::Requirement
62
61
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
67
66
  type: :development
68
67
  prerelease: false
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *2160987340
69
+ - !ruby/object:Gem::Dependency
71
70
  name: mongo_ext
72
- requirement: &id006 !ruby/object:Gem::Requirement
71
+ requirement: &2160986860 !ruby/object:Gem::Requirement
73
72
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
78
77
  type: :development
79
78
  prerelease: false
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
79
+ version_requirements: *2160986860
80
+ - !ruby/object:Gem::Dependency
82
81
  name: bson_ext
83
- requirement: &id007 !ruby/object:Gem::Requirement
82
+ requirement: &2160986440 !ruby/object:Gem::Requirement
84
83
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
89
88
  type: :development
90
89
  prerelease: false
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
90
+ version_requirements: *2160986440
91
+ - !ruby/object:Gem::Dependency
93
92
  name: activerecord
94
- requirement: &id008 !ruby/object:Gem::Requirement
93
+ requirement: &2160985960 !ruby/object:Gem::Requirement
95
94
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: "0"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
100
99
  type: :development
101
100
  prerelease: false
102
- version_requirements: *id008
103
- - !ruby/object:Gem::Dependency
101
+ version_requirements: *2160985960
102
+ - !ruby/object:Gem::Dependency
104
103
  name: sqlite3
105
- requirement: &id009 !ruby/object:Gem::Requirement
104
+ requirement: &2160846320 !ruby/object:Gem::Requirement
106
105
  none: false
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: "0"
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
111
110
  type: :development
112
111
  prerelease: false
113
- version_requirements: *id009
114
- - !ruby/object:Gem::Dependency
112
+ version_requirements: *2160846320
113
+ - !ruby/object:Gem::Dependency
115
114
  name: ohm
116
- requirement: &id010 !ruby/object:Gem::Requirement
115
+ requirement: &2160845880 !ruby/object:Gem::Requirement
117
116
  none: false
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- version: "0"
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
122
121
  type: :development
123
122
  prerelease: false
124
- version_requirements: *id010
125
- - !ruby/object:Gem::Dependency
123
+ version_requirements: *2160845880
124
+ - !ruby/object:Gem::Dependency
126
125
  name: ohm-contrib
127
- requirement: &id011 !ruby/object:Gem::Requirement
126
+ requirement: &2160845460 !ruby/object:Gem::Requirement
128
127
  none: false
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: "0"
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
133
132
  type: :development
134
133
  prerelease: false
135
- version_requirements: *id011
136
- - !ruby/object:Gem::Dependency
134
+ version_requirements: *2160845460
135
+ - !ruby/object:Gem::Dependency
137
136
  name: activesupport
138
- requirement: &id012 !ruby/object:Gem::Requirement
137
+ requirement: &2160845000 !ruby/object:Gem::Requirement
139
138
  none: false
140
- requirements:
141
- - - ">="
142
- - !ruby/object:Gem::Version
143
- version: "0"
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
144
143
  type: :runtime
145
144
  prerelease: false
146
- version_requirements: *id012
147
- - !ruby/object:Gem::Dependency
145
+ version_requirements: *2160845000
146
+ - !ruby/object:Gem::Dependency
148
147
  name: i18n
149
- requirement: &id013 !ruby/object:Gem::Requirement
148
+ requirement: &2160844520 !ruby/object:Gem::Requirement
150
149
  none: false
151
- requirements:
152
- - - ">="
153
- - !ruby/object:Gem::Version
154
- version: "0"
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
155
154
  type: :runtime
156
155
  prerelease: false
157
- version_requirements: *id013
158
- - !ruby/object:Gem::Dependency
156
+ version_requirements: *2160844520
157
+ - !ruby/object:Gem::Dependency
159
158
  name: json
160
- requirement: &id014 !ruby/object:Gem::Requirement
159
+ requirement: &2160844000 !ruby/object:Gem::Requirement
161
160
  none: false
162
- requirements:
163
- - - ">="
164
- - !ruby/object:Gem::Version
165
- version: "0"
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
166
165
  type: :runtime
167
166
  prerelease: false
168
- version_requirements: *id014
169
- - !ruby/object:Gem::Dependency
167
+ version_requirements: *2160844000
168
+ - !ruby/object:Gem::Dependency
170
169
  name: redis
171
- requirement: &id015 !ruby/object:Gem::Requirement
170
+ requirement: &2160843300 !ruby/object:Gem::Requirement
172
171
  none: false
173
- requirements:
174
- - - ">="
175
- - !ruby/object:Gem::Version
176
- version: "0"
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
177
176
  type: :runtime
178
177
  prerelease: false
179
- version_requirements: *id015
180
- - !ruby/object:Gem::Dependency
178
+ version_requirements: *2160843300
179
+ - !ruby/object:Gem::Dependency
181
180
  name: leaderboard
182
- requirement: &id016 !ruby/object:Gem::Requirement
181
+ requirement: &2160842220 !ruby/object:Gem::Requirement
183
182
  none: false
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: "0"
183
+ requirements:
184
+ - - ! '>='
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
188
187
  type: :runtime
189
188
  prerelease: false
190
- version_requirements: *id016
189
+ version_requirements: *2160842220
191
190
  description: Activity feeds backed by Redis
192
- email:
191
+ email:
193
192
  - dczarnecki@agoragames.com
194
193
  executables: []
195
-
196
194
  extensions: []
197
-
198
195
  extra_rdoc_files: []
199
-
200
- files:
196
+ files:
201
197
  - .gitignore
202
198
  - .rvmrc
203
199
  - CHANGELOG.markdown
@@ -222,38 +218,35 @@ files:
222
218
  - spec/version_spec.rb
223
219
  homepage: https://github.com/agoragames/activity_feed
224
220
  licenses: []
225
-
226
221
  post_install_message:
227
222
  rdoc_options: []
228
-
229
- require_paths:
223
+ require_paths:
230
224
  - lib
231
- required_ruby_version: !ruby/object:Gem::Requirement
225
+ required_ruby_version: !ruby/object:Gem::Requirement
232
226
  none: false
233
- requirements:
234
- - - ">="
235
- - !ruby/object:Gem::Version
236
- hash: 2506402929405040614
237
- segments:
227
+ requirements:
228
+ - - ! '>='
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ segments:
238
232
  - 0
239
- version: "0"
240
- required_rubygems_version: !ruby/object:Gem::Requirement
233
+ hash: 680484865266501391
234
+ required_rubygems_version: !ruby/object:Gem::Requirement
241
235
  none: false
242
- requirements:
243
- - - ">="
244
- - !ruby/object:Gem::Version
245
- hash: 2506402929405040614
246
- segments:
236
+ requirements:
237
+ - - ! '>='
238
+ - !ruby/object:Gem::Version
239
+ version: '0'
240
+ segments:
247
241
  - 0
248
- version: "0"
242
+ hash: 680484865266501391
249
243
  requirements: []
250
-
251
244
  rubyforge_project: activity_feed
252
- rubygems_version: 1.8.11
245
+ rubygems_version: 1.8.10
253
246
  signing_key:
254
247
  specification_version: 3
255
248
  summary: Activity feeds backed by Redis
256
- test_files:
249
+ test_files:
257
250
  - spec/activity_feed/custom/item.rb
258
251
  - spec/activity_feed_spec.rb
259
252
  - spec/fabricators/item_fabricator.rb