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
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe FrontendAdapters::Rack do
|
5
|
+
describe Picky::FrontendAdapters::Rack do
|
6
6
|
|
7
7
|
before(:each) do
|
8
8
|
@rack_adapter = described_class.new
|
@@ -47,14 +47,14 @@ describe FrontendAdapters::Rack do
|
|
47
47
|
end
|
48
48
|
context 'with routes' do
|
49
49
|
before(:each) do
|
50
|
-
@rack_adapter.route %r{something} => Search.new
|
50
|
+
@rack_adapter.route %r{something} => Picky::Search.new
|
51
51
|
end
|
52
52
|
it 'returns the right answer' do
|
53
53
|
@rack_adapter.empty?.should == false
|
54
54
|
end
|
55
55
|
describe 'to_s' do
|
56
56
|
it 'outputs correctly' do
|
57
|
-
@rack_adapter.to_s.should == "Note: Anchored (✓) regexps are faster, e.g. /\\A.*\\Z/ or /^.*$/.\n\n something => Search()"
|
57
|
+
@rack_adapter.to_s.should == "Note: Anchored (✓) regexps are faster, e.g. /\\A.*\\Z/ or /^.*$/.\n\n something => Picky::Search()"
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -107,10 +107,10 @@ describe FrontendAdapters::Rack do
|
|
107
107
|
env = rack_defaults_for '/searches/some_route?query=some_query'
|
108
108
|
|
109
109
|
search = stub :search
|
110
|
-
search.should_receive(:search_with_text).once.with(anything, 20, 0).and_return(Results.new)
|
111
|
-
Search.stub! :new => search
|
110
|
+
search.should_receive(:search_with_text).once.with(anything, 20, 0).and_return(Picky::Results.new)
|
111
|
+
Picky::Search.stub! :new => search
|
112
112
|
|
113
|
-
@rack_adapter.route '/searches/some_route' => Search.new(:some_index, :some_other_index)
|
113
|
+
@rack_adapter.route '/searches/some_route' => Picky::Search.new(:some_index, :some_other_index)
|
114
114
|
|
115
115
|
@rack_adapter.routes.freeze
|
116
116
|
@rack_adapter.call(env).should == [200, {"Content-Type"=>"application/json", "Content-Length"=>"52"}, ["{\"allocations\":[],\"offset\":0,\"duration\":0,\"total\":0}"]]
|
@@ -119,10 +119,10 @@ describe FrontendAdapters::Rack do
|
|
119
119
|
env = rack_defaults_for '/searches/some_route?query=some_query&type=some_type'
|
120
120
|
|
121
121
|
search = stub :search
|
122
|
-
search.should_receive(:search_with_text).once.with(anything, 20, 0).and_return(Results.new)
|
123
|
-
Search.stub! :new => search
|
122
|
+
search.should_receive(:search_with_text).once.with(anything, 20, 0).and_return(Picky::Results.new)
|
123
|
+
Picky::Search.stub! :new => search
|
124
124
|
|
125
|
-
@rack_adapter.route '/searches/some_route' => Search.new(:some_index, :some_other_index), :query => { :type => :some_type }
|
125
|
+
@rack_adapter.route '/searches/some_route' => Picky::Search.new(:some_index, :some_other_index), :query => { :type => :some_type }
|
126
126
|
|
127
127
|
@rack_adapter.routes.freeze
|
128
128
|
@rack_adapter.call(env).should == [200, {"Content-Type"=>"application/json", "Content-Length"=>"52"}, ["{\"allocations\":[],\"offset\":0,\"duration\":0,\"total\":0}"]]
|
@@ -132,9 +132,9 @@ describe FrontendAdapters::Rack do
|
|
132
132
|
|
133
133
|
search = stub :search
|
134
134
|
search.should_receive(:search_with_text).never
|
135
|
-
Search.stub! :new => search
|
135
|
+
Picky::Search.stub! :new => search
|
136
136
|
|
137
|
-
@rack_adapter.route '/searches/some_route' => Search.new(:some_index, :some_other_index)
|
137
|
+
@rack_adapter.route '/searches/some_route' => Picky::Search.new(:some_index, :some_other_index)
|
138
138
|
|
139
139
|
@rack_adapter.routes.freeze
|
140
140
|
@rack_adapter.call(env).should == [404, {"Content-Type"=>"text/html", "X-Cascade"=>"pass"}, ["Not Found"]]
|
@@ -188,7 +188,7 @@ describe FrontendAdapters::Rack do
|
|
188
188
|
@rack_adapter.route %r{regexp1} => :query1, %r{regexp2} => :query2, :some => :option
|
189
189
|
end
|
190
190
|
it 'does not accept nil queries' do
|
191
|
-
lambda { @rack_adapter.route %r{some/regexp} => nil }.should raise_error(FrontendAdapters::Rack::RouteTargetNilError, /Routing for \/some\\\/regexp\/ was defined with a nil target object, i.e. \/some\\\/regexp\/ => nil./)
|
191
|
+
lambda { @rack_adapter.route %r{some/regexp} => nil }.should raise_error(Picky::FrontendAdapters::Rack::RouteTargetNilError, /Routing for \/some\\\/regexp\/ was defined with a nil target object, i.e. \/some\\\/regexp\/ => nil./)
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
@@ -202,7 +202,7 @@ describe FrontendAdapters::Rack do
|
|
202
202
|
|
203
203
|
describe 'route_one' do
|
204
204
|
before(:each) do
|
205
|
-
Adapters::Rack.stub! :app_for => :some_query_app
|
205
|
+
Picky::Adapters::Rack.stub! :app_for => :some_query_app
|
206
206
|
end
|
207
207
|
it 'should add the right route' do
|
208
208
|
@routes.should_receive(:add_route).once.with :some_query_app, { :request_method => "GET", :path_info => /some_url/ }, {}, "some_query"
|
@@ -223,7 +223,7 @@ describe FrontendAdapters::Rack do
|
|
223
223
|
|
224
224
|
describe 'default' do
|
225
225
|
it 'should call answer' do
|
226
|
-
@rack_adapter.should_receive(:answer).once.with nil, FrontendAdapters::Rack::STATUSES[200]
|
226
|
+
@rack_adapter.should_receive(:answer).once.with nil, Picky::FrontendAdapters::Rack::STATUSES[200]
|
227
227
|
|
228
228
|
@rack_adapter.default 200
|
229
229
|
end
|
@@ -231,21 +231,21 @@ describe FrontendAdapters::Rack do
|
|
231
231
|
|
232
232
|
describe 'STATUSES' do
|
233
233
|
it 'is a lambda' do
|
234
|
-
FrontendAdapters::Rack::STATUSES[200].respond_to?(:call).should == true
|
234
|
+
Picky::FrontendAdapters::Rack::STATUSES[200].respond_to?(:call).should == true
|
235
235
|
end
|
236
236
|
it 'is a lambda' do
|
237
|
-
FrontendAdapters::Rack::STATUSES[404].respond_to?(:call).should == true
|
237
|
+
Picky::FrontendAdapters::Rack::STATUSES[404].respond_to?(:call).should == true
|
238
238
|
end
|
239
239
|
end
|
240
240
|
|
241
241
|
describe 'root' do
|
242
242
|
it 'should call answer' do
|
243
|
-
@rack_adapter.should_receive(:answer).once.with %r{^/$}, FrontendAdapters::Rack::STATUSES[200]
|
243
|
+
@rack_adapter.should_receive(:answer).once.with %r{^/$}, Picky::FrontendAdapters::Rack::STATUSES[200]
|
244
244
|
|
245
245
|
@rack_adapter.root 200
|
246
246
|
end
|
247
247
|
it 'should call answer' do
|
248
|
-
@rack_adapter.should_receive(:answer).once.with %r{^/$}, FrontendAdapters::Rack::STATUSES[404]
|
248
|
+
@rack_adapter.should_receive(:answer).once.with %r{^/$}, Picky::FrontendAdapters::Rack::STATUSES[404]
|
249
249
|
|
250
250
|
@rack_adapter.root 404
|
251
251
|
end
|
@@ -274,14 +274,14 @@ describe FrontendAdapters::Rack do
|
|
274
274
|
context 'without app' do
|
275
275
|
context 'with url' do
|
276
276
|
it 'should use the 200 with default_options from the url' do
|
277
|
-
@routes.should_receive(:add_route).once.with FrontendAdapters::Rack::STATUSES[200], { :request_method => "GET", :path_info => /some_url/ }
|
277
|
+
@routes.should_receive(:add_route).once.with Picky::FrontendAdapters::Rack::STATUSES[200], { :request_method => "GET", :path_info => /some_url/ }
|
278
278
|
|
279
279
|
@rack_adapter.answer 'some_url'
|
280
280
|
end
|
281
281
|
end
|
282
282
|
context 'without url' do
|
283
283
|
it 'should use the 200 with default_options' do
|
284
|
-
@routes.should_receive(:add_route).once.with FrontendAdapters::Rack::STATUSES[200], { :request_method => "GET" }
|
284
|
+
@routes.should_receive(:add_route).once.with Picky::FrontendAdapters::Rack::STATUSES[200], { :request_method => "GET" }
|
285
285
|
|
286
286
|
@rack_adapter.answer
|
287
287
|
end
|
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe 'aliases' do
|
4
4
|
|
5
5
|
it 'aliases correctly' do
|
6
|
-
Partial.should == Generators::Partial
|
6
|
+
Picky::Partial.should == Picky::Generators::Partial
|
7
7
|
end
|
8
8
|
it 'aliases correctly' do
|
9
|
-
Similarity.should == Generators::Similarity
|
9
|
+
Picky::Similarity.should == Picky::Generators::Similarity
|
10
10
|
end
|
11
11
|
it 'aliases correctly' do
|
12
|
-
Weights.should == Generators::Weights
|
12
|
+
Picky::Weights.should == Picky::Generators::Weights
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Generators::Partial::Default do
|
3
|
+
describe Picky::Generators::Partial::Default do
|
4
4
|
|
5
|
-
let(:default) { Generators::Partial::Default }
|
5
|
+
let(:default) { Picky::Generators::Partial::Default }
|
6
6
|
|
7
7
|
it "should be a subtoken" do
|
8
|
-
default.should be_kind_of(Generators::Partial::Substring)
|
8
|
+
default.should be_kind_of(Picky::Generators::Partial::Substring)
|
9
9
|
end
|
10
10
|
it "should be a the right down to" do
|
11
11
|
default.from.should == -3
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Generators::Partial::None do
|
3
|
+
describe Picky::Generators::Partial::None do
|
4
4
|
|
5
5
|
it 'is not saved' do
|
6
6
|
described_class.new.saved?.should == false
|
7
7
|
end
|
8
8
|
it "has the right superclass" do
|
9
|
-
described_class.should < Generators::Partial::Strategy
|
9
|
+
described_class.should < Picky::Generators::Partial::Strategy
|
10
10
|
end
|
11
11
|
it "returns an empty index" do
|
12
12
|
described_class.new.generate_from(:unimportant).should == {}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Generators::PartialGenerator do
|
3
|
+
describe Picky::Generators::PartialGenerator do
|
4
4
|
|
5
5
|
context 'integration' do
|
6
6
|
it 'should generate the correct values with a given strategy' do
|
7
7
|
generator = described_class.new :meier => [1], :maier => [2]
|
8
8
|
|
9
|
-
generator.generate(Generators::Partial::Substring.new).should == {
|
9
|
+
generator.generate(Picky::Generators::Partial::Substring.new).should == {
|
10
10
|
:meier => [1],
|
11
11
|
:meie => [1],
|
12
12
|
:mei => [1],
|
@@ -21,7 +21,7 @@ describe Generators::PartialGenerator do
|
|
21
21
|
it 'should generate the correct values with a given specific strategy' do
|
22
22
|
generator = described_class.new :meier => [1], :maier => [2]
|
23
23
|
|
24
|
-
generator.generate(Generators::Partial::Substring.new(:from => 3)).should == {
|
24
|
+
generator.generate(Picky::Generators::Partial::Substring.new(:from => 3)).should == {
|
25
25
|
:meier => [1],
|
26
26
|
:meie => [1],
|
27
27
|
:mei => [1],
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Generators::SimilarityGenerator do
|
3
|
+
describe Picky::Generators::SimilarityGenerator do
|
4
4
|
|
5
5
|
context 'integration' do
|
6
6
|
it 'should generate the correct values' do
|
@@ -15,7 +15,7 @@ describe Generators::SimilarityGenerator do
|
|
15
15
|
:meyer => nil,
|
16
16
|
:peter => nil
|
17
17
|
|
18
|
-
generator.generate(Generators::Similarity::DoubleMetaphone.new).should == { :MR => [:meier, :maier, :mayer, :meyer], :PTR => [:peter] }
|
18
|
+
generator.generate(Picky::Generators::Similarity::DoubleMetaphone.new).should == { :MR => [:meier, :maier, :mayer, :meyer], :PTR => [:peter] }
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Indexed::Bundle::Memory do
|
3
|
+
describe Picky::Indexed::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
|
@similarity = stub :similarity
|
10
10
|
@bundle = described_class.new :some_name, @category, @similarity
|
@@ -12,7 +12,7 @@ describe Indexed::Bundle::Memory do
|
|
12
12
|
|
13
13
|
describe 'to_s' do
|
14
14
|
it 'does something' do
|
15
|
-
@bundle.to_s.should == "Indexed::Bundle::Memory(test:some_index:some_category:some_name
|
15
|
+
@bundle.to_s.should == "Picky::Indexed::Bundle::Memory(test:some_index:some_category:some_name)"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -153,8 +153,8 @@ describe Indexed::Bundle::Memory do
|
|
153
153
|
|
154
154
|
describe 'initialization' do
|
155
155
|
before(:each) do
|
156
|
-
@index =
|
157
|
-
@category = Category.new :some_category, @index
|
156
|
+
@index = Picky::Indexes::Memory.new :some_index, source: []
|
157
|
+
@category = Picky::Category.new :some_category, @index
|
158
158
|
|
159
159
|
@bundle = described_class.new :some_name, @category, :similarity
|
160
160
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Indexed::Bundle::Redis do
|
3
|
+
describe Picky::Indexed::Bundle::Redis do
|
4
4
|
|
5
5
|
before(:each) do
|
6
6
|
@backend = stub :backend
|
7
7
|
|
8
|
-
Backend::Redis.stub! :new => @backend
|
8
|
+
Picky::Backend::Redis.stub! :new => @backend
|
9
9
|
|
10
|
-
@index =
|
11
|
-
@category = Category.new :some_category, @index
|
10
|
+
@index = Picky::Indexes::Memory.new :some_index, source: []
|
11
|
+
@category = Picky::Category.new :some_category, @index
|
12
12
|
|
13
13
|
@similarity = stub :similarity
|
14
14
|
@bundle = described_class.new :some_name, @category, @similarity
|
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Indexed::Wrappers::Bundle::Calculation do
|
3
|
+
describe Picky::Indexed::Wrappers::Bundle::Calculation do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
@bundle
|
7
|
-
|
6
|
+
@bundle = stub :bundle
|
8
7
|
@calculation = described_class.new @bundle
|
9
8
|
end
|
10
9
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Indexed::Wrappers::ExactFirst do
|
3
|
+
describe Picky::Indexed::Wrappers::ExactFirst do
|
4
4
|
|
5
5
|
before(:each) do
|
6
6
|
@exact = stub :exact
|
@@ -13,17 +13,17 @@ describe Indexed::Wrappers::ExactFirst do
|
|
13
13
|
describe "self.wrap" do
|
14
14
|
context "index" do
|
15
15
|
it "wraps each category" do
|
16
|
-
index =
|
16
|
+
index = Picky::Indexes::Memory.new :some_index, source: []
|
17
17
|
index.define_category :some_category
|
18
18
|
|
19
|
-
Indexed::Wrappers::ExactFirst.wrap index
|
19
|
+
Picky::Indexed::Wrappers::ExactFirst.wrap index
|
20
20
|
|
21
21
|
index.categories.categories.each do |category|
|
22
|
-
category.should be_kind_of(Indexed::Wrappers::ExactFirst)
|
22
|
+
category.should be_kind_of(Picky::Indexed::Wrappers::ExactFirst)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
it "returns the index" do
|
26
|
-
index =
|
26
|
+
index = Picky::Indexes::Memory.new :some_index, source: []
|
27
27
|
index.define_category :some_category
|
28
28
|
|
29
29
|
described_class.wrap(index).should == index
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Index
|
3
|
+
describe Picky::Indexes::Index do
|
4
4
|
|
5
5
|
context 'without stubbed categories' do
|
6
6
|
before(:each) do
|
@@ -14,7 +14,7 @@ describe Index::Base do
|
|
14
14
|
@index.categories.categories.size.should == 1
|
15
15
|
end
|
16
16
|
it 'returns the new category' do
|
17
|
-
@index.define_category(:some_category_name).should be_kind_of(Category)
|
17
|
+
@index.define_category(:some_category_name).should be_kind_of(Picky::Category)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -39,7 +39,7 @@ describe Index::Base do
|
|
39
39
|
end
|
40
40
|
describe "possible_combinations" do
|
41
41
|
it "delegates to the combinator" do
|
42
|
-
@categories.should_receive(:
|
42
|
+
@categories.should_receive(:possible_combinations).once.with :some_token
|
43
43
|
|
44
44
|
@index.possible_combinations :some_token
|
45
45
|
end
|
@@ -1,6 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Index
|
3
|
+
describe Picky::Indexes::Index do
|
4
|
+
|
5
|
+
describe 'tokenizer' do
|
6
|
+
context 'with tokenizer' do
|
7
|
+
let(:index) { described_class.new :some_name, source: [], tokenizer: 'some tokenizer' }
|
8
|
+
|
9
|
+
it 'does things in order' do
|
10
|
+
index.tokenizer.should == 'some tokenizer'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
context 'without tokenizer' do
|
14
|
+
let(:index) { described_class.new :some_name, source: [] }
|
15
|
+
|
16
|
+
it 'does things in order' do
|
17
|
+
index.tokenizer.should == Picky::Indexes.tokenizer
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
4
21
|
|
5
22
|
context 'in general' do
|
6
23
|
context 'with #each source' do
|
@@ -42,7 +59,7 @@ describe Index::Base do
|
|
42
59
|
end
|
43
60
|
describe "raise_no_source" do
|
44
61
|
it "should raise" do
|
45
|
-
lambda { @index.raise_no_source }.should raise_error(NoSourceSpecifiedException)
|
62
|
+
lambda { @index.raise_no_source }.should raise_error(Picky::NoSourceSpecifiedException)
|
46
63
|
end
|
47
64
|
end
|
48
65
|
describe 'define_source' do
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Index
|
5
|
+
describe Picky::Indexes::Index do
|
6
6
|
|
7
7
|
let(:some_source) { stub :source, :harvest => nil, :inspect => 'some_source' }
|
8
8
|
|
@@ -16,27 +16,8 @@ describe Index::Base do
|
|
16
16
|
it 'fails correctly' do
|
17
17
|
expect { described_class.new :some_index_name, source: :some_source }.to raise_error
|
18
18
|
end
|
19
|
-
it 'fails
|
20
|
-
expect { described_class.new :some_index_name, some_source }.to raise_error
|
21
|
-
|
22
|
-
|
23
|
-
Sources are not passed in as second parameter for Index::Base anymore, but either
|
24
|
-
* as :source option:
|
25
|
-
Index::Base.new(:some_index_name, source: some_source)
|
26
|
-
or
|
27
|
-
* given to the #source method inside the config block:
|
28
|
-
Index::Base.new(:some_index_name) do
|
29
|
-
source some_source
|
30
|
-
end
|
31
|
-
|
32
|
-
Sorry about that breaking change (in 2.2.0), didn't want to go to 3.0.0 yet!
|
33
|
-
|
34
|
-
All the best
|
35
|
-
-- Picky
|
36
|
-
|
37
|
-
|
38
|
-
ERROR
|
39
|
-
)
|
19
|
+
it 'fails correctly' do
|
20
|
+
expect { described_class.new :some_index_name, some_source }.to raise_error
|
40
21
|
end
|
41
22
|
it 'does not fail' do
|
42
23
|
expect { described_class.new :some_index_name, source: [] }.to_not raise_error
|
@@ -44,7 +25,7 @@ ERROR
|
|
44
25
|
it 'registers with the indexes' do
|
45
26
|
@api = described_class.allocate
|
46
27
|
|
47
|
-
::Indexes.should_receive(:register).once.with @api
|
28
|
+
Picky::Indexes.should_receive(:register).once.with @api
|
48
29
|
|
49
30
|
@api.send :initialize, :some_index_name, source: some_source
|
50
31
|
end
|
@@ -73,7 +54,7 @@ ERROR
|
|
73
54
|
end
|
74
55
|
it 'yields both the indexing category and the indexed category' do
|
75
56
|
api.define_category(:some_name) do |category|
|
76
|
-
category.should be_kind_of(Category)
|
57
|
+
category.should be_kind_of(Picky::Category)
|
77
58
|
end
|
78
59
|
end
|
79
60
|
it 'yields the category which has the given name' do
|
@@ -90,7 +71,7 @@ ERROR
|
|
90
71
|
lambda { api.define_category('some_name') }.should_not raise_error
|
91
72
|
end
|
92
73
|
it 'returns itself' do
|
93
|
-
api.define_category(:some_name).should be_kind_of(Category)
|
74
|
+
api.define_category(:some_name).should be_kind_of(Picky::Category)
|
94
75
|
end
|
95
76
|
end
|
96
77
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Indexes do
|
3
|
+
describe Picky::Indexes do
|
4
4
|
|
5
5
|
before(:each) do
|
6
6
|
@index = stub :some_index, :name => :some_index
|
@@ -21,7 +21,7 @@ describe Indexes do
|
|
21
21
|
it 'adds the given index to the indexes' do
|
22
22
|
@indexes.clear_indexes
|
23
23
|
|
24
|
-
|
24
|
+
described_class.register @index
|
25
25
|
|
26
26
|
@indexes.indexes.should == [@index]
|
27
27
|
end
|