picky 4.24.0 → 4.25.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.
- checksums.yaml +4 -4
- data/lib/picky/category.rb +9 -9
- data/lib/picky/category_realtime.rb +2 -2
- data/lib/picky/index.rb +10 -0
- data/lib/picky/search.rb +5 -1
- data/spec/functional/max_allocations_spec.rb +1 -1
- data/spec/functional/symbol_keys_spec.rb +29 -0
- data/spec/functional/terminate_early_spec.rb +1 -1
- data/spec/lib/category_spec.rb +1 -1
- data/spec/lib/picky_spec.rb +0 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d83031c692b720f4c0e208135d1a9132865f6db8
|
4
|
+
data.tar.gz: da41d6d9de9c1762e83aee7c8bb3e62447e24934
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f119107151b6848085eb65eb0cf1c52c4d30bcff59f05bf37c09599007f16d8394bec8fbdeecf0b80ae1465c75496789169055d84ff507f4be632fa21b085b32
|
7
|
+
data.tar.gz: 9ab9540294fb221af016c379eff38486b96f9b0752428ed88e0dad44d60748de52f8d13c0172f99e2ebe503f82c6e81a053c130071efbeae6af315858ab6adf7
|
data/lib/picky/category.rb
CHANGED
@@ -42,21 +42,21 @@ module Picky
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def configure_from options
|
45
|
-
@from
|
45
|
+
@from = options.delete :from
|
46
46
|
|
47
47
|
# Instantly extracted to raise an error instantly.
|
48
48
|
#
|
49
|
-
@source
|
50
|
-
@tokenize
|
51
|
-
@tokenizer
|
52
|
-
@ranger
|
49
|
+
@source = Source.from options[:source], true, @index.name
|
50
|
+
@tokenize = options[:tokenize] != false
|
51
|
+
@tokenizer = Tokenizer.from options[:indexing], @index.name, name
|
52
|
+
@ranger = options[:ranging] || Range
|
53
53
|
|
54
|
-
@key_format
|
55
|
-
@backend
|
54
|
+
@key_format = options.delete :key_format
|
55
|
+
@backend = options.delete :backend
|
56
56
|
|
57
|
-
@qualifiers
|
57
|
+
@qualifiers = extract_qualifiers_from options
|
58
58
|
|
59
|
-
|
59
|
+
@symbol_keys = options[:symbol_keys] || @index.symbol_keys # SYMBOLS.
|
60
60
|
end
|
61
61
|
|
62
62
|
# TODO I do a lot of helper method calls here. Refactor?
|
@@ -64,7 +64,7 @@ module Picky
|
|
64
64
|
# strings to the index for the given id.
|
65
65
|
#
|
66
66
|
def add_text id, text_or_tokens, where = :unshift
|
67
|
-
#
|
67
|
+
# text_or_tokens = text_or_tokens.to_sym if @symbol_keys # SYMBOLS.
|
68
68
|
tokens = nil
|
69
69
|
if tokenizer
|
70
70
|
tokens, _ = tokenizer.tokenize text_or_tokens
|
@@ -92,7 +92,7 @@ module Picky
|
|
92
92
|
return unless text
|
93
93
|
|
94
94
|
id = id.send key_format if format
|
95
|
-
|
95
|
+
text = text.to_sym if @symbol_keys # SYMBOLS.
|
96
96
|
id.freeze
|
97
97
|
|
98
98
|
exact.add id, text, where, static
|
data/lib/picky/index.rb
CHANGED
@@ -150,6 +150,16 @@ module Picky
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
+
# API method.
|
154
|
+
#
|
155
|
+
def symbol_keys value = nil
|
156
|
+
if value
|
157
|
+
@symbol_keys = value
|
158
|
+
else
|
159
|
+
@symbol_keys
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
153
163
|
# The directory used by this index.
|
154
164
|
#
|
155
165
|
# Note: Used @directory ||=, but needs to be dynamic.
|
data/lib/picky/search.rb
CHANGED
@@ -138,6 +138,10 @@ module Picky
|
|
138
138
|
def boost boosts
|
139
139
|
@boosts = extract_boosts boosts
|
140
140
|
end
|
141
|
+
|
142
|
+
def symbol_keys
|
143
|
+
@symbol_keys = true
|
144
|
+
end
|
141
145
|
|
142
146
|
# Ignore given categories and/or combinations of
|
143
147
|
# categories.
|
@@ -258,7 +262,7 @@ module Picky
|
|
258
262
|
def tokenized text, partialize_last = true
|
259
263
|
tokens, originals = tokenizer.tokenize text
|
260
264
|
tokens = Query::Tokens.processed tokens, originals || tokens, @ignore_unassigned
|
261
|
-
|
265
|
+
tokens.symbolize if @symbol_keys # SYMBOLS.
|
262
266
|
tokens.partialize_last if partialize_last
|
263
267
|
tokens
|
264
268
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
describe "Option symbol_keys" do
|
7
|
+
|
8
|
+
let(:index) do
|
9
|
+
Picky::Index.new(:results1) { symbol_keys true }
|
10
|
+
end
|
11
|
+
let(:try) do
|
12
|
+
Picky::Search.new(index) { symbol_keys }
|
13
|
+
end
|
14
|
+
|
15
|
+
# Test the enumerator abilities.
|
16
|
+
#
|
17
|
+
it 'can enumerate through the allocations' do
|
18
|
+
index.category :text
|
19
|
+
|
20
|
+
thing = OpenStruct.new id: 1, text: "ohai"
|
21
|
+
other = OpenStruct.new id: 2, text: "ohai kthxbye"
|
22
|
+
|
23
|
+
index.add thing
|
24
|
+
index.add other
|
25
|
+
|
26
|
+
try.search("text:ohai").ids.should == [2, 1]
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/spec/lib/category_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe Picky::Category do
|
|
20
20
|
|
21
21
|
category.partial.similarity_strategy.should be_kind_of(Picky::Generators::Similarity::None)
|
22
22
|
|
23
|
-
category.instance_variable_get(:@
|
23
|
+
category.instance_variable_get(:@symbol_keys).should == nil
|
24
24
|
end
|
25
25
|
|
26
26
|
context '#==' do
|
data/spec/lib/picky_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Hanke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -266,6 +266,7 @@ files:
|
|
266
266
|
- spec/functional/speed_spec.rb
|
267
267
|
- spec/functional/static_spec.rb
|
268
268
|
- spec/functional/stemming_spec.rb
|
269
|
+
- spec/functional/symbol_keys_spec.rb
|
269
270
|
- spec/functional/terminate_early_spec.rb
|
270
271
|
- spec/functional/to_s_spec.rb
|
271
272
|
- spec/functional/tokenizer_spec.rb
|
@@ -401,7 +402,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
401
402
|
version: '0'
|
402
403
|
requirements: []
|
403
404
|
rubyforge_project: http://rubyforge.org/projects/picky
|
404
|
-
rubygems_version: 2.
|
405
|
+
rubygems_version: 2.4.1
|
405
406
|
signing_key:
|
406
407
|
specification_version: 4
|
407
408
|
summary: 'Picky: Semantic Search Engine. Clever Interface. Good Tools.'
|
@@ -448,6 +449,7 @@ test_files:
|
|
448
449
|
- spec/functional/speed_spec.rb
|
449
450
|
- spec/functional/static_spec.rb
|
450
451
|
- spec/functional/stemming_spec.rb
|
452
|
+
- spec/functional/symbol_keys_spec.rb
|
451
453
|
- spec/functional/terminate_early_spec.rb
|
452
454
|
- spec/functional/to_s_spec.rb
|
453
455
|
- spec/functional/tokenizer_spec.rb
|
@@ -561,4 +563,3 @@ test_files:
|
|
561
563
|
- spec/lib/tokenizer_spec.rb
|
562
564
|
- spec/performant_spec.rb
|
563
565
|
- spec/tools/picky/cli_spec.rb
|
564
|
-
has_rdoc:
|