socialization 0.1.0 → 0.2.0
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.
- data/generators/socialization/USAGE +1 -1
- data/lib/socialization/followable.rb +1 -1
- data/lib/socialization/follower.rb +2 -2
- data/lib/socialization/likeable.rb +1 -1
- data/lib/socialization/liker.rb +2 -2
- data/lib/socialization/version.rb +1 -1
- data/test/follow_test.rb +5 -5
- data/test/like_test.rb +5 -5
- metadata +96 -67
@@ -1 +1 @@
|
|
1
|
-
Generates
|
1
|
+
Generates the Follow and Like models as well as their migrations.
|
@@ -11,7 +11,7 @@ module Socialization
|
|
11
11
|
|
12
12
|
def followed_by?(follower)
|
13
13
|
raise ArgumentError, "#{follower} is not a follower!" unless follower.respond_to?(:is_follower?) && follower.is_follower?
|
14
|
-
!self.followings.where(:follower_type => follower.class.to_s, :follower_id => follower.id).
|
14
|
+
!self.followings.where(:follower_type => follower.class.to_s, :follower_id => follower.id).empty?
|
15
15
|
end
|
16
16
|
|
17
17
|
def followers
|
@@ -11,7 +11,7 @@ module Socialization
|
|
11
11
|
|
12
12
|
def follow!(followable)
|
13
13
|
raise ArgumentError, "#{followable} is not followable!" unless followable.respond_to?(:is_followable?)
|
14
|
-
Follow.create! follower
|
14
|
+
Follow.create! :follower => self, :followable => followable
|
15
15
|
end
|
16
16
|
|
17
17
|
def unfollow!(followable)
|
@@ -22,7 +22,7 @@ module Socialization
|
|
22
22
|
|
23
23
|
def follows?(followable)
|
24
24
|
raise ArgumentError, "#{followable} is not followable!" unless followable.respond_to?(:is_followable?) && followable.is_followable?
|
25
|
-
!self.follows.where(:followable_type => followable.class.to_s, :followable_id => followable.id).
|
25
|
+
!self.follows.where(:followable_type => followable.class.to_s, :followable_id => followable.id).empty?
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
@@ -11,7 +11,7 @@ module Socialization
|
|
11
11
|
|
12
12
|
def liked_by?(liker)
|
13
13
|
raise ArgumentError, "#{liker} is not a liker!" unless liker.respond_to?(:is_liker?) && liker.is_liker?
|
14
|
-
!self.likings.where(:liker_type => liker.class.to_s, :liker_id => liker.id).
|
14
|
+
!self.likings.where(:liker_type => liker.class.to_s, :liker_id => liker.id).empty?
|
15
15
|
end
|
16
16
|
|
17
17
|
def likers
|
data/lib/socialization/liker.rb
CHANGED
@@ -11,7 +11,7 @@ module Socialization
|
|
11
11
|
|
12
12
|
def like!(likeable)
|
13
13
|
raise ArgumentError, "#{likeable} is not likeable!" unless likeable.respond_to?(:is_likeable?)
|
14
|
-
Like.create! liker
|
14
|
+
Like.create! :liker => self, :likeable => likeable
|
15
15
|
end
|
16
16
|
|
17
17
|
def unlike!(likeable)
|
@@ -22,7 +22,7 @@ module Socialization
|
|
22
22
|
|
23
23
|
def likes?(likeable)
|
24
24
|
raise ArgumentError, "#{likeable} is not likeable!" unless likeable.respond_to?(:is_likeable?) && likeable.is_likeable?
|
25
|
-
!self.likes.where(:likeable_type => likeable.class.to_s, :likeable_id => likeable.id).
|
25
|
+
!self.likes.where(:likeable_type => likeable.class.to_s, :likeable_id => likeable.id).empty?
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
data/test/follow_test.rb
CHANGED
@@ -2,11 +2,11 @@ require File.dirname(__FILE__)+'/test_helper'
|
|
2
2
|
|
3
3
|
class FollowTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@u_john = User.create name
|
6
|
-
@u_jane = User.create name
|
7
|
-
@c_chuck = Celebrity.create name
|
8
|
-
@c_uma = Celebrity.create name
|
9
|
-
@c_rick = Celebrity.create name
|
5
|
+
@u_john = User.create :name => 'John Doe'
|
6
|
+
@u_jane = User.create :name => 'Jane Doe'
|
7
|
+
@c_chuck = Celebrity.create :name => 'Chuck Norris'
|
8
|
+
@c_uma = Celebrity.create :name => 'Uma Thurman'
|
9
|
+
@c_rick = Celebrity.create :name => 'Rick Astley'
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_the_world
|
data/test/like_test.rb
CHANGED
@@ -2,11 +2,11 @@ require File.dirname(__FILE__)+'/test_helper'
|
|
2
2
|
|
3
3
|
class LikeTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@u_john = User.create name
|
6
|
-
@u_jane = User.create name
|
7
|
-
@m_seven = Movie.create name
|
8
|
-
@m_pulp = Movie.create name
|
9
|
-
@m_tub = Movie.create name
|
5
|
+
@u_john = User.create :name => 'John Doe'
|
6
|
+
@u_jane = User.create :name => 'Jane Doe'
|
7
|
+
@m_seven = Movie.create :name => 'Seven'
|
8
|
+
@m_pulp = Movie.create :name => 'Pulp Fiction'
|
9
|
+
@m_tub = Movie.create :name => 'Hot Tub Time Machine'
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_the_world
|
metadata
CHANGED
@@ -1,81 +1,102 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: socialization
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Carl Mercier
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-01-15 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
15
22
|
name: activerecord
|
16
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
25
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
22
33
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
26
36
|
name: appraisal
|
27
|
-
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
33
47
|
type: :development
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
37
50
|
name: logger
|
38
|
-
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
53
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
44
61
|
type: :development
|
45
|
-
|
46
|
-
|
47
|
-
- !ruby/object:Gem::Dependency
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
48
64
|
name: mocha
|
49
|
-
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
67
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
55
75
|
type: :development
|
56
|
-
|
57
|
-
|
58
|
-
- !ruby/object:Gem::Dependency
|
76
|
+
version_requirements: *id004
|
77
|
+
- !ruby/object:Gem::Dependency
|
59
78
|
name: sqlite3
|
60
|
-
|
79
|
+
prerelease: false
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
66
89
|
type: :development
|
67
|
-
|
68
|
-
|
69
|
-
description: Socialization allow any model to Follow and/or Like any other model.
|
70
|
-
This is accomplished through a double polymorphic relationship on the Follow and
|
71
|
-
Like models. But you don't need to know that since all the complexity is hidden
|
72
|
-
from you.
|
90
|
+
version_requirements: *id005
|
91
|
+
description: Socialization allow any model to Follow and/or Like any other model. This is accomplished through a double polymorphic relationship on the Follow and Like models. But you don't need to know that since all the complexity is hidden from you.
|
73
92
|
email: carl@carlmercier.com
|
74
93
|
executables: []
|
94
|
+
|
75
95
|
extensions: []
|
76
|
-
|
96
|
+
|
97
|
+
extra_rdoc_files:
|
77
98
|
- README.rdoc
|
78
|
-
files:
|
99
|
+
files:
|
79
100
|
- .gitignore
|
80
101
|
- Appraisals
|
81
102
|
- Gemfile
|
@@ -168,33 +189,41 @@ files:
|
|
168
189
|
- test/follow_test.rb
|
169
190
|
- test/like_test.rb
|
170
191
|
- test/test_helper.rb
|
192
|
+
has_rdoc: true
|
171
193
|
homepage: https://github.com/cmer/socialization
|
172
194
|
licenses: []
|
195
|
+
|
173
196
|
post_install_message:
|
174
|
-
rdoc_options:
|
197
|
+
rdoc_options:
|
175
198
|
- --charset=UTF-8
|
176
|
-
require_paths:
|
199
|
+
require_paths:
|
177
200
|
- lib
|
178
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
201
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
179
202
|
none: false
|
180
|
-
requirements:
|
181
|
-
- -
|
182
|
-
- !ruby/object:Gem::Version
|
183
|
-
|
184
|
-
|
203
|
+
requirements:
|
204
|
+
- - ">="
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
hash: 3
|
207
|
+
segments:
|
208
|
+
- 0
|
209
|
+
version: "0"
|
210
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
211
|
none: false
|
186
|
-
requirements:
|
187
|
-
- -
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
hash: 3
|
216
|
+
segments:
|
217
|
+
- 0
|
218
|
+
version: "0"
|
190
219
|
requirements: []
|
220
|
+
|
191
221
|
rubyforge_project:
|
192
|
-
rubygems_version: 1.
|
222
|
+
rubygems_version: 1.6.2
|
193
223
|
signing_key:
|
194
224
|
specification_version: 3
|
195
225
|
summary: Easily socialize your app with Likes and Follows
|
196
|
-
test_files:
|
226
|
+
test_files:
|
197
227
|
- test/follow_test.rb
|
198
228
|
- test/like_test.rb
|
199
229
|
- test/test_helper.rb
|
200
|
-
has_rdoc: true
|