picky 4.12.13 → 4.13.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/categories.rb +1 -1
- data/lib/picky/categories_indexed.rb +0 -2
- data/lib/picky/category.rb +17 -1
- data/lib/picky.rb +1 -1
- data/spec/lib/category_indexed_spec.rb +2 -2
- data/spec/lib/category_spec.rb +18 -0
- metadata +4 -5
- data/lib/picky/backends/internal.rb +0 -23
data/lib/picky/categories.rb
CHANGED
@@ -53,7 +53,7 @@ module Picky
|
|
53
53
|
#
|
54
54
|
def << category
|
55
55
|
reset_qualifier_mapper # TODO Have an add method on QualifierMapper?
|
56
|
-
categories << category unless categories.include? category # This is wrong, and needs to be handled in index.rb
|
56
|
+
categories << category unless categories.include? category # TODO This is wrong, and needs to be handled in index.rb
|
57
57
|
category_hash[category.name] = category
|
58
58
|
end
|
59
59
|
|
data/lib/picky/category.rb
CHANGED
@@ -42,7 +42,7 @@ module Picky
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def configure_from options
|
45
|
-
@from = options
|
45
|
+
@from = options.delete :from
|
46
46
|
|
47
47
|
# Instantly extracted to raise an error instantly.
|
48
48
|
#
|
@@ -61,6 +61,8 @@ module Picky
|
|
61
61
|
# TODO I do a lot of helper method calls here. Refactor?
|
62
62
|
#
|
63
63
|
def configure_indexes_from options
|
64
|
+
warn_if_unknown options
|
65
|
+
|
64
66
|
weights = weights_from options
|
65
67
|
partial = partial_from options
|
66
68
|
similarity = similarity_from options
|
@@ -70,6 +72,20 @@ module Picky
|
|
70
72
|
|
71
73
|
@prepared = Backends::Prepared::Text.new prepared_index_path
|
72
74
|
end
|
75
|
+
# Since the options hash might contain options that do not exist,
|
76
|
+
# we should warn people if they use the wrong options.
|
77
|
+
# (Problem is that if the option is not found, then Picky will use the default)
|
78
|
+
#
|
79
|
+
# TODO Rewrite it such that this does not need to be maintained separately.
|
80
|
+
#
|
81
|
+
@@known_keys = [:indexing, :partial, :qualifier, :qualifiers, :ranging, :similarity, :source, :weight]
|
82
|
+
def warn_if_unknown options
|
83
|
+
warn <<-WARNING if options && (options.keys - @@known_keys).size > 0
|
84
|
+
|
85
|
+
Warning: Category options #{options} for category #{name} contain an unknown option.
|
86
|
+
Working options are: #{@@known_keys}.
|
87
|
+
WARNING
|
88
|
+
end
|
73
89
|
def weights_from options
|
74
90
|
Generators::Weights.from options[:weight], index_name, name
|
75
91
|
end
|
data/lib/picky.rb
CHANGED
@@ -7,14 +7,14 @@ describe Picky::Category do
|
|
7
7
|
source []
|
8
8
|
end
|
9
9
|
@partial_strategy = stub :partial, :each_partial => nil, :use_exact_for_partial? => false
|
10
|
-
@weight_strategy
|
10
|
+
@weight_strategy = stub :weights, :saved? => true, :weight_for => :some_weight
|
11
11
|
@similarity_strategy = stub :similarity, :encode => nil, :prioritize => nil
|
12
12
|
|
13
13
|
@exact = stub :exact, :dump => nil
|
14
14
|
@partial = stub :partial, :dump => nil
|
15
15
|
|
16
16
|
@category = described_class.new :some_name, @index, :partial => @partial_strategy,
|
17
|
-
:
|
17
|
+
:weight => @weight_strategy,
|
18
18
|
:similarity => @similarity_strategy,
|
19
19
|
:qualifiers => [:q, :qualifier]
|
20
20
|
|
data/spec/lib/category_spec.rb
CHANGED
@@ -45,6 +45,24 @@ describe Picky::Category do
|
|
45
45
|
category.prepared_index_path.should == 'spec/temp/index/test/some_index/some_category'
|
46
46
|
end
|
47
47
|
end
|
48
|
+
|
49
|
+
describe 'options' do
|
50
|
+
let(:category) { described_class.new :some_category, index }
|
51
|
+
it 'warns on wrong options' do
|
52
|
+
category.should_receive(:warn).once.with <<-WARNING
|
53
|
+
|
54
|
+
Warning: Category options {:weights=>:some_weight} for category some_category contain an unknown option.
|
55
|
+
Working options are: [:indexing, :partial, :qualifier, :qualifiers, :ranging, :similarity, :source, :weight].
|
56
|
+
WARNING
|
57
|
+
|
58
|
+
category.warn_if_unknown :weights => :some_weight
|
59
|
+
end
|
60
|
+
it 'does not warn on right options' do
|
61
|
+
category.should_receive(:warn).never
|
62
|
+
|
63
|
+
category.warn_if_unknown :weight => :some_weight
|
64
|
+
end
|
65
|
+
end
|
48
66
|
|
49
67
|
context 'tokenizer' do
|
50
68
|
context 'options hash' 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.13.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: 2013-02-
|
12
|
+
date: 2013-02-18 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.13.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.13.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: text
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,7 +128,6 @@ files:
|
|
128
128
|
- lib/picky/backends/file/json.rb
|
129
129
|
- lib/picky/backends/file.rb
|
130
130
|
- lib/picky/backends/helpers/file.rb
|
131
|
-
- lib/picky/backends/internal.rb
|
132
131
|
- lib/picky/backends/memory/basic.rb
|
133
132
|
- lib/picky/backends/memory/json.rb
|
134
133
|
- lib/picky/backends/memory/marshal.rb
|