picky 2.7.0 → 3.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/picky/adapters/rack/base.rb +20 -16
- data/lib/picky/adapters/rack/live_parameters.rb +28 -24
- data/lib/picky/adapters/rack/search.rb +67 -0
- data/lib/picky/adapters/rack.rb +27 -23
- data/lib/picky/application.rb +246 -236
- data/lib/picky/backend/base.rb +115 -119
- data/lib/picky/backend/file/basic.rb +102 -98
- data/lib/picky/backend/file/json.rb +27 -23
- data/lib/picky/backend/file/marshal.rb +32 -28
- data/lib/picky/backend/file/text.rb +45 -41
- data/lib/picky/backend/files.rb +19 -15
- data/lib/picky/backend/redis/basic.rb +76 -72
- data/lib/picky/backend/redis/list_hash.rb +40 -36
- data/lib/picky/backend/redis/string_hash.rb +30 -26
- data/lib/picky/backend/redis.rb +32 -28
- data/lib/picky/bundle.rb +82 -57
- data/lib/{bundling.rb → picky/bundling.rb} +0 -0
- data/lib/picky/calculations/location.rb +51 -47
- data/lib/picky/categories.rb +60 -56
- data/lib/picky/categories_indexed.rb +73 -82
- data/lib/picky/categories_indexing.rb +12 -8
- data/lib/picky/category.rb +109 -120
- data/lib/picky/category_indexed.rb +39 -41
- data/lib/picky/category_indexing.rb +123 -125
- data/lib/picky/character_substituters/west_european.rb +32 -26
- data/lib/{constants.rb → picky/constants.rb} +0 -0
- data/lib/picky/cores.rb +96 -92
- data/lib/{deployment.rb → picky/deployment.rb} +0 -0
- data/lib/picky/frontend_adapters/rack.rb +133 -118
- data/lib/picky/generators/aliases.rb +5 -3
- data/lib/picky/generators/base.rb +11 -7
- data/lib/picky/generators/partial/default.rb +7 -3
- data/lib/picky/generators/partial/none.rb +24 -20
- data/lib/picky/generators/partial/strategy.rb +20 -16
- data/lib/picky/generators/partial/substring.rb +94 -90
- data/lib/picky/generators/partial_generator.rb +11 -7
- data/lib/picky/generators/similarity/default.rb +9 -5
- data/lib/picky/generators/similarity/double_metaphone.rb +20 -16
- data/lib/picky/generators/similarity/metaphone.rb +20 -16
- data/lib/picky/generators/similarity/none.rb +23 -19
- data/lib/picky/generators/similarity/phonetic.rb +49 -45
- data/lib/picky/generators/similarity/soundex.rb +20 -16
- data/lib/picky/generators/similarity/strategy.rb +10 -6
- data/lib/picky/generators/similarity_generator.rb +11 -7
- data/lib/picky/generators/strategy.rb +14 -10
- data/lib/picky/generators/weights/default.rb +9 -5
- data/lib/picky/generators/weights/logarithmic.rb +30 -26
- data/lib/picky/generators/weights/strategy.rb +10 -6
- data/lib/picky/generators/weights_generator.rb +11 -7
- data/lib/picky/helpers/measuring.rb +20 -16
- data/lib/picky/indexed/bundle/base.rb +39 -37
- data/lib/picky/indexed/bundle/memory.rb +68 -64
- data/lib/picky/indexed/bundle/redis.rb +73 -69
- data/lib/picky/indexed/wrappers/bundle/calculation.rb +26 -22
- data/lib/picky/indexed/wrappers/bundle/location.rb +30 -26
- data/lib/picky/indexed/wrappers/bundle/wrapper.rb +36 -32
- data/lib/picky/indexed/wrappers/category/location.rb +17 -13
- data/lib/picky/indexed/wrappers/exact_first.rb +46 -42
- data/lib/picky/indexers/base.rb +26 -22
- data/lib/picky/indexers/parallel.rb +62 -58
- data/lib/picky/indexers/serial.rb +41 -37
- data/lib/picky/indexes/index.rb +400 -0
- data/lib/picky/indexes/index_indexed.rb +24 -0
- data/lib/picky/indexes/index_indexing.rb +138 -0
- data/lib/picky/indexes/memory.rb +20 -0
- data/lib/picky/indexes/redis.rb +20 -0
- data/lib/picky/indexes.rb +68 -61
- data/lib/picky/indexes_indexed.rb +16 -12
- data/lib/picky/indexes_indexing.rb +41 -37
- data/lib/picky/indexing/bundle/base.rb +216 -205
- data/lib/picky/indexing/bundle/memory.rb +16 -11
- data/lib/picky/indexing/bundle/redis.rb +14 -12
- data/lib/picky/indexing/wrappers/category/location.rb +17 -13
- data/lib/picky/interfaces/live_parameters.rb +159 -154
- data/lib/picky/loader.rb +267 -304
- data/lib/picky/loggers/search.rb +20 -13
- data/lib/picky/no_source_specified_exception.rb +7 -3
- data/lib/picky/performant.rb +6 -2
- data/lib/picky/query/allocation.rb +71 -67
- data/lib/picky/query/allocations.rb +99 -94
- data/lib/picky/query/combination.rb +70 -66
- data/lib/picky/query/combinations/base.rb +56 -52
- data/lib/picky/query/combinations/memory.rb +36 -32
- data/lib/picky/query/combinations/redis.rb +66 -62
- data/lib/picky/query/indexes.rb +175 -160
- data/lib/picky/query/qualifier_category_mapper.rb +43 -0
- data/lib/picky/query/token.rb +165 -172
- data/lib/picky/query/tokens.rb +86 -82
- data/lib/picky/query/weights.rb +44 -48
- data/lib/picky/query.rb +5 -1
- data/lib/picky/rack/harakiri.rb +51 -47
- data/lib/picky/results.rb +81 -77
- data/lib/picky/search.rb +169 -158
- data/lib/picky/sinatra.rb +34 -0
- data/lib/picky/sources/base.rb +73 -70
- data/lib/picky/sources/couch.rb +61 -57
- data/lib/picky/sources/csv.rb +68 -64
- data/lib/picky/sources/db.rb +139 -135
- data/lib/picky/sources/delicious.rb +52 -48
- data/lib/picky/sources/mongo.rb +68 -63
- data/lib/picky/sources/wrappers/base.rb +20 -16
- data/lib/picky/sources/wrappers/location.rb +37 -33
- data/lib/picky/statistics.rb +46 -43
- data/lib/picky/tasks.rb +3 -0
- data/lib/picky/tokenizers/base.rb +192 -187
- data/lib/picky/tokenizers/index.rb +25 -21
- data/lib/picky/tokenizers/location.rb +33 -29
- data/lib/picky/tokenizers/query.rb +49 -43
- data/lib/picky.rb +21 -13
- data/lib/tasks/application.rake +1 -1
- data/lib/tasks/index.rake +3 -3
- data/lib/tasks/routes.rake +1 -1
- data/lib/tasks/server.rake +1 -1
- data/spec/lib/adapters/rack/base_spec.rb +1 -1
- data/spec/lib/adapters/rack/live_parameters_spec.rb +1 -1
- data/spec/lib/adapters/rack/query_spec.rb +1 -1
- data/spec/lib/application_spec.rb +39 -32
- data/spec/lib/backend/file/basic_spec.rb +2 -2
- data/spec/lib/backend/file/json_spec.rb +2 -2
- data/spec/lib/backend/file/marshal_spec.rb +2 -2
- data/spec/lib/backend/file/text_spec.rb +1 -1
- data/spec/lib/backend/files_spec.rb +14 -24
- data/spec/lib/backend/redis/basic_spec.rb +2 -2
- data/spec/lib/backend/redis/list_hash_spec.rb +3 -3
- data/spec/lib/backend/redis/string_hash_spec.rb +3 -3
- data/spec/lib/backend/redis_spec.rb +20 -13
- data/spec/lib/calculations/location_spec.rb +1 -1
- data/spec/lib/categories_indexed_spec.rb +16 -34
- data/spec/lib/category_indexed_spec.rb +9 -27
- data/spec/lib/category_indexing_spec.rb +2 -3
- data/spec/lib/category_spec.rb +10 -10
- data/spec/lib/character_substituters/west_european_spec.rb +6 -5
- data/spec/lib/cores_spec.rb +17 -17
- data/spec/lib/extensions/symbol_spec.rb +15 -1
- data/spec/lib/frontend_adapters/rack_spec.rb +20 -20
- data/spec/lib/generators/aliases_spec.rb +3 -3
- data/spec/lib/generators/cacher_strategy_spec.rb +1 -1
- data/spec/lib/generators/partial/default_spec.rb +3 -3
- data/spec/lib/generators/partial/none_spec.rb +2 -2
- data/spec/lib/generators/partial/substring_spec.rb +1 -1
- data/spec/lib/generators/partial_generator_spec.rb +3 -3
- data/spec/lib/generators/similarity/double_metaphone_spec.rb +1 -1
- data/spec/lib/generators/similarity/metaphone_spec.rb +1 -1
- data/spec/lib/generators/similarity/none_spec.rb +1 -1
- data/spec/lib/generators/similarity/phonetic_spec.rb +1 -1
- data/spec/lib/generators/similarity/soundex_spec.rb +1 -1
- data/spec/lib/generators/similarity_generator_spec.rb +2 -2
- data/spec/lib/generators/weights/logarithmic_spec.rb +1 -1
- data/spec/lib/generators/weights_generator_spec.rb +1 -1
- data/spec/lib/helpers/measuring_spec.rb +2 -2
- data/spec/lib/indexed/bundle/memory_spec.rb +6 -6
- data/spec/lib/indexed/bundle/redis_spec.rb +4 -4
- data/spec/lib/indexed/wrappers/bundle/calculation_spec.rb +2 -3
- data/spec/lib/indexed/wrappers/bundle/wrapper_spec.rb +2 -2
- data/spec/lib/indexed/wrappers/exact_first_spec.rb +5 -5
- data/spec/lib/indexers/base_spec.rb +1 -1
- data/spec/lib/indexers/parallel_spec.rb +1 -1
- data/spec/lib/indexers/serial_spec.rb +1 -1
- data/spec/lib/{index/base_indexed_spec.rb → indexes/index_indexed_spec.rb} +3 -3
- data/spec/lib/{index/base_indexing_spec.rb → indexes/index_indexing_spec.rb} +19 -2
- data/spec/lib/{index/base_spec.rb → indexes/index_spec.rb} +6 -25
- data/spec/lib/{index → indexes}/redis_spec.rb +1 -1
- data/spec/lib/indexes_class_spec.rb +2 -2
- data/spec/lib/indexes_indexed_spec.rb +1 -1
- data/spec/lib/indexes_indexing_spec.rb +1 -1
- data/spec/lib/indexes_spec.rb +1 -1
- data/spec/lib/indexing/bundle/base_spec.rb +7 -5
- data/spec/lib/indexing/bundle/memory_partial_generation_speed_spec.rb +4 -4
- data/spec/lib/indexing/bundle/memory_spec.rb +15 -15
- data/spec/lib/indexing/bundle/redis_spec.rb +9 -9
- data/spec/lib/interfaces/live_parameters_spec.rb +5 -5
- data/spec/lib/loader_spec.rb +17 -19
- data/spec/lib/loggers/search_spec.rb +2 -2
- data/spec/lib/query/allocation_spec.rb +1 -1
- data/spec/lib/query/allocations_spec.rb +1 -1
- data/spec/lib/query/combination_spec.rb +4 -4
- data/spec/lib/query/combinations/base_spec.rb +1 -1
- data/spec/lib/query/combinations/memory_spec.rb +1 -1
- data/spec/lib/query/combinations/redis_spec.rb +1 -1
- data/spec/lib/query/indexes_spec.rb +7 -2
- data/spec/lib/query/qualifier_category_mapper_spec.rb +34 -0
- data/spec/lib/query/token_spec.rb +32 -53
- data/spec/lib/query/tokens_spec.rb +30 -35
- data/spec/lib/query/weights_spec.rb +16 -16
- data/spec/lib/rack/harakiri_spec.rb +5 -5
- data/spec/lib/results_spec.rb +1 -1
- data/spec/lib/search_spec.rb +24 -22
- data/spec/lib/sinatra_spec.rb +36 -0
- data/spec/lib/sources/base_spec.rb +1 -1
- data/spec/lib/sources/couch_spec.rb +9 -9
- data/spec/lib/sources/csv_spec.rb +7 -7
- data/spec/lib/sources/db_spec.rb +2 -2
- data/spec/lib/sources/delicious_spec.rb +5 -5
- data/spec/lib/sources/mongo_spec.rb +7 -7
- data/spec/lib/sources/wrappers/base_spec.rb +2 -2
- data/spec/lib/sources/wrappers/location_spec.rb +1 -1
- data/spec/lib/statistics_spec.rb +1 -1
- data/spec/lib/tokenizers/base_spec.rb +2 -2
- data/spec/lib/tokenizers/index_spec.rb +1 -1
- data/spec/lib/tokenizers/query_spec.rb +1 -1
- metadata +30 -30
- data/lib/picky/adapters/rack/query.rb +0 -65
- data/lib/picky/index/base.rb +0 -409
- data/lib/picky/index/base_indexed.rb +0 -29
- data/lib/picky/index/base_indexing.rb +0 -127
- data/lib/picky/index/memory.rb +0 -16
- data/lib/picky/index/redis.rb +0 -16
- data/lib/picky/query/qualifiers.rb +0 -76
- data/lib/picky/query/solr.rb +0 -60
- data/lib/picky/signals.rb +0 -8
- data/lib/picky-tasks.rb +0 -6
- data/lib/tasks/spec.rake +0 -11
- data/spec/lib/query/qualifiers_spec.rb +0 -31
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Indexing::Bundle::Base do
|
3
|
+
describe Picky::Indexing::Bundle::Base do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
@
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
@category = stub :category,
|
7
|
+
:prepared_index_path => 'prepared/index/path',
|
8
|
+
:identifier => 'some_identifier'
|
9
|
+
Picky::Backend::Files.stub! :new
|
10
|
+
@similarity = Picky::Similarity::DoubleMetaphone.new 3
|
11
|
+
@bundle = described_class.new :some_name, @category, :some_weights, :some_partial, @similarity
|
10
12
|
end
|
11
13
|
|
12
14
|
describe 'identifier' do
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Indexing::Bundle::Memory do
|
3
|
+
describe Picky::Indexing::Bundle::Memory do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
@index =
|
7
|
-
@category = Category.new :some_category, @index
|
6
|
+
@index = Picky::Indexes::Memory.new :some_index, source: []
|
7
|
+
@category = Picky::Category.new :some_category, @index
|
8
8
|
|
9
|
-
@partial_strategy = Generators::Partial::Substring.new :from => 1
|
9
|
+
@partial_strategy = Picky::Generators::Partial::Substring.new :from => 1
|
10
10
|
@exact = described_class.new :some_name, @category, nil, @partial_strategy, nil
|
11
11
|
end
|
12
12
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Indexing::Bundle::Memory do
|
3
|
+
describe Picky::Indexing::Bundle::Memory do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
@index =
|
7
|
-
@category = Category.new :some_category, @index
|
6
|
+
@index = Picky::Indexes::Memory.new :some_index, source: []
|
7
|
+
@category = Picky::Category.new :some_category, @index
|
8
8
|
|
9
9
|
@partial = stub :partial
|
10
10
|
@weights = stub :weights
|
@@ -59,9 +59,9 @@ describe Indexing::Bundle::Memory do
|
|
59
59
|
|
60
60
|
describe 'retrieve' do
|
61
61
|
before(:each) do
|
62
|
-
|
63
|
-
|
64
|
-
index.stub! :
|
62
|
+
prepared = stub :prepared
|
63
|
+
prepared.should_receive(:retrieve).once.and_yield ' 1234', :some_token
|
64
|
+
index.stub! :prepared => prepared
|
65
65
|
|
66
66
|
@ary = stub :ary
|
67
67
|
inverted = stub :inverted, :[] => @ary
|
@@ -69,7 +69,7 @@ describe Indexing::Bundle::Memory do
|
|
69
69
|
end
|
70
70
|
context 'id key format' do
|
71
71
|
before(:each) do
|
72
|
-
|
72
|
+
@category.stub! :key_format => :to_i
|
73
73
|
end
|
74
74
|
it 'should call the other methods correctly' do
|
75
75
|
@ary.should_receive(:<<).once.with 1234
|
@@ -79,7 +79,7 @@ describe Indexing::Bundle::Memory do
|
|
79
79
|
end
|
80
80
|
context 'other key format' do
|
81
81
|
before(:each) do
|
82
|
-
|
82
|
+
@category.stub! :key_format => :strip
|
83
83
|
end
|
84
84
|
it 'should call the other methods correctly' do
|
85
85
|
@ary.should_receive(:<<).once.with '1234'
|
@@ -89,7 +89,7 @@ describe Indexing::Bundle::Memory do
|
|
89
89
|
end
|
90
90
|
context 'no key format - default' do
|
91
91
|
before(:each) do
|
92
|
-
|
92
|
+
@category.stub! :key_format => nil
|
93
93
|
end
|
94
94
|
it 'should call the other methods correctly' do
|
95
95
|
@ary.should_receive(:<<).once.with 1234
|
@@ -211,11 +211,11 @@ describe Indexing::Bundle::Memory do
|
|
211
211
|
end
|
212
212
|
describe 'warn_if_similarity_small' do
|
213
213
|
before(:each) do
|
214
|
-
@
|
214
|
+
@backend = index.backend
|
215
215
|
end
|
216
216
|
context "files similarity cache small" do
|
217
217
|
before(:each) do
|
218
|
-
@
|
218
|
+
@backend.stub! :similarity_cache_small? => true
|
219
219
|
end
|
220
220
|
it "warns" do
|
221
221
|
index.should_receive(:warn_cache_small).once.with :similarity
|
@@ -225,7 +225,7 @@ describe Indexing::Bundle::Memory do
|
|
225
225
|
end
|
226
226
|
context "files similarity cache not small" do
|
227
227
|
before(:each) do
|
228
|
-
@
|
228
|
+
@backend.stub! :similarity_cache_small? => false
|
229
229
|
end
|
230
230
|
it "does not warn" do
|
231
231
|
index.should_receive(:warn_cache_small).never
|
@@ -236,11 +236,11 @@ describe Indexing::Bundle::Memory do
|
|
236
236
|
end
|
237
237
|
describe 'raise_unless_similarity_ok' do
|
238
238
|
before(:each) do
|
239
|
-
@
|
239
|
+
@backend = index.backend
|
240
240
|
end
|
241
241
|
context "files similarity cache ok" do
|
242
242
|
before(:each) do
|
243
|
-
@
|
243
|
+
@backend.stub! :similarity_cache_ok? => true
|
244
244
|
end
|
245
245
|
it "warns" do
|
246
246
|
index.should_receive(:raise_cache_missing).never
|
@@ -250,7 +250,7 @@ describe Indexing::Bundle::Memory do
|
|
250
250
|
end
|
251
251
|
context "files similarity cache not ok" do
|
252
252
|
before(:each) do
|
253
|
-
@
|
253
|
+
@backend.stub! :similarity_cache_ok? => false
|
254
254
|
end
|
255
255
|
it "does not warn" do
|
256
256
|
index.should_receive(:raise_cache_missing).once.with :similarity
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Indexing::Bundle::Redis do
|
3
|
+
describe Picky::Indexing::Bundle::Redis do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
@index =
|
7
|
-
@category = Category.new :some_category, @index
|
6
|
+
@index = Picky::Indexes::Memory.new :some_index, source: []
|
7
|
+
@category = Picky::Category.new :some_category, @index
|
8
8
|
|
9
9
|
@partial = stub :partial
|
10
10
|
@weights = stub :weights
|
@@ -59,9 +59,9 @@ describe Indexing::Bundle::Redis do
|
|
59
59
|
|
60
60
|
describe 'retrieve' do
|
61
61
|
before(:each) do
|
62
|
-
|
63
|
-
|
64
|
-
index.stub! :
|
62
|
+
prepared = stub :prepared
|
63
|
+
prepared.should_receive(:retrieve).once.and_yield ' 1234', :some_token
|
64
|
+
index.stub! :prepared => prepared
|
65
65
|
|
66
66
|
@ary = stub :ary
|
67
67
|
inverted = stub :inverted, :[] => @ary
|
@@ -69,7 +69,7 @@ describe Indexing::Bundle::Redis do
|
|
69
69
|
end
|
70
70
|
context 'id key format' do
|
71
71
|
before(:each) do
|
72
|
-
|
72
|
+
@category.stub! :key_format => :to_i
|
73
73
|
end
|
74
74
|
it 'should call the other methods correctly' do
|
75
75
|
@ary.should_receive(:<<).once.with 1234
|
@@ -79,7 +79,7 @@ describe Indexing::Bundle::Redis do
|
|
79
79
|
end
|
80
80
|
context 'other key format' do
|
81
81
|
before(:each) do
|
82
|
-
|
82
|
+
@category.stub! :key_format => :strip
|
83
83
|
end
|
84
84
|
it 'should call the other methods correctly' do
|
85
85
|
@ary.should_receive(:<<).once.with '1234'
|
@@ -89,7 +89,7 @@ describe Indexing::Bundle::Redis do
|
|
89
89
|
end
|
90
90
|
context 'no key format - default' do
|
91
91
|
before(:each) do
|
92
|
-
|
92
|
+
@category.stub! :key_format => nil
|
93
93
|
end
|
94
94
|
it 'should call the other methods correctly' do
|
95
95
|
@ary.should_receive(:<<).once.with 1234
|
@@ -2,19 +2,19 @@
|
|
2
2
|
#
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe LiveParameters do
|
5
|
+
describe Picky::Interfaces::LiveParameters do
|
6
6
|
|
7
7
|
before(:each) do
|
8
8
|
@parent = stub :parent
|
9
9
|
@child = stub :child
|
10
10
|
IO.stub! :pipe => [@child, @parent]
|
11
|
-
@parameters =
|
11
|
+
@parameters = described_class.new
|
12
12
|
@parameters.stub! :exclaim
|
13
13
|
end
|
14
14
|
|
15
|
-
describe Interfaces::LiveParameters::CouldNotUpdateConfigurationError do
|
15
|
+
describe Picky::Interfaces::LiveParameters::CouldNotUpdateConfigurationError do
|
16
16
|
before(:each) do
|
17
|
-
@error = Interfaces::LiveParameters::CouldNotUpdateConfigurationError.new :some_key, 'some message'
|
17
|
+
@error = Picky::Interfaces::LiveParameters::CouldNotUpdateConfigurationError.new :some_key, 'some message'
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -53,7 +53,7 @@ describe LiveParameters do
|
|
53
53
|
end
|
54
54
|
context 'updating failed' do
|
55
55
|
before(:each) do
|
56
|
-
@parameters.should_receive(:try_updating_configuration_with).and_raise Interfaces::LiveParameters::CouldNotUpdateConfigurationError.new(:a, 'hello')
|
56
|
+
@parameters.should_receive(:try_updating_configuration_with).and_raise Picky::Interfaces::LiveParameters::CouldNotUpdateConfigurationError.new(:a, 'hello')
|
57
57
|
end
|
58
58
|
it 'kills itself and returns' do
|
59
59
|
@parameters.should_receive(:close_child).once.ordered
|
data/spec/lib/loader_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Loader do
|
3
|
+
describe Picky::Loader do
|
4
4
|
|
5
5
|
before(:each) do
|
6
6
|
@loader_path = File.absolute_path("#{File.dirname(__FILE__)}/../../lib/picky/loader.rb")
|
@@ -8,55 +8,53 @@ describe Loader do
|
|
8
8
|
|
9
9
|
describe 'load_application' do
|
10
10
|
before(:each) do
|
11
|
-
|
12
|
-
Loader.stub! :exclaim
|
11
|
+
Picky::Application.stub! :reload
|
13
12
|
end
|
14
13
|
it "does ok" do
|
15
|
-
lambda { Loader.load_application }.should_not raise_error
|
14
|
+
lambda { Picky::Loader.load_application }.should_not raise_error
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
18
|
describe 'load_framework' do
|
20
19
|
before(:each) do
|
21
|
-
Loader.stub! :
|
22
|
-
Loader.stub! :exclaim
|
20
|
+
Picky::Loader.stub! :load_relative
|
23
21
|
end
|
24
22
|
it "does ok" do
|
25
|
-
lambda { Loader.load_framework }.should_not raise_error
|
23
|
+
lambda { Picky::Loader.load_framework }.should_not raise_error
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
27
|
describe 'load_self' do
|
30
28
|
before(:each) do
|
31
|
-
Loader.stub! :load
|
32
|
-
Loader.stub! :exclaim
|
29
|
+
Picky::Loader.stub! :load
|
30
|
+
Picky::Loader.stub! :exclaim
|
33
31
|
end
|
34
32
|
after(:each) do
|
35
|
-
Loader.load_self
|
33
|
+
Picky::Loader.load_self
|
36
34
|
end
|
37
35
|
it 'should load __SELF__' do
|
38
|
-
Loader.should_receive(:load).once.with @loader_path
|
36
|
+
Picky::Loader.should_receive(:load).once.with @loader_path
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
42
40
|
describe 'reload' do
|
43
41
|
before(:each) do
|
44
42
|
load @loader_path
|
45
|
-
Loader.stub! :exclaim
|
46
|
-
Loader.stub! :load_framework
|
47
|
-
Loader.stub! :load_application
|
43
|
+
Picky::Loader.stub! :exclaim
|
44
|
+
Picky::Loader.stub! :load_framework
|
45
|
+
Picky::Loader.stub! :load_application
|
48
46
|
Dir.stub! :chdir
|
49
47
|
end
|
50
48
|
after(:each) do
|
51
|
-
Loader.reload
|
49
|
+
Picky::Loader.reload
|
52
50
|
end
|
53
51
|
it 'should call the right methods in order' do
|
54
|
-
Loader.should_receive(:load_self).ordered
|
55
|
-
Loader.should_receive(:load_framework).ordered
|
56
|
-
Loader.should_receive(:load_application).ordered
|
52
|
+
Picky::Loader.should_receive(:load_self).ordered
|
53
|
+
Picky::Loader.should_receive(:load_framework).ordered
|
54
|
+
Picky::Loader.should_receive(:load_application).ordered
|
57
55
|
end
|
58
56
|
it 'should load itself only once' do
|
59
|
-
Loader.should_receive(:load_self).once
|
57
|
+
Picky::Loader.should_receive(:load_self).once
|
60
58
|
end
|
61
59
|
# it 'should load the app only once' do
|
62
60
|
# Loader.should_receive(:load_framework).once
|
@@ -2,11 +2,11 @@
|
|
2
2
|
#
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Loggers::Search do
|
5
|
+
describe Picky::Loggers::Search do
|
6
6
|
|
7
7
|
before(:each) do
|
8
8
|
@destination = stub :destination
|
9
|
-
@logger =
|
9
|
+
@logger = described_class.new @destination
|
10
10
|
end
|
11
11
|
describe "log" do
|
12
12
|
it "should delegate to info" do
|
@@ -2,11 +2,11 @@
|
|
2
2
|
#
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Query::Combination do
|
5
|
+
describe Picky::Query::Combination do
|
6
6
|
|
7
7
|
before(:each) do
|
8
8
|
@bundle = stub :bundle, :identifier => :bundle_name
|
9
|
-
@token = Query::Token.processed('some_text~')
|
9
|
+
@token = Picky::Query::Token.processed('some_text~')
|
10
10
|
@category = stub :category, :bundle_for => @bundle, :name => :some_category_name
|
11
11
|
|
12
12
|
@combination = described_class.new @token, @category
|
@@ -41,9 +41,9 @@ describe Query::Combination do
|
|
41
41
|
describe 'to_result' do
|
42
42
|
context 'functional with qualifier' do
|
43
43
|
before(:each) do
|
44
|
-
token = Tokenizers::Query.new.tokenize('name:Blä~').first
|
44
|
+
token = Picky::Tokenizers::Query.new.tokenize('name:Blä~').first
|
45
45
|
|
46
|
-
@combination = Query::Combination.new token, @category
|
46
|
+
@combination = Picky::Query::Combination.new token, @category
|
47
47
|
end
|
48
48
|
it 'should return a correct result' do
|
49
49
|
@combination.to_result.should == [:some_category_name, 'Blä~', :blä] # Note: Characters not substituted. That's ok.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Query::Indexes do
|
3
|
+
describe Picky::Query::Indexes do
|
4
4
|
|
5
5
|
3.times do |i|
|
6
6
|
n = i + 1
|
@@ -9,7 +9,12 @@ describe Query::Indexes do
|
|
9
9
|
let(name) { stub name, :internal_indexed => stub(indexed) }
|
10
10
|
end
|
11
11
|
|
12
|
-
let(:indexes)
|
12
|
+
let(:indexes) do
|
13
|
+
indexes = described_class.allocate
|
14
|
+
indexes.stub! :map_categories
|
15
|
+
indexes.send :initialize, index1, index2, index3
|
16
|
+
indexes
|
17
|
+
end
|
13
18
|
|
14
19
|
describe 'expand_combinations_from' do
|
15
20
|
it 'generates all possible combinations from the given ones' do
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Picky::Query::QualifierCategoryMapper do
|
4
|
+
|
5
|
+
let(:mapper) { described_class.new }
|
6
|
+
before(:each) do
|
7
|
+
@category1 = stub(:category1, :qualifiers => ['t1', 'tt1', 'ttt1'])
|
8
|
+
@category2 = stub(:category2, :qualifiers => [:t2, :tt2, :ttt2])
|
9
|
+
@category3 = stub(:category3, :qualifiers => [:t3, :tt3, :ttt3])
|
10
|
+
mapper.add @category1
|
11
|
+
mapper.add @category2
|
12
|
+
mapper.add @category3
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.it_should_map(qualifier, expected)
|
16
|
+
it "should map #{qualifier} to #{expected}" do
|
17
|
+
mapper.map(qualifier).should == expected
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "mapping" do
|
22
|
+
it { mapper.map(:t1).should == @category1 }
|
23
|
+
it { mapper.map(:tt1).should == @category1 }
|
24
|
+
it { mapper.map(:ttt1).should == @category1 }
|
25
|
+
|
26
|
+
it { mapper.map(:t2).should == @category2 }
|
27
|
+
it { mapper.map(:tt2).should == @category2 }
|
28
|
+
it { mapper.map(:ttt2).should == @category2 }
|
29
|
+
|
30
|
+
it { mapper.map(:t3).should == @category3 }
|
31
|
+
it { mapper.map(:tt3).should == @category3 }
|
32
|
+
it { mapper.map(:ttt3).should == @category3 }
|
33
|
+
end
|
34
|
+
end
|
@@ -1,12 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe Query::Token do
|
5
|
-
|
6
|
-
before(:all) do
|
7
|
-
Query::Qualifiers.instance << Query::Qualifier.new(:specific, [:sp, :spec])
|
8
|
-
Query::Qualifiers.instance.prepare
|
9
|
-
end
|
4
|
+
describe Picky::Query::Token do
|
10
5
|
|
11
6
|
describe '==' do
|
12
7
|
it 'is equal if the originals are equal' do
|
@@ -154,13 +149,30 @@ describe Query::Token do
|
|
154
149
|
described_class.new(text).qualify.should == expected_result
|
155
150
|
end
|
156
151
|
end
|
157
|
-
it_should_qualify 'spec:qualifier', [
|
158
|
-
it_should_qualify 'with:qualifier', []
|
159
|
-
it_should_qualify 'without qualifier', nil
|
160
|
-
it_should_qualify 'name:', nil
|
161
|
-
it_should_qualify ':broken qualifier', [] # Unsure about that. Probably should recognize it as text.
|
162
|
-
it_should_qualify '', nil
|
163
|
-
it_should_qualify 'sp:text', [
|
152
|
+
it_should_qualify 'spec:qualifier', [['spec'], 'qualifier']
|
153
|
+
it_should_qualify 'with:qualifier', [['with'], 'qualifier']
|
154
|
+
it_should_qualify 'without qualifier', [nil, 'without qualifier']
|
155
|
+
it_should_qualify 'name:', [nil, 'name']
|
156
|
+
it_should_qualify ':broken qualifier', [[], 'broken qualifier'] # Unsure about that. Probably should recognize it as text.
|
157
|
+
it_should_qualify '', [nil, '']
|
158
|
+
it_should_qualify 'sp:text', [['sp'], 'text']
|
159
|
+
it_should_qualify '""', [nil, '""']
|
160
|
+
it_should_qualify 'name:', [nil, 'name']
|
161
|
+
it_should_qualify 'name:hanke', [['name'], 'hanke']
|
162
|
+
it_should_qualify 'g:gaga', [['g'], 'gaga']
|
163
|
+
it_should_qualify ':nothing', [[], 'nothing']
|
164
|
+
it_should_qualify 'hello', [nil, 'hello']
|
165
|
+
it_should_qualify 'a:b:c', [['a'], 'b:c']
|
166
|
+
it_should_qualify 'a,b:c', [['a','b'], 'c']
|
167
|
+
it_should_qualify 'a,b,c:d', [['a','b','c'], 'd']
|
168
|
+
it_should_qualify ':', [nil, '']
|
169
|
+
it_should_qualify 'vorname:qualifier', [['vorname'], 'qualifier']
|
170
|
+
it_should_qualify 'with:qualifier', [['with'], 'qualifier']
|
171
|
+
it_should_qualify 'without qualifier', [nil, 'without qualifier']
|
172
|
+
it_should_qualify 'name:', [nil, 'name']
|
173
|
+
it_should_qualify ':broken qualifier', [[], 'broken qualifier']
|
174
|
+
it_should_qualify '', [nil, '']
|
175
|
+
it_should_qualify 'fn:text', [['fn'], 'text']
|
164
176
|
end
|
165
177
|
|
166
178
|
describe 'processed' do
|
@@ -260,23 +272,6 @@ describe Query::Token do
|
|
260
272
|
end
|
261
273
|
end
|
262
274
|
|
263
|
-
describe 'split' do
|
264
|
-
def self.it_should_split text, expected_qualifier
|
265
|
-
it "should extract #{expected_qualifier} from #{text}" do
|
266
|
-
described_class.new('any').send(:split, text).should == expected_qualifier
|
267
|
-
end
|
268
|
-
end
|
269
|
-
it_should_split '""', [nil, '""']
|
270
|
-
it_should_split 'name:', [nil, 'name']
|
271
|
-
it_should_split 'name:hanke', [['name'], 'hanke']
|
272
|
-
it_should_split 'g:gaga', [['g'], 'gaga']
|
273
|
-
it_should_split ':nothing', [[], 'nothing']
|
274
|
-
it_should_split 'hello', [nil, 'hello']
|
275
|
-
it_should_split 'a:b:c', [['a'], 'b:c']
|
276
|
-
it_should_split 'a,b:c', [['a','b'], 'c']
|
277
|
-
it_should_split 'a,b,c:d', [['a','b','c'], 'd']
|
278
|
-
end
|
279
|
-
|
280
275
|
describe "original" do
|
281
276
|
it "should keep the original text even when processed" do
|
282
277
|
token = described_class.processed "I'm the original token text."
|
@@ -303,25 +298,25 @@ describe Query::Token do
|
|
303
298
|
it "should display qualifier and text combined with a ':'" do
|
304
299
|
token = described_class.processed('sp:qualifier')
|
305
300
|
|
306
|
-
token.to_s.should == '
|
301
|
+
token.to_s.should == 'Picky::Query::Token(qualifier, ["sp"])'
|
307
302
|
end
|
308
303
|
end
|
309
304
|
describe "without qualifier" do
|
310
305
|
it "should display just the text" do
|
311
306
|
token = described_class.processed('text')
|
312
307
|
|
313
|
-
token.to_s.should == 'text'
|
308
|
+
token.to_s.should == 'Picky::Query::Token(text)'
|
314
309
|
end
|
315
310
|
end
|
316
311
|
end
|
317
312
|
|
318
|
-
describe '
|
313
|
+
describe 'qualifiers' do
|
319
314
|
context 'with qualifier' do
|
320
315
|
before(:each) do
|
321
316
|
@token = described_class.processed('sp:qualifier')
|
322
317
|
end
|
323
318
|
it 'should return the qualifier' do
|
324
|
-
@token.
|
319
|
+
@token.qualifiers.should == ['sp']
|
325
320
|
end
|
326
321
|
end
|
327
322
|
context 'with incorrect qualifier' do
|
@@ -329,7 +324,7 @@ describe Query::Token do
|
|
329
324
|
@token = described_class.processed('specific:qualifier')
|
330
325
|
end
|
331
326
|
it 'should return the qualifier' do
|
332
|
-
@token.
|
327
|
+
@token.qualifiers.should == ['specific']
|
333
328
|
end
|
334
329
|
end
|
335
330
|
context 'with multiple qualifiers' do
|
@@ -337,7 +332,7 @@ describe Query::Token do
|
|
337
332
|
@token = described_class.processed('sp,spec:qualifier')
|
338
333
|
end
|
339
334
|
it 'should return the qualifier' do
|
340
|
-
@token.
|
335
|
+
@token.qualifiers.should == ['sp', 'spec']
|
341
336
|
end
|
342
337
|
end
|
343
338
|
context 'without qualifier' do
|
@@ -345,25 +340,9 @@ describe Query::Token do
|
|
345
340
|
@token = described_class.processed('noqualifier')
|
346
341
|
end
|
347
342
|
it 'should return nil' do
|
348
|
-
@token.
|
349
|
-
end
|
350
|
-
end
|
351
|
-
end
|
352
|
-
|
353
|
-
describe "split" do
|
354
|
-
def self.it_should_split text, expected_result
|
355
|
-
it "should split #{expected_result} from #{text}" do
|
356
|
-
described_class.new('any').send(:split, text).should == expected_result
|
343
|
+
@token.qualifiers.should == nil
|
357
344
|
end
|
358
345
|
end
|
359
|
-
it_should_split ':', [nil, '']
|
360
|
-
it_should_split 'vorname:qualifier', [['vorname'], 'qualifier']
|
361
|
-
it_should_split 'with:qualifier', [['with'], 'qualifier']
|
362
|
-
it_should_split 'without qualifier', [nil, 'without qualifier']
|
363
|
-
it_should_split 'name:', [nil, 'name']
|
364
|
-
it_should_split ':broken qualifier', [[], 'broken qualifier']
|
365
|
-
it_should_split '', [nil, '']
|
366
|
-
it_should_split 'fn:text', [['fn'], 'text']
|
367
346
|
end
|
368
347
|
|
369
348
|
describe 'partial=' do
|