picky 4.10.0 → 4.11.0
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.
- data/lib/picky/backends/memory/json.rb +6 -3
- data/lib/picky/categories.rb +12 -0
- data/lib/picky/categories_indexed.rb +3 -1
- data/lib/picky/extensions/array.rb +1 -11
- data/lib/picky/extensions/class.rb +5 -3
- data/lib/picky/extensions/object.rb +13 -1
- data/lib/picky/generators/similarity/phonetic.rb +0 -2
- data/lib/picky/index.rb +33 -0
- data/lib/picky/index_facets.rb +9 -5
- data/lib/picky/loader.rb +4 -7
- data/lib/picky/pool.rb +10 -7
- data/lib/picky/qualifier_mapper.rb +51 -0
- data/lib/picky/query/boosts.rb +2 -2
- data/lib/picky/query/indexes.rb +1 -29
- data/lib/picky/query/token.rb +7 -3
- data/lib/picky/query/tokens.rb +0 -6
- data/lib/picky/search_facets.rb +45 -9
- data/lib/picky/sinatra.rb +2 -0
- data/lib/picky/tokenizer.rb +19 -11
- data/lib/picky.rb +3 -1
- data/spec/functional/facets_spec.rb +9 -13
- data/spec/functional/multi_index_qualifier_spec.rb +30 -0
- data/spec/functional/only_spec.rb +34 -32
- data/spec/functional/pool_spec.rb +82 -0
- data/spec/functional/remap_qualifiers_spec.rb +1 -9
- data/spec/lib/categories_indexed_spec.rb +2 -2
- data/spec/lib/extensions/array_spec.rb +19 -19
- data/spec/lib/extensions/object_spec.rb +14 -11
- data/spec/lib/extensions/symbol_spec.rb +1 -1
- data/spec/lib/generators/similarity/phonetic_spec.rb +14 -7
- data/spec/lib/picky_spec.rb +1 -1
- data/spec/lib/pool_spec.rb +17 -17
- data/spec/lib/{query/qualifier_category_mapper_spec.rb → qualifier_mapper_spec.rb} +8 -8
- data/spec/lib/query/token_spec.rb +17 -12
- data/spec/lib/rack/harakiri_spec.rb +5 -0
- data/spec/lib/tokenizer_spec.rb +44 -3
- metadata +11 -8
- data/lib/picky/migrations/from_30_to_31.rb +0 -61
- data/lib/picky/query/qualifier_category_mapper.rb +0 -61
data/spec/lib/tokenizer_spec.rb
CHANGED
@@ -137,6 +137,32 @@ ERROR
|
|
137
137
|
tokenizer.normalize_with_patterns('alice & bob').should == 'alice and bob'
|
138
138
|
end
|
139
139
|
end
|
140
|
+
# TODO Reinstate.
|
141
|
+
#
|
142
|
+
# context 'with a normalizer' do
|
143
|
+
# let(:normalizer) {
|
144
|
+
# Class.new do
|
145
|
+
# def normalize_with_patterns text
|
146
|
+
# text.reverse
|
147
|
+
# end
|
148
|
+
# end.new
|
149
|
+
# }
|
150
|
+
# before(:each) do
|
151
|
+
# tokenizer.normalizes_words normalizer
|
152
|
+
# end
|
153
|
+
# it "has normalize_with_patterns" do
|
154
|
+
# expect { tokenizer.normalize_with_patterns('a b/c.d') }.to_not raise_error
|
155
|
+
# end
|
156
|
+
# it "normalizes, but just the first one" do
|
157
|
+
# tokenizer.normalize_with_patterns('1234567890').should == '0987654321'
|
158
|
+
# end
|
159
|
+
# it "works correctly" do
|
160
|
+
# tokenizer.normalize_with_patterns('camera +').should == '+ aremac'
|
161
|
+
# end
|
162
|
+
# it "works correctly" do
|
163
|
+
# tokenizer.normalize_with_patterns('alice & bob').should == 'bob & ecila'
|
164
|
+
# end
|
165
|
+
# end
|
140
166
|
end
|
141
167
|
|
142
168
|
describe "splits_text_on" do
|
@@ -157,17 +183,32 @@ ERROR
|
|
157
183
|
tokenizer.split('this is a test').should == ['this', 'is', 'a', 'test']
|
158
184
|
end
|
159
185
|
end
|
160
|
-
context "with
|
186
|
+
context "with specific splitting pattern" do
|
161
187
|
before(:each) do
|
162
188
|
tokenizer.splits_text_on(/[\s\.\/]/)
|
163
189
|
end
|
164
|
-
it "
|
190
|
+
it "splits text correctly" do
|
165
191
|
expect { tokenizer.split('a b/c.d') }.to_not raise_error
|
166
192
|
end
|
167
|
-
it "
|
193
|
+
it "splits text correctly" do
|
168
194
|
tokenizer.split('a b/c.d').should == ['a','b','c','d']
|
169
195
|
end
|
170
196
|
end
|
197
|
+
context "with a splitter given" do
|
198
|
+
let(:splitter) do
|
199
|
+
Class.new do
|
200
|
+
def split text
|
201
|
+
text.split(/,/)
|
202
|
+
end
|
203
|
+
end.new
|
204
|
+
end
|
205
|
+
before(:each) do
|
206
|
+
tokenizer.splits_text_on splitter
|
207
|
+
end
|
208
|
+
it "splits text correctly" do
|
209
|
+
tokenizer.split('a,b/c.d').should == ['a', 'b/c.d']
|
210
|
+
end
|
211
|
+
end
|
171
212
|
end
|
172
213
|
|
173
214
|
describe "removes_characters" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.11.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 4.
|
37
|
+
version: 4.11.0
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 4.
|
45
|
+
version: 4.11.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: text
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,10 +220,10 @@ files:
|
|
220
220
|
- lib/picky/loggers/default.rb
|
221
221
|
- lib/picky/loggers/silent.rb
|
222
222
|
- lib/picky/loggers/verbose.rb
|
223
|
-
- lib/picky/migrations/from_30_to_31.rb
|
224
223
|
- lib/picky/performant.rb
|
225
224
|
- lib/picky/platforms/macruby.rb
|
226
225
|
- lib/picky/pool.rb
|
226
|
+
- lib/picky/qualifier_mapper.rb
|
227
227
|
- lib/picky/query/allocation.rb
|
228
228
|
- lib/picky/query/allocations.rb
|
229
229
|
- lib/picky/query/boosts.rb
|
@@ -231,7 +231,6 @@ files:
|
|
231
231
|
- lib/picky/query/combinations.rb
|
232
232
|
- lib/picky/query/indexes.rb
|
233
233
|
- lib/picky/query/indexes_check.rb
|
234
|
-
- lib/picky/query/qualifier_category_mapper.rb
|
235
234
|
- lib/picky/query/token.rb
|
236
235
|
- lib/picky/query/tokens.rb
|
237
236
|
- lib/picky/rack/harakiri.rb
|
@@ -279,8 +278,10 @@ files:
|
|
279
278
|
- spec/functional/exact_first_spec.rb
|
280
279
|
- spec/functional/facets_spec.rb
|
281
280
|
- spec/functional/max_allocations_spec.rb
|
281
|
+
- spec/functional/multi_index_qualifier_spec.rb
|
282
282
|
- spec/functional/non_specific_ids_larger_than_20_spec.rb
|
283
283
|
- spec/functional/only_spec.rb
|
284
|
+
- spec/functional/pool_spec.rb
|
284
285
|
- spec/functional/realtime_spec.rb
|
285
286
|
- spec/functional/regression_spec.rb
|
286
287
|
- spec/functional/reloading_spec.rb
|
@@ -374,6 +375,7 @@ files:
|
|
374
375
|
- spec/lib/loggers/verbose_spec.rb
|
375
376
|
- spec/lib/picky_spec.rb
|
376
377
|
- spec/lib/pool_spec.rb
|
378
|
+
- spec/lib/qualifier_mapper_spec.rb
|
377
379
|
- spec/lib/query/allocation_spec.rb
|
378
380
|
- spec/lib/query/allocations_spec.rb
|
379
381
|
- spec/lib/query/boosts_spec.rb
|
@@ -381,7 +383,6 @@ files:
|
|
381
383
|
- spec/lib/query/combinations_spec.rb
|
382
384
|
- spec/lib/query/indexes_check_spec.rb
|
383
385
|
- spec/lib/query/indexes_spec.rb
|
384
|
-
- spec/lib/query/qualifier_category_mapper_spec.rb
|
385
386
|
- spec/lib/query/solr_spec.rb
|
386
387
|
- spec/lib/query/token_spec.rb
|
387
388
|
- spec/lib/query/tokens_spec.rb
|
@@ -440,8 +441,10 @@ test_files:
|
|
440
441
|
- spec/functional/exact_first_spec.rb
|
441
442
|
- spec/functional/facets_spec.rb
|
442
443
|
- spec/functional/max_allocations_spec.rb
|
444
|
+
- spec/functional/multi_index_qualifier_spec.rb
|
443
445
|
- spec/functional/non_specific_ids_larger_than_20_spec.rb
|
444
446
|
- spec/functional/only_spec.rb
|
447
|
+
- spec/functional/pool_spec.rb
|
445
448
|
- spec/functional/realtime_spec.rb
|
446
449
|
- spec/functional/regression_spec.rb
|
447
450
|
- spec/functional/reloading_spec.rb
|
@@ -535,6 +538,7 @@ test_files:
|
|
535
538
|
- spec/lib/loggers/verbose_spec.rb
|
536
539
|
- spec/lib/picky_spec.rb
|
537
540
|
- spec/lib/pool_spec.rb
|
541
|
+
- spec/lib/qualifier_mapper_spec.rb
|
538
542
|
- spec/lib/query/allocation_spec.rb
|
539
543
|
- spec/lib/query/allocations_spec.rb
|
540
544
|
- spec/lib/query/boosts_spec.rb
|
@@ -542,7 +546,6 @@ test_files:
|
|
542
546
|
- spec/lib/query/combinations_spec.rb
|
543
547
|
- spec/lib/query/indexes_check_spec.rb
|
544
548
|
- spec/lib/query/indexes_spec.rb
|
545
|
-
- spec/lib/query/qualifier_category_mapper_spec.rb
|
546
549
|
- spec/lib/query/solr_spec.rb
|
547
550
|
- spec/lib/query/token_spec.rb
|
548
551
|
- spec/lib/query/tokens_spec.rb
|
@@ -1,61 +0,0 @@
|
|
1
|
-
module Picky
|
2
|
-
|
3
|
-
class Indexes
|
4
|
-
|
5
|
-
class Memory
|
6
|
-
|
7
|
-
def initialize(*)
|
8
|
-
raise <<-MESSAGE
|
9
|
-
|
10
|
-
The Picky::Indexes::Memory is not available anymore and has been replaced by Picky::Index.
|
11
|
-
|
12
|
-
So instead of
|
13
|
-
|
14
|
-
index = Picky::Indexes::Memory.new :name do
|
15
|
-
# your config
|
16
|
-
end
|
17
|
-
|
18
|
-
use
|
19
|
-
|
20
|
-
index = Picky::Index.new :name do
|
21
|
-
# your config
|
22
|
-
end
|
23
|
-
|
24
|
-
Thanks and sorry for the inconvenience!
|
25
|
-
|
26
|
-
MESSAGE
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
class Redis
|
32
|
-
|
33
|
-
def initialize(*)
|
34
|
-
raise <<-MESSAGE
|
35
|
-
|
36
|
-
The Picky::Indexes::Redis is not available anymore and has been replaced by Picky::Index.
|
37
|
-
(with the addition of a "backend" option)
|
38
|
-
|
39
|
-
So instead of
|
40
|
-
|
41
|
-
index = Picky::Indexes::Redis.new :name do
|
42
|
-
# your config
|
43
|
-
end
|
44
|
-
|
45
|
-
use
|
46
|
-
|
47
|
-
index = Picky::Index.new :name do
|
48
|
-
backend Picky::Backends::Redis.new
|
49
|
-
# your config
|
50
|
-
end
|
51
|
-
|
52
|
-
Thanks and sorry for the inconvenience!
|
53
|
-
|
54
|
-
MESSAGE
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
module Picky
|
2
|
-
|
3
|
-
# coding: utf-8
|
4
|
-
#
|
5
|
-
module Query
|
6
|
-
|
7
|
-
# Collection class for qualifiers.
|
8
|
-
#
|
9
|
-
class QualifierCategoryMapper
|
10
|
-
|
11
|
-
attr_reader :mapping
|
12
|
-
|
13
|
-
#
|
14
|
-
#
|
15
|
-
def initialize indexes
|
16
|
-
@mapping = {}
|
17
|
-
indexes.each do |index|
|
18
|
-
index.each_category do |category|
|
19
|
-
add category
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
#
|
25
|
-
#
|
26
|
-
def add category
|
27
|
-
category.qualifiers.each do |qualifier|
|
28
|
-
sym_qualifier = qualifier.intern
|
29
|
-
Picky.logger.warn %Q{Warning: Qualifier "#{qualifier}" already mapped to category #{mapping[sym_qualifier].identifier} (ambiguous qualifier mapping).} if mapping.has_key? sym_qualifier
|
30
|
-
mapping[sym_qualifier] = category
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Normalizes the given qualifier.
|
35
|
-
#
|
36
|
-
# Returns nil if it is not allowed, the normalized qualifier if it is.
|
37
|
-
#
|
38
|
-
def map qualifier
|
39
|
-
return nil if qualifier.empty?
|
40
|
-
|
41
|
-
@mapping[qualifier.intern]
|
42
|
-
end
|
43
|
-
|
44
|
-
# Restricts the given categories.
|
45
|
-
#
|
46
|
-
def restrict user_qualified
|
47
|
-
if @restricted
|
48
|
-
user_qualified ? @restricted & user_qualified : @restricted
|
49
|
-
else
|
50
|
-
user_qualified
|
51
|
-
end
|
52
|
-
end
|
53
|
-
def restrict_to *qualifiers
|
54
|
-
@restricted = qualifiers.map { |qualifier| map qualifier }.compact
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|