partisan 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.md CHANGED
@@ -1,22 +1,26 @@
1
- Copyright (c) 2013 Rémi Prévost
1
+ Copyright (c) 2013, Mirego
2
+ All rights reserved.
2
3
 
3
- MIT License
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
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
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
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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 | Reference to the follower |
126
- | ------------------|----------------------------------|
127
- | `before_follow` | `self.about_to_be_followed_by` |
128
- | `after_follow` | `self.just_followed_by` |
129
- | `before_unfollow` | `self.about_to_by_unfollowed_by` |
130
- | `after_unfollow` | `self.just_unfollowed_by` |
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
 
@@ -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 :follow, &blk
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 :unfollow, &blk
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
 
@@ -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 :follow
11
- define_model_callbacks :unfollow
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
 
@@ -1,3 +1,3 @@
1
1
  module Partisan
2
- VERSION = "0.2"
2
+ VERSION = "0.2.1"
3
3
  end
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 the origin acts_as_follower which is no longer maintened'
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/simonprev/partisan'
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($/)
@@ -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
@@ -93,96 +93,48 @@ describe Partisan::Follower do
93
93
  end
94
94
  end
95
95
 
96
- describe 'Follower callbacks' do
97
- describe :before_follow do
98
- before do
99
- follower 'User' do
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
- describe :before_unfollow do
118
- before do
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
- user.follow(band)
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
- describe :after_unfollow do
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 'Followable callbacks' do
143
- describe :before_follow do
144
- before do
145
- followable 'Band' do
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
- it { expect{ user.follow(band) }.to change{ Buffer.tmp_value }.to(user) }
122
+ user.follow(band)
161
123
  end
162
124
 
163
- describe :before_unfollow do
164
- before do
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
- user.follow(band)
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
- it { expect{ user.unfollow(band) }.to change{ Buffer.tmp_value }.to(user) }
134
+ user.follow(band)
173
135
  end
174
136
 
175
- describe :after_unfollow do
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: '0.2'
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 the
96
- origin acts_as_follower which is no longer maintened
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/simonprev/partisan
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: -352093583781721099
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: -352093583781721099
151
+ hash: -3563341390347157269
150
152
  requirements: []
151
153
  rubyforge_project:
152
154
  rubygems_version: 1.8.23