ransack_predicate_cont_any_word 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 71bd49fe276bb879faf9d9d900f13e0c39779379
4
+ data.tar.gz: 848433e80ae0a0fbb53c533961c9b22111e03bbc
5
+ SHA512:
6
+ metadata.gz: 50c2a70de0b2ecf2a76ec8718378dd11992d727388d0be285d17781f6215007ea5540f84454ebd0d381d3098c35d36870e5e3b00388d53f74b71cae8af843fee
7
+ data.tar.gz: cdab942e968781b997d6dd4f3d7af45710dc9ef91732a2916d4e425b32ecca0d807a7aff052fe06c171855dd97363e6dd3d901550b8e1b41f197c8901483d2cb
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 kaspernj
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.md ADDED
@@ -0,0 +1,37 @@
1
+ # RansackPredicateContAnyWord
2
+
3
+ This gem adds the "cont_any_word" predicate to Ransack for filtering more natural and human.
4
+
5
+ ## Usage
6
+
7
+ ```ruby
8
+ User.ransack(email_cont_any_word: "@example.com test").result.to_sql #=> SELECT "users".* FROM "users" WHERE ("users"."email" LIKE '%@example.com%' AND "users"."email" LIKE '%test%')
9
+ ```
10
+
11
+ It is also possible to search for whole sentences
12
+ ```ruby
13
+ User.ransack(encrypted_password_cont_any_word: '"yeah this is my password" password some').result.to_sql #=> SELECT "users".* FROM "users" WHERE ("users"."encrypted_password" LIKE '%yeah this is my password%' AND "users"."encrypted_password" LIKE '%password%' AND "users"."encrypted_password" LIKE '%some%')
14
+ ```
15
+
16
+ ## Installation
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'ransack_predicate_cont_any_word'
21
+ ```
22
+
23
+ And then execute:
24
+ ```bash
25
+ $ bundle
26
+ ```
27
+
28
+ Or install it yourself as:
29
+ ```bash
30
+ $ gem install ransack_predicate_cont_any_word
31
+ ```
32
+
33
+ ## Contributing
34
+ Contribution directions go here.
35
+
36
+ ## License
37
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,31 @@
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 = "RansackPredicateContAnyWord"
12
+ rdoc.options << "--line-numbers"
13
+ rdoc.rdoc_files.include("README.md")
14
+ rdoc.rdoc_files.include("lib/**/*.rb")
15
+ end
16
+
17
+ require "bundler/gem_tasks"
18
+
19
+ require "rake/testtask"
20
+
21
+ Rake::TestTask.new(:test) do |t|
22
+ t.libs << "lib"
23
+ t.libs << "test"
24
+ t.pattern = "test/**/*_test.rb"
25
+ t.verbose = false
26
+ end
27
+
28
+ task default: :test
29
+
30
+ require "best_practice_project"
31
+ BestPracticeProject.load_tasks
@@ -0,0 +1,11 @@
1
+ module RansackPredicateContAnyWord; end
2
+
3
+ require "ransack"
4
+
5
+ Ransack.configure do |config|
6
+ config.add_predicate "cont_any_word",
7
+ arel_predicate: "matches_all",
8
+ formatter: proc { |v| v.scan(/\"(.*?)\"|(\S+)/).flatten.compact.map { |t| "%#{t}%" } },
9
+ validator: proc { |v| v.present? },
10
+ type: :string
11
+ end
@@ -0,0 +1,3 @@
1
+ module RansackPredicateContAnyWord
2
+ VERSION = "0.0.0".freeze
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :ransack_predicate_cont_any_word do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ransack_predicate_cont_any_word
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - kaspernj
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: "'cont_any_word' predicate for Ransack."
14
+ email:
15
+ - kaspernj@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - MIT-LICENSE
21
+ - README.md
22
+ - Rakefile
23
+ - lib/ransack_predicate_cont_any_word.rb
24
+ - lib/ransack_predicate_cont_any_word/version.rb
25
+ - lib/tasks/ransack_predicate_cont_any_word_tasks.rake
26
+ homepage: https://www.github.com/kaspernj/ransack_predicate_cont_any_word
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.6.8
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: "'cont_any_word' predicate for Ransack."
50
+ test_files: []