picky 0.12.1 → 0.12.2
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/Index_api.rb +10 -3
- data/lib/picky/cacher/partial/substring.rb +4 -4
- data/lib/picky/calculations/location.rb +39 -0
- data/lib/picky/configuration/index.rb +2 -2
- data/lib/picky/extensions/array.rb +0 -8
- data/lib/picky/extensions/symbol.rb +2 -16
- data/lib/picky/generator.rb +0 -2
- data/lib/picky/index/bundle.rb +7 -5
- data/lib/picky/index/file/basic.rb +2 -6
- data/lib/picky/index/files.rb +24 -14
- data/lib/picky/indexed/bundle.rb +7 -14
- data/lib/picky/indexed/category.rb +2 -1
- data/lib/picky/indexed/wrappers/bundle/calculation.rb +35 -0
- data/lib/picky/indexed/wrappers/bundle/location.rb +40 -0
- data/lib/picky/indexed/wrappers/bundle/wrapper.rb +25 -0
- data/lib/picky/indexers/serial.rb +1 -1
- data/lib/picky/indexing/bundle.rb +7 -0
- data/lib/picky/indexing/category.rb +22 -1
- data/lib/picky/loader.rb +10 -0
- data/lib/picky/sources/couch.rb +1 -1
- data/lib/picky/sources/csv.rb +6 -4
- data/lib/picky/sources/db.rb +1 -1
- data/lib/picky/sources/delicious.rb +1 -1
- data/lib/picky/sources/wrappers/base.rb +5 -4
- data/lib/picky/sources/wrappers/location.rb +16 -22
- data/lib/tasks/try.rake +2 -2
- data/spec/lib/calculations/location_spec.rb +35 -0
- data/spec/lib/extensions/array_spec.rb +0 -10
- data/spec/lib/extensions/symbol_spec.rb +1 -69
- data/spec/lib/index/files_spec.rb +54 -34
- data/spec/lib/indexed/bundle_spec.rb +17 -14
- data/spec/lib/indexed/wrappers/bundle/calculation_spec.rb +37 -0
- data/spec/lib/indexed/wrappers/bundle/wrapper_spec.rb +27 -0
- data/spec/lib/indexing/bundle_spec.rb +5 -1
- data/spec/lib/sources/couch_spec.rb +1 -1
- data/spec/lib/sources/csv_spec.rb +41 -11
- data/spec/lib/sources/db_spec.rb +5 -5
- data/spec/lib/sources/delicious_spec.rb +6 -6
- data/spec/lib/sources/wrappers/base_spec.rb +7 -3
- data/spec/lib/sources/wrappers/location_spec.rb +11 -12
- metadata +13 -3
data/spec/lib/sources/db_spec.rb
CHANGED
@@ -18,12 +18,12 @@ describe Sources::DB do
|
|
18
18
|
|
19
19
|
describe "get_data" do
|
20
20
|
it "delegates" do
|
21
|
-
type
|
22
|
-
|
21
|
+
type = stub :type, :name => :some_type
|
22
|
+
category = stub :category, :from => :some_category
|
23
23
|
|
24
|
-
@connection.should_receive(:execute).once.with 'SELECT indexed_id,
|
24
|
+
@connection.should_receive(:execute).once.with 'SELECT indexed_id, some_category FROM some_type_type_index st WHERE st.id > some_offset LIMIT 25000'
|
25
25
|
|
26
|
-
@source.get_data type,
|
26
|
+
@source.get_data type, category, :some_offset
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -112,7 +112,7 @@ describe Sources::DB do
|
|
112
112
|
|
113
113
|
describe "harvest_statement_with_offset" do
|
114
114
|
before(:each) do
|
115
|
-
@category = stub :category, :
|
115
|
+
@category = stub :category, :from => :some_category
|
116
116
|
@type = stub :type, :name => :some_type
|
117
117
|
end
|
118
118
|
it "should get a harvest statement and the chunksize to put the statement together" do
|
@@ -46,20 +46,20 @@ describe Sources::Delicious do
|
|
46
46
|
WWW::Delicious.should_receive(:new).and_return delicious
|
47
47
|
end
|
48
48
|
it "should yield the right data" do
|
49
|
-
|
50
|
-
@source.harvest :anything,
|
49
|
+
category = stub :b, :from => :tags
|
50
|
+
@source.harvest :anything, category do |id, token|
|
51
51
|
[id, token].should == [1, "barefoot running shoe"]
|
52
52
|
end
|
53
53
|
end
|
54
54
|
it "should yield the right data" do
|
55
|
-
|
56
|
-
@source.harvest :anything,
|
55
|
+
category = stub :b, :from => :title
|
56
|
+
@source.harvest :anything, category do |id, token|
|
57
57
|
[id, token].should == [1, "VIBRAM - FiveFingers"]
|
58
58
|
end
|
59
59
|
end
|
60
60
|
it "should yield the right data" do
|
61
|
-
|
62
|
-
@source.harvest :anything,
|
61
|
+
category = stub :b, :from => :url
|
62
|
+
@source.harvest :anything, category do |id, token|
|
63
63
|
[id, token].should == [1, "http://www.vibramfivefingers.it/"]
|
64
64
|
end
|
65
65
|
end
|
@@ -2,13 +2,17 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Sources::Wrappers::Base do
|
4
4
|
|
5
|
+
before(:each) do
|
6
|
+
@backend = stub :backend
|
7
|
+
@category = stub :category, :source => @backend
|
8
|
+
end
|
9
|
+
|
5
10
|
context "with backend" do
|
6
11
|
it "doesn't fail" do
|
7
|
-
lambda { Sources::Wrappers::Base.new(
|
12
|
+
lambda { Sources::Wrappers::Base.new(@category) }.should_not raise_error
|
8
13
|
end
|
9
14
|
before(:each) do
|
10
|
-
@
|
11
|
-
@wrapper = Sources::Wrappers::Base.new @backend
|
15
|
+
@wrapper = Sources::Wrappers::Base.new @category
|
12
16
|
end
|
13
17
|
it "delegates harvest" do
|
14
18
|
@backend.should_receive(:harvest).once.with :some_type, :some_field
|
@@ -4,7 +4,8 @@ describe Sources::Wrappers::Location do
|
|
4
4
|
|
5
5
|
context "with backend" do
|
6
6
|
before(:each) do
|
7
|
-
@backend
|
7
|
+
@backend = stub :backend
|
8
|
+
@category = stub :category, :source => @backend
|
8
9
|
end
|
9
10
|
context "without grid option" do
|
10
11
|
it "fails" do
|
@@ -13,15 +14,17 @@ describe Sources::Wrappers::Location do
|
|
13
14
|
end
|
14
15
|
context "with grid option" do
|
15
16
|
before(:each) do
|
16
|
-
@wrapper = Sources::Wrappers::Location.new @
|
17
|
+
@wrapper = Sources::Wrappers::Location.new @category, grid:10
|
17
18
|
end
|
18
19
|
it "uses a default of 1 on the precision" do
|
19
20
|
@wrapper.precision.should == 1
|
20
21
|
end
|
21
22
|
it "delegates harvest" do
|
22
|
-
@
|
23
|
+
@category.stub! :exact => {}
|
23
24
|
|
24
|
-
@
|
25
|
+
@backend.should_receive(:harvest).once.with :some_type, @category
|
26
|
+
|
27
|
+
@wrapper.harvest :some_type, @category
|
25
28
|
end
|
26
29
|
it "delegates take_snapshot" do
|
27
30
|
@backend.should_receive(:take_snapshot).once.with :some_type
|
@@ -36,25 +39,21 @@ describe Sources::Wrappers::Location do
|
|
36
39
|
end
|
37
40
|
context "with grid and precision option" do
|
38
41
|
before(:each) do
|
39
|
-
@wrapper = Sources::Wrappers::Location.new @
|
42
|
+
@wrapper = Sources::Wrappers::Location.new @category, grid:4, precision:2
|
40
43
|
end
|
41
44
|
it "uses the given precision" do
|
42
45
|
@wrapper.precision.should == 2
|
43
46
|
end
|
44
47
|
|
45
48
|
describe "locations_for" do
|
46
|
-
before(:each) do
|
47
|
-
@wrapper.instance_variable_set :@min, -3
|
48
|
-
@wrapper.marginize
|
49
|
-
end
|
50
49
|
it "returns the right array" do
|
51
|
-
@wrapper.locations_for(
|
50
|
+
@wrapper.locations_for(15).should == [13, 14, 15, 16, 17]
|
52
51
|
end
|
53
52
|
it "returns the right array" do
|
54
|
-
@wrapper.locations_for(
|
53
|
+
@wrapper.locations_for(2).should == [0, 1, 2, 3, 4]
|
55
54
|
end
|
56
55
|
it "returns the right array" do
|
57
|
-
@wrapper.locations_for(
|
56
|
+
@wrapper.locations_for(16).should == [14, 15, 16, 17, 18]
|
58
57
|
end
|
59
58
|
end
|
60
59
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 12
|
8
|
-
-
|
9
|
-
version: 0.12.
|
8
|
+
- 2
|
9
|
+
version: 0.12.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Florian Hanke
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-25 00:00:00 +01:00
|
18
18
|
default_executable: picky
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- lib/picky/cacher/weights/logarithmic.rb
|
62
62
|
- lib/picky/cacher/weights/strategy.rb
|
63
63
|
- lib/picky/cacher/weights_generator.rb
|
64
|
+
- lib/picky/calculations/location.rb
|
64
65
|
- lib/picky/character_substituters/west_european.rb
|
65
66
|
- lib/picky/configuration/index.rb
|
66
67
|
- lib/picky/cores.rb
|
@@ -87,6 +88,9 @@ files:
|
|
87
88
|
- lib/picky/indexed/category.rb
|
88
89
|
- lib/picky/indexed/index.rb
|
89
90
|
- lib/picky/indexed/indexes.rb
|
91
|
+
- lib/picky/indexed/wrappers/bundle/calculation.rb
|
92
|
+
- lib/picky/indexed/wrappers/bundle/location.rb
|
93
|
+
- lib/picky/indexed/wrappers/bundle/wrapper.rb
|
90
94
|
- lib/picky/indexed/wrappers/exact_first.rb
|
91
95
|
- lib/picky/indexers/no_source_specified_error.rb
|
92
96
|
- lib/picky/indexers/serial.rb
|
@@ -167,6 +171,7 @@ files:
|
|
167
171
|
- spec/lib/cacher/similarity_generator_spec.rb
|
168
172
|
- spec/lib/cacher/weights/logarithmic_spec.rb
|
169
173
|
- spec/lib/cacher/weights_generator_spec.rb
|
174
|
+
- spec/lib/calculations/location_spec.rb
|
170
175
|
- spec/lib/character_substituters/west_european_spec.rb
|
171
176
|
- spec/lib/configuration/index_spec.rb
|
172
177
|
- spec/lib/cores_spec.rb
|
@@ -188,6 +193,8 @@ files:
|
|
188
193
|
- spec/lib/indexed/categories_spec.rb
|
189
194
|
- spec/lib/indexed/category_spec.rb
|
190
195
|
- spec/lib/indexed/index_spec.rb
|
196
|
+
- spec/lib/indexed/wrappers/bundle/calculation_spec.rb
|
197
|
+
- spec/lib/indexed/wrappers/bundle/wrapper_spec.rb
|
191
198
|
- spec/lib/indexed/wrappers/exact_first_spec.rb
|
192
199
|
- spec/lib/indexers/serial_spec.rb
|
193
200
|
- spec/lib/indexing/bundle_partial_generation_speed_spec.rb
|
@@ -269,6 +276,7 @@ test_files:
|
|
269
276
|
- spec/lib/cacher/similarity_generator_spec.rb
|
270
277
|
- spec/lib/cacher/weights/logarithmic_spec.rb
|
271
278
|
- spec/lib/cacher/weights_generator_spec.rb
|
279
|
+
- spec/lib/calculations/location_spec.rb
|
272
280
|
- spec/lib/character_substituters/west_european_spec.rb
|
273
281
|
- spec/lib/configuration/index_spec.rb
|
274
282
|
- spec/lib/cores_spec.rb
|
@@ -290,6 +298,8 @@ test_files:
|
|
290
298
|
- spec/lib/indexed/categories_spec.rb
|
291
299
|
- spec/lib/indexed/category_spec.rb
|
292
300
|
- spec/lib/indexed/index_spec.rb
|
301
|
+
- spec/lib/indexed/wrappers/bundle/calculation_spec.rb
|
302
|
+
- spec/lib/indexed/wrappers/bundle/wrapper_spec.rb
|
293
303
|
- spec/lib/indexed/wrappers/exact_first_spec.rb
|
294
304
|
- spec/lib/indexers/serial_spec.rb
|
295
305
|
- spec/lib/indexing/bundle_partial_generation_speed_spec.rb
|