pg_search 0.7.6 → 0.7.7

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: 0129477dd69209f0276e0207d137556bfe486039
4
- data.tar.gz: f1c644b3a6659eb823c0993534e3b25dc9ffdf72
3
+ metadata.gz: 165dd9636ca6fe145f0c619c1223f9c5d120d8de
4
+ data.tar.gz: 2aec51ab9d72cf504dc8c8af979ca30c57f4a19a
5
5
  SHA512:
6
- metadata.gz: 38795ff477f256ba5acdb5ce1c368d8830294cabc04bd3ca1b84554f26094e39f14eca31574d6de0821803c987a1040946913b008a06de0ad4d376b7b2cfebfe
7
- data.tar.gz: e7ce0c0536b72f1857cd638cb55eb3a2a1087262a4a973a26057a18e45d6ea15df0818637f4c8bd9e4d9757895feeb3d0fb255893c0c01d0e09aa6c9e066a0bd
6
+ metadata.gz: e80100d386747b57fb18be03e4de9fe04561f58cc0a3dc687971542d41e9491d0daab9f278e19b6672c36d00cab5adfab8c66e45a97cc706c72848891dd512d7
7
+ data.tar.gz: 13b258daf15ced5f205560cda4a1b451d07544e1ca687090e98a996dace0aeedc61a71b7397fd9e43d18ee8b2084669583e047183cce6224d6f33123f97a1bbc
data/.travis.yml CHANGED
@@ -3,13 +3,14 @@ language: ruby
3
3
  rvm:
4
4
  - 1.9.3
5
5
  - 2.0.0
6
- - 2.1.1
6
+ - 2.1.2
7
7
  - jruby-19mode
8
8
 
9
9
  env:
10
10
  - ACTIVE_RECORD_BRANCH="master"
11
11
  - ACTIVE_RECORD_BRANCH="4-1-stable"
12
12
  - ACTIVE_RECORD_BRANCH="4-0-stable"
13
+ - ACTIVE_RECORD_VERSION="~> 4.2.0.beta1"
13
14
  - ACTIVE_RECORD_VERSION="~> 4.1.0"
14
15
  - ACTIVE_RECORD_VERSION="~> 4.0.0"
15
16
  - ACTIVE_RECORD_VERSION="~> 3.2.0"
@@ -21,6 +22,7 @@ matrix:
21
22
  - env: ACTIVE_RECORD_BRANCH="master"
22
23
  - env: ACTIVE_RECORD_BRANCH="4-1-stable"
23
24
  - env: ACTIVE_RECORD_BRANCH="4-0-stable"
25
+ - env: ACTIVE_RECORD_VERSION="~> 4.2.0.beta1"
24
26
 
25
27
  before_script:
26
28
  - "psql -c 'create database pg_search_test;' -U postgres >/dev/null"
data/CHANGELOG.md CHANGED
@@ -1,9 +1,13 @@
1
1
  # pg_search changelog
2
2
 
3
+ ## 0.7.7
4
+
5
+ * Fix future compatibility with Active Record 4.2.
6
+
3
7
  ## 0.7.6
4
8
 
5
9
  * Fix migration generator in Rails 3. (Andrew Marshall and Nora Lin)
6
- * Add :only option for limiting search fields per feature. (Jonathan Greenberg)
10
+ * Add `:only` option for limiting search fields per feature. (Jonathan Greenberg)
7
11
 
8
12
  ## 0.7.5
9
13
 
data/Guardfile CHANGED
@@ -1,4 +1,4 @@
1
- guard 'rspec' do
1
+ guard 'rspec', cmd: "bin/rspec" do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
3
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
4
  watch('spec/spec_helper.rb') { "spec" }
data/bin/guard ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'guard' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('guard', 'guard')
data/bin/rspec ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'rspec')
@@ -5,5 +5,13 @@ module PgSearch
5
5
  read_attribute(:pg_search_rank).to_f
6
6
  end
7
7
  end
8
+
9
+ def self.build_quoted(string)
10
+ if defined?(Arel::Nodes::Quoted)
11
+ Arel::Nodes.build_quoted(string)
12
+ else
13
+ string
14
+ end
15
+ end
8
16
  end
9
17
  end
@@ -1,3 +1,4 @@
1
+ require "pg_search/compatibility"
1
2
  require "active_support/core_ext/module/delegation"
2
3
 
3
4
  module PgSearch
@@ -27,17 +28,22 @@ module PgSearch
27
28
 
28
29
  DISALLOWED_TSQUERY_CHARACTERS = /['?\\:]/
29
30
 
30
- def tsquery_for_term(term)
31
- sanitized_term = term.gsub(DISALLOWED_TSQUERY_CHARACTERS, " ")
31
+ def tsquery_for_term(unsanitized_term)
32
+ sanitized_term = unsanitized_term.gsub(DISALLOWED_TSQUERY_CHARACTERS, " ")
32
33
 
33
34
  term_sql = Arel.sql(normalize(connection.quote(sanitized_term)))
34
35
 
35
36
  # After this, the SQL expression evaluates to a string containing the term surrounded by single-quotes.
36
37
  # If :prefix is true, then the term will also have :* appended to the end.
37
- terms = ["' ", term_sql, " '", (':*' if options[:prefix])].compact
38
+ terms = [
39
+ Compatibility.build_quoted("' "),
40
+ term_sql,
41
+ Compatibility.build_quoted(" '"),
42
+ (Compatibility.build_quoted(":*") if options[:prefix])
43
+ ].compact
38
44
 
39
45
  tsquery_sql = terms.inject do |memo, term|
40
- Arel::Nodes::InfixOperation.new("||", memo, term)
46
+ Arel::Nodes::InfixOperation.new("||", memo, Compatibility.build_quoted(term))
41
47
  end
42
48
 
43
49
  Arel::Nodes::NamedFunction.new(
@@ -84,7 +90,7 @@ module PgSearch
84
90
  end
85
91
 
86
92
  def dictionary
87
- options[:dictionary] || :simple
93
+ Compatibility.build_quoted(options[:dictionary] || :simple)
88
94
  end
89
95
 
90
96
  def arel_wrap(sql_string)
@@ -4,7 +4,7 @@ class CreatePgSearchDocuments < ActiveRecord::Migration
4
4
  create_table :pg_search_documents do |t|
5
5
  t.text :content
6
6
  t.belongs_to :searchable, :polymorphic => true
7
- t.timestamps
7
+ t.timestamps null: false
8
8
  end
9
9
  end
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module PgSearch
2
- VERSION = "0.7.6".freeze
2
+ VERSION = "0.7.7".freeze
3
3
  end
@@ -256,7 +256,7 @@ describe "an Active Record model which includes PgSearch" do
256
256
  context "when the column is not text" do
257
257
  with_model :ModelWithTimestamps do
258
258
  table do |t|
259
- t.timestamps
259
+ t.timestamps null: false
260
260
  end
261
261
 
262
262
  model do
@@ -1012,7 +1012,7 @@ describe "an Active Record model which includes PgSearch" do
1012
1012
  expect(PgSearch::Document).to receive(:search).with(query).and_return(relation)
1013
1013
  end
1014
1014
 
1015
- it { should == relation }
1015
+ it { is_expected.to eq(relation) }
1016
1016
  end
1017
1017
 
1018
1018
  context "with PgSearch.multisearch_options set to a Hash" do
@@ -1031,7 +1031,7 @@ describe "an Active Record model which includes PgSearch" do
1031
1031
 
1032
1032
  let!(:soundalike_record) { MultisearchableModel.create!(:title => 'foning') }
1033
1033
  let(:query) { "Phoning" }
1034
- it { should include(soundalike_record) }
1034
+ it { is_expected.to include(soundalike_record) }
1035
1035
  end
1036
1036
 
1037
1037
  context "with PgSearch.multisearch_options set to a Proc" do
@@ -1064,12 +1064,12 @@ describe "an Active Record model which includes PgSearch" do
1064
1064
 
1065
1065
  context "with soundalike true" do
1066
1066
  let(:soundalike) { true }
1067
- it { should include(soundalike_record) }
1067
+ it { is_expected.to include(soundalike_record) }
1068
1068
  end
1069
1069
 
1070
1070
  context "with soundalike false" do
1071
1071
  let(:soundalike) { false }
1072
- it { should_not include(soundalike_record) }
1072
+ it { is_expected.not_to include(soundalike_record) }
1073
1073
  end
1074
1074
  end
1075
1075
 
@@ -11,7 +11,7 @@ describe PgSearch::Document do
11
11
  end
12
12
  end
13
13
 
14
- it { should be_an(ActiveRecord::Base) }
14
+ it { is_expected.to be_an(ActiveRecord::Base) }
15
15
 
16
16
  describe "callbacks" do
17
17
  describe "before_validation" do
@@ -34,7 +34,7 @@ describe PgSearch::Document do
34
34
 
35
35
  describe '#content' do
36
36
  subject { super().content }
37
- it { should == text }
37
+ it { is_expected.to eq(text) }
38
38
  end
39
39
  end
40
40
 
@@ -48,7 +48,7 @@ describe PgSearch::Document do
48
48
 
49
49
  describe '#content' do
50
50
  subject { super().content }
51
- it { should == "1 2" }
51
+ it { is_expected.to eq("1 2") }
52
52
  end
53
53
  end
54
54
  end
@@ -7,7 +7,7 @@ describe PgSearch::Multisearch do
7
7
  table do |t|
8
8
  t.string :title
9
9
  t.text :content
10
- t.timestamps
10
+ t.timestamps null: false
11
11
  end
12
12
  model do
13
13
  include PgSearch
@@ -7,7 +7,7 @@ describe PgSearch::Normalizer do
7
7
  context "when passed an Arel node" do
8
8
  it "wraps the expression in unaccent()" do
9
9
  config = double("config", :ignore => [:accents], :postgresql_version => 90000)
10
- node = Arel::Nodes::NamedFunction.new("foo", ["bar"])
10
+ node = Arel::Nodes::NamedFunction.new("foo", [PgSearch::Compatibility.build_quoted("bar")])
11
11
 
12
12
  normalizer = PgSearch::Normalizer.new(config)
13
13
  expect(normalizer.add_normalization(node)).to eq("unaccent(foo('bar'))")
@@ -16,7 +16,7 @@ describe PgSearch::Normalizer do
16
16
  context "when a custom unaccent function is specified" do
17
17
  it "wraps the expression in that function" do
18
18
  allow(PgSearch).to receive(:unaccent_function).and_return("my_unaccent")
19
- node = Arel::Nodes::NamedFunction.new("foo", ["bar"])
19
+ node = Arel::Nodes::NamedFunction.new("foo", [PgSearch::Compatibility.build_quoted("bar")])
20
20
 
21
21
  config = double("config", :ignore => [:accents], :postgresql_version => 90000)
22
22
 
data/spec/spec_helper.rb CHANGED
@@ -18,5 +18,5 @@ require 'support/with_model'
18
18
  DOCUMENTS_SCHEMA = lambda do |t|
19
19
  t.belongs_to :searchable, :polymorphic => true
20
20
  t.text :content
21
- t.timestamps
21
+ t.timestamps null: false
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Hutchins
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-16 00:00:00.000000000 Z
12
+ date: 2014-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -114,7 +114,9 @@ description: PgSearch builds Active Record named scopes that take advantage of P
114
114
  email:
115
115
  - gems@nertzy.com
116
116
  - casecommons-dev@googlegroups.com
117
- executables: []
117
+ executables:
118
+ - guard
119
+ - rspec
118
120
  extensions: []
119
121
  extra_rdoc_files: []
120
122
  files:
@@ -129,6 +131,8 @@ files:
129
131
  - LICENSE
130
132
  - README.md
131
133
  - Rakefile
134
+ - bin/guard
135
+ - bin/rspec
132
136
  - lib/pg_search.rb
133
137
  - lib/pg_search/compatibility.rb
134
138
  - lib/pg_search/configuration.rb