kvom 6.8.3.115.227021242 → 6.8.3.174.51542603
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/kvom/adapter/base.rb +1 -1
- data/lib/kvom/adapter/filesystem_adapter.rb +5 -0
- data/spec/model/base_spec.rb +12 -0
- metadata +3 -3
data/lib/kvom/adapter/base.rb
CHANGED
@@ -51,7 +51,7 @@ class Base
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def query(hash_value, range_value, query_options={})
|
54
|
-
query_options.assert_valid_keys(:limit)
|
54
|
+
query_options.assert_valid_keys(:limit, :scan_index_forward)
|
55
55
|
count_document_request do
|
56
56
|
query_docs(hash_value, range_value, query_options)
|
57
57
|
end
|
@@ -53,9 +53,14 @@ class FilesystemAdapter < Base
|
|
53
53
|
else
|
54
54
|
single_file_query(hash_value, range_value)
|
55
55
|
end
|
56
|
+
|
57
|
+
pathes_and_range_values.sort_by!(&:first)
|
58
|
+
pathes_and_range_values.reverse! if query_options[:scan_index_forward] == false
|
59
|
+
|
56
60
|
if limit = query_options[:limit]
|
57
61
|
pathes_and_range_values = pathes_and_range_values.first(limit)
|
58
62
|
end
|
63
|
+
|
59
64
|
pathes_and_range_values.inject([]) do |memo, (path, doc_range_value)|
|
60
65
|
doc_range_value = nil if doc_range_value == ""
|
61
66
|
key = [hash_value, doc_range_value]
|
data/spec/model/base_spec.rb
CHANGED
@@ -325,6 +325,18 @@ describe Kvom::Model::Base do
|
|
325
325
|
adapter.query(volatile_id('one'), Range.new('0001', '0022'), :limit => 8).length.should eq(4)
|
326
326
|
end
|
327
327
|
|
328
|
+
it 'is able to control scan direction' do
|
329
|
+
adapter.query(volatile_id('one'), Range.new('0001', '0022'), :scan_index_forward => true).
|
330
|
+
map(&:key).should eq([one_001, one_002, one_0021, one_0022].map(&:key))
|
331
|
+
adapter.query(volatile_id('one'), Range.new('0001', '0022'), :scan_index_forward => false).
|
332
|
+
map(&:key).should eq([one_0022, one_0021, one_002, one_001].map(&:key))
|
333
|
+
end
|
334
|
+
|
335
|
+
it 'scans forwards by default' do
|
336
|
+
adapter.query(volatile_id('one'), Range.new('0001', '0022')).map(&:key).
|
337
|
+
should eq([one_001, one_002, one_0021, one_0022].map(&:key))
|
338
|
+
end
|
339
|
+
|
328
340
|
context "when range is a single value" do
|
329
341
|
context "when the doc exists" do
|
330
342
|
it "returns a one-element list with the doc's model instance" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kvom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.8.3.
|
4
|
+
version: 6.8.3.174.51542603
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -187,7 +187,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
187
187
|
version: '0'
|
188
188
|
segments:
|
189
189
|
- 0
|
190
|
-
hash: -
|
190
|
+
hash: -968281363
|
191
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
192
|
none: false
|
193
193
|
requirements:
|