pg_search 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +30 -13
- data/lib/pg_search/document.rb +4 -2
- data/lib/pg_search/features/tsearch.rb +23 -19
- data/lib/pg_search/migration/associated_against_generator.rb +4 -16
- data/lib/pg_search/migration/dmetaphone_generator.rb +4 -16
- data/lib/pg_search/migration/generator.rb +28 -0
- data/lib/pg_search/migration/multisearch_generator.rb +4 -8
- data/lib/pg_search/migration/templates/add_pg_search_associated_against_support_functions.rb.erb +2 -2
- data/lib/pg_search/migration/templates/{create_pg_search_documents.rb → create_pg_search_documents.rb.erb} +0 -0
- data/lib/pg_search/scope_options.rb +3 -1
- data/lib/pg_search/version.rb +1 -1
- data/pg_search.gemspec +1 -1
- data/spec/integration/associations_spec.rb +25 -25
- data/spec/integration/pagination_spec.rb +4 -4
- data/spec/integration/pg_search_spec.rb +123 -103
- data/spec/lib/pg_search/configuration/column_spec.rb +2 -2
- data/spec/lib/pg_search/document_spec.rb +11 -4
- data/spec/lib/pg_search/features/dmetaphone_spec.rb +4 -2
- data/spec/lib/pg_search/features/tsearch_spec.rb +4 -2
- data/spec/lib/pg_search/multisearch/rebuilder_spec.rb +16 -16
- data/spec/lib/pg_search/multisearch_spec.rb +15 -18
- data/spec/lib/pg_search/multisearchable_spec.rb +39 -38
- data/spec/lib/pg_search/normalizer_spec.rb +8 -8
- data/spec/spec_helper.rb +8 -94
- data/spec/support/coveralls.rb +7 -0
- data/spec/support/database.rb +83 -0
- data/spec/support/with_model.rb +5 -0
- metadata +14 -7
data/spec/spec_helper.rb
CHANGED
@@ -1,105 +1,19 @@
|
|
1
1
|
require "bundler/setup"
|
2
2
|
require "pg_search"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
Coveralls.wear!
|
8
|
-
rescue LoadError
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
if defined? JRUBY_VERSION
|
13
|
-
require 'activerecord-jdbcpostgresql-adapter'
|
14
|
-
error_classes = [ActiveRecord::JDBCError]
|
15
|
-
else
|
16
|
-
require "pg"
|
17
|
-
error_classes = [PGError]
|
18
|
-
end
|
19
|
-
|
20
|
-
error_classes << ActiveRecord::NoDatabaseError if defined? ActiveRecord::NoDatabaseError
|
21
|
-
|
22
|
-
begin
|
23
|
-
database_user = if ENV["TRAVIS"]
|
24
|
-
"postgres"
|
25
|
-
else
|
26
|
-
ENV["USER"]
|
27
|
-
end
|
28
|
-
|
29
|
-
ActiveRecord::Base.establish_connection(:adapter => 'postgresql',
|
30
|
-
:database => 'pg_search_test',
|
31
|
-
:username => database_user,
|
32
|
-
:min_messages => 'warning')
|
33
|
-
connection = ActiveRecord::Base.connection
|
34
|
-
postgresql_version = connection.send(:postgresql_version)
|
35
|
-
connection.execute("SELECT 1")
|
36
|
-
rescue *error_classes
|
37
|
-
at_exit do
|
38
|
-
puts "-" * 80
|
39
|
-
puts "Unable to connect to database. Please run:"
|
40
|
-
puts
|
41
|
-
puts " createdb pg_search_test"
|
42
|
-
puts "-" * 80
|
43
|
-
end
|
44
|
-
raise $!
|
45
|
-
end
|
46
|
-
|
47
|
-
if ENV["LOGGER"]
|
48
|
-
require "logger"
|
49
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
50
|
-
end
|
51
|
-
|
52
|
-
def install_extension_if_missing(name, query, expected_result)
|
53
|
-
connection = ActiveRecord::Base.connection
|
54
|
-
postgresql_version = connection.send(:postgresql_version)
|
55
|
-
result = connection.select_value(query)
|
56
|
-
raise "Unexpected output for #{query}: #{result.inspect}" unless result.downcase == expected_result.downcase
|
57
|
-
rescue => e
|
58
|
-
begin
|
59
|
-
if postgresql_version >= 90100
|
60
|
-
ActiveRecord::Base.connection.execute "CREATE EXTENSION #{name};"
|
61
|
-
else
|
62
|
-
share_path = `pg_config --sharedir`.strip
|
63
|
-
ActiveRecord::Base.connection.execute File.read(File.join(share_path, 'contrib', "#{name}.sql"))
|
64
|
-
puts $!.message
|
65
|
-
end
|
66
|
-
rescue => e2
|
67
|
-
at_exit do
|
68
|
-
puts "-" * 80
|
69
|
-
puts "Please install the #{name} contrib module"
|
70
|
-
puts "-" * 80
|
71
|
-
end
|
72
|
-
raise e2
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.expect_with :rspec do |c|
|
6
|
+
c.syntax = :expect
|
73
7
|
end
|
74
|
-
end
|
75
8
|
|
76
|
-
|
77
|
-
|
78
|
-
install_extension_if_missing("unaccent", "SELECT unaccent('foo')", "foo")
|
79
|
-
end
|
80
|
-
install_extension_if_missing("fuzzystrmatch", "SELECT dmetaphone('foo')", "f")
|
81
|
-
|
82
|
-
def load_sql(filename)
|
83
|
-
connection = ActiveRecord::Base.connection
|
84
|
-
file_contents = File.read(File.join(File.dirname(__FILE__), '..', 'sql', filename))
|
85
|
-
connection.execute(file_contents)
|
86
|
-
end
|
87
|
-
|
88
|
-
if postgresql_version < 80400
|
89
|
-
unless connection.select_value("SELECT 1 FROM pg_catalog.pg_aggregate WHERE aggfnoid = 'array_agg'::REGPROC") == "1"
|
90
|
-
load_sql("array_agg.sql")
|
9
|
+
config.mock_with :rspec do |c|
|
10
|
+
c.syntax = :expect
|
91
11
|
end
|
92
|
-
load_sql("unnest.sql")
|
93
|
-
end
|
94
|
-
load_sql("dmetaphone.sql")
|
95
|
-
|
96
|
-
require "with_model"
|
97
|
-
|
98
|
-
RSpec.configure do |config|
|
99
|
-
config.extend WithModel
|
100
12
|
end
|
101
13
|
|
102
|
-
|
14
|
+
require 'support/coveralls'
|
15
|
+
require 'support/database'
|
16
|
+
require 'support/with_model'
|
103
17
|
|
104
18
|
DOCUMENTS_SCHEMA = lambda do |t|
|
105
19
|
t.belongs_to :searchable, :polymorphic => true
|
@@ -0,0 +1,83 @@
|
|
1
|
+
if defined? JRUBY_VERSION
|
2
|
+
require 'activerecord-jdbcpostgresql-adapter'
|
3
|
+
error_classes = [ActiveRecord::JDBCError]
|
4
|
+
else
|
5
|
+
require "pg"
|
6
|
+
error_classes = [PGError]
|
7
|
+
end
|
8
|
+
|
9
|
+
error_classes << ActiveRecord::NoDatabaseError if defined? ActiveRecord::NoDatabaseError
|
10
|
+
|
11
|
+
begin
|
12
|
+
database_user = if ENV["TRAVIS"]
|
13
|
+
"postgres"
|
14
|
+
else
|
15
|
+
ENV["USER"]
|
16
|
+
end
|
17
|
+
|
18
|
+
ActiveRecord::Base.establish_connection(:adapter => 'postgresql',
|
19
|
+
:database => 'pg_search_test',
|
20
|
+
:username => database_user,
|
21
|
+
:min_messages => 'warning')
|
22
|
+
connection = ActiveRecord::Base.connection
|
23
|
+
postgresql_version = connection.send(:postgresql_version)
|
24
|
+
connection.execute("SELECT 1")
|
25
|
+
rescue *error_classes
|
26
|
+
at_exit do
|
27
|
+
puts "-" * 80
|
28
|
+
puts "Unable to connect to database. Please run:"
|
29
|
+
puts
|
30
|
+
puts " createdb pg_search_test"
|
31
|
+
puts "-" * 80
|
32
|
+
end
|
33
|
+
raise $!
|
34
|
+
end
|
35
|
+
|
36
|
+
if ENV["LOGGER"]
|
37
|
+
require "logger"
|
38
|
+
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
39
|
+
end
|
40
|
+
|
41
|
+
def install_extension_if_missing(name, query, expected_result)
|
42
|
+
connection = ActiveRecord::Base.connection
|
43
|
+
postgresql_version = connection.send(:postgresql_version)
|
44
|
+
result = connection.select_value(query)
|
45
|
+
raise "Unexpected output for #{query}: #{result.inspect}" unless result.downcase == expected_result.downcase
|
46
|
+
rescue => e
|
47
|
+
begin
|
48
|
+
if postgresql_version >= 90100
|
49
|
+
ActiveRecord::Base.connection.execute "CREATE EXTENSION #{name};"
|
50
|
+
else
|
51
|
+
share_path = `pg_config --sharedir`.strip
|
52
|
+
ActiveRecord::Base.connection.execute File.read(File.join(share_path, 'contrib', "#{name}.sql"))
|
53
|
+
puts $!.message
|
54
|
+
end
|
55
|
+
rescue => e2
|
56
|
+
at_exit do
|
57
|
+
puts "-" * 80
|
58
|
+
puts "Please install the #{name} contrib module"
|
59
|
+
puts "-" * 80
|
60
|
+
end
|
61
|
+
raise e2
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
install_extension_if_missing("pg_trgm", "SELECT 'abcdef' % 'cdef'", "t")
|
66
|
+
unless postgresql_version < 90000
|
67
|
+
install_extension_if_missing("unaccent", "SELECT unaccent('foo')", "foo")
|
68
|
+
end
|
69
|
+
install_extension_if_missing("fuzzystrmatch", "SELECT dmetaphone('foo')", "f")
|
70
|
+
|
71
|
+
def load_sql(filename)
|
72
|
+
connection = ActiveRecord::Base.connection
|
73
|
+
file_contents = File.read(File.join(File.dirname(__FILE__), '..', '..', 'sql', filename))
|
74
|
+
connection.execute(file_contents)
|
75
|
+
end
|
76
|
+
|
77
|
+
if postgresql_version < 80400
|
78
|
+
unless connection.select_value("SELECT 1 FROM pg_catalog.pg_aggregate WHERE aggfnoid = 'array_agg'::REGPROC") == "1"
|
79
|
+
load_sql("array_agg.sql")
|
80
|
+
end
|
81
|
+
load_sql("unnest.sql")
|
82
|
+
end
|
83
|
+
load_sql("dmetaphone.sql")
|
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.
|
4
|
+
version: 0.7.5
|
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-
|
12
|
+
date: 2014-07-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -85,16 +85,16 @@ dependencies:
|
|
85
85
|
name: rspec
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - "
|
88
|
+
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
90
|
+
version: '3.0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - "
|
95
|
+
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
97
|
+
version: '3.0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: with_model
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,10 +144,11 @@ files:
|
|
144
144
|
- lib/pg_search/features/tsearch.rb
|
145
145
|
- lib/pg_search/migration/associated_against_generator.rb
|
146
146
|
- lib/pg_search/migration/dmetaphone_generator.rb
|
147
|
+
- lib/pg_search/migration/generator.rb
|
147
148
|
- lib/pg_search/migration/multisearch_generator.rb
|
148
149
|
- lib/pg_search/migration/templates/add_pg_search_associated_against_support_functions.rb.erb
|
149
150
|
- lib/pg_search/migration/templates/add_pg_search_dmetaphone_support_functions.rb.erb
|
150
|
-
- lib/pg_search/migration/templates/create_pg_search_documents.rb
|
151
|
+
- lib/pg_search/migration/templates/create_pg_search_documents.rb.erb
|
151
152
|
- lib/pg_search/multisearch.rb
|
152
153
|
- lib/pg_search/multisearch/rebuilder.rb
|
153
154
|
- lib/pg_search/multisearchable.rb
|
@@ -172,6 +173,9 @@ files:
|
|
172
173
|
- spec/lib/pg_search/multisearchable_spec.rb
|
173
174
|
- spec/lib/pg_search/normalizer_spec.rb
|
174
175
|
- spec/spec_helper.rb
|
176
|
+
- spec/support/coveralls.rb
|
177
|
+
- spec/support/database.rb
|
178
|
+
- spec/support/with_model.rb
|
175
179
|
- sql/array_agg.sql
|
176
180
|
- sql/dmetaphone.sql
|
177
181
|
- sql/uninstall_array_agg.sql
|
@@ -219,3 +223,6 @@ test_files:
|
|
219
223
|
- spec/lib/pg_search/multisearchable_spec.rb
|
220
224
|
- spec/lib/pg_search/normalizer_spec.rb
|
221
225
|
- spec/spec_helper.rb
|
226
|
+
- spec/support/coveralls.rb
|
227
|
+
- spec/support/database.rb
|
228
|
+
- spec/support/with_model.rb
|