ransacker_translator 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/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +32 -0
- data/lib/ransacker_translator/models/concerns/ransacker_translator.rb +19 -0
- data/lib/ransacker_translator/railtie.rb +11 -0
- data/lib/ransacker_translator/version.rb +3 -0
- data/lib/ransacker_translator/view_helpers.rb +23 -0
- data/lib/ransacker_translator.rb +1 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cfd77242b19a837733fecd9aa1c6e0162b05eb06
|
4
|
+
data.tar.gz: d863db4bdb1bcb8c859df4f407f864a2e00e08e7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aedcae869558a74e827c9f80b9697efab91fc9da52a39bf3a3746bc36bdeda39da58e72b0ebfc1618163fddaa5ca71464f3ea2658e47a5a0c0c3e28f39037b9a
|
7
|
+
data.tar.gz: 08a383a097a4c03b9ca760f2f6afc2646e85b7620fd82f94acba36aebcb9957ca14f16d9951357907ca81b81902fa556fc0a66d59d564d905f2e151706e7aeba
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'RansackerTranslator'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
|
24
|
+
Rake::TestTask.new(:test) do |t|
|
25
|
+
t.libs << 'lib'
|
26
|
+
t.libs << 'test'
|
27
|
+
t.pattern = 'test/**/*_test.rb'
|
28
|
+
t.verbose = false
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'nkf'
|
2
|
+
|
3
|
+
module RansackerTranslator
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
def ransacker_translate(*columns)
|
8
|
+
columns.each do |column|
|
9
|
+
ransacker :"#{column}_translate", formatter: proc {|v| NKF.nkf('-w -XZ0', v.mb_chars) } do |parent|
|
10
|
+
single_byte_char = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz !#$%&¥;:'
|
11
|
+
double_byte_char = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz !#$%&¥;:'
|
12
|
+
Arel::Nodes::NamedFunction.new("UPPER",
|
13
|
+
[Arel::Nodes::NamedFunction.new("TRANSLATE",
|
14
|
+
[parent.table[column], double_byte_char, single_byte_char])])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rails/railtie'
|
2
|
+
require 'ransacker_translator/models/concerns/ransacker_translator'
|
3
|
+
require 'ransacker_translator/view_helpers'
|
4
|
+
|
5
|
+
module RansackerTranslator
|
6
|
+
class Railtie < ::Rails::Railtie
|
7
|
+
initializer "ransacker_translator.view_helpers" do
|
8
|
+
ActionView::Base.send :include, ViewHelpers
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RansackerTranslator
|
2
|
+
module ViewHelpers
|
3
|
+
def ransack_params_array_to_s(key)
|
4
|
+
if params[:q].present? && params[:q][key].present?
|
5
|
+
params[:q][key].join(' ')
|
6
|
+
else
|
7
|
+
''
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def ransack_param_translate_normal_or_key(*columns)
|
12
|
+
"#{columns.join("_translate_or_")}_translate_cont_any"
|
13
|
+
end
|
14
|
+
|
15
|
+
def ransack_param_translate_normal_and_key(*columns)
|
16
|
+
"#{columns.join("_translate_and_")}_translate_cont_any"
|
17
|
+
end
|
18
|
+
|
19
|
+
def ransack_param_translate_ignore_key(*columns)
|
20
|
+
"#{columns.join("_translate_and_")}_translate_not_cont_all"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'ransacker_translator/railtie' if defined? Rails
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ransacker_translator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Toyoaki Oko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.6
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ransack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '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'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: expand search by ransack
|
56
|
+
email:
|
57
|
+
- chariderpato@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.rdoc
|
64
|
+
- Rakefile
|
65
|
+
- lib/ransacker_translator.rb
|
66
|
+
- lib/ransacker_translator/models/concerns/ransacker_translator.rb
|
67
|
+
- lib/ransacker_translator/railtie.rb
|
68
|
+
- lib/ransacker_translator/version.rb
|
69
|
+
- lib/ransacker_translator/view_helpers.rb
|
70
|
+
homepage: https://github.com/patorash/ransacker_translator
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.2.2
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: expand search by ransack
|
94
|
+
test_files: []
|