rails-simple-search 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/README.rdoc +5 -1
  3. data/lib/sql_handler.rb +9 -12
  4. metadata +30 -24
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1fa87087dc4f0c9095a6e1e393ba3a697124ac0b
4
+ data.tar.gz: 04a6a6e9efeeb75a451b0e0a934af16c61ceca6a
5
+ SHA512:
6
+ metadata.gz: 05cca30064e8497ebac3d6b01058f8dfa4f5bd9e1e7da1017db3b5acebc3c06dfd770392149a5d7a26b6d3496888e3bf11cea758174ed2ca9d9fb1cae690ac8b
7
+ data.tar.gz: c5072f099210ab82d751ee2220c64a29298fd338e885ce48066a8c4b87f60650fc3e814289d09821f21acde36b69292f1730449301ffc893060ebe46319b8667
data/README.rdoc CHANGED
@@ -71,7 +71,11 @@ The following is how we implement this searching function with rails-simple-sear
71
71
 
72
72
  == Note
73
73
 
74
- For rails 2.x.x applications, you might want to use the version 0.9.0. Since version 0.9.1, this gem started to support rails 3 now. The latest version 0.9.4 is tested under rails 3.2.6.
74
+ For rails 2.x.x applications, you might want to use the version 0.9.0.
75
+
76
+ From version 0.9.1 to 0.9.7, Rails 3 is supported.
77
+
78
+ From version 0.9.8 on, this gem started to support Rails 4. Version 0.9.8 is tested under Rails 4.1.1.
75
79
 
76
80
  There is a real demo application which you can download and run immediately: https://github.com/yzhanginwa/demo_app_for_rails_simple_search
77
81
 
data/lib/sql_handler.rb CHANGED
@@ -18,11 +18,14 @@ module RailsSimpleSearch
18
18
 
19
19
  def run
20
20
  run_criteria
21
+
22
+ query = @model_class.joins(@joins_str)
23
+ if @conditions
24
+ query = query.where(@conditions)
25
+ end
26
+
21
27
  if @config[:paginate]
22
- @count = @model_class.count({:select => "distinct #{@model_class.table_name}.#{@model_class.primary_key}",
23
- :conditions => @conditions,
24
- :joins => @joins_str }
25
- )
28
+ @count = query.count
26
29
  offset = [((@page || 0) - 1) * @config[:per_page], 0].max
27
30
  limit = @config[:per_page]
28
31
  else
@@ -30,14 +33,8 @@ module RailsSimpleSearch
30
33
  limit = @config[:limit]
31
34
  end
32
35
 
33
- execute_hash = {:select => "distinct #{@model_class.table_name}.*",
34
- :conditions => @conditions,
35
- :joins => @joins_str,
36
- :offset => offset,
37
- :limit => limit
38
- }
39
- execute_hash[:order] = @order if @order
40
- @model_class.all(execute_hash)
36
+ query.order(@order) if @order
37
+ query.select("distinct #{@model_class.table_name}.*").offset(offset).limit(limit)
41
38
  end
42
39
 
43
40
  private
metadata CHANGED
@@ -1,49 +1,55 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rails-simple-search
3
- version: !ruby/object:Gem::Version
4
- version: 0.9.7
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.8
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Yi Zhang
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-29 00:00:00.000000000 Z
11
+
12
+ date: 2014-06-28 00:00:00 Z
13
13
  dependencies: []
14
- description: rails-simple-search is a light and easy to use gem. It could help developers
15
- quickly build a search page.
14
+
15
+ description: rails-simple-search is a light and easy to use gem. It could help developers quickly build a search page.
16
16
  email: yzhang.wa@gmail.com
17
17
  executables: []
18
+
18
19
  extensions: []
20
+
19
21
  extra_rdoc_files: []
20
- files:
22
+
23
+ files:
21
24
  - README.rdoc
22
25
  - lib/rails-simple-search.rb
23
26
  - lib/sql_handler.rb
24
27
  homepage: http://github.com/yzhanginwa/rails-simple-search
25
28
  licenses: []
29
+
30
+ metadata: {}
31
+
26
32
  post_install_message:
27
33
  rdoc_options: []
28
- require_paths:
34
+
35
+ require_paths:
29
36
  - lib
30
- required_ruby_version: !ruby/object:Gem::Requirement
31
- none: false
32
- requirements:
33
- - - ! '>='
34
- - !ruby/object:Gem::Version
35
- version: '0'
36
- required_rubygems_version: !ruby/object:Gem::Requirement
37
- none: false
38
- requirements:
39
- - - ! '>='
40
- - !ruby/object:Gem::Version
41
- version: '0'
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - &id001
40
+ - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: "0"
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - *id001
42
46
  requirements: []
47
+
43
48
  rubyforge_project:
44
- rubygems_version: 1.8.24
49
+ rubygems_version: 2.1.10
45
50
  signing_key:
46
- specification_version: 3
51
+ specification_version: 4
47
52
  summary: A very simple and light get to quick build search function in rails
48
53
  test_files: []
54
+
49
55
  has_rdoc: