partisan 0.2 → 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.
- data/LICENSE.md +23 -19
- data/README.md +6 -6
- data/lib/partisan/follow.rb +2 -2
- data/lib/partisan/followable.rb +2 -2
- data/lib/partisan/version.rb +1 -1
- data/partisan.gemspec +4 -4
- data/spec/followable_spec.rb +58 -1
- data/spec/follower_spec.rb +24 -72
- metadata +8 -6
data/LICENSE.md
CHANGED
@@ -1,22 +1,26 @@
|
|
1
|
-
Copyright (c) 2013
|
1
|
+
Copyright (c) 2013, Mirego
|
2
|
+
All rights reserved.
|
2
3
|
|
3
|
-
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
- Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
- Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
- Neither the name of the Mirego nor the names of its contributors may
|
13
|
+
be used to endorse or promote products derived from this software without
|
14
|
+
specific prior written permission.
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
19
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
20
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
|
+
POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -122,12 +122,12 @@ The available callbacks are:
|
|
122
122
|
|
123
123
|
#### Followable
|
124
124
|
|
125
|
-
| Callback
|
126
|
-
|
|
127
|
-
| `
|
128
|
-
| `
|
129
|
-
| `
|
130
|
-
| `
|
125
|
+
| Callback | Reference to the follower |
|
126
|
+
| --------------------------|----------------------------------|
|
127
|
+
| `before_being_followed` | `self.about_to_be_followed_by` |
|
128
|
+
| `after_being_followed` | `self.just_followed_by` |
|
129
|
+
| `before_being_unfollowed` | `self.about_to_by_unfollowed_by` |
|
130
|
+
| `after_being_unfollowed` | `self.just_unfollowed_by` |
|
131
131
|
|
132
132
|
## License
|
133
133
|
|
data/lib/partisan/follow.rb
CHANGED
@@ -24,7 +24,7 @@ module Partisan
|
|
24
24
|
# Followable's :follow callbacks
|
25
25
|
around_create do |follow, blk|
|
26
26
|
self.followable.about_to_be_followed_by = self.followable.just_followed_by = self.follower
|
27
|
-
self.followable.run_callbacks :
|
27
|
+
self.followable.run_callbacks :being_followed, &blk
|
28
28
|
self.followable.about_to_be_followed_by = self.followable.just_followed_by = nil
|
29
29
|
end
|
30
30
|
|
@@ -38,7 +38,7 @@ module Partisan
|
|
38
38
|
# Followable's :unfollow callbacks
|
39
39
|
around_destroy do |follow, blk|
|
40
40
|
self.followable.about_to_be_unfollowed_by = self.followable.just_unfollowed_by = self.follower
|
41
|
-
self.followable.run_callbacks :
|
41
|
+
self.followable.run_callbacks :being_unfollowed, &blk
|
42
42
|
self.followable.about_to_be_unfollowed_by = self.followable.just_unfollowed_by = nil
|
43
43
|
end
|
44
44
|
|
data/lib/partisan/followable.rb
CHANGED
@@ -7,8 +7,8 @@ module Partisan
|
|
7
7
|
|
8
8
|
included do
|
9
9
|
has_many :followings, as: :followable, class_name: 'Partisan::Follow', dependent: :destroy
|
10
|
-
define_model_callbacks :
|
11
|
-
define_model_callbacks :
|
10
|
+
define_model_callbacks :being_followed
|
11
|
+
define_model_callbacks :being_unfollowed
|
12
12
|
attr_accessor :about_to_be_followed_by, :just_followed_by, :about_to_be_unfollowed_by, :just_unfollowed_by
|
13
13
|
end
|
14
14
|
|
data/lib/partisan/version.rb
CHANGED
data/partisan.gemspec
CHANGED
@@ -6,11 +6,11 @@ require 'partisan/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'partisan'
|
8
8
|
spec.version = Partisan::VERSION
|
9
|
-
spec.authors = ['Simon Prévost']
|
10
|
-
spec.email = ['sprevost@mirego.com']
|
11
|
-
spec.description = 'Partisan is a Ruby library that allows ActiveRecord records to be follower and followable, just like on popular social networks. It’s heavily inspired by
|
9
|
+
spec.authors = ['Simon Prévost', 'Rémi Prévost']
|
10
|
+
spec.email = ['sprevost@mirego.com', 'Rémi Prévost']
|
11
|
+
spec.description = 'Partisan is a Ruby library that allows ActiveRecord records to be follower and followable, just like on popular social networks. It’s heavily inspired by acts_as_follower which is no longer maintened.'
|
12
12
|
spec.summary = 'Partisan is a Ruby library that allows ActiveRecord records to be follower and followable'
|
13
|
-
spec.homepage = 'https://github.com/
|
13
|
+
spec.homepage = 'https://github.com/mirego/partisan'
|
14
14
|
spec.license = 'BSD 3-Clause'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
data/spec/followable_spec.rb
CHANGED
@@ -70,5 +70,62 @@ describe Partisan::Followable do
|
|
70
70
|
it { expect(band.followers_count).to eq 1 }
|
71
71
|
end
|
72
72
|
end
|
73
|
-
end
|
74
73
|
|
74
|
+
describe :Callbacks do
|
75
|
+
before do
|
76
|
+
class Buffer
|
77
|
+
def self.tmp_value=(tmp_value)
|
78
|
+
@tmp_value = tmp_value
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.tmp_value
|
82
|
+
@tmp_value
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe :before_being_followed do
|
88
|
+
before do
|
89
|
+
followable 'Band' do
|
90
|
+
before_being_followed { Buffer.tmp_value = self.about_to_be_followed_by }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
it { expect{ user.follow(band) }.to change{ Buffer.tmp_value }.to(user) }
|
95
|
+
end
|
96
|
+
|
97
|
+
describe :after_being_followed do
|
98
|
+
before do
|
99
|
+
followable 'Band' do
|
100
|
+
after_being_followed { Buffer.tmp_value = self.just_followed_by }
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
it { expect{ user.follow(band) }.to change{ Buffer.tmp_value }.to(user) }
|
105
|
+
end
|
106
|
+
|
107
|
+
describe :before_being_unfollowed do
|
108
|
+
before do
|
109
|
+
followable 'Band' do
|
110
|
+
before_being_unfollowed { Buffer.tmp_value = self.about_to_be_unfollowed_by }
|
111
|
+
end
|
112
|
+
|
113
|
+
user.follow(band)
|
114
|
+
end
|
115
|
+
|
116
|
+
it { expect{ user.unfollow(band) }.to change{ Buffer.tmp_value }.to(user) }
|
117
|
+
end
|
118
|
+
|
119
|
+
describe :after_being_unfollowed do
|
120
|
+
before do
|
121
|
+
followable 'Band' do
|
122
|
+
after_being_unfollowed { Buffer.tmp_value = self.just_unfollowed_by }
|
123
|
+
end
|
124
|
+
|
125
|
+
user.follow(band)
|
126
|
+
end
|
127
|
+
|
128
|
+
it { expect{ user.unfollow(band) }.to change{ Buffer.tmp_value }.to(user) }
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
data/spec/follower_spec.rb
CHANGED
@@ -93,96 +93,48 @@ describe Partisan::Follower do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
describe
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
before_follow { Buffer.tmp_value = self.about_to_follow }
|
101
|
-
end
|
96
|
+
describe :before_follow do
|
97
|
+
before do
|
98
|
+
follower 'User' do
|
99
|
+
before_follow { Buffer.tmp_value = self.about_to_follow }
|
102
100
|
end
|
103
|
-
|
104
|
-
it { expect{ user.follow(band) }.to change{ Buffer.tmp_value }.to(band) }
|
105
|
-
end
|
106
|
-
|
107
|
-
describe :after_follow do
|
108
|
-
before do
|
109
|
-
follower 'User' do
|
110
|
-
after_follow { Buffer.tmp_value = self.just_followed }
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
it { expect{ user.follow(band) }.to change{ Buffer.tmp_value }.to(band) }
|
115
101
|
end
|
116
102
|
|
117
|
-
|
118
|
-
|
119
|
-
follower 'User' do
|
120
|
-
before_unfollow { Buffer.tmp_value = self.about_to_unfollow }
|
121
|
-
end
|
103
|
+
it { expect{ user.follow(band) }.to change{ Buffer.tmp_value }.to(band) }
|
104
|
+
end
|
122
105
|
|
123
|
-
|
106
|
+
describe :after_follow do
|
107
|
+
before do
|
108
|
+
follower 'User' do
|
109
|
+
after_follow { Buffer.tmp_value = self.just_followed }
|
124
110
|
end
|
125
|
-
|
126
|
-
it { expect{ user.unfollow(band) }.to change{ Buffer.tmp_value }.to(band) }
|
127
111
|
end
|
128
112
|
|
129
|
-
|
130
|
-
before do
|
131
|
-
follower 'User' do
|
132
|
-
after_unfollow { Buffer.tmp_value = self.about_to_unfollow }
|
133
|
-
end
|
134
|
-
|
135
|
-
user.follow(band)
|
136
|
-
end
|
137
|
-
|
138
|
-
it { expect{ user.unfollow(band) }.to change{ Buffer.tmp_value }.to(band) }
|
139
|
-
end
|
113
|
+
it { expect{ user.follow(band) }.to change{ Buffer.tmp_value }.to(band) }
|
140
114
|
end
|
141
115
|
|
142
|
-
describe
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
before_follow { Buffer.tmp_value = self.about_to_be_followed_by }
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
it { expect{ user.follow(band) }.to change{ Buffer.tmp_value }.to(user) }
|
151
|
-
end
|
152
|
-
|
153
|
-
describe :after_follow do
|
154
|
-
before do
|
155
|
-
followable 'Band' do
|
156
|
-
after_follow { Buffer.tmp_value = self.just_followed_by }
|
157
|
-
end
|
116
|
+
describe :before_unfollow do
|
117
|
+
before do
|
118
|
+
follower 'User' do
|
119
|
+
before_unfollow { Buffer.tmp_value = self.about_to_unfollow }
|
158
120
|
end
|
159
121
|
|
160
|
-
|
122
|
+
user.follow(band)
|
161
123
|
end
|
162
124
|
|
163
|
-
|
164
|
-
|
165
|
-
followable 'Band' do
|
166
|
-
before_unfollow { Buffer.tmp_value = self.about_to_be_unfollowed_by }
|
167
|
-
end
|
125
|
+
it { expect{ user.unfollow(band) }.to change{ Buffer.tmp_value }.to(band) }
|
126
|
+
end
|
168
127
|
|
169
|
-
|
128
|
+
describe :after_unfollow do
|
129
|
+
before do
|
130
|
+
follower 'User' do
|
131
|
+
after_unfollow { Buffer.tmp_value = self.about_to_unfollow }
|
170
132
|
end
|
171
133
|
|
172
|
-
|
134
|
+
user.follow(band)
|
173
135
|
end
|
174
136
|
|
175
|
-
|
176
|
-
before do
|
177
|
-
followable 'Band' do
|
178
|
-
after_unfollow { Buffer.tmp_value = self.just_unfollowed_by }
|
179
|
-
end
|
180
|
-
|
181
|
-
user.follow(band)
|
182
|
-
end
|
183
|
-
|
184
|
-
it { expect{ user.unfollow(band) }.to change{ Buffer.tmp_value }.to(user) }
|
185
|
-
end
|
137
|
+
it { expect{ user.unfollow(band) }.to change{ Buffer.tmp_value }.to(band) }
|
186
138
|
end
|
187
139
|
end
|
188
140
|
|
metadata
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: partisan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Simon Prévost
|
9
|
+
- Rémi Prévost
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
@@ -92,10 +93,11 @@ dependencies:
|
|
92
93
|
- !ruby/object:Gem::Version
|
93
94
|
version: '0'
|
94
95
|
description: Partisan is a Ruby library that allows ActiveRecord records to be follower
|
95
|
-
and followable, just like on popular social networks. It’s heavily inspired by
|
96
|
-
|
96
|
+
and followable, just like on popular social networks. It’s heavily inspired by acts_as_follower
|
97
|
+
which is no longer maintened.
|
97
98
|
email:
|
98
99
|
- sprevost@mirego.com
|
100
|
+
- Rémi Prévost
|
99
101
|
executables: []
|
100
102
|
extensions: []
|
101
103
|
extra_rdoc_files: []
|
@@ -122,7 +124,7 @@ files:
|
|
122
124
|
- spec/spec_helper.rb
|
123
125
|
- spec/support/macros/database_macros.rb
|
124
126
|
- spec/support/macros/model_macros.rb
|
125
|
-
homepage: https://github.com/
|
127
|
+
homepage: https://github.com/mirego/partisan
|
126
128
|
licenses:
|
127
129
|
- BSD 3-Clause
|
128
130
|
post_install_message:
|
@@ -137,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
139
|
version: '0'
|
138
140
|
segments:
|
139
141
|
- 0
|
140
|
-
hash: -
|
142
|
+
hash: -3563341390347157269
|
141
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
144
|
none: false
|
143
145
|
requirements:
|
@@ -146,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
148
|
version: '0'
|
147
149
|
segments:
|
148
150
|
- 0
|
149
|
-
hash: -
|
151
|
+
hash: -3563341390347157269
|
150
152
|
requirements: []
|
151
153
|
rubyforge_project:
|
152
154
|
rubygems_version: 1.8.23
|