mobility-ransack 1.0.1 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/Gemfile.lock +90 -83
- data/README.md +1 -4
- data/lib/mobility/plugins/ransack.rb +1 -27
- data/lib/mobility/ransack/version.rb +1 -1
- data/lib/mobility/ransack.rb +50 -0
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5494d5b489072ff14d3b7ec1c9a0b406eb8bbbb51c9eccb901144eea6b5d3f2f
|
4
|
+
data.tar.gz: e7fa363227d7f7d752d4865b5bdada8fb5d3fc046948de9184a197eb549d6920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d7bf3c13e6aa14119aae4488b249290676dcf3a574e96e18f9978e8ad6a7fac150cbfa47a1e65bad5e521bb91ad801f03344e93a58c03c51f7e6d53bc312a6c
|
7
|
+
data.tar.gz: d25fb5b6ecdfe0f1fe85790bff449a9d6ec663940c3227b1cd2cd477f188232a77994cebe7f3de4e870a06c177b1d32c195b1614c682bca16c1caacf1395a8a5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Mobility Ransack Changelog
|
2
2
|
|
3
|
+
## 1.1
|
4
|
+
|
5
|
+
### 1.2.1
|
6
|
+
- Require mobility/ransack into plugin file
|
7
|
+
([#26](https://github.com/shioyama/mobility-ransack/pull/26))
|
8
|
+
|
9
|
+
### 1.2.0
|
10
|
+
- [Add compatibility with rails
|
11
|
+
7+](https://github.com/shioyama/mobility-ransack/pull/22), thanks
|
12
|
+
[mhenrixon](https://github.com/mhenrixon)!
|
13
|
+
- [Update mobility-ransack.gemspec](https://github.com/shioyama/mobility-ransack/pull/23),
|
14
|
+
thanks [kevynlebouille](https://github.com/kevynlebouille)!
|
15
|
+
|
16
|
+
### 1.1.0
|
17
|
+
- Make MobilityRansack handle associations correctly
|
18
|
+
([#20](https://github.com/shioyama/mobility-ransack/pull/20))
|
19
|
+
|
3
20
|
## 1.0
|
4
21
|
|
5
22
|
### 1.0.1
|
data/Gemfile.lock
CHANGED
@@ -1,135 +1,141 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mobility-ransack (1.
|
5
|
-
mobility (
|
4
|
+
mobility-ransack (1.1.0)
|
5
|
+
mobility (>= 1.0.1, < 2.0)
|
6
6
|
ransack (>= 1.8.0, < 3.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actioncable (6.
|
12
|
-
actionpack (= 6.
|
11
|
+
actioncable (6.1.3.2)
|
12
|
+
actionpack (= 6.1.3.2)
|
13
|
+
activesupport (= 6.1.3.2)
|
13
14
|
nio4r (~> 2.0)
|
14
15
|
websocket-driver (>= 0.6.1)
|
15
|
-
actionmailbox (6.
|
16
|
-
actionpack (= 6.
|
17
|
-
activejob (= 6.
|
18
|
-
activerecord (= 6.
|
19
|
-
activestorage (= 6.
|
20
|
-
activesupport (= 6.
|
16
|
+
actionmailbox (6.1.3.2)
|
17
|
+
actionpack (= 6.1.3.2)
|
18
|
+
activejob (= 6.1.3.2)
|
19
|
+
activerecord (= 6.1.3.2)
|
20
|
+
activestorage (= 6.1.3.2)
|
21
|
+
activesupport (= 6.1.3.2)
|
21
22
|
mail (>= 2.7.1)
|
22
|
-
actionmailer (6.
|
23
|
-
actionpack (= 6.
|
24
|
-
actionview (= 6.
|
25
|
-
activejob (= 6.
|
23
|
+
actionmailer (6.1.3.2)
|
24
|
+
actionpack (= 6.1.3.2)
|
25
|
+
actionview (= 6.1.3.2)
|
26
|
+
activejob (= 6.1.3.2)
|
27
|
+
activesupport (= 6.1.3.2)
|
26
28
|
mail (~> 2.5, >= 2.5.4)
|
27
29
|
rails-dom-testing (~> 2.0)
|
28
|
-
actionpack (6.
|
29
|
-
actionview (= 6.
|
30
|
-
activesupport (= 6.
|
31
|
-
rack (~> 2.0, >= 2.0.
|
30
|
+
actionpack (6.1.3.2)
|
31
|
+
actionview (= 6.1.3.2)
|
32
|
+
activesupport (= 6.1.3.2)
|
33
|
+
rack (~> 2.0, >= 2.0.9)
|
32
34
|
rack-test (>= 0.6.3)
|
33
35
|
rails-dom-testing (~> 2.0)
|
34
36
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
35
|
-
actiontext (6.
|
36
|
-
actionpack (= 6.
|
37
|
-
activerecord (= 6.
|
38
|
-
activestorage (= 6.
|
39
|
-
activesupport (= 6.
|
37
|
+
actiontext (6.1.3.2)
|
38
|
+
actionpack (= 6.1.3.2)
|
39
|
+
activerecord (= 6.1.3.2)
|
40
|
+
activestorage (= 6.1.3.2)
|
41
|
+
activesupport (= 6.1.3.2)
|
40
42
|
nokogiri (>= 1.8.5)
|
41
|
-
actionview (6.
|
42
|
-
activesupport (= 6.
|
43
|
+
actionview (6.1.3.2)
|
44
|
+
activesupport (= 6.1.3.2)
|
43
45
|
builder (~> 3.1)
|
44
46
|
erubi (~> 1.4)
|
45
47
|
rails-dom-testing (~> 2.0)
|
46
48
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
47
|
-
activejob (6.
|
48
|
-
activesupport (= 6.
|
49
|
+
activejob (6.1.3.2)
|
50
|
+
activesupport (= 6.1.3.2)
|
49
51
|
globalid (>= 0.3.6)
|
50
|
-
activemodel (6.
|
51
|
-
activesupport (= 6.
|
52
|
-
activerecord (6.
|
53
|
-
activemodel (= 6.
|
54
|
-
activesupport (= 6.
|
55
|
-
activestorage (6.
|
56
|
-
actionpack (= 6.
|
57
|
-
activejob (= 6.
|
58
|
-
activerecord (= 6.
|
59
|
-
|
60
|
-
|
52
|
+
activemodel (6.1.3.2)
|
53
|
+
activesupport (= 6.1.3.2)
|
54
|
+
activerecord (6.1.3.2)
|
55
|
+
activemodel (= 6.1.3.2)
|
56
|
+
activesupport (= 6.1.3.2)
|
57
|
+
activestorage (6.1.3.2)
|
58
|
+
actionpack (= 6.1.3.2)
|
59
|
+
activejob (= 6.1.3.2)
|
60
|
+
activerecord (= 6.1.3.2)
|
61
|
+
activesupport (= 6.1.3.2)
|
62
|
+
marcel (~> 1.0.0)
|
63
|
+
mini_mime (~> 1.0.2)
|
64
|
+
activesupport (6.1.3.2)
|
61
65
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
62
|
-
i18n (>=
|
63
|
-
minitest (
|
64
|
-
tzinfo (~>
|
65
|
-
zeitwerk (~> 2.
|
66
|
+
i18n (>= 1.6, < 2)
|
67
|
+
minitest (>= 5.1)
|
68
|
+
tzinfo (~> 2.0)
|
69
|
+
zeitwerk (~> 2.3)
|
66
70
|
builder (3.2.4)
|
67
71
|
byebug (11.1.1)
|
68
72
|
coderay (1.1.2)
|
69
|
-
concurrent-ruby (1.1.
|
73
|
+
concurrent-ruby (1.1.9)
|
70
74
|
crass (1.0.6)
|
71
75
|
database_cleaner (1.8.4)
|
72
76
|
diff-lcs (1.3)
|
73
|
-
erubi (1.
|
77
|
+
erubi (1.10.0)
|
74
78
|
globalid (0.4.2)
|
75
79
|
activesupport (>= 4.2.0)
|
76
|
-
i18n (1.8.
|
80
|
+
i18n (1.8.10)
|
77
81
|
concurrent-ruby (~> 1.0)
|
78
|
-
loofah (2.
|
82
|
+
loofah (2.10.0)
|
79
83
|
crass (~> 1.0.2)
|
80
84
|
nokogiri (>= 1.5.9)
|
81
85
|
mail (2.7.1)
|
82
86
|
mini_mime (>= 0.1.1)
|
83
|
-
marcel (0.
|
84
|
-
mimemagic (~> 0.3.2)
|
87
|
+
marcel (1.0.1)
|
85
88
|
method_source (1.0.0)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
mobility (1.0.0)
|
89
|
+
mini_mime (1.0.3)
|
90
|
+
mini_portile2 (2.5.3)
|
91
|
+
minitest (5.14.4)
|
92
|
+
mobility (1.1.2)
|
91
93
|
i18n (>= 0.6.10, < 2)
|
92
94
|
request_store (~> 1.0)
|
93
|
-
nio4r (2.5.
|
94
|
-
nokogiri (1.
|
95
|
-
mini_portile2 (~> 2.
|
95
|
+
nio4r (2.5.7)
|
96
|
+
nokogiri (1.11.7)
|
97
|
+
mini_portile2 (~> 2.5.0)
|
98
|
+
racc (~> 1.4)
|
99
|
+
nokogiri (1.11.7-x86_64-linux)
|
100
|
+
racc (~> 1.4)
|
96
101
|
pry (0.13.0)
|
97
102
|
coderay (~> 1.1)
|
98
103
|
method_source (~> 1.0)
|
99
104
|
pry-byebug (3.9.0)
|
100
105
|
byebug (~> 11.0)
|
101
106
|
pry (~> 0.13.0)
|
107
|
+
racc (1.5.2)
|
102
108
|
rack (2.2.3)
|
103
109
|
rack-test (1.1.0)
|
104
110
|
rack (>= 1.0, < 3)
|
105
|
-
rails (6.
|
106
|
-
actioncable (= 6.
|
107
|
-
actionmailbox (= 6.
|
108
|
-
actionmailer (= 6.
|
109
|
-
actionpack (= 6.
|
110
|
-
actiontext (= 6.
|
111
|
-
actionview (= 6.
|
112
|
-
activejob (= 6.
|
113
|
-
activemodel (= 6.
|
114
|
-
activerecord (= 6.
|
115
|
-
activestorage (= 6.
|
116
|
-
activesupport (= 6.
|
117
|
-
bundler (>= 1.
|
118
|
-
railties (= 6.
|
111
|
+
rails (6.1.3.2)
|
112
|
+
actioncable (= 6.1.3.2)
|
113
|
+
actionmailbox (= 6.1.3.2)
|
114
|
+
actionmailer (= 6.1.3.2)
|
115
|
+
actionpack (= 6.1.3.2)
|
116
|
+
actiontext (= 6.1.3.2)
|
117
|
+
actionview (= 6.1.3.2)
|
118
|
+
activejob (= 6.1.3.2)
|
119
|
+
activemodel (= 6.1.3.2)
|
120
|
+
activerecord (= 6.1.3.2)
|
121
|
+
activestorage (= 6.1.3.2)
|
122
|
+
activesupport (= 6.1.3.2)
|
123
|
+
bundler (>= 1.15.0)
|
124
|
+
railties (= 6.1.3.2)
|
119
125
|
sprockets-rails (>= 2.0.0)
|
120
126
|
rails-dom-testing (2.0.3)
|
121
127
|
activesupport (>= 4.2.0)
|
122
128
|
nokogiri (>= 1.6)
|
123
129
|
rails-html-sanitizer (1.3.0)
|
124
130
|
loofah (~> 2.3)
|
125
|
-
railties (6.
|
126
|
-
actionpack (= 6.
|
127
|
-
activesupport (= 6.
|
131
|
+
railties (6.1.3.2)
|
132
|
+
actionpack (= 6.1.3.2)
|
133
|
+
activesupport (= 6.1.3.2)
|
128
134
|
method_source
|
129
135
|
rake (>= 0.8.7)
|
130
|
-
thor (
|
136
|
+
thor (~> 1.0)
|
131
137
|
rake (13.0.1)
|
132
|
-
ransack (2.4.
|
138
|
+
ransack (2.4.2)
|
133
139
|
activerecord (>= 5.2.4)
|
134
140
|
activesupport (>= 5.2.4)
|
135
141
|
i18n
|
@@ -156,27 +162,28 @@ GEM
|
|
156
162
|
activesupport (>= 4.0)
|
157
163
|
sprockets (>= 3.0.0)
|
158
164
|
sqlite3 (1.4.2)
|
159
|
-
thor (1.0
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
websocket-driver (0.7.3)
|
165
|
+
thor (1.1.0)
|
166
|
+
tzinfo (2.0.4)
|
167
|
+
concurrent-ruby (~> 1.0)
|
168
|
+
websocket-driver (0.7.4)
|
164
169
|
websocket-extensions (>= 0.1.0)
|
165
170
|
websocket-extensions (0.1.5)
|
166
|
-
zeitwerk (2.4.
|
171
|
+
zeitwerk (2.4.2)
|
167
172
|
|
168
173
|
PLATFORMS
|
169
174
|
ruby
|
175
|
+
x86_64-linux
|
170
176
|
|
171
177
|
DEPENDENCIES
|
172
178
|
database_cleaner (~> 1.7, >= 1.7.0)
|
173
179
|
mobility-ransack!
|
174
180
|
pry
|
175
181
|
pry-byebug
|
176
|
-
rails (~> 6.
|
182
|
+
rails (~> 6.1.0)
|
177
183
|
rake (>= 12.3.3)
|
184
|
+
ransack (= 2.4.2)
|
178
185
|
rspec (~> 3.0)
|
179
186
|
sqlite3 (~> 1.3, >= 1.3.0)
|
180
187
|
|
181
188
|
BUNDLED WITH
|
182
|
-
2.
|
189
|
+
2.2.2
|
data/README.md
CHANGED
@@ -18,12 +18,9 @@ Search on translated attributes with
|
|
18
18
|
Just add the gem to your Gemfile:
|
19
19
|
|
20
20
|
```ruby
|
21
|
-
gem 'mobility-ransack', '~> 1.
|
21
|
+
gem 'mobility-ransack', '~> 1.2.1'
|
22
22
|
```
|
23
23
|
|
24
|
-
(For Mobility versions earlier than 1.0, replace `1.0.0` with `0.2.2`, but be
|
25
|
-
aware this version is no longer supported.)
|
26
|
-
|
27
24
|
Now enable the `ransack` plugin in Mobility's configuration:
|
28
25
|
|
29
26
|
```ruby
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "ransack"
|
2
2
|
require "mobility"
|
3
|
+
require "mobility/ransack"
|
3
4
|
|
4
5
|
module Mobility
|
5
6
|
module Plugins
|
@@ -18,33 +19,6 @@ module Mobility
|
|
18
19
|
names.each do |name|
|
19
20
|
klass.ransacker(name) { backend_class.build_node(name, Mobility.locale) }
|
20
21
|
end
|
21
|
-
klass.extend ClassMethods
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
module ClassMethods
|
26
|
-
def ransack(*)
|
27
|
-
super.extend(Search)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
module Search
|
32
|
-
def result(opts = {})
|
33
|
-
sorted = sorts.inject(super) do |relation, sort|
|
34
|
-
predicate = ::Ransack::Visitor.new.visit_Ransack_Nodes_Sort(sort)
|
35
|
-
apply_mobility_scope(relation, predicate, [sort.attr_name])
|
36
|
-
end
|
37
|
-
conditions.inject(sorted) do |relation, condition|
|
38
|
-
apply_mobility_scope(relation, condition.arel_predicate, condition.attributes.compact.flat_map(&:name))
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def apply_mobility_scope(relation, predicate, attributes)
|
45
|
-
(attributes & object.mobility_attributes).inject(relation) do |i18n_rel, attr|
|
46
|
-
object.mobility_backend_class(attr).apply_scope(i18n_rel, predicate)
|
47
|
-
end
|
48
22
|
end
|
49
23
|
end
|
50
24
|
end
|
data/lib/mobility/ransack.rb
CHANGED
@@ -1,6 +1,56 @@
|
|
1
1
|
require "mobility/ransack/version"
|
2
|
+
require "mobility/plugins/arel"
|
3
|
+
require "ransack"
|
2
4
|
|
3
5
|
module Mobility
|
4
6
|
module Ransack
|
7
|
+
class Visitor < Mobility::Plugins::Arel::Visitor
|
8
|
+
def initialize
|
9
|
+
super(nil, nil)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def visit_collection(objects)
|
15
|
+
objects.map(&method(:visit)).sum([]).uniq
|
16
|
+
end
|
17
|
+
alias :visit_Array :visit_collection
|
18
|
+
alias :visit_Arel_Nodes_Equality :visit_Arel_Nodes_Binary
|
19
|
+
alias :visit_Arel_Nodes_Or :visit_Arel_Nodes_Binary
|
20
|
+
|
21
|
+
def visit_Mobility_Plugins_Arel_Attribute(object)
|
22
|
+
[[object.backend_class, object.locale]]
|
23
|
+
end
|
24
|
+
|
25
|
+
def visit_default(*)
|
26
|
+
[]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module Search
|
31
|
+
def result(opts = {})
|
32
|
+
sorted = sorts.inject(super) do |relation, sort|
|
33
|
+
predicate = ::Ransack::Visitor.new.visit_Ransack_Nodes_Sort(sort)
|
34
|
+
apply_mobility_scope(relation, predicate, [sort.attr_name])
|
35
|
+
end
|
36
|
+
conditions.inject(sorted) do |relation, condition|
|
37
|
+
apply_mobility_scope(relation, condition.arel_predicate, condition.attributes.compact.flat_map(&:name))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def apply_mobility_scope(relation, predicate, attributes)
|
44
|
+
visitor.accept(predicate).inject(relation) do |i18n_rel, (backend_class, locale)|
|
45
|
+
backend_class.apply_scope(i18n_rel, predicate, locale)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def visitor
|
50
|
+
@visitor ||= Visitor.new
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
::Ransack::Search.prepend Search
|
5
55
|
end
|
6
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobility-ransack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Salzberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ransack
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 1.8.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '3.
|
22
|
+
version: '3.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 1.8.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '3.
|
32
|
+
version: '3.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: mobility
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,42 +82,42 @@ dependencies:
|
|
82
82
|
name: sqlite3
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- - ">="
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: 1.3.0
|
88
85
|
- - "~>"
|
89
86
|
- !ruby/object:Gem::Version
|
90
87
|
version: '1.3'
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.3.0
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - ">="
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: 1.3.0
|
98
95
|
- - "~>"
|
99
96
|
- !ruby/object:Gem::Version
|
100
97
|
version: '1.3'
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 1.3.0
|
101
101
|
- !ruby/object:Gem::Dependency
|
102
102
|
name: database_cleaner
|
103
103
|
requirement: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
|
-
- - ">="
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version: 1.7.0
|
108
105
|
- - "~>"
|
109
106
|
- !ruby/object:Gem::Version
|
110
107
|
version: '1.7'
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.7.0
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 1.7.0
|
118
115
|
- - "~>"
|
119
116
|
- !ruby/object:Gem::Version
|
120
117
|
version: '1.7'
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 1.7.0
|
121
121
|
description:
|
122
122
|
email:
|
123
123
|
- chris@dejimata.com
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
|
-
rubygems_version: 3.
|
156
|
+
rubygems_version: 3.1.2
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: Search attributes translated by Mobility with Ransack.
|