amico 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,21 +1,27 @@
1
- # 2.0.1
1
+ # CHANGELOG
2
+
3
+ ## 2.1.0 (2012-08-20)
4
+
5
+ * Added `count(id, type, scope = Amico.default_scope_key)` and `page_count(id, type, page_size = Amico.page_size, scope = Amico.default_scope_key)` as convenience methods for retrieving the count or the page count for the various types of relationships.
6
+
7
+ ## 2.0.1 (2012-03-14)
2
8
 
3
9
  * Added `Amico.all(id, type, scope)` to retrieve all of the individuals for a given id, type (e.g. following) and scope. Thanks to @mettadore for the initial code and inspiration.
4
10
  * Clarified parameters in following, followers, blocked, reciprocated, and pending calls.
5
11
 
6
- # 2.0.0
12
+ ## 2.0.0 (2012-02-28)
7
13
 
8
14
  * Added `Amico.default_scope_key` and `scope` parameter to all of the methods to allow you to scope the calls to express relationships for different types of things
9
15
 
10
- # 1.2.0
16
+ ## 1.2.0 (2012-02-22)
11
17
 
12
18
  * Added pending to relationships
13
19
 
14
- # 1.1.0
20
+ ## 1.1.0 (2012-01-13)
15
21
 
16
22
  * Added blocking to relationships
17
23
  * Added reciprocated to relationships
18
24
 
19
- # 1.0.0 (2012-01-11)
25
+ ## 1.0.0 (2012-01-11)
20
26
 
21
27
  * Initial release
data/README.md CHANGED
@@ -12,9 +12,9 @@ or in your `Gemfile`
12
12
  gem 'amico'
13
13
  ```
14
14
 
15
- Make sure your redis server is running! Redis configuration is outside the scope of this README, but
15
+ Make sure your redis server is running! Redis configuration is outside the scope of this README, but
16
16
  check out the Redis documentation, http://redis.io/documentation.
17
-
17
+
18
18
  ## Usage
19
19
 
20
20
  Configure amico:
@@ -38,7 +38,7 @@ Use amico:
38
38
 
39
39
  ```ruby
40
40
  require 'amico'
41
- => true
41
+ => true
42
42
 
43
43
  Amico.configure do |configuration|
44
44
  configuration.redis = Redis.new
@@ -54,34 +54,34 @@ Amico.configure do |configuration|
54
54
  end
55
55
 
56
56
  Amico.follow(1, 11)
57
- => [1, 1]
57
+ => [1, 1]
58
58
 
59
59
  Amico.following?(1, 11)
60
- => true
60
+ => true
61
61
 
62
62
  Amico.following?(11, 1)
63
- => false
63
+ => false
64
64
 
65
65
  Amico.follow(11, 1)
66
- => [1, 1]
66
+ => [1, 1]
67
67
 
68
68
  Amico.following?(11, 1)
69
- => true
69
+ => true
70
70
 
71
71
  Amico.following_count(1)
72
- => 1
72
+ => 1
73
73
 
74
74
  Amico.followers_count(1)
75
- => 1
75
+ => 1
76
76
 
77
77
  Amico.unfollow(11, 1)
78
- => [1, 1]
78
+ => [1, 1]
79
79
 
80
80
  Amico.following_count(11)
81
- => 0
81
+ => 0
82
82
 
83
83
  Amico.following_count(1)
84
- => 1
84
+ => 1
85
85
 
86
86
  Amico.follower?(1, 11)
87
87
  => false
@@ -90,13 +90,13 @@ Amico.following(1)
90
90
  => ["11"]
91
91
 
92
92
  Amico.block(1, 11)
93
- => [1, 1, 1, 1, 1]
93
+ => [1, 1, 1, 1, 1]
94
94
 
95
95
  Amico.following?(11, 1)
96
- => false
96
+ => false
97
97
 
98
98
  Amico.blocked?(1, 11)
99
- => true
99
+ => true
100
100
 
101
101
  Amico.unblock(1, 11)
102
102
  => true
@@ -121,7 +121,7 @@ Use amico (with pending relationships for follow):
121
121
 
122
122
  ```ruby
123
123
  require 'amico'
124
- => true
124
+ => true
125
125
 
126
126
  Amico.configure do |configuration|
127
127
  configuration.redis = Redis.new
@@ -137,68 +137,68 @@ Amico.configure do |configuration|
137
137
  end
138
138
 
139
139
  Amico.follow(1, 11)
140
- => true
140
+ => true
141
141
 
142
142
  Amico.follow(11, 1)
143
- => true
143
+ => true
144
144
 
145
145
  Amico.pending?(1, 11)
146
- => true
146
+ => true
147
147
 
148
148
  Amico.pending?(11, 1)
149
- => true
149
+ => true
150
150
 
151
151
  Amico.accept(1, 11)
152
- => nil
152
+ => nil
153
153
 
154
154
  Amico.pending?(1, 11)
155
- => false
155
+ => false
156
156
 
157
157
  Amico.pending?(11, 1)
158
- => true
158
+ => true
159
159
 
160
160
  Amico.following?(1, 11)
161
- => true
161
+ => true
162
162
 
163
163
  Amico.following?(11, 1)
164
- => false
164
+ => false
165
165
 
166
166
  Amico.follower?(11, 1)
167
- => true
167
+ => true
168
168
 
169
169
  Amico.follower?(1, 11)
170
- => false
170
+ => false
171
171
 
172
172
  Amico.accept(11, 1)
173
- => [1, 1]
173
+ => [1, 1]
174
174
 
175
175
  Amico.pending?(1, 11)
176
- => false
176
+ => false
177
177
 
178
178
  Amico.pending?(11, 1)
179
- => false
179
+ => false
180
180
 
181
181
  Amico.following?(1, 11)
182
- => true
182
+ => true
183
183
 
184
184
  Amico.following?(11, 1)
185
- => true
185
+ => true
186
186
 
187
187
  Amico.follower?(11, 1)
188
- => true
188
+ => true
189
189
 
190
190
  Amico.follower?(1, 11)
191
- => true
192
-
191
+ => true
192
+
193
193
  Amico.reciprocated?(1, 11)
194
- => true
194
+ => true
195
195
  ```
196
196
 
197
197
  Use amico with nicknames instead of IDs. NOTE: This could cause you much hardship later on if you allow nicknames to change.
198
198
 
199
199
  ```ruby
200
200
  require 'amico'
201
-
201
+
202
202
  Amico.configure do |configuration|
203
203
  configuration.redis = Redis.new
204
204
  configuration.namespace = 'amico'
@@ -213,23 +213,23 @@ Amico.configure do |configuration|
213
213
  end
214
214
 
215
215
  Amico.follow('bob', 'jane')
216
-
216
+
217
217
  Amico.following?('bob', 'jane')
218
- => true
218
+ => true
219
219
 
220
220
  Amico.following?('jane', 'bob')
221
- => false
221
+ => false
222
222
 
223
223
  Amico.follow('jane', 'bob')
224
224
 
225
225
  Amico.following?('jane', 'bob')
226
- => true
226
+ => true
227
227
 
228
228
  Amico.following_count('bob')
229
- => 1
229
+ => 1
230
230
 
231
231
  Amico.followers_count('bob')
232
- => 1
232
+ => 1
233
233
 
234
234
  Amico.unfollow('jane', 'bob')
235
235
 
@@ -237,55 +237,55 @@ Amico.following_count('jane')
237
237
  => 0
238
238
 
239
239
  Amico.following_count('bob')
240
- => 1
240
+ => 1
241
241
 
242
242
  Amico.follower?('bob', 'jane')
243
- => false
243
+ => false
244
244
 
245
245
  Amico.follower?('jane', 'bob')
246
- => true
246
+ => true
247
247
 
248
248
  Amico.following('bob')
249
- => ["jane"]
249
+ => ["jane"]
250
250
 
251
251
  Amico.block('bob', 'jane')
252
252
 
253
253
  Amico.following?('jane', 'bob')
254
- => false
254
+ => false
255
255
 
256
256
  Amico.blocked?('bob', 'jane')
257
- => true
257
+ => true
258
258
 
259
259
  Amico.blocked?('jane', 'bob')
260
- => false
260
+ => false
261
261
 
262
262
  Amico.unblock('bob', 'jane')
263
- => true
263
+ => true
264
264
 
265
- mico.blocked?('bob', 'jane')
266
- => false
265
+ Amico.blocked?('bob', 'jane')
266
+ => false
267
267
 
268
268
  Amico.following?('jane', 'bob')
269
- => false
269
+ => false
270
270
 
271
271
  Amico.follow('jane', 'bob')
272
- => nil
272
+ => nil
273
273
 
274
274
  Amico.follow('bob', 'jane')
275
- => [1, 1]
275
+ => [1, 1]
276
276
 
277
277
  Amico.reciprocated?('bob', 'jane')
278
- => true
278
+ => true
279
279
 
280
280
  Amico.reciprocated('bob')
281
- => ["jane"]
281
+ => ["jane"]
282
282
  ```
283
283
 
284
284
  Use amico with nicknames instead of IDs and pending follows. NOTE: This could cause you much hardship later on if you allow nicknames to change.
285
285
 
286
286
  ```ruby
287
287
  require 'amico'
288
- => true
288
+ => true
289
289
 
290
290
  Amico.configure do |configuration|
291
291
  configuration.redis = Redis.new
@@ -305,53 +305,53 @@ Amico.follow('bob', 'jane')
305
305
  Amico.follow('jane', 'bob')
306
306
 
307
307
  Amico.pending?('bob', 'jane')
308
- => true
308
+ => true
309
309
 
310
310
  Amico.pending?('jane', 'bob')
311
- => true
311
+ => true
312
312
 
313
313
  Amico.accept('bob', 'jane')
314
314
 
315
315
  Amico.pending?('bob', 'jane')
316
- => false
316
+ => false
317
317
 
318
318
  Amico.pending?('jane', 'bob')
319
- => true
319
+ => true
320
320
 
321
321
  Amico.following?('bob', 'jane')
322
- => true
322
+ => true
323
323
 
324
324
  Amico.following?('jane', 'bob')
325
- => false
325
+ => false
326
326
 
327
327
  Amico.follower?('jane', 'bob')
328
- => true
328
+ => true
329
329
 
330
330
  Amico.follower?('bob', 'jane')
331
- => false
331
+ => false
332
332
 
333
333
  Amico.accept('jane', 'bob')
334
334
 
335
335
  Amico.pending?('bob', 'jane')
336
- => false
336
+ => false
337
337
 
338
338
  Amico.pending?('jane', 'bob')
339
- => false
339
+ => false
340
340
 
341
341
  Amico.following?('bob', 'jane')
342
- => true
342
+ => true
343
343
 
344
344
  Amico.following?('jane', 'bob')
345
- => true
345
+ => true
346
346
 
347
347
  Amico.follower?('jane', 'bob')
348
- => true
348
+ => true
349
349
 
350
350
  Amico.follower?('bob', 'jane')
351
- => true
351
+ => true
352
352
 
353
353
  Amico.reciprocated?('bob', 'jane')
354
- => true
354
+ => true
355
355
  ```
356
356
 
357
357
  All of the calls support a `scope` parameter to allow you to scope the calls to express relationships for different types of things. For example:
@@ -375,24 +375,24 @@ end
375
375
  Amico.follow(1, 11)
376
376
 
377
377
  Amico.following?(1, 11)
378
- => true
378
+ => true
379
379
 
380
380
  Amico.following?(1, 11, 'user')
381
- => true
381
+ => true
382
382
 
383
383
  Amico.following(1)
384
- => ["11"]
384
+ => ["11"]
385
385
 
386
386
  Amico.following(1, {:page_size => Amico.page_size, :page => 1}, 'user')
387
- => ["11"]
387
+ => ["11"]
388
388
 
389
389
  Amico.following?(1, 11, 'project')
390
- => false
390
+ => false
391
391
 
392
392
  Amico.follow(1, 11, 'project')
393
393
 
394
394
  Amico.following?(1, 11, 'project')
395
- => true
395
+ => true
396
396
 
397
397
  Amico.following(1, {:page_size => Amico.page_size, :page => 1}, 'project')
398
398
  => ["11"]
@@ -402,37 +402,105 @@ You can retrieve all of a particular type of relationship using the `all(id, typ
402
402
 
403
403
  ```ruby
404
404
  Amico.follow(1, 11)
405
- => nil
405
+ => nil
406
406
  Amico.follow(1, 12)
407
- => nil
407
+ => nil
408
408
  Amico.all(1, :following)
409
- => ["12", "11"]
409
+ => ["12", "11"]
410
410
  ```
411
411
 
412
- `type` can be one of :following, :followers, :blocked, :reciprocated, :pending. Use this with caution
413
- as there may potentially be a large number of items that could be returned from this call.
412
+ `type` can be one of :following, :followers, :blocked, :reciprocated, :pending. Use this with caution
413
+ as there may potentially be a large number of items that could be returned from this call.
414
414
 
415
- ## Documentation
415
+ ## Method Summary
416
416
 
417
- The source for the [relationships module](https://github.com/agoragames/amico/blob/master/lib/amico/relationships.rb) is well-documented. There are some
418
- simple examples in the method documentation. You can also refer to the [online documentation](http://rubydoc.info/github/agoragames/amico/master/frames).
417
+ ```ruby
418
+ # Relations
419
+
420
+ # Establish a follow relationship between two IDs.
421
+ follow(from_id, to_id, scope = Amico.default_scope_key)
422
+ # Remove a follow relationship between two IDs.
423
+ unfollow(from_id, to_id, scope = Amico.default_scope_key)
424
+ # Block a relationship between two IDs.
425
+ block(from_id, to_id, scope = Amico.default_scope_key)
426
+ # Unblock a relationship between two IDs.
427
+ unblock(from_id, to_id, scope = Amico.default_scope_key)
428
+ # Accept a relationship that is pending between two IDs.
429
+ accept(from_id, to_id, scope = Amico.default_scope_key)
430
+
431
+ # Retrieval
432
+
433
+ # Retrieve a page of followed individuals for a given ID.
434
+ following(id, page_options = default_paging_options, scope = Amico.default_scope_key)
435
+ # Retrieve a page of followers for a given ID.
436
+ followers(id, page_options = default_paging_options, scope = Amico.default_scope_key)
437
+ # Retrieve a page of blocked individuals for a given ID.
438
+ blocked(id, page_options = default_paging_options, scope = Amico.default_scope_key)
439
+ # Retrieve a page of individuals that have reciprocated a follow for a given ID.
440
+ reciprocated(id, page_options = default_paging_options, scope = Amico.default_scope_key)
441
+ # Retrieve a page of pending relationships for a given ID.
442
+ pending(id, page_options = default_paging_options, scope = Amico.default_scope_key)
443
+
444
+ # Retrieve all of the individuals for a given id, type (e.g. following) and scope.
445
+ all(id, type, scope = Amico.default_scope_key)
446
+
447
+ # Counts
448
+
449
+ # Count the number of individuals that someone is following.
450
+ following_count(id, scope = Amico.default_scope_key)
451
+ # Count the number of individuals that are following someone.
452
+ followers_count(id, scope = Amico.default_scope_key)
453
+ # Count the number of individuals that someone has blocked.
454
+ blocked_count(id, scope = Amico.default_scope_key)
455
+ # Count the number of individuals that have reciprocated a following relationship.
456
+ reciprocated_count(id, scope = Amico.default_scope_key)
457
+ # Count the number of relationships pending for an individual.
458
+ pending_count(id, scope = Amico.default_scope_key)
459
+
460
+ # Count the number of pages of following relationships for an individual.
461
+ following_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)
462
+ # Count the number of pages of follower relationships for an individual.
463
+ followers_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)
464
+ # Count the number of pages of blocked relationships for an individual.
465
+ blocked_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)
466
+ # Count the number of pages of reciprocated relationships for an individual.
467
+ reciprocated_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)
468
+ # Count the number of pages of pending relationships for an individual.
469
+ pending_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)
470
+
471
+ # Checks
472
+
473
+ # Check to see if one individual is following another individual.
474
+ following?(id, following_id, scope = Amico.default_scope_key)
475
+ # Check to see if one individual is a follower of another individual.
476
+ follower?(id, follower_id, scope = Amico.default_scope_key)
477
+ # Check to see if one individual has blocked another individual.
478
+ blocked?(id, blocked_id, scope = Amico.default_scope_key)
479
+ # Check to see if one individual has reciprocated in following another individual.
480
+ reciprocated?(from_id, to_id, scope = Amico.default_scope_key)
481
+ # Check to see if one individual has a pending relationship in following another individual.
482
+ pending?(from_id, to_id, scope = Amico.default_scope_key)
483
+ ```
419
484
 
420
- ## Future Plans
485
+ ## Documentation
486
+
487
+ The source for the [relationships module](https://github.com/agoragames/amico/blob/master/lib/amico/relationships.rb) is well-documented. There are some
488
+ simple examples in the method documentation. You can also refer to the [online documentation](http://rubydoc.info/github/agoragames/amico/master/frames).
421
489
 
422
490
  ## FAQ?
423
491
 
424
492
  ### Why use Redis sorted sets and not Redis sets?
425
493
 
426
- Based on the work I did in developing [leaderboard](https://github.com/agoragames/leaderboard),
427
- leaderboards backed by Redis, I know I wanted to be able to page through the various relationships.
428
- This does not seem to be possible given the current set of commands for Redis sets.
494
+ Based on the work I did in developing [leaderboard](https://github.com/agoragames/leaderboard),
495
+ leaderboards backed by Redis, I know I wanted to be able to page through the various relationships.
496
+ This does not seem to be possible given the current set of commands for Redis sets.
429
497
 
430
- Also, by using the "score" in Redis sorted sets that is based on the time of when a relationship
431
- is established, we can get our "recent friends". It is possible that the scoring function may be
498
+ Also, by using the "score" in Redis sorted sets that is based on the time of when a relationship
499
+ is established, we can get our "recent friends". It is possible that the scoring function may be
432
500
  user-defined in the future to allow for some specific ordering.
433
-
501
+
434
502
  ## Contributing to amico
435
-
503
+
436
504
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
437
505
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
438
506
  * Fork the project