mobility-ransack 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +95 -0
- data/LICENSE.txt +21 -0
- data/README.md +29 -0
- data/Rakefile +6 -0
- data/lib/mobility/plugins/ransack.rb +39 -0
- data/lib/mobility/ransack.rb +6 -0
- data/lib/mobility/ransack/version.rb +5 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b5c32e465d6d2ecf24aad3f437e3a06206fd535a1252e3e3a4a91fb41ea75b27
|
4
|
+
data.tar.gz: b480db1f5e8719d576295eb344183a5f52af24058be4502ae9df2614baf37037
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2d3839213620e694bab68d8752e2d461158d72d366113c9c4fa9dbdd924a675b9edca9c198e1073b779bbd57e878a78bf68d75def0b12794513d3ce668740b26
|
7
|
+
data.tar.gz: baa9ad034e337e36ee38327896c360ca97f837f8eee564d7adf11a19b3a3efb142b38ab9af8a2bb0e7bb21dc4080ecd737aa5c026e9a37c4915aef37871f54a4
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mobility-ransack (0.0.1)
|
5
|
+
mobility (~> 0.8.0)
|
6
|
+
ransack (~> 1.8.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionpack (5.1.1)
|
12
|
+
actionview (= 5.1.1)
|
13
|
+
activesupport (= 5.1.1)
|
14
|
+
rack (~> 2.0)
|
15
|
+
rack-test (~> 0.6.3)
|
16
|
+
rails-dom-testing (~> 2.0)
|
17
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
18
|
+
actionview (5.1.1)
|
19
|
+
activesupport (= 5.1.1)
|
20
|
+
builder (~> 3.1)
|
21
|
+
erubi (~> 1.4)
|
22
|
+
rails-dom-testing (~> 2.0)
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
24
|
+
activemodel (5.1.1)
|
25
|
+
activesupport (= 5.1.1)
|
26
|
+
activerecord (5.1.1)
|
27
|
+
activemodel (= 5.1.1)
|
28
|
+
activesupport (= 5.1.1)
|
29
|
+
arel (~> 8.0)
|
30
|
+
activesupport (5.1.1)
|
31
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
32
|
+
i18n (~> 0.7)
|
33
|
+
minitest (~> 5.1)
|
34
|
+
tzinfo (~> 1.1)
|
35
|
+
arel (8.0.0)
|
36
|
+
builder (3.2.3)
|
37
|
+
concurrent-ruby (1.0.5)
|
38
|
+
crass (1.0.4)
|
39
|
+
diff-lcs (1.3)
|
40
|
+
erubi (1.7.1)
|
41
|
+
i18n (0.9.5)
|
42
|
+
concurrent-ruby (~> 1.0)
|
43
|
+
loofah (2.2.2)
|
44
|
+
crass (~> 1.0.2)
|
45
|
+
nokogiri (>= 1.5.9)
|
46
|
+
mini_portile2 (2.3.0)
|
47
|
+
minitest (5.11.3)
|
48
|
+
mobility (0.8.0)
|
49
|
+
i18n (>= 0.6.10, < 1.1)
|
50
|
+
request_store (~> 1.0)
|
51
|
+
nokogiri (1.8.4)
|
52
|
+
mini_portile2 (~> 2.3.0)
|
53
|
+
rack (2.0.5)
|
54
|
+
rack-test (0.6.3)
|
55
|
+
rack (>= 1.0)
|
56
|
+
rails-dom-testing (2.0.3)
|
57
|
+
activesupport (>= 4.2.0)
|
58
|
+
nokogiri (>= 1.6)
|
59
|
+
rails-html-sanitizer (1.0.4)
|
60
|
+
loofah (~> 2.2, >= 2.2.2)
|
61
|
+
rake (10.5.0)
|
62
|
+
ransack (1.8.9)
|
63
|
+
actionpack (>= 3.0, <= 5.1.1)
|
64
|
+
activerecord (>= 3.0, <= 5.1.1)
|
65
|
+
activesupport (>= 3.0, <= 5.1.1)
|
66
|
+
i18n
|
67
|
+
request_store (1.4.1)
|
68
|
+
rack (>= 1.4)
|
69
|
+
rspec (3.8.0)
|
70
|
+
rspec-core (~> 3.8.0)
|
71
|
+
rspec-expectations (~> 3.8.0)
|
72
|
+
rspec-mocks (~> 3.8.0)
|
73
|
+
rspec-core (3.8.0)
|
74
|
+
rspec-support (~> 3.8.0)
|
75
|
+
rspec-expectations (3.8.1)
|
76
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
77
|
+
rspec-support (~> 3.8.0)
|
78
|
+
rspec-mocks (3.8.0)
|
79
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
80
|
+
rspec-support (~> 3.8.0)
|
81
|
+
rspec-support (3.8.0)
|
82
|
+
thread_safe (0.3.6)
|
83
|
+
tzinfo (1.2.5)
|
84
|
+
thread_safe (~> 0.1)
|
85
|
+
|
86
|
+
PLATFORMS
|
87
|
+
ruby
|
88
|
+
|
89
|
+
DEPENDENCIES
|
90
|
+
mobility-ransack!
|
91
|
+
rake (~> 10.0)
|
92
|
+
rspec (~> 3.0)
|
93
|
+
|
94
|
+
BUNDLED WITH
|
95
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Chris Salzberg
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Mobility Ransack
|
2
|
+
================
|
3
|
+
|
4
|
+
Search on translated attributes with
|
5
|
+
[Mobility](https://github.com/shioyama/mobility) and
|
6
|
+
[Ransack](https://github.com/activerecord-hackery/ransack).
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Just add the gem to your Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'mobility-ransack'
|
14
|
+
```
|
15
|
+
|
16
|
+
Now enable ransack for attributes on a model with the `ransack` option:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
class Post < ApplicationRecord
|
20
|
+
extend Mobility
|
21
|
+
translates :foo, ransack: true
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
Now you can search on `foo` with Ransack just like any untranslated attribute.
|
26
|
+
|
27
|
+
## License
|
28
|
+
|
29
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "ransack"
|
2
|
+
require "mobility"
|
3
|
+
|
4
|
+
module Mobility
|
5
|
+
module Plugins
|
6
|
+
module Ransack
|
7
|
+
# Applies ransack plugin.
|
8
|
+
# @param [Attributes] attributes
|
9
|
+
# @param [Boolean] option
|
10
|
+
def self.apply(attributes, option)
|
11
|
+
if option
|
12
|
+
backend_class = attributes.backend_class
|
13
|
+
plugin = self
|
14
|
+
attributes.model_class.class_eval do
|
15
|
+
attributes.each do |attr|
|
16
|
+
ransacker(attr) { backend_class.build_node(attr, Mobility.locale) }
|
17
|
+
end
|
18
|
+
extend plugin
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def ransack(params = {}, options = {})
|
24
|
+
Search.new(self, params, options)
|
25
|
+
end
|
26
|
+
|
27
|
+
class Search < ::Ransack::Search
|
28
|
+
def result(opts = {})
|
29
|
+
conditions.inject(@context.evaluate(self, opts)) do |relation, condition|
|
30
|
+
predicate = condition.arel_predicate
|
31
|
+
(condition.attributes.compact.flatten.map(&:name) & object.mobility_attributes).inject(relation) do |i18n_rel, attr|
|
32
|
+
object.mobility_backend_class(attr).apply_scope(i18n_rel, predicate)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mobility-ransack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Salzberg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ransack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.8.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.8.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mobility
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.8.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.8.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- chris@dejimata.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- Gemfile
|
77
|
+
- Gemfile.lock
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/mobility/plugins/ransack.rb
|
82
|
+
- lib/mobility/ransack.rb
|
83
|
+
- lib/mobility/ransack/version.rb
|
84
|
+
homepage: https://github.com/shioyama/mobility-ransack
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.7.6
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Search attributes translated by Mobility with Ransack.
|
108
|
+
test_files: []
|