acts_as_favoritor 5.0.0 → 5.0.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2554cf505e5a47eb5f24bc1de95fb6287d397259cc70685f4905d99be6164e72
|
4
|
+
data.tar.gz: ac5749692ac44627c97dfb2797834671f7d3cc368d32e63aac5d2d9a94e4b6b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 544dda8f78ced970192a0d523f8c7b4804be135d33afe8635a15eaef3263d5413793d54ca5342fa12636d4a1c893b4d52bb1c160180bb72386c4a144a3280a6b
|
7
|
+
data.tar.gz: 28fd936df2e6dc96f6b5a2449fc654f40b4307a7d4bed58e5f648652e283af46d3547f1e3ac2245b928400d1391186fae291ff4fc1756438a14afb8c03858abe
|
data/README.md
CHANGED
@@ -4,40 +4,17 @@ acts_as_favoritor is a Rubygem to allow any ActiveRecord model to associate any
|
|
4
4
|
|
5
5
|
You are able to differentiate followers, favorites, watchers, votes and whatever else you can imagine through a single relationship. This is accomplished by a double polymorphic relationship on the Favorite model. There is also built in support for blocking/un-blocking favorite records as well as caching.
|
6
6
|
|
7
|
-
---
|
8
|
-
|
9
|
-
## Table of Contents
|
10
|
-
|
11
|
-
- [acts_as_favoritor](#actsasfavoritor)
|
12
|
-
- [Table of Contents](#table-of-contents)
|
13
|
-
- [Installation](#installation)
|
14
|
-
- [Usage](#usage)
|
15
|
-
- [Setup](#setup)
|
16
|
-
- [`acts_as_favoritor` methods](#actsasfavoritor-methods)
|
17
|
-
- [`acts_as_favoritable` methods](#actsasfavoritable-methods)
|
18
|
-
- [`Favorite` model](#favorite-model)
|
19
|
-
- [Scopes](#scopes)
|
20
|
-
- [Caching](#caching)
|
21
|
-
- [Configuration](#configuration)
|
22
|
-
- [Testing](#testing)
|
23
|
-
- [Release](#release)
|
24
|
-
- [To do](#to-do)
|
25
|
-
- [Contributing](#contributing)
|
26
|
-
- [Semantic Versioning](#semantic-versioning)
|
27
|
-
|
28
|
-
---
|
29
|
-
|
30
7
|
## Installation
|
31
8
|
|
32
|
-
|
9
|
+
You can add acts_as_favoritor to your `Gemfile` with:
|
33
10
|
|
34
11
|
```ruby
|
35
12
|
gem 'acts_as_favoritor'
|
36
13
|
```
|
37
14
|
|
38
|
-
And then
|
15
|
+
And then run:
|
39
16
|
|
40
|
-
$ bundle
|
17
|
+
$ bundle install
|
41
18
|
|
42
19
|
Or install it yourself as:
|
43
20
|
|
@@ -245,8 +222,6 @@ book.favoritable_favorite_cache # => 1
|
|
245
222
|
|
246
223
|
**Note:** These methods are available for every scope you are using.
|
247
224
|
|
248
|
-
---
|
249
|
-
|
250
225
|
## Configuration
|
251
226
|
|
252
227
|
You can configure acts_as_favoritor by passing a block to `configure`. This can be done in `config/initializers/acts_as_favoritor.rb`:
|
@@ -261,51 +236,41 @@ end
|
|
261
236
|
|
262
237
|
**`cache`** Whether `acts_as_favoritor` uses caching or not. Takes a boolean. Defaults to `false`. Learn more about caching [here](#caching).
|
263
238
|
|
264
|
-
|
265
|
-
|
266
|
-
## Testing
|
267
|
-
|
268
|
-
1. Fork this repository
|
269
|
-
2. Clone your forked git locally
|
270
|
-
3. Install dependencies
|
239
|
+
## Development
|
271
240
|
|
272
|
-
|
241
|
+
To start development you first have to fork this repository and locally clone your fork.
|
273
242
|
|
274
|
-
|
243
|
+
Install the projects dependencies by running:
|
275
244
|
|
276
|
-
|
245
|
+
$ bundle install
|
277
246
|
|
278
|
-
|
247
|
+
### Testing
|
279
248
|
|
280
|
-
|
249
|
+
Tests are written with RSpec and can be found in `/spec`.
|
281
250
|
|
282
|
-
|
251
|
+
To run tests:
|
283
252
|
|
284
|
-
|
253
|
+
$ bundle exec rspec
|
285
254
|
|
286
|
-
|
287
|
-
2. Change the gem version in `lib/acts_as_favoritor/version.rb`
|
288
|
-
3. Reset `CHANGELOG.md`
|
289
|
-
4. Create a pull request to merge the changes into `master`
|
290
|
-
5. After the pull request was merged, create a new release listing the breaking changes and commits on `master` since the last release.
|
291
|
-
6. The release workflow will publish the gems to RubyGems and the GitHub Package Registry
|
255
|
+
To run RuboCop:
|
292
256
|
|
293
|
-
|
257
|
+
$ bundle exec rubocop
|
294
258
|
|
295
|
-
##
|
296
|
-
|
297
|
-
We use [GitHub projects](https://github.com/jonhue/acts_as_favoritor/projects/1) to coordinate the work on this project.
|
298
|
-
|
299
|
-
To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/acts_as_favoritor/issues/new).
|
259
|
+
## Contributing
|
300
260
|
|
301
|
-
|
261
|
+
We warmly welcome everyone who is intersted in contributing. Please reference our [contributing guidelines](CONTRIBUTING.md) and our [Code of Conduct](CODE_OF_CONDUCT.md).
|
302
262
|
|
303
|
-
##
|
263
|
+
## Releases
|
304
264
|
|
305
|
-
|
265
|
+
[Here](https://github.com/jonhue/acts_as_favoritor/releases) you can find details on all past releases. Unreleased breaking changes that are on the current master can be found [here](CHANGELOG.md).
|
306
266
|
|
307
|
-
|
267
|
+
acts_as_favoritor follows Semantic Versioning 2.0 as defined at http://semver.org. Reference our [security policy](SECURITY.md).
|
308
268
|
|
309
|
-
###
|
269
|
+
### Publishing
|
310
270
|
|
311
|
-
|
271
|
+
1. Review breaking changes and deprecations in `CHANGELOG.md`.
|
272
|
+
1. Change the gem version in `lib/acts_as_favoritor/version.rb`.
|
273
|
+
1. Reset `CHANGELOG.md`.
|
274
|
+
1. Create a pull request to merge the changes into `master`.
|
275
|
+
1. After the pull request was merged, create a new release listing the breaking changes and commits on `master` since the last release.
|
276
|
+
2. The release workflow will publish the gem to RubyGems.
|
@@ -38,11 +38,13 @@ module ActsAsFavoritor
|
|
38
38
|
end
|
39
39
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
40
40
|
|
41
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
41
42
|
def respond_to_missing?(method, include_private = false)
|
42
43
|
super || method.to_s[/(.+)_favoritors/] ||
|
43
44
|
method.to_s[/favoritable_(.+)_score/] ||
|
44
45
|
method.to_s[/favoritable_(.+)_total/]
|
45
46
|
end
|
47
|
+
# rubocop:enable Style/OptionalBooleanParameter
|
46
48
|
|
47
49
|
def favoritors(scope: ActsAsFavoritor.configuration.default_scope,
|
48
50
|
scopes: nil)
|
@@ -12,9 +12,11 @@ module ActsAsFavoritor
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
15
16
|
def respond_to_missing?(method, include_private = false)
|
16
17
|
super || method.to_s[/(.+)_list/]
|
17
18
|
end
|
19
|
+
# rubocop:enable Style/OptionalBooleanParameter
|
18
20
|
|
19
21
|
def for_favoritor(favoritor)
|
20
22
|
where(
|
@@ -38,11 +38,13 @@ module ActsAsFavoritor
|
|
38
38
|
end
|
39
39
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
40
40
|
|
41
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
41
42
|
def respond_to_missing?(method, include_private = false)
|
42
43
|
super || method.to_s[/favorited_(.+)/] ||
|
43
44
|
method.to_s[/favoritor_(.+)_score/] ||
|
44
45
|
method.to_s[/favoritor_(.+)_total/]
|
45
46
|
end
|
47
|
+
# rubocop:enable Style/OptionalBooleanParameter
|
46
48
|
|
47
49
|
def favorite(favoritable,
|
48
50
|
scope: ActsAsFavoritor.configuration.default_scope,
|
@@ -158,9 +160,7 @@ module ActsAsFavoritor
|
|
158
160
|
|
159
161
|
favoritable.favoritable_score[scope] =
|
160
162
|
(favoritable.favoritable_score[scope] || 0) - 1
|
161
|
-
unless favoritable.favoritable_score[scope].positive?
|
162
|
-
favoritable.favoritable_score.delete(scope)
|
163
|
-
end
|
163
|
+
favoritable.favoritable_score.delete(scope) unless favoritable.favoritable_score[scope].positive?
|
164
164
|
favoritable.save!
|
165
165
|
end
|
166
166
|
# rubocop:enable Metrics/AbcSize
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_favoritor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Hübotter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
168
|
requirements: []
|
169
|
-
rubygems_version: 3.
|
169
|
+
rubygems_version: 3.1.4
|
170
170
|
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: A Rubygem to add Favorite, Follow, Vote, etc. functionality to ActiveRecord
|