redis_timeline 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib redis_timeline]))
2
+ dir = File.dirname(File.expand_path(__FILE__))
3
+
4
+ #
5
+ # make sure we can run redis
6
+ #
7
+
8
+ if !system("which redis-server")
9
+ puts '', "** can't find `redis-server` in your path"
10
+ puts "** try running `sudo rake install`"
11
+ abort ''
12
+ end
13
+
14
+ #
15
+ # start our own redis when the tests start,
16
+ # kill it when they end
17
+ #
18
+
19
+ at_exit do
20
+ next if $!
21
+
22
+ exit_code = RSpec::Runner.autorun
23
+
24
+ pid = `ps -A -o pid,command | grep [r]edis-test`.split(" ")[0]
25
+ puts "Killing test redis server..."
26
+ `rm -f #{dir}/dump.rdb`
27
+ Process.kill("KILL", pid.to_i)
28
+ exit exit_code
29
+ end
30
+
31
+ puts "Starting redis for testing at localhost:9736..."
32
+ `redis-server #{dir}/redis-test.conf`
33
+ Timeline.redis = 'localhost:9736'
data/spec/stdout ADDED
@@ -0,0 +1,180 @@
1
+ [26640] 11 Apr 18:37:31.162 - DB 0: 5 keys (0 volatile) in 8 slots HT.
2
+ [26640] 11 Apr 18:37:31.162 - 0 clients connected (0 slaves), 970304 bytes in use
3
+ [26640] 11 Apr 18:37:36.190 - DB 0: 5 keys (0 volatile) in 8 slots HT.
4
+ [26640] 11 Apr 18:37:36.191 - 0 clients connected (0 slaves), 970304 bytes in use
5
+ [26640] 11 Apr 18:37:41.218 - DB 0: 5 keys (0 volatile) in 8 slots HT.
6
+ [26640] 11 Apr 18:37:41.218 - 0 clients connected (0 slaves), 970304 bytes in use
7
+ [26640] 11 Apr 18:37:46.254 - DB 0: 5 keys (0 volatile) in 8 slots HT.
8
+ [26640] 11 Apr 18:37:46.254 - 0 clients connected (0 slaves), 970304 bytes in use
9
+ [26908] 11 Apr 18:37:48.419 * Max number of open files set to 10032
10
+ [26908] 11 Apr 18:37:48.420 # Creating Server TCP listening socket *:9736: bind: Address already in use
11
+ [26640] 11 Apr 18:37:48.482 - Accepted ::1:62763
12
+ [26640] 11 Apr 18:37:48.496 - Accepted ::1:62764
13
+ [26640] 11 Apr 18:37:48.519 - Client closed connection
14
+ [26640] 11 Apr 18:37:48.532 - Client closed connection
15
+ [26640] 11 Apr 18:37:51.292 - DB 0: 5 keys (0 volatile) in 8 slots HT.
16
+ [26640] 11 Apr 18:37:51.292 - 0 clients connected (0 slaves), 976352 bytes in use
17
+ [26640] 11 Apr 18:37:56.329 - DB 0: 5 keys (0 volatile) in 8 slots HT.
18
+ [26640] 11 Apr 18:37:56.329 - 0 clients connected (0 slaves), 976352 bytes in use
19
+ [26640] 11 Apr 18:38:01.358 - DB 0: 5 keys (0 volatile) in 8 slots HT.
20
+ [26640] 11 Apr 18:38:01.358 - 0 clients connected (0 slaves), 976352 bytes in use
21
+ [26640] 11 Apr 18:38:06.388 - DB 0: 5 keys (0 volatile) in 8 slots HT.
22
+ [26640] 11 Apr 18:38:06.388 - 0 clients connected (0 slaves), 976352 bytes in use
23
+ [26640] 11 Apr 18:38:11.421 - DB 0: 5 keys (0 volatile) in 8 slots HT.
24
+ [26640] 11 Apr 18:38:11.421 - 0 clients connected (0 slaves), 976352 bytes in use
25
+ [26640] 11 Apr 18:38:16.449 - DB 0: 5 keys (0 volatile) in 8 slots HT.
26
+ [26640] 11 Apr 18:38:16.450 - 0 clients connected (0 slaves), 976352 bytes in use
27
+ [26640] 11 Apr 18:38:21.466 - DB 0: 5 keys (0 volatile) in 8 slots HT.
28
+ [26640] 11 Apr 18:38:21.466 - 0 clients connected (0 slaves), 976352 bytes in use
29
+ [26640] 11 Apr 18:38:26.499 - DB 0: 5 keys (0 volatile) in 8 slots HT.
30
+ [26640] 11 Apr 18:38:26.499 - 0 clients connected (0 slaves), 976352 bytes in use
31
+ [26640] 11 Apr 18:38:31.526 - DB 0: 5 keys (0 volatile) in 8 slots HT.
32
+ [26640] 11 Apr 18:38:31.526 - 0 clients connected (0 slaves), 976352 bytes in use
33
+ [26640] 11 Apr 18:38:36.582 - DB 0: 5 keys (0 volatile) in 8 slots HT.
34
+ [26640] 11 Apr 18:38:36.582 - 0 clients connected (0 slaves), 976352 bytes in use
35
+ [26640] 11 Apr 18:38:41.616 - DB 0: 5 keys (0 volatile) in 8 slots HT.
36
+ [26640] 11 Apr 18:38:41.617 - 0 clients connected (0 slaves), 976352 bytes in use
37
+ [26640] 11 Apr 18:38:46.640 - DB 0: 5 keys (0 volatile) in 8 slots HT.
38
+ [26640] 11 Apr 18:38:46.640 - 0 clients connected (0 slaves), 976352 bytes in use
39
+ [26640] 11 Apr 18:38:51.671 - DB 0: 5 keys (0 volatile) in 8 slots HT.
40
+ [26640] 11 Apr 18:38:51.671 - 0 clients connected (0 slaves), 976352 bytes in use
41
+ [26640] 11 Apr 18:38:56.703 - DB 0: 5 keys (0 volatile) in 8 slots HT.
42
+ [26640] 11 Apr 18:38:56.703 - 0 clients connected (0 slaves), 976352 bytes in use
43
+ [26640] 11 Apr 18:39:01.739 - DB 0: 5 keys (0 volatile) in 8 slots HT.
44
+ [26640] 11 Apr 18:39:01.739 - 0 clients connected (0 slaves), 976352 bytes in use
45
+ [26640] 11 Apr 18:39:06.769 - DB 0: 5 keys (0 volatile) in 8 slots HT.
46
+ [26640] 11 Apr 18:39:06.769 - 0 clients connected (0 slaves), 976352 bytes in use
47
+ [26640] 11 Apr 18:39:11.810 - DB 0: 5 keys (0 volatile) in 8 slots HT.
48
+ [26640] 11 Apr 18:39:11.810 - 0 clients connected (0 slaves), 976352 bytes in use
49
+ [26640] 11 Apr 18:39:16.832 - DB 0: 5 keys (0 volatile) in 8 slots HT.
50
+ [26640] 11 Apr 18:39:16.832 - 0 clients connected (0 slaves), 976352 bytes in use
51
+ [26640] 11 Apr 18:39:21.866 - DB 0: 5 keys (0 volatile) in 8 slots HT.
52
+ [26640] 11 Apr 18:39:21.867 - 0 clients connected (0 slaves), 976352 bytes in use
53
+ [26640] 11 Apr 18:39:26.903 - DB 0: 5 keys (0 volatile) in 8 slots HT.
54
+ [26640] 11 Apr 18:39:26.903 - 0 clients connected (0 slaves), 976352 bytes in use
55
+ [26640] 11 Apr 18:39:31.932 - DB 0: 5 keys (0 volatile) in 8 slots HT.
56
+ [26640] 11 Apr 18:39:31.932 - 0 clients connected (0 slaves), 976352 bytes in use
57
+ [27282] 11 Apr 18:39:33.929 * Max number of open files set to 10032
58
+ [27282] 11 Apr 18:39:33.931 # Creating Server TCP listening socket *:9736: bind: Address already in use
59
+ [26640] 11 Apr 18:39:33.993 - Accepted ::1:62769
60
+ [26640] 11 Apr 18:39:34.007 - Accepted ::1:62770
61
+ [26640] 11 Apr 18:39:34.047 - Client closed connection
62
+ [26640] 11 Apr 18:39:34.053 - Client closed connection
63
+ [26640] 11 Apr 18:39:36.956 - DB 0: 5 keys (0 volatile) in 8 slots HT.
64
+ [26640] 11 Apr 18:39:36.957 - 0 clients connected (0 slaves), 981376 bytes in use
65
+ [26640] 11 Apr 18:39:41.989 - DB 0: 5 keys (0 volatile) in 8 slots HT.
66
+ [26640] 11 Apr 18:39:41.990 - 0 clients connected (0 slaves), 981376 bytes in use
67
+ [26640] 11 Apr 18:39:47.024 - DB 0: 5 keys (0 volatile) in 8 slots HT.
68
+ [26640] 11 Apr 18:39:47.024 - 0 clients connected (0 slaves), 981376 bytes in use
69
+ [26640] 11 Apr 18:39:52.045 - DB 0: 5 keys (0 volatile) in 8 slots HT.
70
+ [26640] 11 Apr 18:39:52.045 - 0 clients connected (0 slaves), 981376 bytes in use
71
+ [26640] 11 Apr 18:39:57.071 - DB 0: 5 keys (0 volatile) in 8 slots HT.
72
+ [26640] 11 Apr 18:39:57.071 - 0 clients connected (0 slaves), 981376 bytes in use
73
+ [26640] 11 Apr 18:40:02.104 - DB 0: 5 keys (0 volatile) in 8 slots HT.
74
+ [26640] 11 Apr 18:40:02.104 - 0 clients connected (0 slaves), 981376 bytes in use
75
+ [27457] 11 Apr 18:40:04.694 * Max number of open files set to 10032
76
+ [27457] 11 Apr 18:40:04.695 # Creating Server TCP listening socket *:9736: bind: Address already in use
77
+ [26640] 11 Apr 18:40:04.768 - Accepted ::1:62772
78
+ [26640] 11 Apr 18:40:04.787 - Accepted ::1:62773
79
+ [26640] 11 Apr 18:40:04.821 - Client closed connection
80
+ [26640] 11 Apr 18:40:04.841 - Client closed connection
81
+ [26640] 11 Apr 18:40:07.137 - DB 0: 5 keys (0 volatile) in 8 slots HT.
82
+ [26640] 11 Apr 18:40:07.137 - 0 clients connected (0 slaves), 987424 bytes in use
83
+ [26640] 11 Apr 18:40:12.161 - DB 0: 5 keys (0 volatile) in 8 slots HT.
84
+ [26640] 11 Apr 18:40:12.161 - 0 clients connected (0 slaves), 987424 bytes in use
85
+ [26640] 11 Apr 18:40:17.197 - DB 0: 5 keys (0 volatile) in 8 slots HT.
86
+ [26640] 11 Apr 18:40:17.197 - 0 clients connected (0 slaves), 987424 bytes in use
87
+ [26640] 11 Apr 18:40:22.229 - DB 0: 5 keys (0 volatile) in 8 slots HT.
88
+ [26640] 11 Apr 18:40:22.229 - 0 clients connected (0 slaves), 987424 bytes in use
89
+ [26640] 11 Apr 18:40:27.258 - DB 0: 5 keys (0 volatile) in 8 slots HT.
90
+ [26640] 11 Apr 18:40:27.259 - 0 clients connected (0 slaves), 987424 bytes in use
91
+ [26640] 11 Apr 18:40:32.288 - DB 0: 5 keys (0 volatile) in 8 slots HT.
92
+ [26640] 11 Apr 18:40:32.288 - 0 clients connected (0 slaves), 987424 bytes in use
93
+ [26640] 11 Apr 18:40:37.314 - DB 0: 5 keys (0 volatile) in 8 slots HT.
94
+ [26640] 11 Apr 18:40:37.314 - 0 clients connected (0 slaves), 987424 bytes in use
95
+ [26640] 11 Apr 18:40:42.346 - DB 0: 5 keys (0 volatile) in 8 slots HT.
96
+ [26640] 11 Apr 18:40:42.347 - 0 clients connected (0 slaves), 987424 bytes in use
97
+ [26640] 11 Apr 18:40:47.372 - DB 0: 5 keys (0 volatile) in 8 slots HT.
98
+ [26640] 11 Apr 18:40:47.372 - 0 clients connected (0 slaves), 987424 bytes in use
99
+ [26640] 11 Apr 18:40:52.404 - DB 0: 5 keys (0 volatile) in 8 slots HT.
100
+ [26640] 11 Apr 18:40:52.404 - 0 clients connected (0 slaves), 987424 bytes in use
101
+ [26640] 11 Apr 18:40:57.434 - DB 0: 5 keys (0 volatile) in 8 slots HT.
102
+ [26640] 11 Apr 18:40:57.435 - 0 clients connected (0 slaves), 987424 bytes in use
103
+ [26640] 11 Apr 18:41:02.455 - DB 0: 5 keys (0 volatile) in 8 slots HT.
104
+ [26640] 11 Apr 18:41:02.456 - 0 clients connected (0 slaves), 987424 bytes in use
105
+ [26640] 11 Apr 18:41:07.488 - DB 0: 5 keys (0 volatile) in 8 slots HT.
106
+ [26640] 11 Apr 18:41:07.488 - 0 clients connected (0 slaves), 987424 bytes in use
107
+ [26640] 11 Apr 18:41:12.518 - DB 0: 5 keys (0 volatile) in 8 slots HT.
108
+ [26640] 11 Apr 18:41:12.518 - 0 clients connected (0 slaves), 987424 bytes in use
109
+ [26640] 11 Apr 18:41:17.547 - DB 0: 5 keys (0 volatile) in 8 slots HT.
110
+ [26640] 11 Apr 18:41:17.547 - 0 clients connected (0 slaves), 987424 bytes in use
111
+ [26640] 11 Apr 18:41:22.574 - DB 0: 5 keys (0 volatile) in 8 slots HT.
112
+ [26640] 11 Apr 18:41:22.574 - 0 clients connected (0 slaves), 987424 bytes in use
113
+ [26640] 11 Apr 18:41:27.604 - DB 0: 5 keys (0 volatile) in 8 slots HT.
114
+ [26640] 11 Apr 18:41:27.604 - 0 clients connected (0 slaves), 987424 bytes in use
115
+ [26640] 11 Apr 18:41:32.622 - DB 0: 5 keys (0 volatile) in 8 slots HT.
116
+ [26640] 11 Apr 18:41:32.623 - 0 clients connected (0 slaves), 987424 bytes in use
117
+ [26640] 11 Apr 18:41:37.653 - DB 0: 5 keys (0 volatile) in 8 slots HT.
118
+ [26640] 11 Apr 18:41:37.653 - 0 clients connected (0 slaves), 987424 bytes in use
119
+ [26640] 11 Apr 18:41:42.684 - DB 0: 5 keys (0 volatile) in 8 slots HT.
120
+ [26640] 11 Apr 18:41:42.684 - 0 clients connected (0 slaves), 987424 bytes in use
121
+ [26640] 11 Apr 18:41:47.714 - DB 0: 5 keys (0 volatile) in 8 slots HT.
122
+ [26640] 11 Apr 18:41:47.714 - 0 clients connected (0 slaves), 987424 bytes in use
123
+ [26640] 11 Apr 18:41:52.745 - DB 0: 5 keys (0 volatile) in 8 slots HT.
124
+ [26640] 11 Apr 18:41:52.745 - 0 clients connected (0 slaves), 987424 bytes in use
125
+ [26640] 11 Apr 18:41:56.073 * 10 changes in 300 seconds. Saving...
126
+ [26640] 11 Apr 18:41:56.073 * Background saving started by pid 27704
127
+ [27704] 11 Apr 18:41:56.075 * DB saved on disk
128
+ [26640] 11 Apr 18:41:56.175 * Background saving terminated with success
129
+ [26640] 11 Apr 18:41:57.780 - DB 0: 5 keys (0 volatile) in 8 slots HT.
130
+ [26640] 11 Apr 18:41:57.780 - 0 clients connected (0 slaves), 987424 bytes in use
131
+ [26640] 11 Apr 18:42:02.812 - DB 0: 5 keys (0 volatile) in 8 slots HT.
132
+ [26640] 11 Apr 18:42:02.812 - 0 clients connected (0 slaves), 987424 bytes in use
133
+ [26640] 11 Apr 18:42:07.842 - DB 0: 5 keys (0 volatile) in 8 slots HT.
134
+ [26640] 11 Apr 18:42:07.843 - 0 clients connected (0 slaves), 987424 bytes in use
135
+ [26640] 11 Apr 18:42:12.867 - DB 0: 5 keys (0 volatile) in 8 slots HT.
136
+ [26640] 11 Apr 18:42:12.867 - 0 clients connected (0 slaves), 987424 bytes in use
137
+ [26640] 11 Apr 18:42:17.903 - DB 0: 5 keys (0 volatile) in 8 slots HT.
138
+ [26640] 11 Apr 18:42:17.903 - 0 clients connected (0 slaves), 987424 bytes in use
139
+ [26640] 11 Apr 18:42:22.934 - DB 0: 5 keys (0 volatile) in 8 slots HT.
140
+ [26640] 11 Apr 18:42:22.934 - 0 clients connected (0 slaves), 987424 bytes in use
141
+ [26640] 11 Apr 18:42:27.966 - DB 0: 5 keys (0 volatile) in 8 slots HT.
142
+ [26640] 11 Apr 18:42:27.966 - 0 clients connected (0 slaves), 987424 bytes in use
143
+ [26640] 11 Apr 18:42:32.993 - DB 0: 5 keys (0 volatile) in 8 slots HT.
144
+ [26640] 11 Apr 18:42:32.993 - 0 clients connected (0 slaves), 987424 bytes in use
145
+ [26640] 11 Apr 18:42:38.026 - DB 0: 5 keys (0 volatile) in 8 slots HT.
146
+ [26640] 11 Apr 18:42:38.027 - 0 clients connected (0 slaves), 987424 bytes in use
147
+ [26640] 11 Apr 18:42:43.058 - DB 0: 5 keys (0 volatile) in 8 slots HT.
148
+ [26640] 11 Apr 18:42:43.059 - 0 clients connected (0 slaves), 987424 bytes in use
149
+ [26640] 11 Apr 18:42:48.091 - DB 0: 5 keys (0 volatile) in 8 slots HT.
150
+ [26640] 11 Apr 18:42:48.092 - 0 clients connected (0 slaves), 987424 bytes in use
151
+ [26640] 11 Apr 18:42:53.121 - DB 0: 5 keys (0 volatile) in 8 slots HT.
152
+ [26640] 11 Apr 18:42:53.121 - 0 clients connected (0 slaves), 987424 bytes in use
153
+ [26640] 11 Apr 18:42:58.145 - DB 0: 5 keys (0 volatile) in 8 slots HT.
154
+ [26640] 11 Apr 18:42:58.145 - 0 clients connected (0 slaves), 987424 bytes in use
155
+ [26640] 11 Apr 18:43:03.176 - DB 0: 5 keys (0 volatile) in 8 slots HT.
156
+ [26640] 11 Apr 18:43:03.176 - 0 clients connected (0 slaves), 987424 bytes in use
157
+ [26640] 11 Apr 18:43:08.201 - DB 0: 5 keys (0 volatile) in 8 slots HT.
158
+ [26640] 11 Apr 18:43:08.201 - 0 clients connected (0 slaves), 987424 bytes in use
159
+ [26640] 11 Apr 18:43:13.231 - DB 0: 5 keys (0 volatile) in 8 slots HT.
160
+ [26640] 11 Apr 18:43:13.231 - 0 clients connected (0 slaves), 987424 bytes in use
161
+ [26640] 11 Apr 18:43:18.262 - DB 0: 5 keys (0 volatile) in 8 slots HT.
162
+ [26640] 11 Apr 18:43:18.262 - 0 clients connected (0 slaves), 987424 bytes in use
163
+ [26640] 11 Apr 18:43:23.293 - DB 0: 5 keys (0 volatile) in 8 slots HT.
164
+ [26640] 11 Apr 18:43:23.293 - 0 clients connected (0 slaves), 987424 bytes in use
165
+ [26640] 11 Apr 18:43:28.323 - DB 0: 5 keys (0 volatile) in 8 slots HT.
166
+ [26640] 11 Apr 18:43:28.323 - 0 clients connected (0 slaves), 987424 bytes in use
167
+ [26640] 11 Apr 18:43:33.353 - DB 0: 5 keys (0 volatile) in 8 slots HT.
168
+ [26640] 11 Apr 18:43:33.354 - 0 clients connected (0 slaves), 987424 bytes in use
169
+ [26640] 11 Apr 18:43:38.382 - DB 0: 5 keys (0 volatile) in 8 slots HT.
170
+ [26640] 11 Apr 18:43:38.382 - 0 clients connected (0 slaves), 987424 bytes in use
171
+ [26640] 11 Apr 18:43:43.410 - DB 0: 5 keys (0 volatile) in 8 slots HT.
172
+ [26640] 11 Apr 18:43:43.411 - 0 clients connected (0 slaves), 987424 bytes in use
173
+ [26640] 11 Apr 18:43:48.435 - DB 0: 5 keys (0 volatile) in 8 slots HT.
174
+ [26640] 11 Apr 18:43:48.435 - 0 clients connected (0 slaves), 987424 bytes in use
175
+ [26640] 11 Apr 18:43:53.469 - DB 0: 5 keys (0 volatile) in 8 slots HT.
176
+ [26640] 11 Apr 18:43:53.470 - 0 clients connected (0 slaves), 987424 bytes in use
177
+ [26640] 11 Apr 18:43:58.496 - DB 0: 5 keys (0 volatile) in 8 slots HT.
178
+ [26640] 11 Apr 18:43:58.496 - 0 clients connected (0 slaves), 987424 bytes in use
179
+ [26640] 11 Apr 18:44:03.531 - DB 0: 5 keys (0 volatile) in 8 slots HT.
180
+ [26640] 11 Apr 18:44:03.531 - 0 clients connected (0 slaves), 987424 bytes in use
@@ -0,0 +1,12 @@
1
+ require File.join(File.dirname(__FILE__), %w[spec_helper])
2
+
3
+ describe Timeline do
4
+ it("can set a redis instance") { Timeline.should respond_to(:redis=) }
5
+ it("has a namespace, timeline") { Timeline.redis.namespace.should == :timeline }
6
+
7
+ it "sets the namespace through a url-like string" do
8
+ Timeline.redis = 'localhost:9736/namespace'
9
+ Timeline.redis.namespace.should == 'namespace'
10
+ end
11
+ end
12
+
@@ -0,0 +1,139 @@
1
+ require File.join(File.dirname(__FILE__), %w[spec_helper])
2
+
3
+ require 'active_model'
4
+
5
+ class Post
6
+ extend ActiveModel::Callbacks
7
+
8
+ define_model_callbacks :create
9
+ attr_accessor :id, :to_param, :creator_id, :name
10
+
11
+ include Timeline::Track
12
+ track :new_post
13
+
14
+ def initialize(options={})
15
+ @creator_id = options.delete :creator_id
16
+ @name = options.delete :name
17
+ end
18
+
19
+ def save
20
+ run_callbacks :create
21
+ true
22
+ end
23
+
24
+ def creator
25
+ User.find(creator_id)
26
+ end
27
+
28
+ def to_s
29
+ name
30
+ end
31
+ end
32
+
33
+ class Comment
34
+ extend ActiveModel::Callbacks
35
+
36
+ define_model_callbacks :create
37
+ attr_accessor :id, :creator_id, :body
38
+
39
+ include Timeline::Track
40
+
41
+ track :new_comment, object: [:post_name, :post_id, :body], mentionable: :body
42
+
43
+ def initialize(options={})
44
+ @creator_id = options.delete :creator_id
45
+ @body = options.delete :body
46
+ end
47
+
48
+ def save
49
+ run_callbacks :create
50
+ true
51
+ end
52
+
53
+ def post_id
54
+ 1
55
+ end
56
+
57
+ def post_name
58
+ "My Post"
59
+ end
60
+
61
+ def creator
62
+ User.find(creator_id)
63
+ end
64
+
65
+ def to_s
66
+ "Comment"
67
+ end
68
+ end
69
+
70
+ class User
71
+ include Timeline::Actor
72
+ attr_accessor :id, :to_param, :username
73
+
74
+ def initialize(options={})
75
+ @id = options.delete :id
76
+ @username = options.delete :username
77
+ end
78
+
79
+ class << self
80
+ def find user_id
81
+ User.new(id: user_id)
82
+ end
83
+
84
+ def find_by_username username
85
+ User.new(username: username)
86
+ end
87
+ end
88
+ end
89
+
90
+ describe Timeline::Track do
91
+ let(:creator) { User.new(id: 1, username: "first_user") }
92
+ let(:post) { Post.new(creator_id: creator.id, name: "New post") }
93
+ let(:comment) { Comment.new(creator_id: creator.id, id: 1) }
94
+
95
+ describe "included in an ActiveModel-compliant class" do
96
+ it "tracks on create by default" do
97
+ post.should_receive(:track_new_post_after_create)
98
+ post.save
99
+ end
100
+
101
+ it "uses the creator as the actor by default" do
102
+ post.should_receive(:creator).and_return(mock("User", id: 1, to_param: "1", followers: []))
103
+ post.save
104
+ end
105
+
106
+ it "adds the activity to the global timeline set" do
107
+ post.save
108
+ creator.timeline(:global).last.should be_kind_of(Timeline::Activity)
109
+ end
110
+
111
+ it "adds the activity to the actor's timeline" do
112
+ post.save
113
+ creator.timeline.last.should be_kind_of(Timeline::Activity)
114
+ end
115
+
116
+ it "cc's the actor's followers by default" do
117
+ follower = User.new(id: 2)
118
+ User.any_instance.should_receive(:followers).and_return([follower])
119
+ post.save
120
+ follower.timeline.last.verb.should == "new_post"
121
+ follower.timeline.last.actor.id.should == 1
122
+ end
123
+ end
124
+
125
+ describe "with extra_fields" do
126
+ it "stores the extra fields in the timeline" do
127
+ comment.save
128
+ creator.timeline.first.object.should respond_to :post_id
129
+ end
130
+ end
131
+
132
+ describe "tracking mentions" do
133
+ it "adds to a user's mentions timeline" do
134
+ User.stub(:find_by_username).and_return(creator)
135
+ Comment.new(creator_id: creator.id, body: "@first_user should see this").save
136
+ creator.timeline(:mentions).first.object.body.should == "@first_user should see this"
137
+ end
138
+ end
139
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redis_timeline
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Felix Clack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activemodel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: redis
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: hashie
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
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: redis-namespace
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sqlite3
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: ''
140
+ email:
141
+ - felixclack@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - MIT-LICENSE
147
+ - README.md
148
+ - Rakefile
149
+ - lib/redis_timeline.rb
150
+ - lib/tasks/timeline_tasks.rake
151
+ - lib/timeline/activity.rb
152
+ - lib/timeline/actor.rb
153
+ - lib/timeline/config.rb
154
+ - lib/timeline/helpers.rb
155
+ - lib/timeline/track.rb
156
+ - lib/timeline/version.rb
157
+ - spec/activity_spec.rb
158
+ - spec/actor_spec.rb
159
+ - spec/dump.rdb
160
+ - spec/redis-test.conf
161
+ - spec/spec_helper.rb
162
+ - spec/stdout
163
+ - spec/timeline_spec.rb
164
+ - spec/track_spec.rb
165
+ homepage: http://felixclack.github.com/redis-timeline
166
+ licenses: []
167
+ metadata: {}
168
+ post_install_message:
169
+ rdoc_options: []
170
+ require_paths:
171
+ - lib
172
+ required_ruby_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ requirements: []
183
+ rubyforge_project:
184
+ rubygems_version: 2.2.0
185
+ signing_key:
186
+ specification_version: 4
187
+ summary: Redis backed timeline for your activity feeds.
188
+ test_files:
189
+ - spec/activity_spec.rb
190
+ - spec/actor_spec.rb
191
+ - spec/dump.rdb
192
+ - spec/redis-test.conf
193
+ - spec/spec_helper.rb
194
+ - spec/stdout
195
+ - spec/timeline_spec.rb
196
+ - spec/track_spec.rb