mobility-ransack 0.2.2 → 1.0.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fccffc8cd01e9b5ffa2b14855cbdb69179c686ef637b4e1875f05714d12240aa
4
- data.tar.gz: 17206ff86d0633b9ba24fe328c479e08d6608c11ebbbce5d820a84ff8d72cdec
3
+ metadata.gz: f3df672b8192defc4e9888ff5d5e11d8321611a5ed8f14903499e481447d7530
4
+ data.tar.gz: 656a8ca330a761e02595f58670dce0f9dd7a705192e82d17e7357909cf0b8301
5
5
  SHA512:
6
- metadata.gz: fceda5efd7e9a0e21b1d2c49e0c53881ad68633c38a30722bf8d19bf8f31f08364a8897754418b7c9ae33321b81e38c37baf552a86f32ded4e63c21e1f30feb0
7
- data.tar.gz: bb32ad4495c1091e5dc81e89498ca579f5a24caa98616213c989dd6650c08e1d01c5fe47f911d3e5b312235bb8d8b7990050fa17a922f38829649f3114467771
6
+ metadata.gz: 7c31d6ddadc41ac4538220aafa399beaf2d99cdb93145ba38d6aa1ca8af276bc817934597c2d85db16edd70c24fbb9922b8382a859441d30b597f8a24667f6cf
7
+ data.tar.gz: 0dceb9bafd2fc61681afe5fe37b1fdb37c19625749772ca0ad6d91659df9b4c63d3fd76f043fbf7d845a59f42b5c665c6a57d7117439c4cebea7f1d73df6cfb3
data/Gemfile CHANGED
@@ -6,13 +6,7 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
6
  gemspec
7
7
 
8
8
  group :development, :test do
9
- if ENV['RAILS_VERSION'] == '5.1'
10
- gem 'rails', '>= 5.1', '< 5.2'
11
- elsif ENV['RAILS_VERSION'] == '5.0'
12
- gem 'rails', '>= 5.0', '< 5.1'
13
- else
14
- gem 'rails', '>= 5.2.0.rc2', '< 5.3'
15
- end
9
+ gem 'rails', "~> #{ENV['RAILS_VERSION'] || '6.0'}"
16
10
 
17
11
  gem 'pry'
18
12
  gem 'pry-byebug'
@@ -1,168 +1,185 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mobility-ransack (0.2.1)
4
+ mobility-ransack (0.2.2)
5
5
  mobility (~> 0.8.0)
6
- ransack (>= 1.8.0, < 2.1)
6
+ ransack (>= 1.8.0, < 3.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (5.2.1)
12
- actionpack (= 5.2.1)
11
+ actioncable (6.0.3.4)
12
+ actionpack (= 6.0.3.4)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
- actionmailer (5.2.1)
16
- actionpack (= 5.2.1)
17
- actionview (= 5.2.1)
18
- activejob (= 5.2.1)
15
+ actionmailbox (6.0.3.4)
16
+ actionpack (= 6.0.3.4)
17
+ activejob (= 6.0.3.4)
18
+ activerecord (= 6.0.3.4)
19
+ activestorage (= 6.0.3.4)
20
+ activesupport (= 6.0.3.4)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.0.3.4)
23
+ actionpack (= 6.0.3.4)
24
+ actionview (= 6.0.3.4)
25
+ activejob (= 6.0.3.4)
19
26
  mail (~> 2.5, >= 2.5.4)
20
27
  rails-dom-testing (~> 2.0)
21
- actionpack (5.2.1)
22
- actionview (= 5.2.1)
23
- activesupport (= 5.2.1)
24
- rack (~> 2.0)
28
+ actionpack (6.0.3.4)
29
+ actionview (= 6.0.3.4)
30
+ activesupport (= 6.0.3.4)
31
+ rack (~> 2.0, >= 2.0.8)
25
32
  rack-test (>= 0.6.3)
26
33
  rails-dom-testing (~> 2.0)
27
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
- actionview (5.2.1)
29
- activesupport (= 5.2.1)
34
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
+ actiontext (6.0.3.4)
36
+ actionpack (= 6.0.3.4)
37
+ activerecord (= 6.0.3.4)
38
+ activestorage (= 6.0.3.4)
39
+ activesupport (= 6.0.3.4)
40
+ nokogiri (>= 1.8.5)
41
+ actionview (6.0.3.4)
42
+ activesupport (= 6.0.3.4)
30
43
  builder (~> 3.1)
31
44
  erubi (~> 1.4)
32
45
  rails-dom-testing (~> 2.0)
33
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
- activejob (5.2.1)
35
- activesupport (= 5.2.1)
46
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
+ activejob (6.0.3.4)
48
+ activesupport (= 6.0.3.4)
36
49
  globalid (>= 0.3.6)
37
- activemodel (5.2.1)
38
- activesupport (= 5.2.1)
39
- activerecord (5.2.1)
40
- activemodel (= 5.2.1)
41
- activesupport (= 5.2.1)
42
- arel (>= 9.0)
43
- activestorage (5.2.1)
44
- actionpack (= 5.2.1)
45
- activerecord (= 5.2.1)
50
+ activemodel (6.0.3.4)
51
+ activesupport (= 6.0.3.4)
52
+ activerecord (6.0.3.4)
53
+ activemodel (= 6.0.3.4)
54
+ activesupport (= 6.0.3.4)
55
+ activestorage (6.0.3.4)
56
+ actionpack (= 6.0.3.4)
57
+ activejob (= 6.0.3.4)
58
+ activerecord (= 6.0.3.4)
46
59
  marcel (~> 0.3.1)
47
- activesupport (5.2.1)
60
+ activesupport (6.0.3.4)
48
61
  concurrent-ruby (~> 1.0, >= 1.0.2)
49
62
  i18n (>= 0.7, < 2)
50
63
  minitest (~> 5.1)
51
64
  tzinfo (~> 1.1)
52
- arel (9.0.0)
53
- builder (3.2.3)
54
- byebug (10.0.2)
65
+ zeitwerk (~> 2.2, >= 2.2.2)
66
+ builder (3.2.4)
67
+ byebug (11.1.1)
55
68
  coderay (1.1.2)
56
- concurrent-ruby (1.0.5)
57
- crass (1.0.4)
58
- database_cleaner (1.7.0)
69
+ concurrent-ruby (1.1.7)
70
+ crass (1.0.6)
71
+ database_cleaner (1.8.4)
59
72
  diff-lcs (1.3)
60
- erubi (1.7.1)
61
- globalid (0.4.1)
73
+ erubi (1.9.0)
74
+ globalid (0.4.2)
62
75
  activesupport (>= 4.2.0)
63
- i18n (1.0.1)
76
+ i18n (1.8.5)
64
77
  concurrent-ruby (~> 1.0)
65
- loofah (2.2.2)
78
+ loofah (2.7.0)
66
79
  crass (~> 1.0.2)
67
80
  nokogiri (>= 1.5.9)
68
- mail (2.7.0)
81
+ mail (2.7.1)
69
82
  mini_mime (>= 0.1.1)
70
- marcel (0.3.2)
83
+ marcel (0.3.3)
71
84
  mimemagic (~> 0.3.2)
72
- method_source (0.9.0)
73
- mimemagic (0.3.2)
74
- mini_mime (1.0.1)
75
- mini_portile2 (2.3.0)
76
- minitest (5.11.3)
77
- mobility (0.8.0)
78
- i18n (>= 0.6.10, < 1.1)
85
+ method_source (1.0.0)
86
+ mimemagic (0.3.5)
87
+ mini_mime (1.0.2)
88
+ mini_portile2 (2.4.0)
89
+ minitest (5.14.2)
90
+ mobility (0.8.13)
91
+ i18n (>= 0.6.10, < 2)
79
92
  request_store (~> 1.0)
80
- nio4r (2.3.1)
81
- nokogiri (1.8.4)
82
- mini_portile2 (~> 2.3.0)
83
- pry (0.11.3)
84
- coderay (~> 1.1.0)
85
- method_source (~> 0.9.0)
86
- pry-byebug (3.6.0)
87
- byebug (~> 10.0)
88
- pry (~> 0.10)
89
- rack (2.0.5)
93
+ nio4r (2.5.4)
94
+ nokogiri (1.10.10)
95
+ mini_portile2 (~> 2.4.0)
96
+ polyamorous (2.3.2)
97
+ activerecord (>= 5.2.1)
98
+ pry (0.13.0)
99
+ coderay (~> 1.1)
100
+ method_source (~> 1.0)
101
+ pry-byebug (3.9.0)
102
+ byebug (~> 11.0)
103
+ pry (~> 0.13.0)
104
+ rack (2.2.3)
90
105
  rack-test (1.1.0)
91
106
  rack (>= 1.0, < 3)
92
- rails (5.2.1)
93
- actioncable (= 5.2.1)
94
- actionmailer (= 5.2.1)
95
- actionpack (= 5.2.1)
96
- actionview (= 5.2.1)
97
- activejob (= 5.2.1)
98
- activemodel (= 5.2.1)
99
- activerecord (= 5.2.1)
100
- activestorage (= 5.2.1)
101
- activesupport (= 5.2.1)
107
+ rails (6.0.3.4)
108
+ actioncable (= 6.0.3.4)
109
+ actionmailbox (= 6.0.3.4)
110
+ actionmailer (= 6.0.3.4)
111
+ actionpack (= 6.0.3.4)
112
+ actiontext (= 6.0.3.4)
113
+ actionview (= 6.0.3.4)
114
+ activejob (= 6.0.3.4)
115
+ activemodel (= 6.0.3.4)
116
+ activerecord (= 6.0.3.4)
117
+ activestorage (= 6.0.3.4)
118
+ activesupport (= 6.0.3.4)
102
119
  bundler (>= 1.3.0)
103
- railties (= 5.2.1)
120
+ railties (= 6.0.3.4)
104
121
  sprockets-rails (>= 2.0.0)
105
122
  rails-dom-testing (2.0.3)
106
123
  activesupport (>= 4.2.0)
107
124
  nokogiri (>= 1.6)
108
- rails-html-sanitizer (1.0.4)
109
- loofah (~> 2.2, >= 2.2.2)
110
- railties (5.2.1)
111
- actionpack (= 5.2.1)
112
- activesupport (= 5.2.1)
125
+ rails-html-sanitizer (1.3.0)
126
+ loofah (~> 2.3)
127
+ railties (6.0.3.4)
128
+ actionpack (= 6.0.3.4)
129
+ activesupport (= 6.0.3.4)
113
130
  method_source
114
131
  rake (>= 0.8.7)
115
- thor (>= 0.19.0, < 2.0)
116
- rake (10.5.0)
117
- ransack (2.0.1)
118
- actionpack (>= 5.0)
119
- activerecord (>= 5.0)
120
- activesupport (>= 5.0)
132
+ thor (>= 0.20.3, < 2.0)
133
+ rake (13.0.1)
134
+ ransack (2.3.2)
135
+ activerecord (>= 5.2.1)
136
+ activesupport (>= 5.2.1)
121
137
  i18n
122
- request_store (1.4.1)
138
+ polyamorous (= 2.3.2)
139
+ request_store (1.5.0)
123
140
  rack (>= 1.4)
124
- rspec (3.8.0)
125
- rspec-core (~> 3.8.0)
126
- rspec-expectations (~> 3.8.0)
127
- rspec-mocks (~> 3.8.0)
128
- rspec-core (3.8.0)
129
- rspec-support (~> 3.8.0)
130
- rspec-expectations (3.8.1)
141
+ rspec (3.9.0)
142
+ rspec-core (~> 3.9.0)
143
+ rspec-expectations (~> 3.9.0)
144
+ rspec-mocks (~> 3.9.0)
145
+ rspec-core (3.9.1)
146
+ rspec-support (~> 3.9.1)
147
+ rspec-expectations (3.9.1)
131
148
  diff-lcs (>= 1.2.0, < 2.0)
132
- rspec-support (~> 3.8.0)
133
- rspec-mocks (3.8.0)
149
+ rspec-support (~> 3.9.0)
150
+ rspec-mocks (3.9.1)
134
151
  diff-lcs (>= 1.2.0, < 2.0)
135
- rspec-support (~> 3.8.0)
136
- rspec-support (3.8.0)
137
- sprockets (3.7.2)
152
+ rspec-support (~> 3.9.0)
153
+ rspec-support (3.9.2)
154
+ sprockets (4.0.2)
138
155
  concurrent-ruby (~> 1.0)
139
156
  rack (> 1, < 3)
140
- sprockets-rails (3.2.1)
157
+ sprockets-rails (3.2.2)
141
158
  actionpack (>= 4.0)
142
159
  activesupport (>= 4.0)
143
160
  sprockets (>= 3.0.0)
144
- sqlite3 (1.3.13)
145
- thor (0.20.0)
161
+ sqlite3 (1.4.2)
162
+ thor (1.0.1)
146
163
  thread_safe (0.3.6)
147
- tzinfo (1.2.5)
164
+ tzinfo (1.2.7)
148
165
  thread_safe (~> 0.1)
149
- websocket-driver (0.7.0)
166
+ websocket-driver (0.7.3)
150
167
  websocket-extensions (>= 0.1.0)
151
- websocket-extensions (0.1.3)
168
+ websocket-extensions (0.1.5)
169
+ zeitwerk (2.4.1)
152
170
 
153
171
  PLATFORMS
154
172
  ruby
155
173
 
156
174
  DEPENDENCIES
157
- database_cleaner (~> 1.7.0)
175
+ database_cleaner (~> 1.7, >= 1.7.0)
158
176
  mobility-ransack!
159
177
  pry
160
178
  pry-byebug
161
- rails (>= 5.2.0.rc2, < 5.3)
162
- rake (~> 10.0)
163
- ransack (~> 2.0.0)
179
+ rails (~> 6.0)
180
+ rake (>= 12.3.3)
164
181
  rspec (~> 3.0)
165
- sqlite3
182
+ sqlite3 (~> 1.3, >= 1.3.0)
166
183
 
167
184
  BUNDLED WITH
168
- 1.16.1
185
+ 2.0.2
data/README.md CHANGED
@@ -18,7 +18,7 @@ Search on translated attributes with
18
18
  Just add the gem to your Gemfile:
19
19
 
20
20
  ```ruby
21
- gem 'mobility-ransack', '~> 0.2.1'
21
+ gem 'mobility-ransack', '~> 0.2.2'
22
22
  ```
23
23
 
24
24
  Now enable the `ransack` plugin in Mobility's configuration so that it can be
@@ -4,21 +4,28 @@ require "mobility"
4
4
  module Mobility
5
5
  module Plugins
6
6
  module Ransack
7
+ extend Plugin
8
+
9
+ default true
10
+ requires :backend, include: :before
11
+ requires :active_record
12
+
7
13
  # Applies ransack plugin.
8
14
  # @param [Attributes] attributes
9
15
  # @param [Boolean] option
10
- def self.apply(attributes, option)
11
- if option
12
- backend_class, model_class = attributes.backend_class, attributes.model_class
13
- attributes.each do |attr|
14
- model_class.ransacker(attr) { backend_class.build_node(attr, Mobility.locale) }
16
+ included_hook do |klass, backend_class|
17
+ if options[:ransack]
18
+ names.each do |name|
19
+ klass.ransacker(name) { backend_class.build_node(name, Mobility.locale) }
15
20
  end
16
- model_class.extend self
21
+ klass.extend ClassMethods
17
22
  end
18
23
  end
19
24
 
20
- def ransack(*)
21
- super.extend(Search)
25
+ module ClassMethods
26
+ def ransack(*)
27
+ super.extend(Search)
28
+ end
22
29
  end
23
30
 
24
31
  module Search
@@ -35,11 +42,14 @@ module Mobility
35
42
  private
36
43
 
37
44
  def apply_mobility_scope(relation, predicate, attributes)
38
- (attributes & object.mobility_attributes).inject(relation) do |i18n_rel, attr|
45
+ mobility_attributes = attributes.select { |attr| object.mobility_attribute?(attr) }
46
+ mobility_attributes.inject(relation) do |i18n_rel, attr|
39
47
  object.mobility_backend_class(attr).apply_scope(i18n_rel, predicate)
40
48
  end
41
49
  end
42
50
  end
43
51
  end
52
+
53
+ register_plugin(:ransack, Ransack)
44
54
  end
45
55
  end
@@ -1,5 +1,5 @@
1
1
  module Mobility
2
2
  module Ransack
3
- VERSION = "0.2.2"
3
+ VERSION = "1.0.0.alpha"
4
4
  end
5
5
  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: 0.2.2
4
+ version: 1.0.0.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-10 00:00:00.000000000 Z
11
+ date: 2020-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ransack
@@ -36,28 +36,28 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 0.8.0
39
+ version: 1.0.0.beta1
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 0.8.0
46
+ version: 1.0.0.beta1
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '10.0'
53
+ version: 12.3.3
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '10.0'
60
+ version: 12.3.3
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rspec
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -76,43 +76,43 @@ dependencies:
76
76
  name: sqlite3
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '1.3'
82
79
  - - ">="
83
80
  - !ruby/object:Gem::Version
84
81
  version: 1.3.0
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '1.3'
85
85
  type: :development
86
86
  prerelease: false
87
87
  version_requirements: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - "~>"
90
- - !ruby/object:Gem::Version
91
- version: '1.3'
92
89
  - - ">="
93
90
  - !ruby/object:Gem::Version
94
91
  version: 1.3.0
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '1.3'
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: database_cleaner
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - "~>"
100
- - !ruby/object:Gem::Version
101
- version: '1.7'
102
99
  - - ">="
103
100
  - !ruby/object:Gem::Version
104
101
  version: 1.7.0
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '1.7'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: '1.7'
112
109
  - - ">="
113
110
  - !ruby/object:Gem::Version
114
111
  version: 1.7.0
115
- description:
112
+ - - "~>"
113
+ - !ruby/object:Gem::Version
114
+ version: '1.7'
115
+ description:
116
116
  email:
117
117
  - chris@dejimata.com
118
118
  executables: []
@@ -132,7 +132,7 @@ homepage: https://github.com/shioyama/mobility-ransack
132
132
  licenses:
133
133
  - MIT
134
134
  metadata: {}
135
- post_install_message:
135
+ post_install_message:
136
136
  rdoc_options: []
137
137
  require_paths:
138
138
  - lib
@@ -143,13 +143,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  requirements:
146
- - - ">="
146
+ - - ">"
147
147
  - !ruby/object:Gem::Version
148
- version: '0'
148
+ version: 1.3.1
149
149
  requirements: []
150
- rubyforge_project:
151
- rubygems_version: 2.7.6
152
- signing_key:
150
+ rubygems_version: 3.0.6
151
+ signing_key:
153
152
  specification_version: 4
154
153
  summary: Search attributes translated by Mobility with Ransack.
155
154
  test_files: []