acts_as_favoritor 2.1.0 → 2.1.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: 7ff8778bb55338480286174f66774251914fa4ef19aabb79dd5588d3c6bf40dc
4
- data.tar.gz: 239c8bfbacb746ac449a4682ec731adf4c85da8493d983bd210627c0ebd105bd
3
+ metadata.gz: 30781714c67378af58887aafea858cbde652a85473654e114550ecff6242d31b
4
+ data.tar.gz: 38d762ecfbace438d672b9a17d14550185fc837bbc96b5f88af1555f20a76598
5
5
  SHA512:
6
- metadata.gz: 262b98216f3e58c124de01bf1e78b29a8aceca911cb46726996e51d2fa7f43162a8f9100d17fc359c7bbb9faa427a58d8973d73de4c7979cafe981385880e931
7
- data.tar.gz: 025be50ca7f9b0e3671a999a1e385ee6c2b2d89a7f339073d9d82c0c44550adc95cc0818ab5509b6e6f6f4156ff83771dfccd7f969566111bac0733312cb4134
6
+ metadata.gz: 34fc997d31e4255f91902c94c98b7872c9108f35c8331b9c8fd00ca26be2a302fe80348f63e87ef849b23c56e50986b7f6633fa98b06b557f7c6c1d3f669b63d
7
+ data.tar.gz: d4f4d4949d1f569f1eb4c00967a26ed2e3abeae2ab561fe98d491010dfcbd183a5720dfb07a32971c013681d177aa1d3530787c75465ed906765d7c28f4e7c4f
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
@@ -83,17 +83,17 @@ end
83
83
  ### `acts_as_favoritor` methods
84
84
 
85
85
  ```ruby
86
- book = Book.find 1
87
- user = User.find 1
86
+ book = Book.find(1)
87
+ user = User.find(1)
88
88
 
89
89
  # `user` favorites `book`.
90
- user.favorite book
90
+ user.favorite(book)
91
91
 
92
92
  # `user` removes `book` from favorites.
93
- user.remove_favorite book
93
+ user.remove_favorite(book)
94
94
 
95
95
  # Whether `user` has marked `book` as his favorite. Returns `true` or `false`.
96
- user.favorited? book
96
+ user.favorited?(book)
97
97
 
98
98
  # Total number of favorites by `user`.
99
99
  user.favorites_count
@@ -105,16 +105,16 @@ user.all_favorites
105
105
  user.all_favorited
106
106
 
107
107
  # Returns an array of `Favorite` records where the `favoritable_type` is `Book`.
108
- user.favorites_by_type 'Book'
108
+ user.favorites_by_type('Book')
109
109
 
110
110
  # Returns an array of all favorited objects of `user` where `favoritable_type` is 'Book', this can be a collection of different object types, e.g.: `User`, `Book`.
111
- user.favorited_by_type 'Book'
111
+ user.favorited_by_type('Book')
112
112
 
113
113
  # Returns the exact same result as `user.favorited_by_type 'User'`.
114
114
  user.favorited_users
115
115
 
116
116
  # Total number of favorited books by `user`.
117
- user.favorited_by_type_count 'Book'
117
+ user.favorited_by_type_count('Book')
118
118
 
119
119
  # Returns the exact same result as `user.favorited_by_type_count 'Book'`.
120
120
  user.favorited_books_count
@@ -124,13 +124,13 @@ user.favorited_books_count
124
124
  book.favorites_scoped
125
125
 
126
126
  # Block a favoritable
127
- user.block book
127
+ user.block(book)
128
128
 
129
129
  # Unblock a favoritable
130
- user.unblock book
130
+ user.unblock(book)
131
131
 
132
132
  # Whether `user` has blocked `book`. Returns `true` or `false`.
133
- user.blocked? book
133
+ user.blocked?(book)
134
134
 
135
135
  # Returns an array including all blocked Favoritable records.
136
136
  user.blocks
@@ -139,7 +139,7 @@ user.blocks
139
139
  user.blocked_favoritables_count
140
140
 
141
141
  # Whether `user` has favorited, not favorited or blocked `book`. Returns `true`, `nil` or `false`.
142
- user.favoritable_type book
142
+ user.favoritable_type(book)
143
143
  ```
144
144
 
145
145
  These methods take an optional hash parameter of ActiveRecord options (`:limit`, `:order`, etc...)
@@ -159,28 +159,28 @@ book.favoritors_scoped
159
159
  book.favoritors_count
160
160
 
161
161
  # Returns an array of records with type `User` following `book`.
162
- book.favoritors_by_type 'User'
162
+ book.favoritors_by_type('User')
163
163
 
164
164
  # Returns the exact same as `book.favoritors_by_type 'User'`.
165
165
  book.user_favoritors
166
166
 
167
167
  # Total number of favoritors with type `User`.
168
- book.favoritors_by_type_count 'User'
168
+ book.favoritors_by_type_count('User')
169
169
 
170
170
  # Returns the exact same as `book.favoritors_by_type_count 'User'`.
171
171
  book.count_user_favoritors
172
172
 
173
173
  # Whether `book` has been favorited by `user`. Returns `true` or `false`.
174
- book.favorited_by? user
174
+ book.favorited_by?(user)
175
175
 
176
176
  # Block a favoritor
177
- book.block user
177
+ book.block(user)
178
178
 
179
179
  # Unblock a favoritor
180
- book.unblock user
180
+ book.unblock(user)
181
181
 
182
182
  # Whether `book` has blocked `user` as favoritor. Returns `true` or `false`.
183
- book.blocked? user
183
+ book.blocked?(user)
184
184
 
185
185
  # Returns an array including all blocked Favoritor records.
186
186
  book.blocks
@@ -189,7 +189,7 @@ book.blocks
189
189
  book.blocked_favoritors_count
190
190
 
191
191
  # Whether `user` has favorited, not favorited or blocked `book`. Returns `true`, `nil` or `false`.
192
- book.favoritor_type user
192
+ book.favoritor_type(user)
193
193
  ```
194
194
 
195
195
  These methods take an optional hash parameter of ActiveRecord options (`:limit`, `:order`, etc...)
@@ -209,13 +209,13 @@ Favorite.descending
209
209
 
210
210
  # Returns all `Favorite` records in an array, which have been created in a specified timeframe. Default is 2 weeks.
211
211
  Favorite.recent
212
- Favorite.recent 1.month.ago
212
+ Favorite.recent(1.month.ago)
213
213
 
214
214
  # Returns all favorites of `user`, including those who were blocked.
215
- Favorite.for_favoritor user
215
+ Favorite.for_favoritor(user)
216
216
 
217
217
  # Returns all favoritors of `book`, including those who were blocked.
218
- Favorite.for_favoritable book
218
+ Favorite.for_favoritable(book)
219
219
  ```
220
220
 
221
221
  ### Scopes
@@ -229,11 +229,11 @@ You can create new scopes on the fly. Every single method takes `scope` as an op
229
229
  So lets see how this works:
230
230
 
231
231
  ```ruby
232
- user.favorite book, scope: [:favorite, :watching]
233
- user.remove_favorite book, scope: [:watching]
234
- second_user = User.find 2
235
- user.favorite second_user, scope: [:follow]
236
- book.block user, scope: [:all] # applies to all scopes
232
+ user.favorite(book, scope: [:favorite, :watching])
233
+ user.remove_favorite(book, scope: [:watching])
234
+ second_user = User.find(2)
235
+ user.favorite(second_user, scope: [:follow])
236
+ book.block(user, scope: [:all]) # applies to all scopes
237
237
  ```
238
238
 
239
239
  That's simple!
@@ -241,8 +241,8 @@ That's simple!
241
241
  When you call a method which returns something while specifying multiple scopes, the method returns the results in a hash with the scopes as keys:
242
242
 
243
243
  ```ruby
244
- user.favorited? book, scope: [:favorite, :watching] # => { favorite: true, watching: false }
245
- user.favorited? book, scope: [:all] # => true
244
+ user.favorited?(book, scope: [:favorite, :watching]) # => { favorite: true, watching: false }
245
+ user.favorited?(book, scope: [:all]) # => true
246
246
  ```
247
247
 
248
248
  `acts_as_favoritor` also provides some handy scopes for you to call on the `Favorite` model:
@@ -333,7 +333,7 @@ Tests are written with Shoulda on top of `Test::Unit` with Factory Girl being us
333
333
 
334
334
  4. Run tests
335
335
 
336
- `$ rake test`
336
+ `$ bundle exec rake test`
337
337
 
338
338
  5. Run RuboCop
339
339
 
File without changes
File without changes
File without changes
File without changes
@@ -28,15 +28,16 @@ module ActsAsFavoritor
28
28
  elsif options[:multiple_scopes]
29
29
  results = {}
30
30
  options[:scope].each do |scope|
31
- results[scope] = Favorite.unblocked.send(scope + '_list')
31
+ results[scope] = Favorite.unblocked.send(scope.to_s + '_list')
32
32
  .for_favoritor(self)
33
33
  .for_favoritable(favoritable).count
34
34
  .positive?
35
35
  end
36
36
  results
37
37
  else
38
- Favorite.unblocked.send(options[:scope] + '_list').for_favoritor(self)
39
- .for_favoritable(favoritable).count.positive?
38
+ Favorite.unblocked.send(options[:scope].to_s + '_list')
39
+ .for_favoritor(self).for_favoritable(favoritable)
40
+ .count.positive?
40
41
  end
41
42
  end
42
43
 
@@ -394,12 +395,12 @@ module ActsAsFavoritor
394
395
  elsif options[:multiple_scopes]
395
396
  results = {}
396
397
  options[:scope].each do |scope|
397
- results[scope] = favorites.unblocked.send(scope + '_list')
398
+ results[scope] = favorites.unblocked.send(scope.to_s + '_list')
398
399
  .for_favoritable(favoritable).first
399
400
  end
400
401
  results
401
402
  else
402
- favorites.unblocked.send(options[:scope] + '_list')
403
+ favorites.unblocked.send(options[:scope].to_s + '_list')
403
404
  .for_favoritable(favoritable).first
404
405
  end
405
406
  end
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActsAsFavoritor
4
- VERSION = '2.1.0'
4
+ VERSION = '2.1.1'
5
5
  end
File without changes
File without changes
File without changes
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: 2.1.0
4
+ version: 2.1.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: 2018-07-25 00:00:00.000000000 Z
11
+ date: 2019-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord