socialization 0.5.0.beta → 0.5.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -2
- data/demo/app/models/follow.rb +2 -1
- data/demo/app/models/like.rb +1 -1
- data/demo/app/models/mention.rb +1 -1
- data/lib/generators/socialization/templates/active_record/model_follow.rb +1 -1
- data/lib/generators/socialization/templates/active_record/model_like.rb +1 -1
- data/lib/generators/socialization/templates/active_record/model_mention.rb +1 -1
- data/lib/generators/socialization/templates/redis/model_follow.rb +2 -0
- data/lib/generators/socialization/templates/redis/model_like.rb +2 -0
- data/lib/generators/socialization/templates/redis/model_mention.rb +2 -0
- data/lib/socialization.rb +17 -2
- data/lib/socialization/actors/follower.rb +13 -3
- data/lib/socialization/actors/liker.rb +13 -3
- data/lib/socialization/actors/mentioner.rb +13 -3
- data/lib/socialization/{config.rb → config/config.rb} +0 -0
- data/lib/socialization/{acts_as_helpers.rb → helpers/acts_as_helpers.rb} +0 -4
- data/lib/socialization/stores/active_record/{follow_store.rb → follow.rb} +4 -8
- data/lib/socialization/stores/active_record/{like_store.rb → like.rb} +4 -8
- data/lib/socialization/stores/active_record/{mention_store.rb → mention.rb} +4 -8
- data/lib/socialization/stores/active_record/mixins/base.rb +9 -0
- data/lib/socialization/stores/mixins/base.rb +10 -0
- data/lib/socialization/stores/mixins/follow.rb +8 -0
- data/lib/socialization/stores/mixins/like.rb +8 -0
- data/lib/socialization/stores/mixins/mention.rb +8 -0
- data/lib/socialization/stores/redis/base.rb +0 -2
- data/lib/socialization/stores/redis/{follow_store.rb → follow.rb} +5 -2
- data/lib/socialization/stores/redis/{like_store.rb → like.rb} +5 -2
- data/lib/socialization/stores/redis/{mention_store.rb → mention.rb} +5 -2
- data/lib/socialization/stores/redis/mixins/base.rb +8 -0
- data/lib/socialization/version.rb +1 -1
- data/lib/socialization/victims/followable.rb +10 -2
- data/lib/socialization/victims/likeable.rb +11 -2
- data/lib/socialization/victims/mentionable.rb +11 -2
- data/test/actors/follower_test.rb +22 -0
- data/test/actors/liker_test.rb +22 -0
- data/test/actors/mentioner_test.rb +21 -0
- data/test/stores/active_record/follow_store_test.rb +3 -3
- data/test/stores/active_record/like_store_test.rb +4 -4
- data/test/stores/active_record/mention_store_test.rb +3 -3
- data/test/stores/redis/follow_store_test.rb +3 -3
- data/test/stores/redis/like_store_test.rb +3 -3
- data/test/stores/redis/mention_store_test.rb +3 -3
- data/test/string_test.rb +1 -1
- data/test/test_helper.rb +9 -9
- data/test/victims/followable_test.rb +8 -0
- data/test/victims/likeable_test.rb +7 -0
- data/test/victims/mentionable_test.rb +8 -1
- metadata +21 -11
data/CHANGELOG.md
CHANGED
@@ -2,11 +2,14 @@
|
|
2
2
|
|
3
3
|
## 0.5.0.beta (June 6, 2012)
|
4
4
|
|
5
|
-
* **
|
6
|
-
*
|
5
|
+
* **IMPORTANT:** This release includes many changes, some breaking. Make sure to test your code carefully after upgrading.
|
6
|
+
* **BREAKING CHANGE:** Your Like, Follow and Mention models should now inherit the Socialization store base class instead of using the acts_as helper. (e.g.: class Follow < Socialization::ActiveRecordStores::Follow). See demo app for an example.
|
7
|
+
* **BREAKING CHANGE:** the `followers`, `followables` etc methods now return an array of objects. Use methods such as `followers_relation` for an ActiveRecord::Relation.
|
8
|
+
* Changed: The persistence logic has now been moved to the Socialization::ActiveRecordStores namespace. More stores can be easily added.
|
7
9
|
* Changed: `like!`, `follow!`, and `mention!` now return a boolean. True when the action was successful, false when it wasn't (e.g.: the relationship already exists).
|
8
10
|
* Changed: `unlike!`, `unfollow!` and `unmention!` will now return false if there is no record to destroy rather than raising `ActiveRecord::RecordNotFound`.
|
9
11
|
* Changed: Records can now like, follow or mention themselves. If you want to prevent this, it should be enforced directly in your application.
|
12
|
+
* Added: Data can now be stored in Redis.
|
10
13
|
* Added: `toggle_like!`, `toggle_follow!` and `toggle_mention!` methods. Thanks to [@balvig](https://github.com/balvig).
|
11
14
|
* Added: support for single table inheritance. Thanks to [@balvig](https://github.com/balvig).
|
12
15
|
|
data/demo/app/models/follow.rb
CHANGED
data/demo/app/models/like.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
class Like < Socialization::ActiveRecordStores::
|
1
|
+
class Like < Socialization::ActiveRecordStores::Like
|
2
2
|
end
|
data/demo/app/models/mention.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
class Mention < Socialization::ActiveRecordStores::
|
1
|
+
class Mention < Socialization::ActiveRecordStores::Mention
|
2
2
|
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
class Follow < Socialization::ActiveRecordStores::
|
1
|
+
class Follow < Socialization::ActiveRecordStores::Follow
|
2
2
|
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
class Like < Socialization::ActiveRecordStores::
|
1
|
+
class Like < Socialization::ActiveRecordStores::Like
|
2
2
|
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
class Mention < Socialization::ActiveRecordStores::
|
1
|
+
class Mention < Socialization::ActiveRecordStores::Mention
|
2
2
|
end
|
data/lib/socialization.rb
CHANGED
@@ -1,4 +1,19 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
%w(
|
2
|
+
stores/mixins/base.rb
|
3
|
+
stores/mixins/**/*.rb
|
4
|
+
stores/active_record/mixins/base.rb
|
5
|
+
stores/active_record/mixins/**/*.rb
|
6
|
+
stores/redis/mixins/base.rb
|
7
|
+
stores/redis/mixins/**/*.rb
|
8
|
+
stores/active_record/**/*.rb
|
9
|
+
stores/redis/base.rb
|
10
|
+
stores/redis/**/*.rb
|
11
|
+
actors/**/*.rb
|
12
|
+
victims/**/*.rb
|
13
|
+
helpers/**/*.rb
|
14
|
+
config/**/*.rb
|
15
|
+
).each do |path|
|
16
|
+
Dir["#{File.dirname(__FILE__)}/socialization/#{path}"].each { |f| require(f) }
|
17
|
+
end
|
3
18
|
|
4
19
|
ActiveRecord::Base.send :include, Socialization::ActsAsHelpers
|
@@ -18,7 +18,7 @@ module Socialization
|
|
18
18
|
true
|
19
19
|
end
|
20
20
|
|
21
|
-
# Create a new {
|
21
|
+
# Create a new {Follow follow} relationship.
|
22
22
|
#
|
23
23
|
# @param [Followable] followable the object to be followed.
|
24
24
|
# @return [Boolean]
|
@@ -27,7 +27,7 @@ module Socialization
|
|
27
27
|
Socialization.follow_model.follow!(self, followable)
|
28
28
|
end
|
29
29
|
|
30
|
-
# Delete a {
|
30
|
+
# Delete a {Follow follow} relationship.
|
31
31
|
#
|
32
32
|
# @param [Followable] followable the object to unfollow.
|
33
33
|
# @return [Boolean]
|
@@ -36,7 +36,7 @@ module Socialization
|
|
36
36
|
Socialization.follow_model.unfollow!(self, followable)
|
37
37
|
end
|
38
38
|
|
39
|
-
# Toggles a {
|
39
|
+
# Toggles a {Follow follow} relationship.
|
40
40
|
#
|
41
41
|
# @param [Followable] followable the object to follow/unfollow.
|
42
42
|
# @return [Boolean]
|
@@ -68,7 +68,17 @@ module Socialization
|
|
68
68
|
def followables(klass, opts = {})
|
69
69
|
Socialization.follow_model.followables(self, klass, opts)
|
70
70
|
end
|
71
|
+
alias :followees :followables
|
71
72
|
|
73
|
+
# Returns a relation for all the followables of a certain type that are followed by self
|
74
|
+
#
|
75
|
+
# @params [Followable] klass the type of {Followable} you want
|
76
|
+
# @params [Hash] opts a hash of options
|
77
|
+
# @return ActiveRecord::Relation
|
78
|
+
def followables_relation(klass, opts = {})
|
79
|
+
Socialization.follow_model.followables_relation(self, klass, opts)
|
80
|
+
end
|
81
|
+
alias :followees_relation :followables_relation
|
72
82
|
end
|
73
83
|
end
|
74
84
|
end
|
@@ -18,7 +18,7 @@ module Socialization
|
|
18
18
|
true
|
19
19
|
end
|
20
20
|
|
21
|
-
# Create a new {
|
21
|
+
# Create a new {Like like} relationship.
|
22
22
|
#
|
23
23
|
# @param [Likeable] likeable the object to be liked.
|
24
24
|
# @return [Boolean]
|
@@ -27,7 +27,7 @@ module Socialization
|
|
27
27
|
Socialization.like_model.like!(self, likeable)
|
28
28
|
end
|
29
29
|
|
30
|
-
# Delete a {
|
30
|
+
# Delete a {Like like} relationship.
|
31
31
|
#
|
32
32
|
# @param [Likeable] likeable the object to unlike.
|
33
33
|
# @return [Boolean]
|
@@ -36,7 +36,7 @@ module Socialization
|
|
36
36
|
Socialization.like_model.unlike!(self, likeable)
|
37
37
|
end
|
38
38
|
|
39
|
-
# Toggles a {
|
39
|
+
# Toggles a {Like like} relationship.
|
40
40
|
#
|
41
41
|
# @param [Likeable] likeable the object to like/unlike.
|
42
42
|
# @return [Boolean]
|
@@ -68,7 +68,17 @@ module Socialization
|
|
68
68
|
def likeables(klass, opts = {})
|
69
69
|
Socialization.like_model.likeables(self, klass, opts)
|
70
70
|
end
|
71
|
+
alias :likees :likeables
|
71
72
|
|
73
|
+
# Returns a relation for all the likeables of a certain type that are liked by self
|
74
|
+
#
|
75
|
+
# @params [Likeable] klass the type of {Likeable} you want
|
76
|
+
# @params [Hash] opts a hash of options
|
77
|
+
# @return ActiveRecord::Relation
|
78
|
+
def likeables_relation(klass, opts = {})
|
79
|
+
Socialization.like_model.likeables_relation(self, klass, opts)
|
80
|
+
end
|
81
|
+
alias :likees_relation :likeables_relation
|
72
82
|
end
|
73
83
|
end
|
74
84
|
end
|
@@ -18,7 +18,7 @@ module Socialization
|
|
18
18
|
true
|
19
19
|
end
|
20
20
|
|
21
|
-
# Create a new {
|
21
|
+
# Create a new {Mention mention} relationship.
|
22
22
|
#
|
23
23
|
# @param [Mentionable] mentionable the object to be mentioned.
|
24
24
|
# @return [Boolean]
|
@@ -27,7 +27,7 @@ module Socialization
|
|
27
27
|
Socialization.mention_model.mention!(self, mentionable)
|
28
28
|
end
|
29
29
|
|
30
|
-
# Delete a {
|
30
|
+
# Delete a {Mention mention} relationship.
|
31
31
|
#
|
32
32
|
# @param [Mentionable] mentionable the object to unmention.
|
33
33
|
# @return [Boolean]
|
@@ -36,7 +36,7 @@ module Socialization
|
|
36
36
|
Socialization.mention_model.unmention!(self, mentionable)
|
37
37
|
end
|
38
38
|
|
39
|
-
# Toggles a {
|
39
|
+
# Toggles a {Mention mention} relationship.
|
40
40
|
#
|
41
41
|
# @param [Mentionable] mentionable the object to mention/unmention.
|
42
42
|
# @return [Boolean]
|
@@ -68,7 +68,17 @@ module Socialization
|
|
68
68
|
def mentionables(klass, opts = {})
|
69
69
|
Socialization.mention_model.mentionables(self, klass, opts)
|
70
70
|
end
|
71
|
+
alias :mentionees :mentionables
|
71
72
|
|
73
|
+
# Returns a relation for all the mentionables of a certain type that are mentioned by self
|
74
|
+
#
|
75
|
+
# @params [Mentionable] klass the type of {Mentionable} you want
|
76
|
+
# @params [Hash] opts a hash of options
|
77
|
+
# @return ActiveRecord::Relation
|
78
|
+
def mentionables_relation(klass, opts = {})
|
79
|
+
Socialization.mention_model.mentionables_relation(self, klass, opts)
|
80
|
+
end
|
81
|
+
alias :mentionees_relation :mentionables_relation
|
72
82
|
end
|
73
83
|
end
|
74
84
|
end
|
File without changes
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module Socialization
|
2
2
|
module ActiveRecordStores
|
3
|
-
class
|
3
|
+
class Follow < ActiveRecord::Base
|
4
|
+
include Socialization::ActiveRecordStores::Mixins::Base
|
5
|
+
include Socialization::Stores::Mixins::Follow
|
6
|
+
|
4
7
|
belongs_to :follower, :polymorphic => true
|
5
8
|
belongs_to :followable, :polymorphic => true
|
6
9
|
|
@@ -14,14 +17,7 @@ module Socialization
|
|
14
17
|
:followable_id => followable.id)
|
15
18
|
}
|
16
19
|
|
17
|
-
@@after_create_hook = nil
|
18
|
-
@@after_destroy_hook = nil
|
19
|
-
|
20
20
|
class << self
|
21
|
-
def table_name
|
22
|
-
'follows'
|
23
|
-
end
|
24
|
-
|
25
21
|
def follow!(follower, followable)
|
26
22
|
unless follows?(follower, followable)
|
27
23
|
self.create! do |follow|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module Socialization
|
2
2
|
module ActiveRecordStores
|
3
|
-
class
|
3
|
+
class Like < ActiveRecord::Base
|
4
|
+
include Socialization::ActiveRecordStores::Mixins::Base
|
5
|
+
include Socialization::Stores::Mixins::Like
|
6
|
+
|
4
7
|
belongs_to :liker, :polymorphic => true
|
5
8
|
belongs_to :likeable, :polymorphic => true
|
6
9
|
|
@@ -14,14 +17,7 @@ module Socialization
|
|
14
17
|
:likeable_id => likeable.id)
|
15
18
|
}
|
16
19
|
|
17
|
-
@@after_create_hook = nil
|
18
|
-
@@after_destroy_hook = nil
|
19
|
-
|
20
20
|
class << self
|
21
|
-
def table_name
|
22
|
-
'likes'
|
23
|
-
end
|
24
|
-
|
25
21
|
def like!(liker, likeable)
|
26
22
|
unless likes?(liker, likeable)
|
27
23
|
self.create! do |like|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module Socialization
|
2
2
|
module ActiveRecordStores
|
3
|
-
class
|
3
|
+
class Mention < ActiveRecord::Base
|
4
|
+
include Socialization::ActiveRecordStores::Mixins::Base
|
5
|
+
include Socialization::Stores::Mixins::Mention
|
6
|
+
|
4
7
|
belongs_to :mentioner, :polymorphic => true
|
5
8
|
belongs_to :mentionable, :polymorphic => true
|
6
9
|
|
@@ -14,14 +17,7 @@ module Socialization
|
|
14
17
|
:mentionable_id => mentionable.id)
|
15
18
|
}
|
16
19
|
|
17
|
-
@@after_create_hook = nil
|
18
|
-
@@after_destroy_hook = nil
|
19
|
-
|
20
20
|
class << self
|
21
|
-
def table_name
|
22
|
-
'mentions'
|
23
|
-
end
|
24
|
-
|
25
21
|
def mention!(mentioner, mentionable)
|
26
22
|
unless mentions?(mentioner, mentionable)
|
27
23
|
self.create! do |mention|
|
@@ -1,8 +1,11 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__)) + '/base'
|
1
|
+
# require File.expand_path(File.dirname(__FILE__)) + '/base'
|
2
2
|
|
3
3
|
module Socialization
|
4
4
|
module RedisStores
|
5
|
-
class
|
5
|
+
class Follow < Socialization::RedisStores::Base
|
6
|
+
include Socialization::RedisStores::Mixins::Base
|
7
|
+
include Socialization::Stores::Mixins::Follow
|
8
|
+
|
6
9
|
class << self
|
7
10
|
def follow!(follower, followable)
|
8
11
|
unless follows?(follower, followable)
|
@@ -1,8 +1,11 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__)) + '/base'
|
1
|
+
# require File.expand_path(File.dirname(__FILE__)) + '/base'
|
2
2
|
|
3
3
|
module Socialization
|
4
4
|
module RedisStores
|
5
|
-
class
|
5
|
+
class Like < Socialization::RedisStores::Base
|
6
|
+
include Socialization::RedisStores::Mixins::Base
|
7
|
+
include Socialization::Stores::Mixins::Follow
|
8
|
+
|
6
9
|
class << self
|
7
10
|
def like!(liker, likeable)
|
8
11
|
unless likes?(liker, likeable)
|
@@ -1,8 +1,11 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__)) + '/base'
|
1
|
+
# require File.expand_path(File.dirname(__FILE__)) + '/base'
|
2
2
|
|
3
3
|
module Socialization
|
4
4
|
module RedisStores
|
5
|
-
class
|
5
|
+
class Mention < Socialization::RedisStores::Base
|
6
|
+
include Socialization::RedisStores::Mixins::Base
|
7
|
+
include Socialization::Stores::Mixins::Mention
|
8
|
+
|
6
9
|
class << self
|
7
10
|
def mention!(mentioner, mentionable)
|
8
11
|
unless mentions?(mentioner, mentionable)
|
@@ -26,13 +26,21 @@ module Socialization
|
|
26
26
|
Socialization.follow_model.follows?(follower, self)
|
27
27
|
end
|
28
28
|
|
29
|
-
# Returns
|
29
|
+
# Returns an array of {Follower}s following self.
|
30
30
|
#
|
31
|
-
# @param [Class] klass the {Follower} class to be included
|
31
|
+
# @param [Class] klass the {Follower} class to be included. e.g. `User`
|
32
32
|
# @return [Array<Follower, Numeric>] An array of Follower objects or IDs
|
33
33
|
def followers(klass, opts = {})
|
34
34
|
Socialization.follow_model.followers(self, klass, opts)
|
35
35
|
end
|
36
|
+
|
37
|
+
# Returns a scope of the {Follower}s following self.
|
38
|
+
#
|
39
|
+
# @param [Class] klass the {Follower} class to be included in the scope. e.g. `User`
|
40
|
+
# @return ActiveRecord::Relation
|
41
|
+
def followers_relation(klass, opts = {})
|
42
|
+
Socialization.follow_model.followers_relation(self, klass, opts)
|
43
|
+
end
|
36
44
|
end
|
37
45
|
end
|
38
46
|
end
|
@@ -26,13 +26,22 @@ module Socialization
|
|
26
26
|
Socialization.like_model.likes?(liker, self)
|
27
27
|
end
|
28
28
|
|
29
|
-
# Returns
|
29
|
+
# Returns an array of {Liker}s liking self.
|
30
30
|
#
|
31
|
-
# @param [Class] klass the {Liker} class to be included
|
31
|
+
# @param [Class] klass the {Liker} class to be included. e.g. `User`
|
32
32
|
# @return [Array<Liker, Numeric>] An array of Liker objects or IDs
|
33
33
|
def likers(klass, opts = {})
|
34
34
|
Socialization.like_model.likers(self, klass, opts)
|
35
35
|
end
|
36
|
+
|
37
|
+
# Returns a scope of the {Liker}s liking self.
|
38
|
+
#
|
39
|
+
# @param [Class] klass the {Liker} class to be included in the scope. e.g. `User`
|
40
|
+
# @return ActiveRecord::Relation
|
41
|
+
def likers_relation(klass, opts = {})
|
42
|
+
Socialization.like_model.likers_relation(self, klass, opts)
|
43
|
+
end
|
44
|
+
|
36
45
|
end
|
37
46
|
end
|
38
47
|
end
|
@@ -26,13 +26,22 @@ module Socialization
|
|
26
26
|
Socialization.mention_model.mentions?(mentioner, self)
|
27
27
|
end
|
28
28
|
|
29
|
-
# Returns
|
29
|
+
# Returns an array of {Mentioner}s mentioning self.
|
30
30
|
#
|
31
|
-
# @param [Class] klass the {Mentioner} class to be included
|
31
|
+
# @param [Class] klass the {Mentioner} class to be included. e.g. `User`
|
32
32
|
# @return [Array<Mentioner, Numeric>] An array of Mentioner objects or IDs
|
33
33
|
def mentioners(klass, opts = {})
|
34
34
|
Socialization.mention_model.mentioners(self, klass, opts)
|
35
35
|
end
|
36
|
+
|
37
|
+
# Returns a scope of the {Mentioner}s mentioning self.
|
38
|
+
#
|
39
|
+
# @param [Class] klass the {Mentioner} class to be included in the scope. e.g. `User`
|
40
|
+
# @return ActiveRecord::Relation
|
41
|
+
def mentioners_relation(klass, opts = {})
|
42
|
+
Socialization.mention_model.mentioners_relation(self, klass, opts)
|
43
|
+
end
|
44
|
+
|
36
45
|
end
|
37
46
|
end
|
38
47
|
end
|
@@ -70,5 +70,27 @@ class FollowerTest < Test::Unit::TestCase
|
|
70
70
|
@follower.followables(@followable.class, { :foo => :bar })
|
71
71
|
end
|
72
72
|
end
|
73
|
+
|
74
|
+
context "#followees" do
|
75
|
+
should "call $Follow.followables" do
|
76
|
+
$Follow.expects(:followables).with(@follower, @followable.class, { :foo => :bar })
|
77
|
+
@follower.followees(@followable.class, { :foo => :bar })
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "#followables_relation" do
|
82
|
+
should "call $Follow.followables_relation" do
|
83
|
+
$Follow.expects(:followables_relation).with(@follower, @followable.class, { :foo => :bar })
|
84
|
+
@follower.followables_relation(@followable.class, { :foo => :bar })
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "#followees_relation" do
|
89
|
+
should "call $Follow.followables_relation" do
|
90
|
+
$Follow.expects(:followables_relation).with(@follower, @followable.class, { :foo => :bar })
|
91
|
+
@follower.followees_relation(@followable.class, { :foo => :bar })
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
73
95
|
end
|
74
96
|
end
|
data/test/actors/liker_test.rb
CHANGED
@@ -70,5 +70,27 @@ class LikerTest < Test::Unit::TestCase
|
|
70
70
|
@liker.likeables(@likeable.class, { :foo => :bar })
|
71
71
|
end
|
72
72
|
end
|
73
|
+
|
74
|
+
context "#likees" do
|
75
|
+
should "call $Like.likeables" do
|
76
|
+
$Like.expects(:likeables).with(@liker, @likeable.class, { :foo => :bar })
|
77
|
+
@liker.likees(@likeable.class, { :foo => :bar })
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "#likeables_relation" do
|
82
|
+
should "call $Follow.likeables_relation" do
|
83
|
+
$Like.expects(:likeables_relation).with(@liker, @likeable.class, { :foo => :bar })
|
84
|
+
@liker.likeables_relation(@likeable.class, { :foo => :bar })
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "#likees_relation" do
|
89
|
+
should "call $Follow.likeables_relation" do
|
90
|
+
$Like.expects(:likeables_relation).with(@liker, @likeable.class, { :foo => :bar })
|
91
|
+
@liker.likees_relation(@likeable.class, { :foo => :bar })
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
73
95
|
end
|
74
96
|
end
|
@@ -70,5 +70,26 @@ class MentionerTest < Test::Unit::TestCase
|
|
70
70
|
@mentioner.mentionables(@mentionable.class, { :foo => :bar })
|
71
71
|
end
|
72
72
|
end
|
73
|
+
|
74
|
+
context "#mentionees" do
|
75
|
+
should "call $Mention.mentionables" do
|
76
|
+
$Mention.expects(:mentionables).with(@mentioner, @mentionable.class, { :foo => :bar })
|
77
|
+
@mentioner.mentionees(@mentionable.class, { :foo => :bar })
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "#mentionables_relation" do
|
82
|
+
should "call $Mention.mentionables_relation" do
|
83
|
+
$Mention.expects(:mentionables_relation).with(@mentioner, @mentionable.class, { :foo => :bar })
|
84
|
+
@mentioner.mentionables_relation(@mentionable.class, { :foo => :bar })
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "#mentionees_relation" do
|
89
|
+
should "call $Mention.mentionables_relation" do
|
90
|
+
$Mention.expects(:mentionables_relation).with(@mentioner, @mentionable.class, { :foo => :bar })
|
91
|
+
@mentioner.mentionees_relation(@mentionable.class, { :foo => :bar })
|
92
|
+
end
|
93
|
+
end
|
73
94
|
end
|
74
95
|
end
|
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__))+'/../../test_helper'
|
|
3
3
|
class ActiveRecordFollowStoreTest < Test::Unit::TestCase
|
4
4
|
context "ActiveRecordStores::FollowStoreTest" do
|
5
5
|
setup do
|
6
|
-
@klass = Socialization::ActiveRecordStores::
|
6
|
+
@klass = Socialization::ActiveRecordStores::Follow
|
7
7
|
@klass.touch nil
|
8
8
|
@klass.after_follow nil
|
9
9
|
@klass.after_unfollow nil
|
@@ -12,8 +12,8 @@ class ActiveRecordFollowStoreTest < Test::Unit::TestCase
|
|
12
12
|
end
|
13
13
|
|
14
14
|
context "data store" do
|
15
|
-
should "inherit Socialization::ActiveRecordStores::
|
16
|
-
assert_equal Socialization::ActiveRecordStores::
|
15
|
+
should "inherit Socialization::ActiveRecordStores::Follow" do
|
16
|
+
assert_equal Socialization::ActiveRecordStores::Follow, Socialization.follow_model
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__))+'/../../test_helper'
|
2
2
|
|
3
3
|
class ActiveRecordLikeStoreTest < Test::Unit::TestCase
|
4
|
-
context "
|
4
|
+
context "ActiveRecordStores::LikeStoreTest" do
|
5
5
|
setup do
|
6
|
-
@klass = Socialization::ActiveRecordStores::
|
6
|
+
@klass = Socialization::ActiveRecordStores::Like
|
7
7
|
@klass.touch nil
|
8
8
|
@klass.after_like nil
|
9
9
|
@klass.after_unlike nil
|
@@ -12,8 +12,8 @@ class ActiveRecordLikeStoreTest < Test::Unit::TestCase
|
|
12
12
|
end
|
13
13
|
|
14
14
|
context "data store" do
|
15
|
-
should "inherit Socialization::ActiveRecordStores::
|
16
|
-
assert_equal Socialization::ActiveRecordStores::
|
15
|
+
should "inherit Socialization::ActiveRecordStores::Like" do
|
16
|
+
assert_equal Socialization::ActiveRecordStores::Like, Socialization.like_model
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__))+'/../../test_helper'
|
|
3
3
|
class ActiveRecordMentionStoreTest < Test::Unit::TestCase
|
4
4
|
context "ActiveRecordStores::MentionStoreTest" do
|
5
5
|
setup do
|
6
|
-
@klass = Socialization::ActiveRecordStores::
|
6
|
+
@klass = Socialization::ActiveRecordStores::Mention
|
7
7
|
@klass.touch nil
|
8
8
|
@klass.after_mention nil
|
9
9
|
@klass.after_unmention nil
|
@@ -12,8 +12,8 @@ class ActiveRecordMentionStoreTest < Test::Unit::TestCase
|
|
12
12
|
end
|
13
13
|
|
14
14
|
context "data store" do
|
15
|
-
should "inherit Socialization::ActiveRecordStores::
|
16
|
-
assert_equal Socialization::ActiveRecordStores::
|
15
|
+
should "inherit Socialization::ActiveRecordStores::Mention" do
|
16
|
+
assert_equal Socialization::ActiveRecordStores::Mention, Socialization.mention_model
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -4,7 +4,7 @@ class RedisFollowStoreTest < Test::Unit::TestCase
|
|
4
4
|
context "RedisStores::FollowStoreTest" do
|
5
5
|
setup do
|
6
6
|
use_redis_store
|
7
|
-
@klass = Socialization::RedisStores::
|
7
|
+
@klass = Socialization::RedisStores::Follow
|
8
8
|
@klass.touch nil
|
9
9
|
@klass.after_follow nil
|
10
10
|
@klass.after_unfollow nil
|
@@ -13,8 +13,8 @@ class RedisFollowStoreTest < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
context "Stores" do
|
16
|
-
should "inherit Socialization::RedisStores::
|
17
|
-
assert_equal Socialization::RedisStores::
|
16
|
+
should "inherit Socialization::RedisStores::Follow" do
|
17
|
+
assert_equal Socialization::RedisStores::Follow, Socialization.follow_model
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -4,7 +4,7 @@ class RedisLikeStoreTest < Test::Unit::TestCase
|
|
4
4
|
context "RedisStores::LikeStoreTest" do
|
5
5
|
setup do
|
6
6
|
use_redis_store
|
7
|
-
@klass = Socialization::RedisStores::
|
7
|
+
@klass = Socialization::RedisStores::Like
|
8
8
|
@klass.touch nil
|
9
9
|
@klass.after_like nil
|
10
10
|
@klass.after_unlike nil
|
@@ -13,8 +13,8 @@ class RedisLikeStoreTest < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
context "Stores" do
|
16
|
-
should "inherit Socialization::RedisStores::
|
17
|
-
assert_equal Socialization::RedisStores::
|
16
|
+
should "inherit Socialization::RedisStores::Like" do
|
17
|
+
assert_equal Socialization::RedisStores::Like, Socialization.like_model
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -4,7 +4,7 @@ class RedisMentionStoreTest < Test::Unit::TestCase
|
|
4
4
|
context "RedisStores::MentionStoreTest" do
|
5
5
|
setup do
|
6
6
|
use_redis_store
|
7
|
-
@klass = Socialization::RedisStores::
|
7
|
+
@klass = Socialization::RedisStores::Mention
|
8
8
|
@klass.touch nil
|
9
9
|
@klass.after_mention nil
|
10
10
|
@klass.after_unmention nil
|
@@ -13,8 +13,8 @@ class RedisMentionStoreTest < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
context "Stores" do
|
16
|
-
should "inherit Socialization::RedisStores::
|
17
|
-
assert_equal Socialization::RedisStores::
|
16
|
+
should "inherit Socialization::RedisStores::Mention" do
|
17
|
+
assert_equal Socialization::RedisStores::Mention, Socialization.mention_model
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/test/string_test.rb
CHANGED
@@ -5,7 +5,7 @@ class StringTest < Test::Unit::TestCase
|
|
5
5
|
should "return a class" do
|
6
6
|
assert_equal Socialization, "Socialization".deep_const_get
|
7
7
|
assert_equal Socialization::ActiveRecordStores, "Socialization::ActiveRecordStores".deep_const_get
|
8
|
-
assert_equal Socialization::ActiveRecordStores::
|
8
|
+
assert_equal Socialization::ActiveRecordStores::Follow, "Socialization::ActiveRecordStores::Follow".deep_const_get
|
9
9
|
|
10
10
|
assert_raise(NameError) { "Foo::Bar".deep_const_get }
|
11
11
|
end
|
data/test/test_helper.rb
CHANGED
@@ -42,16 +42,16 @@ class Test::Unit::TestCase
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def use_redis_store
|
45
|
-
Socialization.follow_model = Socialization::RedisStores::
|
46
|
-
Socialization.mention_model = Socialization::RedisStores::
|
47
|
-
Socialization.like_model = Socialization::RedisStores::
|
45
|
+
Socialization.follow_model = Socialization::RedisStores::Follow
|
46
|
+
Socialization.mention_model = Socialization::RedisStores::Mention
|
47
|
+
Socialization.like_model = Socialization::RedisStores::Like
|
48
48
|
setup_model_shortcuts
|
49
49
|
end
|
50
50
|
|
51
51
|
def use_ar_store
|
52
|
-
Socialization.follow_model = Socialization::ActiveRecordStores::
|
53
|
-
Socialization.mention_model = Socialization::ActiveRecordStores::
|
54
|
-
Socialization.like_model = Socialization::ActiveRecordStores::
|
52
|
+
Socialization.follow_model = Socialization::ActiveRecordStores::Follow
|
53
|
+
Socialization.mention_model = Socialization::ActiveRecordStores::Mention
|
54
|
+
Socialization.like_model = Socialization::ActiveRecordStores::Like
|
55
55
|
setup_model_shortcuts
|
56
56
|
end
|
57
57
|
|
@@ -176,9 +176,9 @@ class Movie < ActiveRecord::Base
|
|
176
176
|
has_many :comments
|
177
177
|
end
|
178
178
|
|
179
|
-
# class Follow < Socialization::ActiveRecordStores::
|
180
|
-
# class Like < Socialization::ActiveRecordStores::
|
181
|
-
# class Mention < Socialization::ActiveRecordStores::
|
179
|
+
# class Follow < Socialization::ActiveRecordStores::Follow; end
|
180
|
+
# class Like < Socialization::ActiveRecordStores::Like; end
|
181
|
+
# class Mention < Socialization::ActiveRecordStores::Mention; end
|
182
182
|
|
183
183
|
class ImAFollower < ActiveRecord::Base
|
184
184
|
acts_as_follower
|
@@ -30,5 +30,13 @@ class FollowableTest < Test::Unit::TestCase
|
|
30
30
|
@followable.followers(@follower.class, { :foo => :bar })
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
context "#followers_relation" do
|
35
|
+
should "call $Follow.followers_relation" do
|
36
|
+
$Follow.expects(:followers_relation).with(@followable, @follower.class, { :foo => :bar })
|
37
|
+
@followable.followers_relation(@follower.class, { :foo => :bar })
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
33
41
|
end
|
34
42
|
end
|
@@ -30,5 +30,12 @@ class LikeableTest < Test::Unit::TestCase
|
|
30
30
|
@likeable.likers(@liker.class, { :foo => :bar })
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
context "#likers_relation" do
|
35
|
+
should "call $Like.likers_relation" do
|
36
|
+
$Like.expects(:likers_relation).with(@likeable, @liker.class, { :foo => :bar })
|
37
|
+
@likeable.likers_relation(@liker.class, { :foo => :bar })
|
38
|
+
end
|
39
|
+
end
|
33
40
|
end
|
34
41
|
end
|
@@ -25,10 +25,17 @@ class MentionableTest < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
context "#mentioners" do
|
28
|
-
should "call $
|
28
|
+
should "call $Mention.mentioners" do
|
29
29
|
$Mention.expects(:mentioners).with(@mentionable, @mentioner.class, { :foo => :bar })
|
30
30
|
@mentionable.mentioners(@mentioner.class, { :foo => :bar })
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
context "#mentioners_relation" do
|
35
|
+
should "call $Mention.mentioners" do
|
36
|
+
$Mention.expects(:mentioners_relation).with(@mentionable, @mentioner.class, { :foo => :bar })
|
37
|
+
@mentionable.mentioners_relation(@mentioner.class, { :foo => :bar })
|
38
|
+
end
|
39
|
+
end
|
33
40
|
end
|
34
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socialization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: -1564876628
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
|
11
|
+
- 2
|
12
|
+
version: 0.5.0.beta2
|
12
13
|
platform: ruby
|
13
14
|
authors:
|
14
15
|
- Carl Mercier
|
@@ -16,7 +17,7 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2012-06-
|
20
|
+
date: 2012-06-08 00:00:00 -04:00
|
20
21
|
default_executable:
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
@@ -224,21 +225,30 @@ files:
|
|
224
225
|
- lib/generators/socialization/templates/active_record/model_follow.rb
|
225
226
|
- lib/generators/socialization/templates/active_record/model_like.rb
|
226
227
|
- lib/generators/socialization/templates/active_record/model_mention.rb
|
228
|
+
- lib/generators/socialization/templates/redis/model_follow.rb
|
229
|
+
- lib/generators/socialization/templates/redis/model_like.rb
|
230
|
+
- lib/generators/socialization/templates/redis/model_mention.rb
|
227
231
|
- lib/socialization.rb
|
228
232
|
- lib/socialization/actors/follower.rb
|
229
233
|
- lib/socialization/actors/liker.rb
|
230
234
|
- lib/socialization/actors/mentioner.rb
|
231
|
-
- lib/socialization/
|
232
|
-
- lib/socialization/
|
235
|
+
- lib/socialization/config/config.rb
|
236
|
+
- lib/socialization/helpers/acts_as_helpers.rb
|
233
237
|
- lib/socialization/helpers/string.rb
|
234
|
-
- lib/socialization/stores/active_record/
|
235
|
-
- lib/socialization/stores/active_record/
|
236
|
-
- lib/socialization/stores/active_record/
|
238
|
+
- lib/socialization/stores/active_record/follow.rb
|
239
|
+
- lib/socialization/stores/active_record/like.rb
|
240
|
+
- lib/socialization/stores/active_record/mention.rb
|
241
|
+
- lib/socialization/stores/active_record/mixins/base.rb
|
242
|
+
- lib/socialization/stores/mixins/base.rb
|
243
|
+
- lib/socialization/stores/mixins/follow.rb
|
244
|
+
- lib/socialization/stores/mixins/like.rb
|
245
|
+
- lib/socialization/stores/mixins/mention.rb
|
237
246
|
- lib/socialization/stores/redis/base.rb
|
238
247
|
- lib/socialization/stores/redis/config.rb
|
239
|
-
- lib/socialization/stores/redis/
|
240
|
-
- lib/socialization/stores/redis/
|
241
|
-
- lib/socialization/stores/redis/
|
248
|
+
- lib/socialization/stores/redis/follow.rb
|
249
|
+
- lib/socialization/stores/redis/like.rb
|
250
|
+
- lib/socialization/stores/redis/mention.rb
|
251
|
+
- lib/socialization/stores/redis/mixins/base.rb
|
242
252
|
- lib/socialization/version.rb
|
243
253
|
- lib/socialization/victims/followable.rb
|
244
254
|
- lib/socialization/victims/likeable.rb
|