pg_search 2.1.3 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +9 -6
  3. data/.travis.yml +12 -3
  4. data/CHANGELOG.md +121 -116
  5. data/Gemfile +2 -0
  6. data/README.md +1 -1
  7. data/Rakefile +2 -0
  8. data/lib/pg_search.rb +5 -3
  9. data/lib/pg_search/configuration.rb +5 -3
  10. data/lib/pg_search/configuration/association.rb +2 -0
  11. data/lib/pg_search/configuration/column.rb +2 -0
  12. data/lib/pg_search/configuration/foreign_column.rb +2 -0
  13. data/lib/pg_search/document.rb +4 -2
  14. data/lib/pg_search/features.rb +2 -0
  15. data/lib/pg_search/features/dmetaphone.rb +2 -0
  16. data/lib/pg_search/features/feature.rb +3 -1
  17. data/lib/pg_search/features/trigram.rb +2 -0
  18. data/lib/pg_search/features/tsearch.rb +2 -0
  19. data/lib/pg_search/migration/dmetaphone_generator.rb +3 -1
  20. data/lib/pg_search/migration/generator.rb +2 -0
  21. data/lib/pg_search/migration/multisearch_generator.rb +2 -1
  22. data/lib/pg_search/multisearch.rb +3 -3
  23. data/lib/pg_search/multisearch/rebuilder.rb +4 -2
  24. data/lib/pg_search/multisearchable.rb +2 -2
  25. data/lib/pg_search/normalizer.rb +2 -0
  26. data/lib/pg_search/railtie.rb +2 -0
  27. data/lib/pg_search/scope_options.rb +8 -6
  28. data/lib/pg_search/tasks.rb +2 -0
  29. data/lib/pg_search/version.rb +3 -1
  30. data/pg_search.gemspec +6 -5
  31. data/spec/integration/associations_spec.rb +9 -7
  32. data/spec/integration/pagination_spec.rb +2 -0
  33. data/spec/integration/pg_search_spec.rb +26 -24
  34. data/spec/integration/single_table_inheritance_spec.rb +2 -1
  35. data/spec/lib/pg_search/configuration/association_spec.rb +5 -3
  36. data/spec/lib/pg_search/configuration/column_spec.rb +2 -0
  37. data/spec/lib/pg_search/configuration/foreign_column_spec.rb +3 -1
  38. data/spec/lib/pg_search/features/dmetaphone_spec.rb +2 -0
  39. data/spec/lib/pg_search/features/trigram_spec.rb +2 -0
  40. data/spec/lib/pg_search/features/tsearch_spec.rb +6 -4
  41. data/spec/lib/pg_search/multisearch/rebuilder_spec.rb +2 -0
  42. data/spec/lib/pg_search/multisearch_spec.rb +2 -0
  43. data/spec/lib/pg_search/multisearchable_spec.rb +8 -6
  44. data/spec/lib/pg_search/normalizer_spec.rb +2 -0
  45. data/spec/lib/pg_search_spec.rb +5 -3
  46. data/spec/spec_helper.rb +2 -0
  47. data/spec/support/database.rb +3 -1
  48. data/spec/support/with_model.rb +2 -0
  49. metadata +6 -23
  50. data/.rubocop_todo.yml +0 -153
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe "a pg_search_scope on an STI subclass" do
@@ -82,4 +84,3 @@ describe "a pg_search_scope on an STI subclass" do
82
84
  end
83
85
  end
84
86
  end
85
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe PgSearch::Configuration::Association do
@@ -19,8 +21,8 @@ describe PgSearch::Configuration::Association do
19
21
  has_one :avatar, :class_name => "Avatar"
20
22
  belongs_to :site
21
23
 
22
- pg_search_scope :with_avatar, :associated_against => {:avatar => :url}
23
- pg_search_scope :with_site, :associated_against => {:site => :title}
24
+ pg_search_scope :with_avatar, :associated_against => { :avatar => :url }
25
+ pg_search_scope :with_site, :associated_against => { :site => :title }
24
26
  end
25
27
  end
26
28
 
@@ -33,7 +35,7 @@ describe PgSearch::Configuration::Association do
33
35
  include PgSearch
34
36
  has_many :users, :class_name => "User"
35
37
 
36
- pg_search_scope :with_users, :associated_against => {:users => :name}
38
+ pg_search_scope :with_users, :associated_against => { :users => :name }
37
39
  end
38
40
  end
39
41
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe PgSearch::Configuration::Column do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe PgSearch::Configuration::ForeignColumn do
@@ -18,7 +20,7 @@ describe PgSearch::Configuration::ForeignColumn do
18
20
  include PgSearch
19
21
  belongs_to :another_model, class_name: 'AssociatedModel'
20
22
 
21
- pg_search_scope :with_another, :associated_against => {:another_model => :title}
23
+ pg_search_scope :with_another, :associated_against => { :another_model => :title }
22
24
  end
23
25
  end
24
26
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe PgSearch::Features::DMetaphone do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'ostruct'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
  require "active_support/deprecation"
3
5
 
@@ -58,7 +60,7 @@ describe PgSearch::Features::TSearch do
58
60
  PgSearch::Configuration::Column.new(:name, nil, Model),
59
61
  PgSearch::Configuration::Column.new(:content, nil, Model)
60
62
  ]
61
- options = {:negation => true}
63
+ options = { :negation => true }
62
64
  config = double(:config, :ignore => [])
63
65
  normalizer = PgSearch::Normalizer.new(config)
64
66
 
@@ -76,7 +78,7 @@ describe PgSearch::Features::TSearch do
76
78
  PgSearch::Configuration::Column.new(:name, nil, Model),
77
79
  PgSearch::Configuration::Column.new(:content, nil, Model)
78
80
  ]
79
- options = {:negation => false}
81
+ options = { :negation => false }
80
82
  config = double(:config, :ignore => [])
81
83
  normalizer = PgSearch::Normalizer.new(config)
82
84
 
@@ -94,7 +96,7 @@ describe PgSearch::Features::TSearch do
94
96
  PgSearch::Configuration::Column.new(:name, nil, Model),
95
97
  PgSearch::Configuration::Column.new(:content, nil, Model)
96
98
  ]
97
- options = {tsvector_column: "my_tsvector"}
99
+ options = { tsvector_column: "my_tsvector" }
98
100
  config = double(:config, :ignore => [])
99
101
  normalizer = PgSearch::Normalizer.new(config)
100
102
 
@@ -112,7 +114,7 @@ describe PgSearch::Features::TSearch do
112
114
  PgSearch::Configuration::Column.new(:name, nil, Model),
113
115
  PgSearch::Configuration::Column.new(:content, nil, Model)
114
116
  ]
115
- options = {tsvector_column: ["tsvector1", "tsvector2"]}
117
+ options = { tsvector_column: ["tsvector1", "tsvector2"] }
116
118
  config = double(:config, :ignore => [])
117
119
  normalizer = PgSearch::Normalizer.new(config)
118
120
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  def has_microsecond_precision?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe PgSearch::Multisearch do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe PgSearch::Multisearchable do
@@ -143,7 +145,7 @@ describe PgSearch::Multisearchable do
143
145
  end
144
146
 
145
147
  context "when searching against a single column" do
146
- let(:multisearchable_options) { {:against => :some_content} }
148
+ let(:multisearchable_options) { { :against => :some_content } }
147
149
  let(:text) { "foo bar" }
148
150
  before do
149
151
  allow(record).to receive(:some_content) { text }
@@ -157,7 +159,7 @@ describe PgSearch::Multisearchable do
157
159
  end
158
160
 
159
161
  context "when searching against multiple columns" do
160
- let(:multisearchable_options) { {:against => %i[attr1 attr2]} }
162
+ let(:multisearchable_options) { { :against => %i[attr1 attr2] } }
161
163
  before do
162
164
  allow(record).to receive(:attr1) { '1' }
163
165
  allow(record).to receive(:attr2) { '2' }
@@ -180,7 +182,7 @@ describe PgSearch::Multisearchable do
180
182
  end
181
183
 
182
184
  context "when searching against a single column" do
183
- let(:multisearchable_options) { {:against => :some_content} }
185
+ let(:multisearchable_options) { { :against => :some_content } }
184
186
  let(:text) { "foo bar" }
185
187
  before do
186
188
  allow(record).to receive(:some_content) { text }
@@ -194,7 +196,7 @@ describe PgSearch::Multisearchable do
194
196
  end
195
197
 
196
198
  context "when searching against multiple columns" do
197
- let(:multisearchable_options) { {:against => %i[attr1 attr2]} }
199
+ let(:multisearchable_options) { { :against => %i[attr1 attr2] } }
198
200
  before do
199
201
  allow(record).to receive(:attr1) { '1' }
200
202
  allow(record).to receive(:attr2) { '2' }
@@ -254,7 +256,7 @@ describe PgSearch::Multisearchable do
254
256
 
255
257
  it "does not update the document" do
256
258
  expect_any_instance_of(PgSearch::Document)
257
- .to_not receive(:update_attributes)
259
+ .to_not receive(:update)
258
260
 
259
261
  record.save
260
262
  end
@@ -267,7 +269,7 @@ describe PgSearch::Multisearchable do
267
269
 
268
270
  it "updates the document" do
269
271
  expect_any_instance_of(PgSearch::Document)
270
- .to receive(:update_attributes)
272
+ .to receive(:update)
271
273
 
272
274
  record.save
273
275
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe PgSearch::Normalizer do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  # For AR 5 and greater, the association reflection's cache needs be cleared
@@ -61,9 +63,9 @@ describe PgSearch do
61
63
  allow(PgSearch).to receive(:multisearch_options) do
62
64
  lambda do |query, soundalike|
63
65
  if soundalike
64
- {:using => :dmetaphone, :query => query}
66
+ { :using => :dmetaphone, :query => query }
65
67
  else
66
- {:query => query}
68
+ { :query => query }
67
69
  end
68
70
  end
69
71
  end
@@ -174,7 +176,7 @@ describe PgSearch do
174
176
  expect(PgSearch::Document.count).to be 2
175
177
 
176
178
  PgSearch::Document.clear_searchable_cache
177
- classes = PgSearch::Document.all.collect {|d| d.searchable.class }
179
+ classes = PgSearch::Document.all.collect { |d| d.searchable.class }
178
180
  expect(classes).to include SearchableSubclassModel
179
181
  expect(classes).to include AnotherSearchableSubclassModel
180
182
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'simplecov'
2
4
  SimpleCov.start
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if defined? JRUBY_VERSION
2
4
  require "activerecord-jdbc-adapter"
3
5
  error_classes = [ActiveRecord::JDBCError]
@@ -54,7 +56,7 @@ end
54
56
 
55
57
  def install_extension_if_missing(name, query, expected_result)
56
58
  result = ActiveRecord::Base.connection.select_value(query)
57
- raise "Unexpected output for #{query}: #{result.inspect}" unless result.downcase == expected_result.downcase
59
+ raise "Unexpected output for #{query}: #{result.inspect}" unless result.casecmp(expected_result).zero?
58
60
  rescue StandardError
59
61
  install_extension(name)
60
62
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "with_model"
2
4
 
3
5
  RSpec.configure do |config|
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: 2.1.3
4
+ version: 2.1.4
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: 2018-12-09 00:00:00.000000000 Z
12
+ date: 2019-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -39,20 +39,6 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '4.2'
42
- - !ruby/object:Gem::Dependency
43
- name: arel
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: '6'
49
- type: :runtime
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '6'
56
42
  - !ruby/object:Gem::Dependency
57
43
  name: codeclimate-test-reporter
58
44
  requirement: !ruby/object:Gem::Requirement
@@ -115,14 +101,14 @@ dependencies:
115
101
  requirements:
116
102
  - - ">="
117
103
  - !ruby/object:Gem::Version
118
- version: 0.54.0
104
+ version: 0.63.0
119
105
  type: :development
120
106
  prerelease: false
121
107
  version_requirements: !ruby/object:Gem::Requirement
122
108
  requirements:
123
109
  - - ">="
124
110
  - !ruby/object:Gem::Version
125
- version: 0.54.0
111
+ version: 0.63.0
126
112
  - !ruby/object:Gem::Dependency
127
113
  name: simplecov
128
114
  requirement: !ruby/object:Gem::Requirement
@@ -166,7 +152,6 @@ files:
166
152
  - ".gitignore"
167
153
  - ".rspec"
168
154
  - ".rubocop.yml"
169
- - ".rubocop_todo.yml"
170
155
  - ".travis.yml"
171
156
  - CHANGELOG.md
172
157
  - CONTRIBUTING.md
@@ -174,7 +159,6 @@ files:
174
159
  - LICENSE
175
160
  - README.md
176
161
  - Rakefile
177
- - bin/rake
178
162
  - lib/pg_search.rb
179
163
  - lib/pg_search/configuration.rb
180
164
  - lib/pg_search/configuration/association.rb
@@ -233,15 +217,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
217
  requirements:
234
218
  - - ">="
235
219
  - !ruby/object:Gem::Version
236
- version: '2.2'
220
+ version: '2.3'
237
221
  required_rubygems_version: !ruby/object:Gem::Requirement
238
222
  requirements:
239
223
  - - ">="
240
224
  - !ruby/object:Gem::Version
241
225
  version: '0'
242
226
  requirements: []
243
- rubyforge_project:
244
- rubygems_version: 2.7.6
227
+ rubygems_version: 3.0.1
245
228
  signing_key:
246
229
  specification_version: 4
247
230
  summary: PgSearch builds Active Record named scopes that take advantage of PostgreSQL's
@@ -1,153 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2017-07-21 13:18:24 -0500 using RuboCop version 0.49.1.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 26
10
- # Cop supports --auto-correct.
11
- # Configuration parameters: SupportedStyles, IndentationWidth.
12
- # SupportedStyles: special_inside_parentheses, consistent, align_brackets
13
- Layout/IndentArray:
14
- EnforcedStyle: consistent
15
-
16
- # Offense count: 3
17
- # Cop supports --auto-correct.
18
- # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
19
- # SupportedStyles: aligned, indented, indented_relative_to_receiver
20
- Layout/MultilineMethodCallIndentation:
21
- Exclude:
22
- - 'spec/integration/pg_search_spec.rb'
23
-
24
- # Offense count: 1
25
- # Cop supports --auto-correct.
26
- Layout/SpaceAfterComma:
27
- Exclude:
28
- - 'lib/pg_search/configuration.rb'
29
-
30
- # Offense count: 1
31
- # Cop supports --auto-correct.
32
- # Configuration parameters: EnforcedStyle, SupportedStyles.
33
- # SupportedStyles: space, no_space
34
- Layout/SpaceAroundEqualsInParameterDefault:
35
- Exclude:
36
- - 'lib/pg_search/multisearch.rb'
37
-
38
- # Offense count: 3
39
- # Cop supports --auto-correct.
40
- # Configuration parameters: EnforcedStyle, SupportedStyles.
41
- # SupportedStyles: space, no_space
42
- Layout/SpaceBeforeBlockBraces:
43
- Exclude:
44
- - 'lib/pg_search/features/tsearch.rb'
45
- - 'spec/integration/pg_search_spec.rb'
46
-
47
- # Offense count: 4
48
- # Cop supports --auto-correct.
49
- # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters.
50
- # SupportedStyles: space, no_space
51
- # SupportedStylesForEmptyBraces: space, no_space
52
- Layout/SpaceInsideBlockBraces:
53
- Exclude:
54
- - 'lib/pg_search/features/tsearch.rb'
55
- - 'spec/integration/pg_search_spec.rb'
56
- - 'spec/lib/pg_search_spec.rb'
57
-
58
- # Offense count: 86
59
- # Cop supports --auto-correct.
60
- # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces.
61
- # SupportedStyles: space, no_space, compact
62
- # SupportedStylesForEmptyBraces: space, no_space
63
- Layout/SpaceInsideHashLiteralBraces:
64
- Exclude:
65
- - 'lib/pg_search.rb'
66
- - 'lib/pg_search/configuration.rb'
67
- - 'lib/pg_search/document.rb'
68
- - 'spec/integration/associations_spec.rb'
69
- - 'spec/integration/pg_search_spec.rb'
70
- - 'spec/lib/pg_search/configuration/association_spec.rb'
71
- - 'spec/lib/pg_search/configuration/foreign_column_spec.rb'
72
- - 'spec/lib/pg_search/features/tsearch_spec.rb'
73
- - 'spec/lib/pg_search/multisearchable_spec.rb'
74
- - 'spec/lib/pg_search_spec.rb'
75
-
76
- # Offense count: 4
77
- # Cop supports --auto-correct.
78
- # Configuration parameters: EnforcedStyle, SupportedStyles.
79
- # SupportedStyles: final_newline, final_blank_line
80
- Layout/TrailingBlankLines:
81
- Exclude:
82
- - 'Guardfile'
83
- - 'lib/pg_search/migration/multisearch_generator.rb'
84
- - 'lib/pg_search/multisearch.rb'
85
- - 'spec/integration/single_table_inheritance_spec.rb'
86
-
87
- # Offense count: 1
88
- # Cop supports --auto-correct.
89
- Performance/Casecmp:
90
- Exclude:
91
- - 'spec/support/database.rb'
92
-
93
- # Offense count: 27
94
- Style/Documentation:
95
- Enabled: false
96
-
97
- # Offense count: 1
98
- Style/IfInsideElse:
99
- Exclude:
100
- - 'lib/pg_search/multisearchable.rb'
101
-
102
- # Offense count: 2
103
- # Cop supports --auto-correct.
104
- Style/MutableConstant:
105
- Exclude:
106
- - 'lib/pg_search/configuration.rb'
107
- - 'lib/pg_search/scope_options.rb'
108
-
109
- # Offense count: 1
110
- # Cop supports --auto-correct.
111
- Style/PerlBackrefs:
112
- Exclude:
113
- - 'lib/pg_search/scope_options.rb'
114
-
115
- # Offense count: 5
116
- # Cop supports --auto-correct.
117
- # Configuration parameters: EnforcedStyle, SupportedStyles.
118
- # SupportedStyles: compact, exploded
119
- Style/RaiseArgs:
120
- Exclude:
121
- - 'lib/pg_search.rb'
122
- - 'lib/pg_search/multisearch/rebuilder.rb'
123
- - 'lib/pg_search/scope_options.rb'
124
-
125
- # Offense count: 1
126
- # Cop supports --auto-correct.
127
- # Configuration parameters: AllowMultipleReturnValues.
128
- Style/RedundantReturn:
129
- Exclude:
130
- - 'lib/pg_search/scope_options.rb'
131
-
132
- # Offense count: 2
133
- # Cop supports --auto-correct.
134
- # Configuration parameters: IgnoredMethods.
135
- # IgnoredMethods: respond_to, define_method
136
- Style/SymbolProc:
137
- Exclude:
138
- - 'lib/pg_search/features/feature.rb'
139
- - 'lib/pg_search/multisearch/rebuilder.rb'
140
-
141
- # Offense count: 2
142
- # Cop supports --auto-correct.
143
- Style/UnneededPercentQ:
144
- Exclude:
145
- - 'pg_search.gemspec'
146
-
147
- # Offense count: 3
148
- # Cop supports --auto-correct.
149
- # Configuration parameters: SupportedStyles, WordRegex.
150
- # SupportedStyles: percent, brackets
151
- Style/WordArray:
152
- EnforcedStyle: percent
153
- MinSize: 3