picky 4.0.0pre2 → 4.0.0pre3
Sign up to get free protection for your applications and to get access to all the features.
- data/aux/picky/cli.rb +1 -1
- data/lib/picky/backends/backend.rb +0 -16
- data/lib/picky/backends/file.rb +5 -10
- data/lib/picky/backends/memory.rb +5 -10
- data/lib/picky/backends/redis/basic.rb +3 -3
- data/lib/picky/backends/redis/list.rb +5 -6
- data/lib/picky/backends/redis/string.rb +1 -1
- data/lib/picky/backends/redis.rb +24 -27
- data/lib/picky/backends/sqlite/basic.rb +4 -4
- data/lib/picky/backends/sqlite.rb +7 -13
- data/lib/picky/bundle.rb +39 -43
- data/lib/picky/bundle_indexed.rb +17 -2
- data/lib/picky/bundle_indexing.rb +1 -26
- data/lib/picky/bundle_realtime.rb +2 -6
- data/lib/picky/category_indexing.rb +2 -2
- data/lib/picky/generators/similarity/phonetic.rb +3 -1
- data/lib/picky/index_indexing.rb +1 -1
- data/lib/picky/indexers/base.rb +5 -4
- data/lib/picky/indexers/parallel.rb +3 -3
- data/lib/picky/indexers/serial.rb +2 -2
- data/lib/picky/wrappers/bundle/location.rb +3 -5
- data/spec/functional/backends/redis_bundle_realtime_spec.rb +1 -1
- data/spec/functional/backends/redis_spec.rb +29 -6
- data/spec/functional/backends/special_spec.rb +229 -0
- data/spec/functional/backends/sqlite_bundle_realtime_spec.rb +1 -1
- data/spec/functional/backends/sqlite_spec.rb +1 -1
- data/spec/lib/backends/backend_spec.rb +40 -24
- data/spec/lib/backends/file_spec.rb +25 -25
- data/spec/lib/backends/memory_spec.rb +51 -51
- data/spec/lib/backends/redis_spec.rb +77 -77
- data/spec/lib/backends/sqlite/array_spec.rb +1 -1
- data/spec/lib/backends/sqlite_spec.rb +51 -51
- data/spec/lib/{indexed/bundle_spec.rb → bundle_indexed_spec.rb} +0 -0
- data/spec/lib/{indexing/bundle_spec.rb → bundle_indexing_spec.rb} +2 -9
- data/spec/lib/{indexing/bundle_partial_generation_speed_spec.rb → bundle_partial_generation_speed_spec.rb} +0 -0
- data/spec/lib/{indexed/bundle_realtime_spec.rb → bundle_realtime_spec.rb} +0 -0
- data/spec/lib/category_indexed_spec.rb +2 -2
- data/spec/lib/category_spec.rb +2 -2
- data/spec/lib/extensions/object_spec.rb +8 -8
- data/spec/lib/generators/similarity/phonetic_spec.rb +13 -7
- data/spec/lib/index_spec.rb +16 -0
- data/spec/lib/indexers/base_spec.rb +1 -1
- metadata +27 -25
@@ -2,83 +2,83 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Picky::Backends::Redis do
|
4
4
|
|
5
|
-
context 'with options' do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
context 'with lambda options' do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
5
|
+
# context 'with options' do
|
6
|
+
# before(:each) do
|
7
|
+
# @backend = described_class.new inverted: Picky::Backends::Redis::Float.new(:unimportant, :unimportant),
|
8
|
+
# weights: Picky::Backends::Redis::String.new(:unimportant, :unimportant),
|
9
|
+
# similarity: Picky::Backends::Redis::Float.new(:unimportant, :unimportant),
|
10
|
+
# configuration: Picky::Backends::Redis::List.new(:unimportant, :unimportant)
|
11
|
+
#
|
12
|
+
# @backend.stub! :timed_exclaim
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# describe "redis_with_scripting?" do
|
16
|
+
# let(:client) { stub :client}
|
17
|
+
# let(:redis) { described_class.new client: client }
|
18
|
+
#
|
19
|
+
# it "answers correctly" do
|
20
|
+
# client.stub! :info => {"redis_version"=>"2.2.2", "redis_git_sha1"=>"00000000", "redis_git_dirty"=>"0", "arch_bits"=>"64", "multiplexing_api"=>"kqueue", "process_id"=>"70364", "uptime_in_seconds"=>"86804", "uptime_in_days"=>"1", "lru_clock"=>"2057342", "used_cpu_sys"=>"12.76", "used_cpu_user"=>"13.44", "used_cpu_sys_childrens"=>"0.62", "used_cpu_user_childrens"=>"0.30", "connected_clients"=>"1", "connected_slaves"=>"0", "client_longest_output_list"=>"0", "client_biggest_input_buf"=>"0", "blocked_clients"=>"0", "used_memory"=>"34389632", "used_memory_human"=>"32.80M", "used_memory_rss"=>"675840", "mem_fragmentation_ratio"=>"0.02", "use_tcmalloc"=>"0", "loading"=>"0", "aof_enabled"=>"0", "changes_since_last_save"=>"0", "bgsave_in_progress"=>"0", "last_save_time"=>"1320721195", "bgrewriteaof_in_progress"=>"0", "total_connections_received"=>"20", "total_commands_processed"=>"327594", "expired_keys"=>"0", "evicted_keys"=>"0", "keyspace_hits"=>"218584", "keyspace_misses"=>"98664", "hash_max_zipmap_entries"=>"512", "hash_max_zipmap_value"=>"64", "pubsub_channels"=>"0", "pubsub_patterns"=>"0", "vm_enabled"=>"0", "role"=>"master", "allocation_stats"=>"2=74,6=1,8=15,9=156,10=142939,11=104891,12=290902,13=263791,14=14570,15=29143,16=1661979,17=8986,18=6370,19=4508,20=18010,21=1622,22=1136,23=544,24=419271,25=154,26=73,27=32,28=30,29=14,32=419046,33=6,34=7,35=15,36=10,37=12,38=625,39=7127,40=207716,41=40840,42=7246,43=2645,44=28390,45=37835,46=35164,47=67465,48=54765,49=41247,50=44391,51=36420,52=29582,53=21491,54=18575,55=14101,56=61954,57=5476,58=3246,59=2227,60=1502,61=868,62=541,63=282,64=69006,65=87,66=58,67=32,68=30,69=6,70=2,71=5,72=12723,74=19,75=2,76=13,77=6,80=12500,81=10,82=4,83=8,84=10,85=14,86=5,87=37,88=97714,89=58,91=30,93=68,94=14,95=35,97=56,99=46,101=24,103=17,104=846,105=1,106=15,107=19,109=4,110=6,111=13,113=8,114=8,115=4,116=5,117=8,118=11,119=4,120=217,121=18,122=6,125=5,126=12,128=4411,131=12,133=8,136=57,137=14,138=10,142=6,143=4,145=6,147=14,150=4,152=23,153=6,157=4,158=6,159=14,163=8,164=18,166=4,168=6,169=1,170=16,171=27,173=7,174=10,175=31,177=14,178=6,179=13,181=39,182=4,183=12,184=7,185=42,187=16,189=69,191=22,193=17,195=8,196=16,197=23,199=20,201=23,203=12,205=4,206=16,207=6,208=4,209=10,211=1,213=8,215=4,216=10,217=4,218=14,219=10,221=14,223=4,225=8,226=6,227=4,228=10,230=10,232=6,234=6,237=4,238=6,239=8,240=6,241=4,242=6,245=6,248=4,249=16,250=6,252=4,253=4,>=256=113463", "db15"=>"keys=26605,expires=0"}
|
21
|
+
#
|
22
|
+
# redis.redis_with_scripting?.should == false
|
23
|
+
# end
|
24
|
+
# it "answers correctly" do
|
25
|
+
# client.stub! :info => {"redis_version"=>"2.6.0", "redis_git_sha1"=>"00000000", "redis_git_dirty"=>"0", "arch_bits"=>"64", "multiplexing_api"=>"kqueue", "process_id"=>"70364", "uptime_in_seconds"=>"86804", "uptime_in_days"=>"1", "lru_clock"=>"2057342", "used_cpu_sys"=>"12.76", "used_cpu_user"=>"13.44", "used_cpu_sys_childrens"=>"0.62", "used_cpu_user_childrens"=>"0.30", "connected_clients"=>"1", "connected_slaves"=>"0", "client_longest_output_list"=>"0", "client_biggest_input_buf"=>"0", "blocked_clients"=>"0", "used_memory"=>"34389632", "used_memory_human"=>"32.80M", "used_memory_rss"=>"675840", "mem_fragmentation_ratio"=>"0.02", "use_tcmalloc"=>"0", "loading"=>"0", "aof_enabled"=>"0", "changes_since_last_save"=>"0", "bgsave_in_progress"=>"0", "last_save_time"=>"1320721195", "bgrewriteaof_in_progress"=>"0", "total_connections_received"=>"20", "total_commands_processed"=>"327594", "expired_keys"=>"0", "evicted_keys"=>"0", "keyspace_hits"=>"218584", "keyspace_misses"=>"98664", "hash_max_zipmap_entries"=>"512", "hash_max_zipmap_value"=>"64", "pubsub_channels"=>"0", "pubsub_patterns"=>"0", "vm_enabled"=>"0", "role"=>"master", "allocation_stats"=>"2=74,6=1,8=15,9=156,10=142939,11=104891,12=290902,13=263791,14=14570,15=29143,16=1661979,17=8986,18=6370,19=4508,20=18010,21=1622,22=1136,23=544,24=419271,25=154,26=73,27=32,28=30,29=14,32=419046,33=6,34=7,35=15,36=10,37=12,38=625,39=7127,40=207716,41=40840,42=7246,43=2645,44=28390,45=37835,46=35164,47=67465,48=54765,49=41247,50=44391,51=36420,52=29582,53=21491,54=18575,55=14101,56=61954,57=5476,58=3246,59=2227,60=1502,61=868,62=541,63=282,64=69006,65=87,66=58,67=32,68=30,69=6,70=2,71=5,72=12723,74=19,75=2,76=13,77=6,80=12500,81=10,82=4,83=8,84=10,85=14,86=5,87=37,88=97714,89=58,91=30,93=68,94=14,95=35,97=56,99=46,101=24,103=17,104=846,105=1,106=15,107=19,109=4,110=6,111=13,113=8,114=8,115=4,116=5,117=8,118=11,119=4,120=217,121=18,122=6,125=5,126=12,128=4411,131=12,133=8,136=57,137=14,138=10,142=6,143=4,145=6,147=14,150=4,152=23,153=6,157=4,158=6,159=14,163=8,164=18,166=4,168=6,169=1,170=16,171=27,173=7,174=10,175=31,177=14,178=6,179=13,181=39,182=4,183=12,184=7,185=42,187=16,189=69,191=22,193=17,195=8,196=16,197=23,199=20,201=23,203=12,205=4,206=16,207=6,208=4,209=10,211=1,213=8,215=4,216=10,217=4,218=14,219=10,221=14,223=4,225=8,226=6,227=4,228=10,230=10,232=6,234=6,237=4,238=6,239=8,240=6,241=4,242=6,245=6,248=4,249=16,250=6,252=4,253=4,>=256=113463", "db15"=>"keys=26605,expires=0"}
|
26
|
+
#
|
27
|
+
# redis.redis_with_scripting?.should == true
|
28
|
+
# end
|
29
|
+
# it "answers correctly" do
|
30
|
+
# client.stub! :info => {:redis_version=>"2.2.2", "redis_git_sha1"=>"00000000", "redis_git_dirty"=>"0", "arch_bits"=>"64", "multiplexing_api"=>"kqueue", "process_id"=>"70364", "uptime_in_seconds"=>"86804", "uptime_in_days"=>"1", "lru_clock"=>"2057342", "used_cpu_sys"=>"12.76", "used_cpu_user"=>"13.44", "used_cpu_sys_childrens"=>"0.62", "used_cpu_user_childrens"=>"0.30", "connected_clients"=>"1", "connected_slaves"=>"0", "client_longest_output_list"=>"0", "client_biggest_input_buf"=>"0", "blocked_clients"=>"0", "used_memory"=>"34389632", "used_memory_human"=>"32.80M", "used_memory_rss"=>"675840", "mem_fragmentation_ratio"=>"0.02", "use_tcmalloc"=>"0", "loading"=>"0", "aof_enabled"=>"0", "changes_since_last_save"=>"0", "bgsave_in_progress"=>"0", "last_save_time"=>"1320721195", "bgrewriteaof_in_progress"=>"0", "total_connections_received"=>"20", "total_commands_processed"=>"327594", "expired_keys"=>"0", "evicted_keys"=>"0", "keyspace_hits"=>"218584", "keyspace_misses"=>"98664", "hash_max_zipmap_entries"=>"512", "hash_max_zipmap_value"=>"64", "pubsub_channels"=>"0", "pubsub_patterns"=>"0", "vm_enabled"=>"0", "role"=>"master", "allocation_stats"=>"2=74,6=1,8=15,9=156,10=142939,11=104891,12=290902,13=263791,14=14570,15=29143,16=1661979,17=8986,18=6370,19=4508,20=18010,21=1622,22=1136,23=544,24=419271,25=154,26=73,27=32,28=30,29=14,32=419046,33=6,34=7,35=15,36=10,37=12,38=625,39=7127,40=207716,41=40840,42=7246,43=2645,44=28390,45=37835,46=35164,47=67465,48=54765,49=41247,50=44391,51=36420,52=29582,53=21491,54=18575,55=14101,56=61954,57=5476,58=3246,59=2227,60=1502,61=868,62=541,63=282,64=69006,65=87,66=58,67=32,68=30,69=6,70=2,71=5,72=12723,74=19,75=2,76=13,77=6,80=12500,81=10,82=4,83=8,84=10,85=14,86=5,87=37,88=97714,89=58,91=30,93=68,94=14,95=35,97=56,99=46,101=24,103=17,104=846,105=1,106=15,107=19,109=4,110=6,111=13,113=8,114=8,115=4,116=5,117=8,118=11,119=4,120=217,121=18,122=6,125=5,126=12,128=4411,131=12,133=8,136=57,137=14,138=10,142=6,143=4,145=6,147=14,150=4,152=23,153=6,157=4,158=6,159=14,163=8,164=18,166=4,168=6,169=1,170=16,171=27,173=7,174=10,175=31,177=14,178=6,179=13,181=39,182=4,183=12,184=7,185=42,187=16,189=69,191=22,193=17,195=8,196=16,197=23,199=20,201=23,203=12,205=4,206=16,207=6,208=4,209=10,211=1,213=8,215=4,216=10,217=4,218=14,219=10,221=14,223=4,225=8,226=6,227=4,228=10,230=10,232=6,234=6,237=4,238=6,239=8,240=6,241=4,242=6,245=6,248=4,249=16,250=6,252=4,253=4,>=256=113463", "db15"=>"keys=26605,expires=0"}
|
31
|
+
#
|
32
|
+
# redis.redis_with_scripting?.should == false
|
33
|
+
# end
|
34
|
+
# it "answers correctly" do
|
35
|
+
# client.stub! :info => {:redis_version=>"2.6.0", "redis_git_sha1"=>"00000000", "redis_git_dirty"=>"0", "arch_bits"=>"64", "multiplexing_api"=>"kqueue", "process_id"=>"70364", "uptime_in_seconds"=>"86804", "uptime_in_days"=>"1", "lru_clock"=>"2057342", "used_cpu_sys"=>"12.76", "used_cpu_user"=>"13.44", "used_cpu_sys_childrens"=>"0.62", "used_cpu_user_childrens"=>"0.30", "connected_clients"=>"1", "connected_slaves"=>"0", "client_longest_output_list"=>"0", "client_biggest_input_buf"=>"0", "blocked_clients"=>"0", "used_memory"=>"34389632", "used_memory_human"=>"32.80M", "used_memory_rss"=>"675840", "mem_fragmentation_ratio"=>"0.02", "use_tcmalloc"=>"0", "loading"=>"0", "aof_enabled"=>"0", "changes_since_last_save"=>"0", "bgsave_in_progress"=>"0", "last_save_time"=>"1320721195", "bgrewriteaof_in_progress"=>"0", "total_connections_received"=>"20", "total_commands_processed"=>"327594", "expired_keys"=>"0", "evicted_keys"=>"0", "keyspace_hits"=>"218584", "keyspace_misses"=>"98664", "hash_max_zipmap_entries"=>"512", "hash_max_zipmap_value"=>"64", "pubsub_channels"=>"0", "pubsub_patterns"=>"0", "vm_enabled"=>"0", "role"=>"master", "allocation_stats"=>"2=74,6=1,8=15,9=156,10=142939,11=104891,12=290902,13=263791,14=14570,15=29143,16=1661979,17=8986,18=6370,19=4508,20=18010,21=1622,22=1136,23=544,24=419271,25=154,26=73,27=32,28=30,29=14,32=419046,33=6,34=7,35=15,36=10,37=12,38=625,39=7127,40=207716,41=40840,42=7246,43=2645,44=28390,45=37835,46=35164,47=67465,48=54765,49=41247,50=44391,51=36420,52=29582,53=21491,54=18575,55=14101,56=61954,57=5476,58=3246,59=2227,60=1502,61=868,62=541,63=282,64=69006,65=87,66=58,67=32,68=30,69=6,70=2,71=5,72=12723,74=19,75=2,76=13,77=6,80=12500,81=10,82=4,83=8,84=10,85=14,86=5,87=37,88=97714,89=58,91=30,93=68,94=14,95=35,97=56,99=46,101=24,103=17,104=846,105=1,106=15,107=19,109=4,110=6,111=13,113=8,114=8,115=4,116=5,117=8,118=11,119=4,120=217,121=18,122=6,125=5,126=12,128=4411,131=12,133=8,136=57,137=14,138=10,142=6,143=4,145=6,147=14,150=4,152=23,153=6,157=4,158=6,159=14,163=8,164=18,166=4,168=6,169=1,170=16,171=27,173=7,174=10,175=31,177=14,178=6,179=13,181=39,182=4,183=12,184=7,185=42,187=16,189=69,191=22,193=17,195=8,196=16,197=23,199=20,201=23,203=12,205=4,206=16,207=6,208=4,209=10,211=1,213=8,215=4,216=10,217=4,218=14,219=10,221=14,223=4,225=8,226=6,227=4,228=10,230=10,232=6,234=6,237=4,238=6,239=8,240=6,241=4,242=6,245=6,248=4,249=16,250=6,252=4,253=4,>=256=113463", "db15"=>"keys=26605,expires=0"}
|
36
|
+
#
|
37
|
+
# redis.redis_with_scripting?.should == true
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# describe 'create_...' do
|
42
|
+
# [
|
43
|
+
# [:inverted, Picky::Backends::Redis::Float],
|
44
|
+
# [:weights, Picky::Backends::Redis::String],
|
45
|
+
# [:similarity, Picky::Backends::Redis::Float],
|
46
|
+
# [:configuration, Picky::Backends::Redis::List]
|
47
|
+
# ].each do |type, kind|
|
48
|
+
# it "creates and returns a(n) #{type} index" do
|
49
|
+
# @backend.send(:"create_#{type}",
|
50
|
+
# stub(type, :identifier => "some_identifier:#{type}")
|
51
|
+
# ).should be_kind_of(kind)
|
52
|
+
# end
|
53
|
+
# end
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
|
57
|
+
# context 'with lambda options' do
|
58
|
+
# before(:each) do
|
59
|
+
# @backend = described_class.new inverted: ->(bundle, client){ Picky::Backends::Redis::Float.new(client, bundle.identifier(:inverted)) },
|
60
|
+
# weights: ->(bundle, client){ Picky::Backends::Redis::String.new(client, bundle.identifier(:weights)) },
|
61
|
+
# similarity: ->(bundle, client){ Picky::Backends::Redis::Float.new(client, bundle.identifier(:similarity)) },
|
62
|
+
# configuration: ->(bundle, client){ Picky::Backends::Redis::List.new(client, bundle.identifier(:configuration)) }
|
63
|
+
#
|
64
|
+
# @backend.stub! :timed_exclaim
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# describe 'create_...' do
|
68
|
+
# [
|
69
|
+
# [:inverted, Picky::Backends::Redis::Float],
|
70
|
+
# [:weights, Picky::Backends::Redis::String],
|
71
|
+
# [:similarity, Picky::Backends::Redis::Float],
|
72
|
+
# [:configuration, Picky::Backends::Redis::List]
|
73
|
+
# ].each do |type, kind|
|
74
|
+
# it "creates and returns a(n) #{type} index" do
|
75
|
+
# to_a_able_stub = Object.new
|
76
|
+
# to_a_able_stub.stub! :identifier => "some_identifier:#{type}"
|
77
|
+
# @backend.send(:"create_#{type}", to_a_able_stub).should be_kind_of(kind)
|
78
|
+
# end
|
79
|
+
# end
|
80
|
+
# end
|
81
|
+
# end
|
82
82
|
|
83
83
|
context 'without options' do
|
84
84
|
before(:each) do
|
@@ -73,7 +73,7 @@ describe Picky::Backends::SQLite::Array do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
context 'hash-based indexes' do
|
76
|
-
let(:db) { described_class.new 'some/cache/path/to/file',
|
76
|
+
let(:db) { described_class.new 'some/cache/path/to/file', realtime: true }
|
77
77
|
|
78
78
|
describe 'dump' do
|
79
79
|
it 'delegates to the given hash' do
|
@@ -4,57 +4,57 @@ require 'sqlite3'
|
|
4
4
|
|
5
5
|
describe Picky::Backends::SQLite do
|
6
6
|
|
7
|
-
context 'with options' do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'with lambda options' do
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
7
|
+
# context 'with options' do
|
8
|
+
# before(:each) do
|
9
|
+
# @backend = described_class.new inverted: Picky::Backends::SQLite::Value.new(:unimportant),
|
10
|
+
# weights: Picky::Backends::SQLite::Array.new(:unimportant),
|
11
|
+
# similarity: Picky::Backends::SQLite::Value.new(:unimportant),
|
12
|
+
# configuration: Picky::Backends::SQLite::Array.new(:unimportant)
|
13
|
+
#
|
14
|
+
# @backend.stub! :timed_exclaim
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# describe 'create_...' do
|
18
|
+
# [
|
19
|
+
# [:inverted, Picky::Backends::SQLite::Value],
|
20
|
+
# [:weights, Picky::Backends::SQLite::Array],
|
21
|
+
# [:similarity, Picky::Backends::SQLite::Value],
|
22
|
+
# [:configuration, Picky::Backends::SQLite::Array]
|
23
|
+
# ].each do |type, kind|
|
24
|
+
# it "creates and returns a(n) #{type} index" do
|
25
|
+
# @backend.send(:"create_#{type}",
|
26
|
+
# stub(type, :index_path => "spec/test_directory/index/test/some_index/some_category_some_bundle_#{type}")
|
27
|
+
# ).should be_kind_of(kind)
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# context 'with lambda options' do
|
34
|
+
# before(:each) do
|
35
|
+
# @backend = described_class.new inverted: ->(bundle){ Picky::Backends::SQLite::Value.new(bundle.index_path(:inverted)) },
|
36
|
+
# weights: ->(bundle){ Picky::Backends::SQLite::Array.new(bundle.index_path(:weights)) },
|
37
|
+
# similarity: ->(bundle){ Picky::Backends::SQLite::Value.new(bundle.index_path(:similarity)) },
|
38
|
+
# configuration: ->(bundle){ Picky::Backends::SQLite::Array.new(bundle.index_path(:configuration)) }
|
39
|
+
#
|
40
|
+
# @backend.stub! :timed_exclaim
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# describe 'create_...' do
|
44
|
+
# [
|
45
|
+
# [:inverted, Picky::Backends::SQLite::Value],
|
46
|
+
# [:weights, Picky::Backends::SQLite::Array],
|
47
|
+
# [:similarity, Picky::Backends::SQLite::Value],
|
48
|
+
# [:configuration, Picky::Backends::SQLite::Array]
|
49
|
+
# ].each do |type, kind|
|
50
|
+
# it "creates and returns a(n) #{type} index" do
|
51
|
+
# to_a_able_stub = Object.new
|
52
|
+
# to_a_able_stub.stub! :index_path => "spec/test_directory/index/test/some_index/some_category_some_bundle_#{type}"
|
53
|
+
# @backend.send(:"create_#{type}", to_a_able_stub).should be_kind_of(kind)
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
# end
|
57
|
+
# end
|
58
58
|
|
59
59
|
context 'without options' do
|
60
60
|
before(:each) do
|
File without changes
|
@@ -25,7 +25,7 @@ describe Picky::Bundle do
|
|
25
25
|
bundle.similar(:dragon).should == [:dargon]
|
26
26
|
end
|
27
27
|
it 'returns the right similars' do
|
28
|
-
bundle.similar(:trkn).should == [:
|
28
|
+
bundle.similar(:trkn).should == [:dragon, :dargon]
|
29
29
|
end
|
30
30
|
it 'performs' do
|
31
31
|
performance_of { bundle.similar(:dragon) }.should < 0.000075
|
@@ -37,13 +37,6 @@ describe Picky::Bundle do
|
|
37
37
|
|
38
38
|
describe 'dump' do
|
39
39
|
it 'should trigger dumps' do
|
40
|
-
bundle.stub! :timed_exclaim
|
41
|
-
|
42
|
-
bundle.should_receive(:dump_inverted).once.with
|
43
|
-
bundle.should_receive(:dump_weights).once.with
|
44
|
-
bundle.should_receive(:dump_similarity).once.with
|
45
|
-
bundle.should_receive(:dump_configuration).once.with
|
46
|
-
|
47
40
|
bundle.dump
|
48
41
|
end
|
49
42
|
end
|
@@ -67,7 +60,7 @@ describe Picky::Bundle do
|
|
67
60
|
bundle.partial_strategy.should == :some_partial
|
68
61
|
end
|
69
62
|
it 'should initialize the weights strategy correctly' do
|
70
|
-
bundle.
|
63
|
+
bundle.weight_strategy.should == @weights
|
71
64
|
end
|
72
65
|
it 'should initialize the similarity strategy correctly' do
|
73
66
|
bundle.similarity_strategy.should == @similarity
|
File without changes
|
File without changes
|
@@ -7,14 +7,14 @@ describe Picky::Category do
|
|
7
7
|
source []
|
8
8
|
end
|
9
9
|
@partial_strategy = stub :partial, :use_exact_for_partial? => false
|
10
|
-
@
|
10
|
+
@weight_strategy = stub :weights, :saved? => true
|
11
11
|
@similarity_strategy = stub :similarity
|
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
|
-
:weights => @
|
17
|
+
:weights => @weight_strategy,
|
18
18
|
:similarity => @similarity_strategy,
|
19
19
|
:qualifiers => [:q, :qualifier]
|
20
20
|
|
data/spec/lib/category_spec.rb
CHANGED
@@ -6,11 +6,11 @@ describe Picky::Category do
|
|
6
6
|
let(:category) { described_class.new :some_category, index }
|
7
7
|
|
8
8
|
it 'should set defaults correctly' do
|
9
|
-
category.exact.
|
9
|
+
category.exact.weight_strategy.should == Picky::Generators::Weights::Default
|
10
10
|
category.exact.partial_strategy.should be_kind_of(Picky::Generators::Partial::None)
|
11
11
|
category.exact.similarity_strategy.should == Picky::Generators::Similarity::Default
|
12
12
|
|
13
|
-
category.partial.
|
13
|
+
category.partial.weight_strategy.should be_kind_of(Picky::Generators::Weights::Logarithmic)
|
14
14
|
category.partial.partial_strategy.should == Picky::Generators::Partial::Default
|
15
15
|
category.partial.similarity_strategy.should be_kind_of(Picky::Generators::Similarity::None)
|
16
16
|
|
@@ -5,14 +5,14 @@ describe Object do
|
|
5
5
|
context 'basic object' do
|
6
6
|
let(:object) { described_class.new }
|
7
7
|
|
8
|
-
describe "exclaim" do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
8
|
+
# describe "exclaim" do
|
9
|
+
# it "delegates to puts" do
|
10
|
+
# STDOUT.should_receive(:puts).once.with :bla
|
11
|
+
# STDOUT.should_receive(:flush).once.with
|
12
|
+
#
|
13
|
+
# object.exclaim :bla
|
14
|
+
# end
|
15
|
+
# end
|
16
16
|
|
17
17
|
describe "timed_exclaim" do
|
18
18
|
it "should exclaim right" do
|
@@ -21,48 +21,54 @@ describe Picky::Generators::Similarity::Phonetic do
|
|
21
21
|
instance.send :initialize
|
22
22
|
end
|
23
23
|
|
24
|
-
describe '
|
24
|
+
describe 'prioritize!' do
|
25
25
|
let(:phonetic) { described_class.allocate }
|
26
26
|
it 'sorts correctly' do
|
27
27
|
phonetic.instance_variable_set :@amount, 2
|
28
28
|
|
29
29
|
ary = [:a, :b, :c]
|
30
|
-
phonetic.
|
30
|
+
phonetic.prioritize! ary, :b
|
31
|
+
|
31
32
|
ary.should == [:b, :a]
|
32
33
|
end
|
33
34
|
it 'sorts correctly' do
|
34
35
|
phonetic.instance_variable_set :@amount, 2
|
35
36
|
|
36
37
|
ary = [:aaa, :aa, :aaaa]
|
37
|
-
phonetic.
|
38
|
+
phonetic.prioritize! ary, :aaa
|
39
|
+
|
38
40
|
ary.should == [:aaa, :aa]
|
39
41
|
end
|
40
42
|
it 'sorts correctly' do
|
41
43
|
phonetic.instance_variable_set :@amount, 3
|
42
44
|
|
43
45
|
ary = [:aaa, :aa, :aaaa]
|
44
|
-
phonetic.
|
46
|
+
phonetic.prioritize! ary, :aaa
|
47
|
+
|
45
48
|
ary.should == [:aaa, :aa, :aaaa]
|
46
49
|
end
|
47
50
|
it 'sorts correctly' do
|
48
51
|
phonetic.instance_variable_set :@amount, 3
|
49
52
|
|
50
53
|
ary = [:aaaaa, :aa, :aaaa]
|
51
|
-
phonetic.
|
54
|
+
phonetic.prioritize! ary, :aaa
|
55
|
+
|
52
56
|
ary.should == [:aaaa, :aa, :aaaaa]
|
53
57
|
end
|
54
58
|
it 'sorts correctly' do
|
55
59
|
phonetic.instance_variable_set :@amount, 3
|
56
60
|
|
57
61
|
ary = [:aaaaa, :aa]
|
58
|
-
phonetic.
|
62
|
+
phonetic.prioritize! ary, :aaa
|
63
|
+
|
59
64
|
ary.should == [:aa, :aaaaa]
|
60
65
|
end
|
61
66
|
it 'sorts correctly' do
|
62
67
|
phonetic.instance_variable_set :@amount, 3
|
63
68
|
|
64
69
|
ary = [:aaa]
|
65
|
-
phonetic.
|
70
|
+
phonetic.prioritize! ary, :aaa
|
71
|
+
|
66
72
|
ary.should == [:aaa]
|
67
73
|
end
|
68
74
|
end
|
data/spec/lib/index_spec.rb
CHANGED
@@ -20,6 +20,22 @@ describe Picky::Index do
|
|
20
20
|
it 'does not fail' do
|
21
21
|
expect { described_class.new :some_index_name do source [] end }.to_not raise_error
|
22
22
|
end
|
23
|
+
it 'does not fail' do
|
24
|
+
expect { described_class.new :some_index_name do source { [] } end }.to_not raise_error
|
25
|
+
end
|
26
|
+
it 'evaluates the source every time' do
|
27
|
+
expector = stub :expector
|
28
|
+
|
29
|
+
data = described_class.new :some_index_name do
|
30
|
+
source do
|
31
|
+
expector.call
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
expector.should_receive(:call).twice.with()
|
36
|
+
|
37
|
+
data.prepare
|
38
|
+
end
|
23
39
|
it 'registers with the indexes' do
|
24
40
|
@api = described_class.allocate
|
25
41
|
|
@@ -35,7 +35,7 @@ describe Picky::Indexers::Base do
|
|
35
35
|
it 'processes' do
|
36
36
|
categories = stub :categories, :empty => nil, :cache => nil
|
37
37
|
|
38
|
-
indexer.should_receive(:process).once.with categories, anything
|
38
|
+
indexer.should_receive(:process).once.with :some_source, categories, anything
|
39
39
|
|
40
40
|
indexer.prepare categories
|
41
41
|
end
|