filtered 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -3
- data/README.md +9 -4
- data/filtered.gemspec +1 -1
- data/lib/filtered/base.rb +6 -2
- data/lib/filtered/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fd8d853511d646c6e86d81560915c8a86cdd7f5cbfb3806c1fa65d12572c6e8
|
4
|
+
data.tar.gz: 8368e29206b271979c4390f766e38483265420c8b38896bba60f92b26158d44f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 673323fbecc678b4c0b521623cd605f9b9a7b6e66dbcdcddee58e1fffab87c9d58da713883a07c727f67613511a0b03fb5fff80fe3a4af380132ba14f7b5cd89
|
7
|
+
data.tar.gz: 434e027c34e922ef4566d8c201a236a000c71216a056fe7b6ae8cd048ef03fb3cef3f1fe35f7760db8c48728f0c728436bfa72ae1c1657604bac444568b4080e
|
data/.travis.yml
CHANGED
@@ -5,7 +5,11 @@ cache: bundler
|
|
5
5
|
addons:
|
6
6
|
postgresql: "9.6"
|
7
7
|
rvm:
|
8
|
-
|
8
|
+
# TODO fix build set up
|
9
|
+
# - 2.0.0-p648
|
10
|
+
# - 2.1.10
|
11
|
+
# - 2.2.6
|
12
|
+
- 2.3.7
|
9
13
|
- 2.4.2
|
10
14
|
- 2.5.1
|
11
15
|
- 2.6.3
|
@@ -30,7 +34,7 @@ matrix:
|
|
30
34
|
exclude:
|
31
35
|
- rvm: 2.2.6
|
32
36
|
gemfile: gemfiles/activerecord_6.0rc1.gemfile
|
33
|
-
- rvm: 2.3.
|
37
|
+
- rvm: 2.3.7
|
34
38
|
gemfile: gemfiles/activerecord_6.0rc1.gemfile
|
35
39
|
- rvm: 2.4.2
|
36
40
|
gemfile: gemfiles/activerecord_6.0rc1.gemfile
|
@@ -47,7 +51,7 @@ matrix:
|
|
47
51
|
- rvm: jruby-head
|
48
52
|
|
49
53
|
before_install:
|
50
|
-
|
54
|
+
#- gem update --system
|
51
55
|
- gem install bundler
|
52
56
|
script:
|
53
57
|
- bundle exec rake
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
[![Build Status](https://travis-ci.org/dubadub/filtered.svg?branch=master)](https://travis-ci.org/dubadub/filtered)
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/filtered.svg)](https://badge.fury.io/rb/filtered)[![Build Status](https://travis-ci.org/dubadub/filtered.svg?branch=master)](https://travis-ci.org/dubadub/filtered)
|
2
2
|
|
3
3
|
|
4
4
|
# Filtered - add filter to ActiveRecord queries
|
5
5
|
|
6
|
-
|
6
|
+
The gem helps to create filters for Rails’ ActiveRecord in an old-fashion way. It makes your controller simpler and forms effortless.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
@@ -30,7 +30,7 @@ To create a new filter with a generator:
|
|
30
30
|
|
31
31
|
```bash
|
32
32
|
$ rails generate filter car make model year body # fields can be added later
|
33
|
-
create app/
|
33
|
+
create app/filters/car_filter.rb
|
34
34
|
```
|
35
35
|
|
36
36
|
|
@@ -50,7 +50,7 @@ class NoiseMeasurementsController < ApplicationController
|
|
50
50
|
|
51
51
|
def set_filter
|
52
52
|
# it can take an optional block if you need to set an auxilary variable:
|
53
|
-
@filter =
|
53
|
+
@filter = CarFilter.new(filter_params) do |f|
|
54
54
|
f.user = current_user
|
55
55
|
end
|
56
56
|
end
|
@@ -180,6 +180,11 @@ To use the same `@filter` object in views (it will automatically set all the rel
|
|
180
180
|
|
181
181
|
Filtered uses API provided by ActiveRecord [merge method](https://api.rubyonrails.org/classes/ActiveRecord/SpawnMethods.html#method-i-merge). There are a few open issues in ActiveRecord related to that method, please, have a look through it [here](https://github.com/rails/rails/search?q=activerecord+merge&state=open&type=Issues).
|
182
182
|
|
183
|
+
## Ruby/Rails versions supported
|
184
|
+
|
185
|
+
Ruby: 2.3.x, 2.4.x, 2.5.x, 2.6.x, jruby-9.1.x, jruby-9.2.x.
|
186
|
+
Rails: 4.0.x, 4.1.x, 4.2.x, 5.0.x, 5.1.x, 5.2.x, 6.0.0rc.
|
187
|
+
|
183
188
|
## Credits
|
184
189
|
|
185
190
|
This gem woudn't exist without original ideas of [@caJaeger](https://github.com/caJaeger).
|
data/filtered.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
# Specify which files should be added to the gem when it is released.
|
17
17
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
18
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|examples|docs|gemfiles)/}) }
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|examples|docs|gemfiles|Appraisals)/}) }
|
20
20
|
end
|
21
21
|
spec.bindir = "exe"
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
data/lib/filtered/base.rb
CHANGED
@@ -188,6 +188,12 @@ module Filtered
|
|
188
188
|
end
|
189
189
|
|
190
190
|
yield self if block_given?
|
191
|
+
|
192
|
+
fields.each do |name, value, definition|
|
193
|
+
next if value || !definition.default_computer
|
194
|
+
|
195
|
+
fields[name] = definition.default_computer.(self)
|
196
|
+
end
|
191
197
|
end
|
192
198
|
|
193
199
|
|
@@ -221,8 +227,6 @@ module Filtered
|
|
221
227
|
return enum_for(:entitled_fields) unless block_given?
|
222
228
|
|
223
229
|
fields.each do |name, value, definition|
|
224
|
-
value = definition.default_computer.(self) if !value && definition.default_computer
|
225
|
-
|
226
230
|
value_accepted = eval_option_proc(definition.acceptance_computer, value)
|
227
231
|
value_declined = eval_option_proc(definition.decline_computer, value)
|
228
232
|
|
data/lib/filtered/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filtered
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Dubovskoy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|