pg_search 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -5,4 +5,5 @@ doc
5
5
  .idea
6
6
  tags
7
7
  *~
8
- gemfiles/**/Gemfile.lock
8
+ gemfiles/rails2/Gemfile.lock
9
+ gemfiles/rails3/Gemfile.lock
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.1.1
2
+
3
+ Fix a bug with dmetaphone searches containing " w " (which dmetaphone maps to
4
+ an empty string)
5
+
1
6
  ### 0.1
2
7
 
3
8
  Change API to {:ignoring => :accents} from {:normalizing => :diacritics}
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ task :default => :spec
6
6
  environments = %w[rails2 rails3]
7
7
 
8
8
  in_environment = lambda do |environment, command|
9
- sh %Q{export BUNDLE_GEMFILE="gemfiles/#{environment}/Gemfile"; bundle --quiet update && bundle exec #{command}}
9
+ sh %Q{export BUNDLE_GEMFILE="gemfiles/#{environment}/Gemfile"; bundle update && bundle exec #{command}}
10
10
  end
11
11
 
12
12
  in_all_environments = lambda do |command|
data/TODO CHANGED
@@ -1,12 +1,10 @@
1
1
  * Railtie for rake tasks
2
- * README
3
2
  * Tracker project
4
- * Mailing list
5
- * License
6
- * Publish gem
7
3
  * Exceptions for missing trigram, dmetaphone, etc. support
8
4
  * LIKE search
9
- * ability to specify multiple ranks: :ranked_by => [:tsearch, :trigram]
10
- * ability to mix ranks together with weights: :ranked_by => {:tsearch => 1.0, :trigram => 0.5}
11
5
  * accept a block and pass it to the underlying scope
12
6
  * ability to search again a tsvector column
7
+ * Generate indexes
8
+ * Allow for chaining multiple pg_search scopes
9
+
10
+ Also see https://github.com/Casecommons/pg_search/issues
@@ -3,7 +3,7 @@ source "http://rubygems.org"
3
3
  gem "pg"
4
4
 
5
5
  group :test do
6
- gem "rspec"
6
+ gem "rspec", ">=2.4"
7
7
  gem "autotest"
8
8
  gem "with_model", '0.1'
9
9
  end
@@ -40,7 +40,7 @@ module PgSearch
40
40
  term_sql = @normalizer.add_normalization(connection.quote(sanitized_term))
41
41
 
42
42
  # After this, the SQL expression evaluates to a string containing the term surrounded by single-quotes.
43
- tsquery_sql = "#{connection.quote("'")} || #{term_sql} || #{connection.quote("'")}"
43
+ tsquery_sql = "#{connection.quote("' ")} || #{term_sql} || #{connection.quote(" '")}"
44
44
 
45
45
  # Add tsearch prefix operator if we're using a prefix search.
46
46
  tsquery_sql = "#{tsquery_sql} || #{connection.quote(':*')}" if @options[:prefix]
@@ -1,3 +1,3 @@
1
1
  module PgSearch
2
- VERSION = "0.1"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -246,6 +246,7 @@ describe "an ActiveRecord model which includes PgSearch" do
246
246
  results = model_with_pg_search.search_content("foo bar .,?() \\")
247
247
  results.should == [included]
248
248
  end
249
+
249
250
  it "accepts non-string queries and calls #to_s on them" do
250
251
  foo = model_with_pg_search.create!(:content => "foo")
251
252
  not_a_string = stub(:to_s => "foo")
@@ -456,6 +457,16 @@ describe "an ActiveRecord model which includes PgSearch" do
456
457
  results = model_with_pg_search.with_dmetaphones('Wight')
457
458
  results.should == [included]
458
459
  end
460
+
461
+ it "can handle terms that do not have a dmetaphone equivalent" do
462
+ term_with_blank_metaphone = "w"
463
+
464
+ included = model_with_pg_search.create!(:title => 'White', :content => nil)
465
+ excluded = model_with_pg_search.create!(:title => 'Black', :content => nil)
466
+
467
+ results = model_with_pg_search.with_dmetaphones('Wight W')
468
+ results.should == [included]
469
+ end
459
470
  end
460
471
 
461
472
  context "using multiple features" do
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_search
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- version: "0.1"
9
+ - 1
10
+ version: 0.1.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Case Commons, LLC
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-01-18 00:00:00 -05:00
18
+ date: 2011-01-20 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies: []
20
21