texticle 2.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +1 -0
  2. data/lib/texticle.rb +7 -3
  3. data/spec/texticle_spec.rb +21 -0
  4. metadata +48 -52
data/README.rdoc CHANGED
@@ -41,6 +41,7 @@ Your models now have access to the search method:
41
41
  == REQUIREMENTS:
42
42
 
43
43
  * ActiveRecord
44
+ * Ruby 1.9.2
44
45
 
45
46
  == INSTALL:
46
47
 
data/lib/texticle.rb CHANGED
@@ -3,7 +3,7 @@ require 'active_record'
3
3
  module Texticle
4
4
 
5
5
  def search(query = "", exclusive = true)
6
- language = connection.quote('english')
6
+ language = connection.quote(searchable_language)
7
7
 
8
8
  unless query.is_a?(Hash)
9
9
  exclusive = false
@@ -18,8 +18,8 @@ module Texticle
18
18
  query.each do |column, search_term|
19
19
  column = connection.quote_column_name(column)
20
20
  search_term = connection.quote normalize(Helper.normalize(search_term))
21
- similarities << "ts_rank(to_tsvector(#{quoted_table_name}.#{column}), to_tsquery(#{search_term}))"
22
- conditions << "to_tsvector(#{language}, #{column}) @@ to_tsquery(#{search_term})"
21
+ similarities << "ts_rank(to_tsvector(#{language}, #{quoted_table_name}.#{column}), to_tsquery(#{language}, #{search_term}))"
22
+ conditions << "to_tsvector(#{language}, #{column}) @@ to_tsquery(#{language}, #{search_term})"
23
23
  end
24
24
 
25
25
  rank = connection.quote_column_name('rank' + rand.to_s)
@@ -62,6 +62,10 @@ module Texticle
62
62
  columns.select {|column| column.type == :string }.map(&:name)
63
63
  end
64
64
 
65
+ def searchable_language
66
+ 'english'
67
+ end
68
+
65
69
  module Helper
66
70
  class << self
67
71
  def normalize(query)
@@ -148,4 +148,25 @@ class TexticleTest < Test::Unit::TestCase
148
148
  end
149
149
  end
150
150
 
151
+ context "when setting a custom search language" do
152
+ setup do
153
+ def Game.searchable_language
154
+ 'spanish'
155
+ end
156
+ Game.create :system => "PS3", :title => "Harry Potter & the Deathly Hallows"
157
+ end
158
+
159
+ teardown do
160
+ def Game.searchable_language
161
+ 'english'
162
+ end
163
+ Game.delete_all
164
+ end
165
+
166
+ should "still find results" do
167
+ assert_not_empty Game.search_by_title("harry")
168
+ p
169
+ end
170
+ end
171
+
151
172
  end
metadata CHANGED
@@ -1,65 +1,62 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: texticle
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.1
4
5
  prerelease:
5
- version: "2.0"
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - ecin
9
9
  - Aaron Patterson
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
-
14
- date: 2011-07-10 00:00:00 Z
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
13
+ date: 2011-07-10 00:00:00.000000000 -04:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
17
  name: pg
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: &2168525460 !ruby/object:Gem::Requirement
20
19
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
24
23
  version: 0.11.0
25
24
  type: :development
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: shoulda
29
25
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
26
+ version_requirements: *2168525460
27
+ - !ruby/object:Gem::Dependency
28
+ name: shoulda
29
+ requirement: &2168524980 !ruby/object:Gem::Requirement
31
30
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
35
34
  version: 2.11.3
36
35
  type: :development
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: activerecord
40
36
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
37
+ version_requirements: *2168524980
38
+ - !ruby/object:Gem::Dependency
39
+ name: activerecord
40
+ requirement: &2168524500 !ruby/object:Gem::Requirement
42
41
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
46
45
  version: 3.0.0
47
46
  type: :runtime
48
- version_requirements: *id003
49
- description: |-
50
- Texticle exposes full text search capabilities from PostgreSQL, extending
51
- ActiveRecord with scopes making search easy and fun!
52
- email:
47
+ prerelease: false
48
+ version_requirements: *2168524500
49
+ description: ! "Texticle exposes full text search capabilities from PostgreSQL, extending\n
50
+ \ ActiveRecord with scopes making search easy and fun!"
51
+ email:
53
52
  - ecin@copypastel.com
54
53
  executables: []
55
-
56
54
  extensions: []
57
-
58
- extra_rdoc_files:
55
+ extra_rdoc_files:
59
56
  - Manifest.txt
60
57
  - CHANGELOG.rdoc
61
58
  - README.rdoc
62
- files:
59
+ files:
63
60
  - CHANGELOG.rdoc
64
61
  - Manifest.txt
65
62
  - README.rdoc
@@ -71,35 +68,34 @@ files:
71
68
  - spec/texticle_spec.rb
72
69
  - spec/texticle/searchable_spec.rb
73
70
  - spec/config.yml
71
+ has_rdoc: true
74
72
  homepage: http://tenderlove.github.com/texticle
75
73
  licenses: []
76
-
77
74
  post_install_message:
78
- rdoc_options:
75
+ rdoc_options:
79
76
  - --main
80
77
  - README.rdoc
81
- require_paths:
78
+ require_paths:
82
79
  - lib
83
- required_ruby_version: !ruby/object:Gem::Requirement
80
+ required_ruby_version: !ruby/object:Gem::Requirement
84
81
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: "0"
89
- required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
87
  none: false
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- version: "0"
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
95
92
  requirements: []
96
-
97
93
  rubyforge_project: texticle
98
- rubygems_version: 1.7.2
94
+ rubygems_version: 1.6.2
99
95
  signing_key:
100
96
  specification_version: 3
101
97
  summary: Texticle exposes full text search capabilities from PostgreSQL
102
- test_files:
98
+ test_files:
103
99
  - spec/spec_helper.rb
104
100
  - spec/texticle_spec.rb
105
101
  - spec/config.yml