quick_search 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'quick_search/active_record'
3
+
4
+ ActiveRecord::Base.extend QuickSearch
@@ -0,0 +1,45 @@
1
+ # Powered By Urazov Marat
2
+ # Marat QuickSearch Lib for Abt module
3
+ module QuickSearch
4
+ def quick_search(options)
5
+ scope :quick_search, lambda { |q_string|
6
+ c = ARCondition.new(nil, "OR")
7
+ options[:fields].each do |field|
8
+ c << ["#{field} ILIKE ? ", "%#{q_string}%"]
9
+ end
10
+ joins(options[:joins]).includes(options[:include]).where(c.conditions) if options
11
+ }
12
+
13
+ #scope :qs, lambda{|q_string| guick_search(q_string) }
14
+
15
+ scope :first_letter_search, lambda { |q_string|
16
+ c = ARCondition.new(nil, "OR")
17
+ options[:fields].each do |field|
18
+ c << ["#{field} ILIKE ? ", "#{q_string}%"]
19
+ end
20
+ joins(options[:joins]).includes(options[:include]).where(c.conditions) if options
21
+ }
22
+
23
+ #scope :fls, lambda{|q_string| first_letter_search(q_string) }
24
+
25
+ include InstanceMethods
26
+
27
+ class << self
28
+ alias_method :qs, :quick_search
29
+ alias_method :fls, :first_letter_search
30
+ end
31
+ end
32
+
33
+ alias_method :qs, :quick_search
34
+
35
+ module InstanceMethods
36
+
37
+ end
38
+ end
39
+
40
+
41
+
42
+
43
+
44
+
45
+
@@ -0,0 +1,4 @@
1
+ # -*- encoding: utf-8 -*-
2
+ module QuickSearch
3
+ VERSION = '0.0.1'
4
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quick_search
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Belorusov Dmitriy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: ar_condition
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.0.1
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.0.1
46
+ description: Quick Search Helper for Find by Text or String fields in database Ruby
47
+ on Rails.
48
+ email:
49
+ - Develby@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - lib/quick_search.rb
55
+ - lib/quick_search/active_record.rb
56
+ - lib/quick_search/version.rb
57
+ homepage: http://worldalias.com
58
+ licenses: []
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 1.8.19
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: Quick Search Helper for Find by Text or String fields in database Ruby on
81
+ Rails.
82
+ test_files: []