amistad 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
amistad (0.9.
|
4
|
+
amistad (0.9.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
@@ -48,6 +48,8 @@ GEM
|
|
48
48
|
pg (0.14.1)
|
49
49
|
plucky (0.5.2)
|
50
50
|
mongo (~> 1.5)
|
51
|
+
polyamorous (0.5.0)
|
52
|
+
activerecord (~> 3.0)
|
51
53
|
rake (0.9.2.2)
|
52
54
|
rspec (2.11.0)
|
53
55
|
rspec-core (~> 2.11.0)
|
@@ -60,6 +62,10 @@ GEM
|
|
60
62
|
rspec-mocks (2.11.3)
|
61
63
|
ruby-progressbar (1.0.2)
|
62
64
|
sqlite3 (1.3.6)
|
65
|
+
squeel (1.0.11)
|
66
|
+
activerecord (~> 3.0)
|
67
|
+
activesupport (~> 3.0)
|
68
|
+
polyamorous (~> 0.5.0)
|
63
69
|
tzinfo (0.3.33)
|
64
70
|
|
65
71
|
PLATFORMS
|
@@ -80,3 +86,4 @@ DEPENDENCIES
|
|
80
86
|
rake
|
81
87
|
rspec
|
82
88
|
sqlite3
|
89
|
+
squeel
|
data/amistad.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_development_dependency "fuubar"
|
28
28
|
s.add_development_dependency "awesome_print"
|
29
29
|
s.add_development_dependency "mongo_mapper"
|
30
|
+
s.add_development_dependency "squeel"
|
30
31
|
|
31
32
|
s.files = `git ls-files`.split("\n")
|
32
33
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'squeel'
|
2
|
+
|
1
3
|
module Amistad
|
2
4
|
module ActiveRecordFriendModel
|
3
5
|
extend ActiveSupport::Concern
|
@@ -72,13 +74,33 @@ module Amistad
|
|
72
74
|
def remove_friendship(user)
|
73
75
|
friendship = find_any_friendship_with(user)
|
74
76
|
return false if friendship.nil?
|
75
|
-
friendship.destroy
|
77
|
+
friendship.destroy
|
78
|
+
self.reload && user.reload if friendship.destroyed?
|
76
79
|
end
|
77
80
|
|
78
81
|
# returns the list of approved friends
|
79
82
|
def friends
|
80
|
-
|
81
|
-
|
83
|
+
friendship_model = Amistad::Friendships.const_get(:"#{Amistad.friendship_model}")
|
84
|
+
|
85
|
+
approved_friendships = friendship_model.where{
|
86
|
+
( friendable_id == my{id} ) &
|
87
|
+
( pending == false ) &
|
88
|
+
( blocker_id == nil )
|
89
|
+
}
|
90
|
+
|
91
|
+
approved_inverse_friendships = friendship_model.where{
|
92
|
+
( friend_id == my{id} ) &
|
93
|
+
( pending == false ) &
|
94
|
+
( blocker_id == nil )
|
95
|
+
}
|
96
|
+
|
97
|
+
predicate = self.class.where{
|
98
|
+
( id.in(approved_friendships.select{friend_id}) ) |
|
99
|
+
( id.in(approved_inverse_friendships.select{friendable_id}) )
|
100
|
+
}
|
101
|
+
|
102
|
+
# puts predicate.to_sql
|
103
|
+
predicate
|
82
104
|
end
|
83
105
|
|
84
106
|
# total # of invited and invited_by without association loading
|
data/lib/amistad/version.rb
CHANGED
@@ -166,6 +166,7 @@ shared_examples_for "a friend model" do
|
|
166
166
|
@mary.friends.size.should == 1
|
167
167
|
@mary.friends.should include(@victoria)
|
168
168
|
@mary.invited_by.should include(@victoria)
|
169
|
+
|
169
170
|
@victoria.remove_friendship(@mary).should be_true
|
170
171
|
@victoria.friends.size.should == 2
|
171
172
|
@victoria.friends.should_not include(@mary)
|
@@ -182,6 +183,7 @@ shared_examples_for "a friend model" do
|
|
182
183
|
@james.friends.size.should == 2
|
183
184
|
@james.friends.should include(@victoria)
|
184
185
|
@james.invited.should include(@victoria)
|
186
|
+
|
185
187
|
@victoria.remove_friendship(@james).should be_true
|
186
188
|
@victoria.friends.size.should == 2
|
187
189
|
@victoria.friends.should_not include(@james)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amistad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -219,6 +219,22 @@ dependencies:
|
|
219
219
|
- - ! '>='
|
220
220
|
- !ruby/object:Gem::Version
|
221
221
|
version: '0'
|
222
|
+
- !ruby/object:Gem::Dependency
|
223
|
+
name: squeel
|
224
|
+
requirement: !ruby/object:Gem::Requirement
|
225
|
+
none: false
|
226
|
+
requirements:
|
227
|
+
- - ! '>='
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
none: false
|
234
|
+
requirements:
|
235
|
+
- - ! '>='
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: '0'
|
222
238
|
description: Extends your user model with friendships management methods
|
223
239
|
email:
|
224
240
|
- dev@raw1z.fr
|
@@ -277,7 +293,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
277
293
|
version: '0'
|
278
294
|
segments:
|
279
295
|
- 0
|
280
|
-
hash:
|
296
|
+
hash: -1868389087235153998
|
281
297
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
282
298
|
none: false
|
283
299
|
requirements:
|
@@ -286,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
286
302
|
version: '0'
|
287
303
|
segments:
|
288
304
|
- 0
|
289
|
-
hash:
|
305
|
+
hash: -1868389087235153998
|
290
306
|
requirements: []
|
291
307
|
rubyforge_project: amistad
|
292
308
|
rubygems_version: 1.8.23
|