kvom 6.8.2.36.82613853 → 6.8.3.1.23895778
Sign up to get free protection for your applications and to get access to all the features.
data/kvom.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
23
|
|
24
|
-
s.add_runtime_dependency "multi_json", "
|
24
|
+
s.add_runtime_dependency "multi_json", ">= 1.5.1"
|
25
25
|
s.add_runtime_dependency "activesupport", ">= 3" # does not support rational versioning, does it?
|
26
26
|
s.add_runtime_dependency "activemodel", ">= 3" # adapters
|
27
27
|
|
data/lib/kvom/adapter/base.rb
CHANGED
@@ -50,9 +50,10 @@ class Base
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
def query(hash_value, range_value)
|
53
|
+
def query(hash_value, range_value, query_options={})
|
54
|
+
query_options.assert_valid_keys(:limit)
|
54
55
|
count_document_request do
|
55
|
-
query_docs(hash_value, range_value)
|
56
|
+
query_docs(hash_value, range_value, query_options)
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
@@ -36,7 +36,7 @@ class DynamodbAdapter < Base
|
|
36
36
|
item.delete
|
37
37
|
end
|
38
38
|
|
39
|
-
def query_docs(hash_value, range_value)
|
39
|
+
def query_docs(hash_value, range_value, query_options={})
|
40
40
|
raise "Unsupported range value <empty string>" if range_value == ""
|
41
41
|
case range_value
|
42
42
|
when nil, String
|
@@ -52,11 +52,12 @@ class DynamodbAdapter < Base
|
|
52
52
|
dynamo_range_start = dynamo_range_value(range_value.begin)
|
53
53
|
dynamo_range_end = dynamo_range_value(range_value.end)
|
54
54
|
|
55
|
-
query_options =
|
55
|
+
query_options = query_options.merge(
|
56
56
|
:hash_value => partitioned_hash_value(hash_value),
|
57
57
|
:range_value => Range.new(dynamo_range_start, dynamo_range_end),
|
58
|
-
:select => :all
|
59
|
-
|
58
|
+
:select => :all
|
59
|
+
)
|
60
|
+
|
60
61
|
table.items.query(query_options).map do |item_data|
|
61
62
|
item = item_data.item
|
62
63
|
key = key_from_item(item)
|
@@ -45,7 +45,7 @@ class FilesystemAdapter < Base
|
|
45
45
|
FileUtils.rm_f(filepath_for_hash_and_range(key.first, key[1]))
|
46
46
|
end
|
47
47
|
|
48
|
-
def query_docs(hash_value, range_value)
|
48
|
+
def query_docs(hash_value, range_value, query_options={})
|
49
49
|
pathes_and_range_values =
|
50
50
|
case range_value
|
51
51
|
when Range
|
@@ -53,6 +53,9 @@ class FilesystemAdapter < Base
|
|
53
53
|
else
|
54
54
|
single_file_query(hash_value, range_value)
|
55
55
|
end
|
56
|
+
if limit = query_options[:limit]
|
57
|
+
pathes_and_range_values = pathes_and_range_values.first(limit)
|
58
|
+
end
|
56
59
|
pathes_and_range_values.inject([]) do |memo, (path, doc_range_value)|
|
57
60
|
doc_range_value = nil if doc_range_value == ""
|
58
61
|
key = [hash_value, doc_range_value]
|
data/spec/model/base_spec.rb
CHANGED
@@ -291,7 +291,7 @@ describe Kvom::Model::Base do
|
|
291
291
|
end
|
292
292
|
end
|
293
293
|
|
294
|
-
describe "adapter.query(<hash_value>, <range_spec>)" do
|
294
|
+
describe "adapter.query(<hash_value>, <range_spec>, <query_options>)" do
|
295
295
|
|
296
296
|
def set_of_keys(documents)
|
297
297
|
keys = documents.map{|doc| doc.key}.to_set
|
@@ -319,6 +319,12 @@ describe Kvom::Model::Base do
|
|
319
319
|
[one_001, one_002, one_0021, one_0022, one_3, two_two, three_empty]
|
320
320
|
end
|
321
321
|
|
322
|
+
it 'should be able to limit results' do
|
323
|
+
adapter.query(volatile_id('one'), Range.new('0001', '0022'), :limit => 2).length.should eq(2)
|
324
|
+
adapter.query(volatile_id('one'), Range.new('0001', '0022'), :limit => 4).length.should eq(4)
|
325
|
+
adapter.query(volatile_id('one'), Range.new('0001', '0022'), :limit => 8).length.should eq(4)
|
326
|
+
end
|
327
|
+
|
322
328
|
context "when range is a single value" do
|
323
329
|
context "when the doc exists" do
|
324
330
|
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.
|
4
|
+
version: 6.8.3.1.23895778
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 1.5.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 1.5.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: activesupport
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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: -10481197
|
191
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
192
|
none: false
|
193
193
|
requirements:
|