pg_search 2.2.0 → 2.3.0

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
  SHA256:
3
- metadata.gz: 292701a98892eef31e95d8b5d723e94ce71fd47e4956e8bed595b8f87797f49c
4
- data.tar.gz: cc08372ce5c032e288c28b2f6409c218d361b271fc271de08acbe8e5430c8dcb
3
+ metadata.gz: c8e6c02c032d2a7a39ebe47e50584410cebe923e868dc6be720af23cd3748e55
4
+ data.tar.gz: 24d70a673be8c9993c007b812af1d9af89cc565dfbbae9ed37c205d90ca893da
5
5
  SHA512:
6
- metadata.gz: e95e7240968269703ae6d010639f2b4380e7616962c7a07f4932ad5e21c77affae6ea3c90e9a8171641a506988fa076ecdb30224f2b081d1468fb13618713d2e
7
- data.tar.gz: 4910a636f53e444c3995e0ca728bd21475d11347d8a4d8223a1e881f3360bf8dc7e4f5689bd05cc559dad106a08b077abda1b3f50c6108221e4dbf75c4d73ffa
6
+ metadata.gz: 06e43bdc63bd98ea57943068cde6723780000ca3765a016d9baecdac3eea7006a1deae35885654b88b4752e3ad6f136190ac8602ffad62b3aac356425fad66d0
7
+ data.tar.gz: 500d85f688710b48bf235eb1765c66e569dd7db98d95f03eaa81242f12c746d2ce8a57176185700c8d1b6ca903039d2c9b42fd5b71c84a8e4f8c46d7ef3464f7
@@ -0,0 +1,10 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ end_of_line = lf
7
+ insert_final_newline = true
8
+ charset = utf-8
9
+ indent_style = space
10
+ indent_size = 2
@@ -1,5 +1,10 @@
1
1
  # pg_search changelog
2
2
 
3
+ ## 2.3.0
4
+
5
+ * Extract `PgSearch::Model` module
6
+ * Deprecate `include PgSearch`. Use `include PgSearch::Model` instead.
7
+
3
8
  ## 2.2.0
4
9
 
5
10
  * Add word_similarity option to trigram search (Severin Räz)
data/README.md CHANGED
@@ -49,7 +49,7 @@ To add PgSearch to an Active Record model, simply include the PgSearch module.
49
49
 
50
50
  ```ruby
51
51
  class Shape < ActiveRecord::Base
52
- include PgSearch
52
+ include PgSearch::Model
53
53
  end
54
54
  ```
55
55
 
@@ -87,12 +87,12 @@ multisearchable in its class definition.
87
87
 
88
88
  ```ruby
89
89
  class EpicPoem < ActiveRecord::Base
90
- include PgSearch
90
+ include PgSearch::Model
91
91
  multisearchable against: [:title, :author]
92
92
  end
93
93
 
94
94
  class Flower < ActiveRecord::Base
95
- include PgSearch
95
+ include PgSearch::Model
96
96
  multisearchable against: :color
97
97
  end
98
98
  ```
@@ -112,13 +112,13 @@ particular record should be included.
112
112
 
113
113
  ```ruby
114
114
  class Convertible < ActiveRecord::Base
115
- include PgSearch
115
+ include PgSearch::Model
116
116
  multisearchable against: [:make, :model],
117
117
  if: :available_in_red?
118
118
  end
119
119
 
120
120
  class Jalopy < ActiveRecord::Base
121
- include PgSearch
121
+ include PgSearch::Model
122
122
  multisearchable against: [:make, :model],
123
123
  if: lambda { |record| record.model_year > 1970 }
124
124
  end
@@ -132,7 +132,7 @@ timestamp.
132
132
 
133
133
  ```ruby
134
134
  class AntipatternExample
135
- include PgSearch
135
+ include PgSearch::Model
136
136
  multisearchable against: [:contents],
137
137
  if: :published?
138
138
 
@@ -374,7 +374,7 @@ To search against a column, pass a symbol as the :against option.
374
374
 
375
375
  ```ruby
376
376
  class BlogPost < ActiveRecord::Base
377
- include PgSearch
377
+ include PgSearch::Model
378
378
  pg_search_scope :search_by_title, against: :title
379
379
  end
380
380
  ```
@@ -394,7 +394,7 @@ Just pass an Array if you'd like to search more than one column.
394
394
 
395
395
  ```ruby
396
396
  class Person < ActiveRecord::Base
397
- include PgSearch
397
+ include PgSearch::Model
398
398
  pg_search_scope :search_by_full_name, against: [:first_name, :last_name]
399
399
  end
400
400
  ```
@@ -421,7 +421,7 @@ value if you wanted.
421
421
 
422
422
  ```ruby
423
423
  class Person < ActiveRecord::Base
424
- include PgSearch
424
+ include PgSearch::Model
425
425
  pg_search_scope :search_by_name, lambda { |name_part, query|
426
426
  raise ArgumentError unless [:first, :last].include?(name_part)
427
427
  {
@@ -459,7 +459,7 @@ class Cheese < ActiveRecord::Base
459
459
  end
460
460
 
461
461
  class Salami < ActiveRecord::Base
462
- include PgSearch
462
+ include PgSearch::Model
463
463
 
464
464
  belongs_to :cracker
465
465
  has_many :cheeses, through: :cracker
@@ -494,7 +494,7 @@ search techniques.
494
494
 
495
495
  ```ruby
496
496
  class Beer < ActiveRecord::Base
497
- include PgSearch
497
+ include PgSearch::Model
498
498
  pg_search_scope :search_name, against: :name, using: [:tsearch, :trigram, :dmetaphone]
499
499
  end
500
500
  ```
@@ -520,7 +520,7 @@ subtitle, and finally the content.
520
520
 
521
521
  ```ruby
522
522
  class NewsArticle < ActiveRecord::Base
523
- include PgSearch
523
+ include PgSearch::Model
524
524
  pg_search_scope :search_full_text, against: {
525
525
  title: 'A',
526
526
  subtitle: 'B',
@@ -535,7 +535,7 @@ weight. If you omit the weight, a default will be used.
535
535
 
536
536
  ```ruby
537
537
  class NewsArticle < ActiveRecord::Base
538
- include PgSearch
538
+ include PgSearch::Model
539
539
  pg_search_scope :search_full_text, against: [
540
540
  [:title, 'A'],
541
541
  [:subtitle, 'B'],
@@ -544,7 +544,7 @@ class NewsArticle < ActiveRecord::Base
544
544
  end
545
545
 
546
546
  class NewsArticle < ActiveRecord::Base
547
- include PgSearch
547
+ include PgSearch::Model
548
548
  pg_search_scope :search_full_text, against: [
549
549
  [:title, 'A'],
550
550
  {subtitle: 'B'},
@@ -562,7 +562,7 @@ shown in the following example.
562
562
 
563
563
  ```ruby
564
564
  class Superhero < ActiveRecord::Base
565
- include PgSearch
565
+ include PgSearch::Model
566
566
  pg_search_scope :whose_name_starts_with,
567
567
  against: :name,
568
568
  using: {
@@ -591,7 +591,7 @@ term that you were trying to exclude.
591
591
 
592
592
  ```ruby
593
593
  class Animal < ActiveRecord::Base
594
- include PgSearch
594
+ include PgSearch::Model
595
595
  pg_search_scope :with_name_matching,
596
596
  against: :name,
597
597
  using: {
@@ -620,7 +620,7 @@ dictionary will be used.
620
620
 
621
621
  ```ruby
622
622
  class BoringTweet < ActiveRecord::Base
623
- include PgSearch
623
+ include PgSearch::Model
624
624
  pg_search_scope :kinda_matching,
625
625
  against: :text,
626
626
  using: {
@@ -664,7 +664,7 @@ their numbers together.
664
664
 
665
665
  ```ruby
666
666
  class BigLongDocument < ActiveRecord::Base
667
- include PgSearch
667
+ include PgSearch::Model
668
668
  pg_search_scope :regular_search,
669
669
  against: :text
670
670
 
@@ -688,7 +688,7 @@ models containing any word in the search terms.
688
688
 
689
689
  ```ruby
690
690
  class Number < ActiveRecord::Base
691
- include PgSearch
691
+ include PgSearch::Model
692
692
  pg_search_scope :search_any_word,
693
693
  against: :text,
694
694
  using: {
@@ -714,7 +714,7 @@ but will not include it in the query's WHERE condition.
714
714
 
715
715
  ```ruby
716
716
  class Person < ActiveRecord::Base
717
- include PgSearch
717
+ include PgSearch::Model
718
718
  pg_search_scope :search,
719
719
  against: :name,
720
720
  using: {
@@ -739,7 +739,7 @@ Adding .with_pg_search_highlight after the pg_search_scope you can access to
739
739
 
740
740
  ```ruby
741
741
  class Person < ActiveRecord::Base
742
- include PgSearch
742
+ include PgSearch::Model
743
743
  pg_search_scope :search,
744
744
  against: :bio,
745
745
  using: {
@@ -793,7 +793,7 @@ The following example shows how to use :dmetaphone.
793
793
 
794
794
  ```ruby
795
795
  class Word < ActiveRecord::Base
796
- include PgSearch
796
+ include PgSearch::Model
797
797
  pg_search_scope :that_sounds_like,
798
798
  against: :spelling,
799
799
  using: :dmetaphone
@@ -824,7 +824,7 @@ feature can be used.
824
824
 
825
825
  ```ruby
826
826
  class Website < ActiveRecord::Base
827
- include PgSearch
827
+ include PgSearch::Model
828
828
  pg_search_scope :kinda_spelled_like,
829
829
  against: :name,
830
830
  using: :trigram
@@ -849,7 +849,7 @@ threshold will force a table scan as the derived query uses the
849
849
 
850
850
  ```ruby
851
851
  class Vegetable < ActiveRecord::Base
852
- include PgSearch
852
+ include PgSearch::Model
853
853
 
854
854
  pg_search_scope :strictly_spelled_like,
855
855
  against: :name,
@@ -887,7 +887,7 @@ and the word with greatest similarity.
887
887
 
888
888
  ```ruby
889
889
  class Sentence < ActiveRecord::Base
890
- include PgSearch
890
+ include PgSearch::Model
891
891
 
892
892
  pg_search_scope :similarity_like,
893
893
  against: :words,
@@ -918,7 +918,7 @@ which fields using the 'only' option:
918
918
 
919
919
  ```ruby
920
920
  class Image < ActiveRecord::Base
921
- include PgSearch
921
+ include PgSearch::Model
922
922
 
923
923
  pg_search_scope :combined_search,
924
924
  against: [:file_name, :short_description, :long_description]
@@ -953,7 +953,7 @@ must be installed before this feature can be used.
953
953
 
954
954
  ```ruby
955
955
  class SpanishQuestion < ActiveRecord::Base
956
- include PgSearch
956
+ include PgSearch::Model
957
957
  pg_search_scope :gringo_search,
958
958
  against: :word,
959
959
  ignoring: :accents
@@ -7,6 +7,7 @@ require "active_support/core_ext/string/strip"
7
7
 
8
8
  require "pg_search/configuration"
9
9
  require "pg_search/features"
10
+ require "pg_search/model"
10
11
  require "pg_search/multisearch"
11
12
  require "pg_search/multisearchable"
12
13
  require "pg_search/normalizer"
@@ -14,7 +15,15 @@ require "pg_search/scope_options"
14
15
  require "pg_search/version"
15
16
 
16
17
  module PgSearch
17
- extend ActiveSupport::Concern
18
+ def self.included(base)
19
+ ActiveSupport::Deprecation.warn <<-MESSAGE.strip_heredoc
20
+ Directly including `PgSearch` into an Active Record model is deprecated and will be removed in pg_search 3.0.
21
+
22
+ Please replace `include PgSearch` with `include PgSearch::Model`.
23
+ MESSAGE
24
+
25
+ base.include PgSearch::Model
26
+ end
18
27
 
19
28
  mattr_accessor :multisearch_options
20
29
  self.multisearch_options = {}
@@ -22,30 +31,6 @@ module PgSearch
22
31
  mattr_accessor :unaccent_function
23
32
  self.unaccent_function = "unaccent"
24
33
 
25
- module ClassMethods
26
- def pg_search_scope(name, options)
27
- options_proc = if options.respond_to?(:call)
28
- options
29
- elsif options.respond_to?(:merge)
30
- ->(query) { { query: query }.merge(options) }
31
- else
32
- raise ArgumentError, 'pg_search_scope expects a Hash or Proc'
33
- end
34
-
35
- define_singleton_method(name) do |*args|
36
- config = Configuration.new(options_proc.call(*args), self)
37
- scope_options = ScopeOptions.new(config)
38
- scope_options.apply(self)
39
- end
40
- end
41
-
42
- def multisearchable(options = {})
43
- include PgSearch::Multisearchable
44
- class_attribute :pg_search_multisearchable_options
45
- self.pg_search_multisearchable_options = options
46
- end
47
- end
48
-
49
34
  class << self
50
35
  def multisearch(*args)
51
36
  PgSearch::Document.search(*args)
@@ -67,32 +52,6 @@ module PgSearch
67
52
  end
68
53
  end
69
54
 
70
- def method_missing(symbol, *args)
71
- case symbol
72
- when :pg_search_rank
73
- raise PgSearchRankNotSelected unless respond_to?(:pg_search_rank)
74
-
75
- read_attribute(:pg_search_rank).to_f
76
- when :pg_search_highlight
77
- raise PgSearchHighlightNotSelected unless respond_to?(:pg_search_highlight)
78
-
79
- read_attribute(:pg_search_highlight)
80
- else
81
- super
82
- end
83
- end
84
-
85
- def respond_to_missing?(symbol, *args)
86
- case symbol
87
- when :pg_search_rank
88
- attributes.key?(:pg_search_rank)
89
- when :pg_search_highlight
90
- attributes.key?(:pg_search_highlight)
91
- else
92
- super
93
- end
94
- end
95
-
96
55
  class PgSearchRankNotSelected < StandardError
97
56
  def message
98
57
  "You must chain .with_pg_search_rank after the pg_search_scope " \
@@ -4,7 +4,7 @@ require 'logger'
4
4
 
5
5
  module PgSearch
6
6
  class Document < ActiveRecord::Base
7
- include PgSearch
7
+ include PgSearch::Model
8
8
 
9
9
  self.table_name = 'pg_search_documents'
10
10
  belongs_to :searchable, polymorphic: true
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PgSearch
4
+ module Model
5
+ extend ActiveSupport::Concern
6
+
7
+ module ClassMethods
8
+ def pg_search_scope(name, options)
9
+ options_proc = if options.respond_to?(:call)
10
+ options
11
+ elsif options.respond_to?(:merge)
12
+ ->(query) { { query: query }.merge(options) }
13
+ else
14
+ raise ArgumentError, 'pg_search_scope expects a Hash or Proc'
15
+ end
16
+
17
+ define_singleton_method(name) do |*args|
18
+ config = Configuration.new(options_proc.call(*args), self)
19
+ scope_options = ScopeOptions.new(config)
20
+ scope_options.apply(self)
21
+ end
22
+ end
23
+
24
+ def multisearchable(options = {})
25
+ include PgSearch::Multisearchable
26
+ class_attribute :pg_search_multisearchable_options
27
+ self.pg_search_multisearchable_options = options
28
+ end
29
+ end
30
+
31
+ def method_missing(symbol, *args)
32
+ case symbol
33
+ when :pg_search_rank
34
+ raise PgSearchRankNotSelected unless respond_to?(:pg_search_rank)
35
+
36
+ read_attribute(:pg_search_rank).to_f
37
+ when :pg_search_highlight
38
+ raise PgSearchHighlightNotSelected unless respond_to?(:pg_search_highlight)
39
+
40
+ read_attribute(:pg_search_highlight)
41
+ else
42
+ super
43
+ end
44
+ end
45
+
46
+ def respond_to_missing?(symbol, *args)
47
+ case symbol
48
+ when :pg_search_rank
49
+ attributes.key?(:pg_search_rank)
50
+ when :pg_search_highlight
51
+ attributes.key?(:pg_search_highlight)
52
+ else
53
+ super
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgSearch
4
- VERSION = '2.2.0'
4
+ VERSION = '2.3.0'
5
5
  end
@@ -18,7 +18,7 @@ describe PgSearch do
18
18
  end
19
19
 
20
20
  model do
21
- include PgSearch
21
+ include PgSearch::Model
22
22
  belongs_to :another_model, class_name: 'AssociatedModel'
23
23
 
24
24
  pg_search_scope :with_another, associated_against: { another_model: :title }
@@ -55,7 +55,7 @@ describe PgSearch do
55
55
  end
56
56
 
57
57
  model do
58
- include PgSearch
58
+ include PgSearch::Model
59
59
  belongs_to :another_model, class_name: 'AssociatedModel'
60
60
 
61
61
  pg_search_scope :with_associated, against: :title, associated_against: { another_model: :title }
@@ -91,7 +91,7 @@ describe PgSearch do
91
91
  end
92
92
 
93
93
  model do
94
- include PgSearch
94
+ include PgSearch::Model
95
95
  has_many :other_models, class_name: 'AssociatedModelWithHasMany', foreign_key: 'ModelWithHasMany_id'
96
96
 
97
97
  pg_search_scope :with_associated, against: [:title], associated_against: { other_models: :title }
@@ -163,7 +163,7 @@ describe PgSearch do
163
163
  end
164
164
 
165
165
  model do
166
- include PgSearch
166
+ include PgSearch::Model
167
167
 
168
168
  has_many :models_of_first_type,
169
169
  class_name: 'FirstAssociatedModel',
@@ -222,7 +222,7 @@ describe PgSearch do
222
222
  end
223
223
 
224
224
  model do
225
- include PgSearch
225
+ include PgSearch::Model
226
226
 
227
227
  has_many :things,
228
228
  class_name: 'DoublyAssociatedModel',
@@ -282,7 +282,7 @@ describe PgSearch do
282
282
  end
283
283
 
284
284
  model do
285
- include PgSearch
285
+ include PgSearch::Model
286
286
  belongs_to :another_model, class_name: 'AssociatedModel'
287
287
 
288
288
  pg_search_scope :with_associated, associated_against: { another_model: %i[title author] }
@@ -335,7 +335,7 @@ describe PgSearch do
335
335
  end
336
336
 
337
337
  model do
338
- include PgSearch
338
+ include PgSearch::Model
339
339
  belongs_to :another_model, class_name: 'AssociatedModel'
340
340
 
341
341
  pg_search_scope :with_associated, associated_against: { another_model: :number }
@@ -366,7 +366,7 @@ describe PgSearch do
366
366
 
367
367
  model do
368
368
  has_many :children
369
- include PgSearch
369
+ include PgSearch::Model
370
370
  pg_search_scope :search_name, against: :name
371
371
  end
372
372
  end
@@ -409,7 +409,7 @@ describe PgSearch do
409
409
  end
410
410
 
411
411
  model do
412
- include PgSearch
412
+ include PgSearch::Model
413
413
  belongs_to :model_with_association
414
414
 
415
415
  pg_search_scope :search_content, against: :content
@@ -455,7 +455,7 @@ describe PgSearch do
455
455
  end
456
456
 
457
457
  model do
458
- include PgSearch
458
+ include PgSearch::Model
459
459
  pg_search_scope :search, against: :title, using: %i[tsearch trigram]
460
460
  end
461
461
  end
@@ -496,7 +496,7 @@ describe PgSearch do
496
496
  end
497
497
 
498
498
  model do
499
- include PgSearch
499
+ include PgSearch::Model
500
500
  pg_search_scope :search, against: :title, using: %i[tsearch trigram]
501
501
  end
502
502
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ describe "Including the deprecated PgSearch module" do
6
+ with_model :SomeModel do
7
+ model do
8
+ ActiveSupport::Deprecation.silence do
9
+ include PgSearch
10
+ end
11
+ end
12
+ end
13
+
14
+ with_model :AnotherModel
15
+
16
+ it "includes PgSearch::Model" do
17
+ expect(SomeModel.ancestors).to include PgSearch::Model
18
+ end
19
+
20
+ it "prints a deprecation message" do
21
+ allow(ActiveSupport::Deprecation).to receive(:warn)
22
+
23
+ AnotherModel.include(PgSearch)
24
+
25
+ expect(ActiveSupport::Deprecation).to have_received(:warn).with(
26
+ <<-MESSAGE.strip_heredoc
27
+ Directly including `PgSearch` into an Active Record model is deprecated and will be removed in pg_search 3.0.
28
+
29
+ Please replace `include PgSearch` with `include PgSearch::Model`.
30
+ MESSAGE
31
+ )
32
+ end
33
+ end
@@ -10,7 +10,7 @@ describe "pagination" do
10
10
  end
11
11
 
12
12
  model do
13
- include PgSearch
13
+ include PgSearch::Model
14
14
  pg_search_scope :search_name, against: :name
15
15
 
16
16
  def self.page(page_number)
@@ -12,7 +12,7 @@ describe "an Active Record model which includes PgSearch" do
12
12
  end
13
13
 
14
14
  model do
15
- include PgSearch
15
+ include PgSearch::Model
16
16
  belongs_to :parent_model
17
17
  end
18
18
  end
@@ -22,7 +22,7 @@ describe "an Active Record model which includes PgSearch" do
22
22
  end
23
23
 
24
24
  model do
25
- include PgSearch
25
+ include PgSearch::Model
26
26
  has_many :models_with_pg_search
27
27
  scope :active, -> { where(active: true) }
28
28
  end
@@ -208,7 +208,7 @@ describe "an Active Record model which includes PgSearch" do
208
208
  end
209
209
 
210
210
  model do
211
- include PgSearch
211
+ include PgSearch::Model
212
212
  belongs_to :person
213
213
  pg_search_scope :search_city, against: [:city]
214
214
  end
@@ -220,7 +220,7 @@ describe "an Active Record model which includes PgSearch" do
220
220
  end
221
221
 
222
222
  model do
223
- include PgSearch
223
+ include PgSearch::Model
224
224
  has_many :houses
225
225
  pg_search_scope :named, against: [:name]
226
226
  scope :with_house_in_city, lambda { |city|
@@ -462,7 +462,7 @@ describe "an Active Record model which includes PgSearch" do
462
462
  end
463
463
 
464
464
  model do
465
- include PgSearch
465
+ include PgSearch::Model
466
466
 
467
467
  # WARNING: searching timestamps is not something PostgreSQL
468
468
  # full-text search is good at. Use at your own risk.
@@ -995,7 +995,7 @@ describe "an Active Record model which includes PgSearch" do
995
995
  end
996
996
 
997
997
  model do
998
- include PgSearch
998
+ include PgSearch::Model
999
999
  has_many :comments
1000
1000
  end
1001
1001
  end
@@ -1038,7 +1038,7 @@ describe "an Active Record model which includes PgSearch" do
1038
1038
  context 'using multiple tsvector columns' do
1039
1039
  with_model :ModelWithTsvector do
1040
1040
  model do
1041
- include PgSearch
1041
+ include PgSearch::Model
1042
1042
 
1043
1043
  pg_search_scope :search_by_multiple_tsvector_columns,
1044
1044
  against: ['content', 'message'],
@@ -1066,7 +1066,7 @@ describe "an Active Record model which includes PgSearch" do
1066
1066
  t.tsvector 'content_tsvector'
1067
1067
  end
1068
1068
 
1069
- model { include PgSearch }
1069
+ model { include PgSearch::Model }
1070
1070
  end
1071
1071
 
1072
1072
  let!(:expected) { ModelWithTsvector.create!(content: 'tiling is grouty') }
@@ -11,7 +11,7 @@ describe "a pg_search_scope on an STI subclass" do
11
11
  end
12
12
 
13
13
  model do
14
- include PgSearch
14
+ include PgSearch::Model
15
15
  pg_search_scope :search_content, against: :content
16
16
  end
17
17
  end
@@ -51,7 +51,7 @@ describe "a pg_search_scope on an STI subclass" do
51
51
  end
52
52
 
53
53
  model do
54
- include PgSearch
54
+ include PgSearch::Model
55
55
  self.inheritance_column = 'custom_type'
56
56
  pg_search_scope :search_content, against: :content
57
57
  end
@@ -17,7 +17,7 @@ describe PgSearch::Configuration::Association do
17
17
  end
18
18
 
19
19
  model do
20
- include PgSearch
20
+ include PgSearch::Model
21
21
  has_one :avatar, class_name: "Avatar"
22
22
  belongs_to :site
23
23
 
@@ -32,7 +32,7 @@ describe PgSearch::Configuration::Association do
32
32
  end
33
33
 
34
34
  model do
35
- include PgSearch
35
+ include PgSearch::Model
36
36
  has_many :users, class_name: "User"
37
37
 
38
38
  pg_search_scope :with_users, associated_against: { users: :name }
@@ -17,7 +17,7 @@ describe PgSearch::Configuration::ForeignColumn do
17
17
  end
18
18
 
19
19
  model do
20
- include PgSearch
20
+ include PgSearch::Model
21
21
  belongs_to :another_model, class_name: 'AssociatedModel'
22
22
 
23
23
  pg_search_scope :with_another, associated_against: { another_model: :title }
@@ -28,7 +28,7 @@ describe PgSearch::Multisearch::Rebuilder do
28
28
  context "and multisearchable is not conditional" do
29
29
  with_model :Model do
30
30
  model do
31
- include PgSearch
31
+ include PgSearch::Model
32
32
  multisearchable
33
33
 
34
34
  def rebuild_pg_search_documents
@@ -52,7 +52,7 @@ describe PgSearch::Multisearch::Rebuilder do
52
52
  end
53
53
 
54
54
  model do
55
- include PgSearch
55
+ include PgSearch::Model
56
56
  multisearchable conditional_key => :active?
57
57
 
58
58
  def rebuild_pg_search_documents
@@ -79,7 +79,7 @@ describe PgSearch::Multisearch::Rebuilder do
79
79
  end
80
80
 
81
81
  model do
82
- include PgSearch
82
+ include PgSearch::Model
83
83
  multisearchable against: :name
84
84
  end
85
85
  end
@@ -141,7 +141,7 @@ describe PgSearch::Multisearch::Rebuilder do
141
141
  end
142
142
 
143
143
  model do
144
- include PgSearch
144
+ include PgSearch::Model
145
145
  multisearchable against: :name
146
146
  end
147
147
  end
@@ -160,7 +160,7 @@ describe PgSearch::Multisearch::Rebuilder do
160
160
  end
161
161
 
162
162
  model do
163
- include PgSearch
163
+ include PgSearch::Model
164
164
  multisearchable against: :name
165
165
  end
166
166
  end
@@ -206,7 +206,7 @@ describe PgSearch::Multisearch::Rebuilder do
206
206
  end
207
207
 
208
208
  model do
209
- include PgSearch
209
+ include PgSearch::Model
210
210
  multisearchable against: [:foo]
211
211
 
212
212
  def foo
@@ -246,7 +246,7 @@ describe PgSearch::Multisearch::Rebuilder do
246
246
  end
247
247
 
248
248
  model do
249
- include PgSearch
249
+ include PgSearch::Model
250
250
  multisearchable if: :active?
251
251
  end
252
252
  end
@@ -282,7 +282,7 @@ describe PgSearch::Multisearch::Rebuilder do
282
282
  end
283
283
 
284
284
  model do
285
- include PgSearch
285
+ include PgSearch::Model
286
286
  multisearchable unless: :inactive?
287
287
  end
288
288
  end
@@ -12,7 +12,7 @@ describe PgSearch::Multisearch do
12
12
  t.timestamps null: false
13
13
  end
14
14
  model do
15
- include PgSearch
15
+ include PgSearch::Model
16
16
  end
17
17
  end
18
18
 
@@ -8,7 +8,7 @@ describe PgSearch::Multisearchable do
8
8
  describe "a model that is multisearchable" do
9
9
  with_model :ModelThatIsMultisearchable do
10
10
  model do
11
- include PgSearch
11
+ include PgSearch::Model
12
12
  multisearchable
13
13
  end
14
14
  end
@@ -19,7 +19,7 @@ describe PgSearch::Multisearchable do
19
19
  end
20
20
 
21
21
  model do
22
- include PgSearch
22
+ include PgSearch::Model
23
23
  multisearchable
24
24
 
25
25
  has_many :multisearchable_children, dependent: :destroy
@@ -287,7 +287,7 @@ describe PgSearch::Multisearchable do
287
287
  end
288
288
 
289
289
  model do
290
- include PgSearch
290
+ include PgSearch::Model
291
291
  multisearchable if: ->(record) { record.multisearchable? }
292
292
  end
293
293
  end
@@ -415,7 +415,7 @@ describe PgSearch::Multisearchable do
415
415
  end
416
416
 
417
417
  model do
418
- include PgSearch
418
+ include PgSearch::Model
419
419
  multisearchable unless: ->(record) { record.not_multisearchable? }
420
420
  end
421
421
  end
@@ -544,7 +544,7 @@ describe PgSearch::Multisearchable do
544
544
  end
545
545
 
546
546
  model do
547
- include PgSearch
547
+ include PgSearch::Model
548
548
  multisearchable if: :multisearchable?
549
549
  end
550
550
  end
@@ -676,7 +676,7 @@ describe PgSearch::Multisearchable do
676
676
  end
677
677
 
678
678
  model do
679
- include PgSearch
679
+ include PgSearch::Model
680
680
  multisearchable unless: :not_multisearchable?
681
681
  end
682
682
  end
@@ -43,7 +43,7 @@ describe PgSearch do
43
43
  t.string :title
44
44
  end
45
45
  model do
46
- include PgSearch
46
+ include PgSearch::Model
47
47
  multisearchable against: :title
48
48
  end
49
49
  end
@@ -76,7 +76,7 @@ describe PgSearch do
76
76
  t.string :title
77
77
  end
78
78
  model do
79
- include PgSearch
79
+ include PgSearch::Model
80
80
  multisearchable against: :title
81
81
  end
82
82
  end
@@ -106,7 +106,7 @@ describe PgSearch do
106
106
 
107
107
  before do
108
108
  searchable_subclass_model = Class.new(SuperclassModel) do
109
- include PgSearch
109
+ include PgSearch::Model
110
110
  multisearchable against: :content
111
111
  end
112
112
  stub_const("SearchableSubclassModel", searchable_subclass_model)
@@ -196,7 +196,7 @@ describe PgSearch do
196
196
 
197
197
  before do
198
198
  searchable_subclass_model = Class.new(SuperclassModel) do
199
- include PgSearch
199
+ include PgSearch::Model
200
200
  multisearchable against: :content
201
201
  end
202
202
  stub_const("SearchableSubclassModel", searchable_subclass_model)
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.2.0
4
+ version: 2.3.0
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: 2019-05-26 00:00:00.000000000 Z
12
+ date: 2019-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -149,6 +149,7 @@ files:
149
149
  - ".autotest"
150
150
  - ".bundle/config"
151
151
  - ".codeclimate.yml"
152
+ - ".editorconfig"
152
153
  - ".gitignore"
153
154
  - ".rspec"
154
155
  - ".rubocop.yml"
@@ -175,6 +176,7 @@ files:
175
176
  - lib/pg_search/migration/multisearch_generator.rb
176
177
  - lib/pg_search/migration/templates/add_pg_search_dmetaphone_support_functions.rb.erb
177
178
  - lib/pg_search/migration/templates/create_pg_search_documents.rb.erb
179
+ - lib/pg_search/model.rb
178
180
  - lib/pg_search/multisearch.rb
179
181
  - lib/pg_search/multisearch/rebuilder.rb
180
182
  - lib/pg_search/multisearchable.rb
@@ -186,6 +188,7 @@ files:
186
188
  - pg_search.gemspec
187
189
  - spec/.rubocop.yml
188
190
  - spec/integration/associations_spec.rb
191
+ - spec/integration/deprecation_spec.rb
189
192
  - spec/integration/pagination_spec.rb
190
193
  - spec/integration/pg_search_spec.rb
191
194
  - spec/integration/single_table_inheritance_spec.rb
@@ -231,6 +234,7 @@ summary: PgSearch builds Active Record named scopes that take advantage of Postg
231
234
  full text search
232
235
  test_files:
233
236
  - spec/integration/associations_spec.rb
237
+ - spec/integration/deprecation_spec.rb
234
238
  - spec/integration/pagination_spec.rb
235
239
  - spec/integration/pg_search_spec.rb
236
240
  - spec/integration/single_table_inheritance_spec.rb