easy_search_form 0.3.0 → 0.4.0

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
  SHA1:
3
- metadata.gz: 379f53407b4c1f01a02dd8e8851e67b7f051d010
4
- data.tar.gz: a373cc04571579a52786f5d248173ed1a60ebbf0
3
+ metadata.gz: 4f43365cd0c27c216ac7cdc9d9486fb645c9e8a5
4
+ data.tar.gz: fff9db69b0dccb86122275214152c91dcc47fc12
5
5
  SHA512:
6
- metadata.gz: dd82b909f155707bcbdd8a49fae96d549cdd06bdfb31e5dd09ee188d5c0673a04be7a280c218a0fd941aee32377585365e3a4cadc8d934ad84164e08dbd41c3b
7
- data.tar.gz: 983edabb501b515333001c9b369430f63cd3ce8cfa1245736d5a8a26eaaf00187847c59d8eee7114dfaf7c8f23cfc0e6bb43a5c2115852b6fcde6a71d7b8165f
6
+ metadata.gz: c38cf298a2fccc48cc1a09ed5754e8d01f2b8f3fae30bc6334d64b8ae93eaacc0f1a0e4b0256fb5491906e5dcdaf880468f5fd8951e5210508c202058d681e93
7
+ data.tar.gz: 8b2ca7e9c3bb3acf2aa245cf671b346edda9957bea804d16222fde3a0a495a83ee8c1fa6ba05ef99ca520e111ee49d0c40d6e9fa10990c6888e5c60a305db471
data/README.md CHANGED
@@ -8,6 +8,14 @@
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
+ for Rails < 3.2:
12
+
13
+ ```ruby
14
+ gem 'easy_search_form', "~>0.3"
15
+ ```
16
+
17
+ for Rails > 3.2:
18
+
11
19
  ```ruby
12
20
  gem 'easy_search_form'
13
21
  ```
@@ -22,7 +30,7 @@ Or install it yourself as:
22
30
 
23
31
  ## Example
24
32
 
25
- Migrations
33
+ Migrations
26
34
 
27
35
  ```ruby
28
36
  create_table :products do |t|
@@ -39,24 +47,24 @@ Or install it yourself as:
39
47
  acts_as_searchable :description, :size => :equals
40
48
  end
41
49
  ```
42
-
50
+
43
51
  Controller
44
-
52
+
45
53
  ```ruby
46
54
  def index
47
55
  # Replace the all for search and pass the param if the param is null it will return all.
48
- @users = User.search params[:query]
56
+ @users = User.search params[:query]
49
57
  end
50
58
  ```
51
-
59
+
52
60
  View
53
61
  ```ruby
54
62
  # Put the search_form when you want to print the search form.
55
- <%= search_form %>
63
+ <%= search_form %>
56
64
  ```
57
65
 
58
66
  ## Contact
59
-
67
+
60
68
  if you need help contanct me: bfscordeiro (at) gmail.com
61
69
 
62
70
 
@@ -64,4 +72,4 @@ Copyright (c) 2010 Bruno Cordeiro, released under the MIT license
64
72
 
65
73
  ## License
66
74
 
67
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
75
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -1,3 +1,3 @@
1
1
  module EasySearchForm
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -5,14 +5,14 @@ module EasySearchForm
5
5
  def self.included(base)
6
6
  base.send :extend, ClassMethods
7
7
  end
8
-
8
+
9
9
  module ClassMethods
10
10
  def acts_as_searchable(*args)
11
11
  @search_options = args
12
12
  self.send :extend, SearchClassMethods
13
13
  end
14
14
  end
15
-
15
+
16
16
  module SearchClassMethods
17
17
  def search(search)
18
18
  if search
@@ -20,7 +20,7 @@ module EasySearchForm
20
20
  values = []
21
21
  @search_options.each do |opt|
22
22
  condition_type = nil
23
-
23
+
24
24
  if opt.instance_of?(Hash)
25
25
  debugger
26
26
  case opt[opt.keys.first]
@@ -29,29 +29,29 @@ module EasySearchForm
29
29
  else
30
30
  condition_type = "LIKE"
31
31
  end
32
-
32
+
33
33
  query << "#{opt.keys.first} #{condition_type} ?"
34
34
  else
35
35
  query << "#{opt} LIKE ?"
36
36
  end
37
-
37
+
38
38
  if condition_type.nil? or condition_type == "LIKE"
39
39
  values << "%#{search}%"
40
40
  else
41
41
  values << search
42
- end
42
+ end
43
43
  end
44
-
44
+
45
45
  conditions = [query.join(" OR ")]
46
46
  conditions += values
47
-
48
- find(:all, :conditions => conditions)
47
+
48
+ where(conditions)
49
49
  else
50
50
  all
51
51
  end
52
- end
52
+ end
53
53
  end
54
54
  end
55
55
 
56
56
  ActionView::Base.send :include, EasySearchHelper
57
- ActiveRecord::Base.send :include, EasySearchForm
57
+ ActiveRecord::Base.send :include, EasySearchForm
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_search_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Cordeiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-24 00:00:00.000000000 Z
11
+ date: 2016-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: Make easy create simple search formss.
@@ -59,8 +59,8 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - .gitignore
63
- - .travis.yml
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
64
  - Gemfile
65
65
  - LICENSE.txt
66
66
  - README.md
@@ -82,17 +82,17 @@ require_paths:
82
82
  - lib
83
83
  required_ruby_version: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - '>='
85
+ - - ">="
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - '>='
90
+ - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubyforge_project:
95
- rubygems_version: 2.4.6
95
+ rubygems_version: 2.4.8
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: Make easy create simple search formss.