textacular 3.2.2 → 4.0.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
  SHA1:
3
- metadata.gz: 0c424e3436f89ec19e61d9f932a17fb2b4eaafae
4
- data.tar.gz: 7d53e4d8a74f6948943a7db4c6e5dd4fce49ba30
3
+ metadata.gz: 7b88b1c0a51ee49341f51fe2c2c6010b7d929644
4
+ data.tar.gz: fbe37bec170667ee3b828aa8156bd16aab704919
5
5
  SHA512:
6
- metadata.gz: b931560f6e448f9bd3c391641780816e130b3e48a9f5255bf6fdf19e1f4ba0e9994291d826908b5d5f910c543130613d48cb8120bdc7db7e932442c3bcb45821
7
- data.tar.gz: 03b42bb0a6ee835d797596bb770de66881b759c43aa1c477b77080cb8d0c733bedd1185c2a3a0f8ab9d3a7d27aef769c9809d6ead794a9e18f89bca281a4d77b
6
+ metadata.gz: 484b15d62a5bb4e87b3a90766b80fe6bf76106b732d271669ced769abfbec8703388d18239262e4bb670371b7e7d8f98968f0d4315c2d0386e9d9c893a8078eb
7
+ data.tar.gz: 94c859fc1ba3d8d71c052daeac3b3056ac3a5de68c0c9bc5399c8b442d45e264ac32f7417edb742e94a39f34330c2a85221568f0c9c09d3a322aa1c446944c31
@@ -8,6 +8,7 @@
8
8
  * Fix search term escaping
9
9
  * Trigram installation migration only install extension if not installed yet.
10
10
  * Update the README to illustrate how to change the similarity threshold.
11
+ * Remove deprecated dynamic search methods.
11
12
 
12
13
  ## 3.2.1
13
14
 
data/README.md CHANGED
@@ -25,7 +25,7 @@ extending ActiveRecord with scopes making search easy and fun!
25
25
 
26
26
  ### Quick Start
27
27
 
28
- #### Rails 3 (or 4!)
28
+ #### Rails 3, Rails 4 and Rails 5!
29
29
 
30
30
  In the project's Gemfile add
31
31
 
@@ -37,34 +37,6 @@ module Textacular
37
37
  assemble_query(similarities, conditions, exclusive)
38
38
  end
39
39
 
40
- def method_missing(method, *search_terms)
41
- return super if self.abstract_class?
42
- if Helper.dynamic_search_method?(method, self.columns)
43
- warn("You are using a dynamic Textacular search method #{method}. These methods are deprecated and will be removed at the next major version release. Please use the has syntax for basic_search and advanced_search.")
44
- exclusive = Helper.exclusive_dynamic_search_method?(method, self.columns)
45
- columns = exclusive ? Helper.exclusive_dynamic_search_columns(method) : Helper.inclusive_dynamic_search_columns(method)
46
- metaclass = class << self; self; end
47
- metaclass.__send__(:define_method, method) do |*args|
48
- query = columns.inject({}) do |query, column|
49
- query.merge column => args.shift
50
- end
51
- self.send(Helper.search_type(method), query, exclusive)
52
- end
53
- __send__(method, *search_terms, exclusive)
54
- else
55
- super
56
- end
57
- rescue ActiveRecord::StatementInvalid
58
- super
59
- end
60
-
61
- def respond_to?(method, include_private = false)
62
- return super if self.abstract_class?
63
- Helper.dynamic_search_method?(method, self.columns) or super
64
- rescue StandardError
65
- super
66
- end
67
-
68
40
  private
69
41
 
70
42
  def munge_exclusive_and_query(exclusive, query)
@@ -157,7 +129,7 @@ module Textacular
157
129
  end
158
130
 
159
131
  def select_values
160
- if ActiveRecord::VERSION::MAJOR == 4
132
+ if ActiveRecord::VERSION::MAJOR >= 4
161
133
  all.select_values
162
134
  else
163
135
  scoped.select_values
@@ -181,55 +153,6 @@ module Textacular
181
153
  def normalize(query)
182
154
  query.to_s.gsub(/\s(?![\&|\!|\|])/, '\\\\ ')
183
155
  end
184
-
185
- def method_name_regex
186
- /^(?<search_type>((basic|advanced|fuzzy)_)?search)_by_(?<columns>[_a-zA-Z]\w*)$/
187
- end
188
-
189
- def search_type(method)
190
- method.to_s.match(method_name_regex)[:search_type]
191
- end
192
-
193
- def exclusive_dynamic_search_columns(method)
194
- if match = method.to_s.match(method_name_regex)
195
- match[:columns].split('_and_')
196
- else
197
- []
198
- end
199
- end
200
-
201
- def inclusive_dynamic_search_columns(method)
202
- if match = method.to_s.match(method_name_regex)
203
- match[:columns].split('_or_')
204
- else
205
- []
206
- end
207
- end
208
-
209
- def exclusive_dynamic_search_method?(method, class_columns)
210
- string_columns = class_columns.map(&:name)
211
- columns = exclusive_dynamic_search_columns(method)
212
- unless columns.empty?
213
- columns.all? {|column| string_columns.include?(column) }
214
- else
215
- false
216
- end
217
- end
218
-
219
- def inclusive_dynamic_search_method?(method, class_columns)
220
- string_columns = class_columns.map(&:name)
221
- columns = inclusive_dynamic_search_columns(method)
222
- unless columns.empty?
223
- columns.all? {|column| string_columns.include?(column) }
224
- else
225
- false
226
- end
227
- end
228
-
229
- def dynamic_search_method?(method, class_columns)
230
- exclusive_dynamic_search_method?(method, class_columns) or
231
- inclusive_dynamic_search_method?(method, class_columns)
232
- end
233
156
  end
234
157
  end
235
158
  end
@@ -1,5 +1,5 @@
1
1
  module Textacular
2
- VERSION = '3.2.2'
2
+ VERSION = '4.0.0'
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -259,77 +259,6 @@ RSpec.describe Textacular do
259
259
  end
260
260
  end
261
261
 
262
- context "via dynamic method names" do
263
- it "only exists prior to 4.0.0" do
264
- current_version = Gem::Version.new(Textacular.version)
265
-
266
- expect(current_version).to be < Gem::Version.new("4.0.0")
267
- end
268
-
269
- it "generates methods for each string column" do
270
- expect(
271
- GameExtendedWithTextacular.advanced_search_by_title("Mario")
272
- ).to eq([mario])
273
- expect(
274
- GameExtendedWithTextacular.advanced_search_by_system("Saturn")
275
- ).to eq([takun])
276
- end
277
-
278
- it "generates methods for each text column" do
279
- expect(
280
- GameExtendedWithTextacular.advanced_search_by_description("platform")
281
- ).to eq([mario])
282
- end
283
-
284
- it "generates methods for any combination of string and text columns" do
285
- expect(
286
- GameExtendedWithTextacular.advanced_search_by_title_and_system("Mario", "NES")
287
- ).to eq([mario])
288
- expect(
289
- GameExtendedWithTextacular.advanced_search_by_system_and_title("Genesis", "Sonic")
290
- ).to eq([sonic])
291
- expect(
292
- GameExtendedWithTextacular.advanced_search_by_title_and_title("Mario", "Mario")
293
- ).to eq([mario])
294
- expect(
295
- GameExtendedWithTextacular.advanced_search_by_title_and_description("Man", "Brain")
296
- ).to eq([mega_man])
297
- end
298
-
299
- it "generates methods for inclusive searches" do
300
- expect(
301
- GameExtendedWithTextacular.advanced_search_by_system_or_title("Saturn", "Mega Man").to_set
302
- ).to eq(Set.new([mega_man, takun]))
303
- end
304
-
305
- it "scopes consecutively" do
306
- expect(
307
- GameExtendedWithTextacular.advanced_search_by_system("Genesis").advanced_search_by_title("Street Fighter")
308
- ).to eq([sf_genesis])
309
- end
310
-
311
- it "generates methods for non-string columns" do
312
- expect(
313
- GameExtendedWithTextacular.advanced_search_by_id(mario.id)
314
- ).to eq([mario])
315
- end
316
-
317
- it "works with #respond_to?" do
318
- expect(GameExtendedWithTextacular).to respond_to(:advanced_search_by_system)
319
- expect(GameExtendedWithTextacular).to respond_to(:advanced_search_by_title)
320
- expect(GameExtendedWithTextacular).to respond_to(:advanced_search_by_system_and_title)
321
- expect(GameExtendedWithTextacular).to respond_to(:advanced_search_by_system_or_title)
322
- expect(GameExtendedWithTextacular).to respond_to(:advanced_search_by_title_and_title_and_title)
323
- expect(GameExtendedWithTextacular).to respond_to(:advanced_search_by_id)
324
-
325
- expect(GameExtendedWithTextacular).to_not respond_to(:advanced_search_by_title_and_title_or_title)
326
- end
327
-
328
- it "allows for 2 arguments to #respond_to?" do
329
- expect(GameExtendedWithTextacular.respond_to?(:searchable_language, true)).to be_truthy
330
- end
331
- end
332
-
333
262
  context "after selecting columns to return" do
334
263
  it "doesn't fetch extra columns" do
335
264
  expect {
@@ -348,7 +277,7 @@ RSpec.describe Textacular do
348
277
 
349
278
  it "finds results" do
350
279
  expect(
351
- GameExtendedWithTextacularAndCustomLanguage.advanced_search_by_title("harry")
280
+ GameExtendedWithTextacularAndCustomLanguage.advanced_search(title: "harry")
352
281
  ).to eq([harry_potter_7])
353
282
  end
354
283
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textacular
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Hamill
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-03-28 00:00:00.000000000 Z
14
+ date: 2016-05-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: pg
@@ -104,7 +104,7 @@ dependencies:
104
104
  - - ">="
105
105
  - !ruby/object:Gem::Version
106
106
  version: '3.0'
107
- - - "<"
107
+ - - "<="
108
108
  - !ruby/object:Gem::Version
109
109
  version: '5.0'
110
110
  type: :runtime
@@ -114,7 +114,7 @@ dependencies:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
116
  version: '3.0'
117
- - - "<"
117
+ - - "<="
118
118
  - !ruby/object:Gem::Version
119
119
  version: '5.0'
120
120
  description: |-
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubyforge_project:
184
- rubygems_version: 2.2.2
184
+ rubygems_version: 2.4.5.1
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: Textacular exposes full text search capabilities from PostgreSQL