dm-chunked_query 0.1.1 → 0.1.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/ChangeLog.md +5 -0
- data/gemspec.yml +1 -1
- data/lib/dm-chunked_query/chunks.rb +2 -2
- data/spec/chunks_spec.rb +28 -8
- metadata +1 -1
data/ChangeLog.md
CHANGED
data/gemspec.yml
CHANGED
@@ -42,7 +42,7 @@ module DataMapper
|
|
42
42
|
|
43
43
|
chunk_at(index,span)
|
44
44
|
when Integer
|
45
|
-
chunk_at(
|
45
|
+
chunk_at(key)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -57,7 +57,7 @@ module DataMapper
|
|
57
57
|
# bounds, `nil` will be returned.
|
58
58
|
#
|
59
59
|
def at(index)
|
60
|
-
chunk_at(
|
60
|
+
chunk_at(index.to_i)
|
61
61
|
end
|
62
62
|
|
63
63
|
#
|
data/spec/chunks_spec.rb
CHANGED
@@ -17,18 +17,38 @@ describe DataMapper::ChunkedQuery::Chunks do
|
|
17
17
|
TestModel.chunks(TestModel.count * 0.75).length.should == 2
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
context "#[]" do
|
21
|
+
it "should allow direct access to individual chunks" do
|
22
|
+
resources = subject[1]
|
23
|
+
numbers = resources.map { |resource| resource.number }
|
23
24
|
|
24
|
-
|
25
|
+
numbers.should == (11..20).to_a
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should allow direct access to a range of chunks" do
|
29
|
+
resources = subject[1..2]
|
30
|
+
numbers = resources.map { |resource| resource.number }
|
31
|
+
|
32
|
+
numbers.should == (11..30).to_a
|
33
|
+
end
|
25
34
|
end
|
26
35
|
|
27
|
-
|
28
|
-
|
29
|
-
|
36
|
+
context "#at" do
|
37
|
+
let(:expected_numbers) { (11..20).to_a }
|
38
|
+
|
39
|
+
it "should allow accessing chunks at given indices" do
|
40
|
+
resources = subject.at(1)
|
41
|
+
numbers = resources.map { |resource| resource.number }
|
42
|
+
|
43
|
+
numbers.should == expected_numbers
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should allow accessing chunks using non-Integer indices" do
|
47
|
+
resources = subject.at('1')
|
48
|
+
numbers = resources.map { |resource| resource.number }
|
30
49
|
|
31
|
-
|
50
|
+
numbers.should == expected_numbers
|
51
|
+
end
|
32
52
|
end
|
33
53
|
|
34
54
|
it "should allow enumerating through every chunk" do
|