jor 0.1.1
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/.gitignore +3 -0
- data/Gemfile +2 -0
- data/LICENCE +22 -0
- data/README.md +319 -0
- data/Rakefile +10 -0
- data/config.ru +2 -0
- data/jor.gemspec +29 -0
- data/lib/jor.rb +14 -0
- data/lib/jor/collection.rb +449 -0
- data/lib/jor/doc.rb +62 -0
- data/lib/jor/errors.rb +96 -0
- data/lib/jor/server.rb +52 -0
- data/lib/jor/storage.rb +88 -0
- data/lib/jor/version.rb +3 -0
- data/test/test_helper.rb +11 -0
- data/test/test_helpers/fixtures.rb +71 -0
- data/test/unit/collection_test.rb +884 -0
- data/test/unit/doc_test.rb +139 -0
- data/test/unit/server_test.rb +113 -0
- data/test/unit/storage_test.rb +171 -0
- data/test/unit/test_case.rb +21 -0
- metadata +170 -0
@@ -0,0 +1,139 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class StorageTest < JOR::Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
@jor.create_collection("test")
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_all_paths
|
11
|
+
doc = create_sample_doc_restaurant({"_id" => 1})
|
12
|
+
paths = JOR::Doc.paths("",doc)
|
13
|
+
|
14
|
+
expected_paths = [
|
15
|
+
{"path_to"=>"/_id", "obj"=>1, "class"=>Fixnum},
|
16
|
+
{"path_to"=>"/name", "obj"=>"restaurant", "class"=>String},
|
17
|
+
{"path_to"=>"/stars", "obj"=>3, "class"=>Fixnum},
|
18
|
+
{"path_to"=>"/cuisine", "obj"=>"asian", "class"=>String},
|
19
|
+
{"path_to"=>"/cuisine", "obj"=>"japanese", "class"=>String},
|
20
|
+
{"path_to"=>"/address/address", "obj"=>"Main St 100", "class"=>String},
|
21
|
+
{"path_to"=>"/address/city", "obj"=>"Ann Arbor", "class"=>String},
|
22
|
+
{"path_to"=>"/address/zipcode", "obj"=>"08104", "class"=>String},
|
23
|
+
{"path_to"=>"/description", "obj"=>"very long description that we might not want to index", "class"=>String},
|
24
|
+
{"path_to"=>"/wines/name", "obj"=>"wine1", "class"=>String},
|
25
|
+
{"path_to"=>"/wines/year", "obj"=>1998, "class"=>Fixnum},
|
26
|
+
{"path_to"=>"/wines/type", "obj"=>"garnatxa", "class"=>String},
|
27
|
+
{"path_to"=>"/wines/type", "obj"=>"merlot", "class"=>String},
|
28
|
+
{"path_to"=>"/wines/name", "obj"=>"wine2", "class"=>String},
|
29
|
+
{"path_to"=>"/wines/year", "obj"=>2009, "class"=>Fixnum},
|
30
|
+
{"path_to"=>"/wines/type", "obj"=>"syrah", "class"=>String},
|
31
|
+
{"path_to"=>"/wines/type", "obj"=>"merlot", "class"=>String}
|
32
|
+
]
|
33
|
+
|
34
|
+
assert_equal expected_paths, paths
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_path_selectors
|
38
|
+
doc = {"_id" => 1, "year" => 1898, "list" => {"quantity" => 15}}
|
39
|
+
paths = JOR::Doc.paths("",doc)
|
40
|
+
|
41
|
+
expected_paths = [
|
42
|
+
{"path_to"=>"/_id", "obj"=>1, "class"=>Fixnum},
|
43
|
+
{"path_to"=>"/year", "obj"=>1898, "class"=>Fixnum},
|
44
|
+
{"path_to"=>"/list/quantity", "obj"=>15, "class"=>Fixnum}
|
45
|
+
]
|
46
|
+
assert_equal expected_paths, paths
|
47
|
+
|
48
|
+
doc = {"_id" => 1, "year" => 1898, "list" => {"quantity" => {"$lt" => 60}}}
|
49
|
+
paths = JOR::Doc.paths("",doc)
|
50
|
+
|
51
|
+
expected_paths = [
|
52
|
+
{"path_to"=>"/_id", "obj"=>1, "class"=>Fixnum},
|
53
|
+
{"path_to"=>"/year", "obj"=>1898, "class"=>Fixnum},
|
54
|
+
{"path_to"=>"/list/quantity", "obj"=>{"$lt"=>60}, "class"=>Hash, "selector"=>true}
|
55
|
+
]
|
56
|
+
assert_equal expected_paths, paths
|
57
|
+
|
58
|
+
doc = {"_id" => 1, "year" => 1898, "list" => {"quantity" => {"$gt" => 10, "$lt" => 60}}}
|
59
|
+
paths = JOR::Doc.paths("",doc)
|
60
|
+
|
61
|
+
expected_paths = [
|
62
|
+
{"path_to"=>"/_id", "obj"=>1, "class"=>Fixnum},
|
63
|
+
{"path_to"=>"/year", "obj"=>1898, "class"=>Fixnum},
|
64
|
+
{"path_to"=>"/list/quantity", "obj"=>{"$gt"=>10, "$lt"=>60}, "class"=>Hash, "selector"=>true}
|
65
|
+
]
|
66
|
+
assert_equal expected_paths, paths
|
67
|
+
|
68
|
+
doc = {"_id" => {"$in" => [1, 2, 42]}}
|
69
|
+
paths = JOR::Doc.paths("",doc)
|
70
|
+
expected_paths = [
|
71
|
+
{"path_to"=>"/_id", "obj"=>{"$in"=>[1, 2, 42]}, "class"=>Hash, "selector"=>true}
|
72
|
+
]
|
73
|
+
assert_equal expected_paths, paths
|
74
|
+
|
75
|
+
doc = {"_id" => {"$all" => [1, 2, 42]}}
|
76
|
+
paths = JOR::Doc.paths("",doc)
|
77
|
+
expected_paths = [
|
78
|
+
{"path_to"=>"/_id", "obj"=>{"$all"=>[1, 2, 42]}, "class"=>Hash, "selector"=>true}
|
79
|
+
]
|
80
|
+
assert_equal expected_paths, paths
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_difference
|
84
|
+
|
85
|
+
doc = {"_id" => 1, "year" => 1898,
|
86
|
+
"list" => {"quantity" => 15, "extra" => "long description that you want to skip"}}
|
87
|
+
paths = JOR::Doc.paths("",doc)
|
88
|
+
|
89
|
+
expected_paths = [
|
90
|
+
{"path_to"=>"/_id", "obj"=>1, "class"=>Fixnum},
|
91
|
+
{"path_to"=>"/year", "obj"=>1898, "class"=>Fixnum},
|
92
|
+
{"path_to"=>"/list/quantity", "obj"=>15, "class"=>Fixnum},
|
93
|
+
{"path_to"=>"/list/extra", "obj"=>"long description that you want to skip", "class"=>String}
|
94
|
+
]
|
95
|
+
assert_equal expected_paths, paths
|
96
|
+
|
97
|
+
paths_to_exclude = JOR::Doc.paths("",{"_id" => 1})
|
98
|
+
|
99
|
+
assert_raise JOR::FieldIdCannotBeExcludedFromIndex do
|
100
|
+
JOR::Doc.difference(paths,paths_to_exclude)
|
101
|
+
end
|
102
|
+
|
103
|
+
paths_to_exclude = JOR::Doc.paths("",{"list" => {"extra" => ""}})
|
104
|
+
|
105
|
+
expected_paths = [
|
106
|
+
{"path_to"=>"/list/extra", "obj"=>"", "class"=>String}
|
107
|
+
]
|
108
|
+
assert_equal expected_paths, paths_to_exclude
|
109
|
+
|
110
|
+
diff_paths = JOR::Doc.difference(paths, paths_to_exclude)
|
111
|
+
|
112
|
+
expected_paths = [
|
113
|
+
{"path_to"=>"/_id", "obj"=>1, "class"=>Fixnum},
|
114
|
+
{"path_to"=>"/year", "obj"=>1898, "class"=>Fixnum},
|
115
|
+
{"path_to"=>"/list/quantity", "obj"=>15, "class"=>Fixnum}
|
116
|
+
]
|
117
|
+
assert_equal expected_paths, diff_paths
|
118
|
+
|
119
|
+
paths_to_exclude = JOR::Doc.paths("",{"list" => true})
|
120
|
+
diff_paths = JOR::Doc.difference(paths, paths_to_exclude)
|
121
|
+
|
122
|
+
expected_paths = [
|
123
|
+
{"path_to"=>"/_id", "obj"=>1, "class"=>Fixnum},
|
124
|
+
{"path_to"=>"/year", "obj"=>1898, "class"=>Fixnum},
|
125
|
+
]
|
126
|
+
assert_equal expected_paths, diff_paths
|
127
|
+
|
128
|
+
|
129
|
+
paths_to_exclude = JOR::Doc.paths("",{"list" => {"extra" => true}, "year" => true})
|
130
|
+
diff_paths = JOR::Doc.difference(paths, paths_to_exclude)
|
131
|
+
|
132
|
+
expected_paths = [
|
133
|
+
{"path_to"=>"/_id", "obj"=>1, "class"=>Fixnum},
|
134
|
+
{"path_to"=>"/list/quantity", "obj"=>15, "class"=>Fixnum}
|
135
|
+
]
|
136
|
+
assert_equal expected_paths, diff_paths
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class ServerTest < JOR::Test::Unit::TestCase
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
def app
|
7
|
+
JOR::Server.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def setup
|
11
|
+
super
|
12
|
+
@jor.create_collection("test")
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_calling_methods
|
16
|
+
|
17
|
+
put '/last_id'
|
18
|
+
assert_equal 422, last_response.status
|
19
|
+
assert_equal "Collection \"last_id\" does not exist", JSON::parse(last_response.body)["error"]
|
20
|
+
|
21
|
+
put '/test.last_id'
|
22
|
+
assert_equal 200, last_response.status
|
23
|
+
assert_equal 0, JSON::parse(last_response.body)["value"]
|
24
|
+
|
25
|
+
put '/test.last_id'
|
26
|
+
assert_equal 200, last_response.status
|
27
|
+
assert_equal 0, JSON::parse(last_response.body)["value"]
|
28
|
+
|
29
|
+
doc1 = create_sample_doc_restaurant({"_id" => 1})
|
30
|
+
|
31
|
+
put '/test.insert', [doc1].to_json
|
32
|
+
assert_equal 200, last_response.status
|
33
|
+
|
34
|
+
doc2 = create_sample_doc_restaurant({"_id" => 2})
|
35
|
+
put '/test.insert', [doc2].to_json
|
36
|
+
assert_equal 200, last_response.status
|
37
|
+
|
38
|
+
docs = [create_sample_doc_restaurant({"_id" => 3}), create_sample_doc_restaurant({"_id" => 4})]
|
39
|
+
put '/test.insert', [docs].to_json
|
40
|
+
assert_equal 200, last_response.status
|
41
|
+
|
42
|
+
put '/test.find', [{"_id" => 4}].to_json
|
43
|
+
assert_equal 200, last_response.status
|
44
|
+
results = JSON::parse(last_response.body)
|
45
|
+
assert_equal 1, results.size
|
46
|
+
|
47
|
+
put '/test.find', [{}].to_json
|
48
|
+
assert_equal 200, last_response.status
|
49
|
+
results = JSON::parse(last_response.body)
|
50
|
+
assert_equal 4, results.size
|
51
|
+
4.times do |i|
|
52
|
+
assert_equal i+1, results[i]["_id"]
|
53
|
+
end
|
54
|
+
|
55
|
+
put '/test.find', [{}, {"reversed" => true}].to_json
|
56
|
+
assert_equal 200, last_response.status
|
57
|
+
results = JSON::parse(last_response.body)
|
58
|
+
assert_equal 4, results.size
|
59
|
+
4.times do |i|
|
60
|
+
assert_equal 4-i, results[i]["_id"]
|
61
|
+
end
|
62
|
+
|
63
|
+
put '/test.find', [{},{"reversed" => true}].to_json
|
64
|
+
assert_equal 200, last_response.status
|
65
|
+
results = JSON::parse(last_response.body)
|
66
|
+
assert_equal 4, results.size
|
67
|
+
4.times do |i|
|
68
|
+
assert_equal 4-i, results[i]["_id"]
|
69
|
+
end
|
70
|
+
|
71
|
+
put '/test.find', [{"fake" => "super_fake"}].to_json
|
72
|
+
assert_equal 200, last_response.status
|
73
|
+
results = JSON::parse(last_response.body)
|
74
|
+
assert_equal 0, results.size
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_create_collection
|
79
|
+
put '/create_collection', ["with_autoincrement", {:auto_increment => true}].to_json
|
80
|
+
assert_equal 200, last_response.status
|
81
|
+
|
82
|
+
put '/create_collection', ["without_autoincrement", {:auto_increment => false}].to_json
|
83
|
+
assert_equal 200, last_response.status
|
84
|
+
|
85
|
+
put '/collections', [].to_json
|
86
|
+
assert_equal 200, last_response.status
|
87
|
+
results = JSON::parse(last_response.body)
|
88
|
+
|
89
|
+
assert_equal ["with_autoincrement", "without_autoincrement", "test"].sort, results.sort
|
90
|
+
|
91
|
+
put '/with_autoincrement.insert', [{"foo" => "bar"}].to_json
|
92
|
+
assert_equal 200, last_response.status
|
93
|
+
|
94
|
+
put '/with_autoincrement.insert', [{"_id" => 42, "foo" => "bar"}].to_json
|
95
|
+
assert_equal 422, last_response.status
|
96
|
+
results = JSON::parse(last_response.body)
|
97
|
+
assert_equal JOR::DocumentDoesNotNeedId.new("with_autoincrement").to_s, results["error"]
|
98
|
+
|
99
|
+
put '/without_autoincrement.insert', [{"foo" => "bar"}].to_json
|
100
|
+
assert_equal 422, last_response.status
|
101
|
+
results = JSON::parse(last_response.body)
|
102
|
+
assert_equal JOR::DocumentNeedsId.new("without_autoincrement").to_s, results["error"]
|
103
|
+
|
104
|
+
put '/without_autoincrement.insert', [{"_id" => 42, "foo" => "bar"}].to_json
|
105
|
+
assert_equal 200, last_response.status
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_is_not_put
|
109
|
+
post '/create_collection', ["with_autoincrement", {:auto_increment => true}].to_json
|
110
|
+
assert_equal 422, last_response.status
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class StorageTest < JOR::Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_create_collection
|
10
|
+
@jor.create_collection("coll_foo")
|
11
|
+
@jor.create_collection("coll_bar")
|
12
|
+
assert_equal ["coll_foo", "coll_bar"].sort, @jor.collections.sort
|
13
|
+
|
14
|
+
@jor.create_collection("coll_zoe")
|
15
|
+
assert_equal ["coll_foo", "coll_bar", "coll_zoe"].sort, @jor.collections.sort
|
16
|
+
|
17
|
+
assert_raise JOR::CollectionAlreadyExists do
|
18
|
+
@jor.create_collection("coll_zoe")
|
19
|
+
end
|
20
|
+
assert_equal ["coll_foo", "coll_bar", "coll_zoe"].sort, @jor.collections.sort
|
21
|
+
|
22
|
+
assert_raise JOR::CollectionNotValid do
|
23
|
+
@jor.create_collection("collections")
|
24
|
+
end
|
25
|
+
assert_equal ["coll_foo", "coll_bar", "coll_zoe"].sort, @jor.collections.sort
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_destroy_collection
|
30
|
+
@jor.create_collection("coll_1")
|
31
|
+
@jor.create_collection("coll_2")
|
32
|
+
@jor.create_collection("coll_3")
|
33
|
+
assert_equal ["coll_1", "coll_2", "coll_3"].sort, @jor.collections.sort
|
34
|
+
|
35
|
+
assert_raise JOR::CollectionDoesNotExist do
|
36
|
+
@jor.destroy_collection("foo")
|
37
|
+
end
|
38
|
+
assert_equal ["coll_1", "coll_2", "coll_3"].sort, @jor.collections.sort
|
39
|
+
|
40
|
+
@jor.destroy_collection("coll_1")
|
41
|
+
assert_equal ["coll_2", "coll_3"].sort, @jor.collections.sort
|
42
|
+
|
43
|
+
@jor.destroy_all()
|
44
|
+
assert_equal [].sort, @jor.collections.sort
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_destroy_all_does_not_leave_documents_hanging
|
48
|
+
|
49
|
+
@jor.create_collection("coll_1")
|
50
|
+
@jor.create_collection("coll_2")
|
51
|
+
@jor.create_collection("coll_3")
|
52
|
+
|
53
|
+
@jor.coll_1.insert(create_sample_doc_restaurant({"_id" => 1}))
|
54
|
+
@jor.coll_2.insert(create_sample_doc_restaurant({"_id" => 1}))
|
55
|
+
@jor.coll_3.insert(create_sample_doc_restaurant({"_id" => 1}))
|
56
|
+
|
57
|
+
assert_equal true, @jor.redis.keys("#{JOR::Storage::NAMESPACE}/coll_1/*").size > 0
|
58
|
+
assert_equal true, @jor.redis.keys("#{JOR::Storage::NAMESPACE}/coll_2/*").size > 0
|
59
|
+
assert_equal true, @jor.redis.keys("#{JOR::Storage::NAMESPACE}/coll_3/*").size > 0
|
60
|
+
assert_equal true, @jor.redis.keys("#{JOR::Storage::NAMESPACE}/collection/*").size > 0
|
61
|
+
|
62
|
+
assert_equal ["coll_1", "coll_2", "coll_3"].sort, @jor.collections.sort
|
63
|
+
|
64
|
+
keys_clean = []
|
65
|
+
keys_from_index = @jor.redis.smembers(@jor.coll_1.send(:idx_set_key,1))
|
66
|
+
keys_from_index.each do |key|
|
67
|
+
keys_clean << key.gsub("_zrem","").gsub("_srem","")
|
68
|
+
end
|
69
|
+
|
70
|
+
assert_equal @jor.redis.keys("#{JOR::Storage::NAMESPACE}/coll_1/idx/*").sort, keys_clean.sort
|
71
|
+
|
72
|
+
@jor.destroy_all()
|
73
|
+
|
74
|
+
assert_equal [], @jor.collections
|
75
|
+
|
76
|
+
puts @jor.redis.keys("*")
|
77
|
+
|
78
|
+
assert_equal 0, @jor.redis.keys("#{JOR::Storage::NAMESPACE}/coll_1/*").size
|
79
|
+
assert_equal 0, @jor.redis.keys("#{JOR::Storage::NAMESPACE}/coll_2/*").size
|
80
|
+
assert_equal 0, @jor.redis.keys("#{JOR::Storage::NAMESPACE}/coll_3/*").size
|
81
|
+
assert_equal 0, @jor.redis.keys("#{JOR::Storage::NAMESPACE}/collection/*").size
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_collection_has_not_been_created_or_removed
|
86
|
+
|
87
|
+
assert_raise JOR::CollectionDoesNotExist do
|
88
|
+
@jor.restaurant.insert(create_sample_doc_restaurant({"_id" => 1}))
|
89
|
+
end
|
90
|
+
|
91
|
+
@jor.create_collection("restaurant")
|
92
|
+
@jor.restaurant.insert(create_sample_doc_restaurant({"_id" => 1}))
|
93
|
+
@jor.restaurant.insert(create_sample_doc_restaurant({"_id" => 2}))
|
94
|
+
@jor.restaurant.insert(create_sample_doc_restaurant({"_id" => 3}))
|
95
|
+
assert_equal 3, @jor.restaurant.count()
|
96
|
+
|
97
|
+
@jor.destroy_collection("restaurant")
|
98
|
+
|
99
|
+
assert_raise JOR::CollectionDoesNotExist do
|
100
|
+
@jor.restaurant.insert(create_sample_doc_restaurant({"_id" => 1}))
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_switching_between_collections
|
106
|
+
@jor.create_collection("restaurant")
|
107
|
+
@jor.create_collection("cs")
|
108
|
+
|
109
|
+
10.times do |i|
|
110
|
+
@jor.restaurant.insert(create_sample_doc_restaurant({"_id" => i}))
|
111
|
+
end
|
112
|
+
|
113
|
+
assert_equal 10, @jor.restaurant.count()
|
114
|
+
assert_equal 0, @jor.cs.count()
|
115
|
+
|
116
|
+
100.times do |i|
|
117
|
+
@jor.cs.insert(create_sample_doc_cs({"_id" => i}))
|
118
|
+
end
|
119
|
+
assert_equal 10, @jor.restaurant.count()
|
120
|
+
assert_equal 100, @jor.cs.count()
|
121
|
+
|
122
|
+
@jor.destroy_collection("restaurant")
|
123
|
+
assert_raise JOR::CollectionDoesNotExist do
|
124
|
+
@jor.restaurant.count()
|
125
|
+
end
|
126
|
+
assert_equal 100, @jor.cs.count()
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_info
|
130
|
+
@jor.create_collection("restaurant")
|
131
|
+
@jor.create_collection("cs")
|
132
|
+
|
133
|
+
1000.times do |i|
|
134
|
+
@jor.cs.insert(create_sample_doc_cs({"_id" => i}))
|
135
|
+
end
|
136
|
+
|
137
|
+
2000.times do |i|
|
138
|
+
@jor.restaurant.insert(create_sample_doc_restaurant({"_id" => i}),
|
139
|
+
{:excluded_fields_to_index => {"description" => true}})
|
140
|
+
end
|
141
|
+
|
142
|
+
info = @jor.info
|
143
|
+
assert_equal true, info["used_memory_in_redis"] > 0
|
144
|
+
assert_equal 2, info["num_collections"]
|
145
|
+
assert_equal 2000, info["collections"]["restaurant"]["num_documents"]
|
146
|
+
assert_equal false, info["collections"]["restaurant"]["auto_increment"]
|
147
|
+
assert_equal 1000, info["collections"]["cs"]["num_documents"]
|
148
|
+
assert_equal false, info["collections"]["cs"]["auto_increment"]
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_deleting_collections_from_other_jor
|
152
|
+
@other_jor = JOR::Storage.new(@jor.redis)
|
153
|
+
@other_jor.create_collection("restaurant")
|
154
|
+
|
155
|
+
20.times do |i|
|
156
|
+
@other_jor.restaurant.insert create_sample_doc_restaurant({"_id" => i})
|
157
|
+
end
|
158
|
+
assert_equal 20, @other_jor.restaurant.count()
|
159
|
+
|
160
|
+
@jor.destroy_all
|
161
|
+
|
162
|
+
assert_raise JOR::CollectionDoesNotExist do
|
163
|
+
@jor.restaurant.count()
|
164
|
+
end
|
165
|
+
|
166
|
+
assert_raise JOR::CollectionDoesNotExist do
|
167
|
+
@other_jor.restaurant.count()
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
module JOR
|
4
|
+
module Test
|
5
|
+
module Unit
|
6
|
+
class TestCase < ::Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@jor = JOR::Storage.new(Redis.new(:db => 9, :driver => :hiredis))
|
9
|
+
JOR::Storage::NAMESPACE.replace("jor-test")
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
keys = @jor.redis.keys("jor-test/*")
|
14
|
+
@jor.redis.pipelined do
|
15
|
+
keys.each { |key| @jor.redis.del(key) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Josep M. Pujol
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-07-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: hiredis
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.4.5
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.4.5
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: redis
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - '='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 3.0.3
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.0.3
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rack
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.5.2
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - '='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.5.2
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rack-test
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: thin
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: JSON on top of Redis
|
111
|
+
email: josep@3scale.net
|
112
|
+
executables: []
|
113
|
+
extensions: []
|
114
|
+
extra_rdoc_files: []
|
115
|
+
files:
|
116
|
+
- .gitignore
|
117
|
+
- Gemfile
|
118
|
+
- LICENCE
|
119
|
+
- README.md
|
120
|
+
- Rakefile
|
121
|
+
- config.ru
|
122
|
+
- jor.gemspec
|
123
|
+
- lib/jor.rb
|
124
|
+
- lib/jor/collection.rb
|
125
|
+
- lib/jor/doc.rb
|
126
|
+
- lib/jor/errors.rb
|
127
|
+
- lib/jor/server.rb
|
128
|
+
- lib/jor/storage.rb
|
129
|
+
- lib/jor/version.rb
|
130
|
+
- test/test_helper.rb
|
131
|
+
- test/test_helpers/fixtures.rb
|
132
|
+
- test/unit/collection_test.rb
|
133
|
+
- test/unit/doc_test.rb
|
134
|
+
- test/unit/server_test.rb
|
135
|
+
- test/unit/storage_test.rb
|
136
|
+
- test/unit/test_case.rb
|
137
|
+
homepage: ''
|
138
|
+
licenses: []
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ! '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ! '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 1.8.24
|
158
|
+
signing_key:
|
159
|
+
specification_version: 3
|
160
|
+
summary: Storage engine for JSON documents using Redis. It allows fast find operations
|
161
|
+
(index) by any field of the JSON document (ala MongoDB)
|
162
|
+
test_files:
|
163
|
+
- test/test_helper.rb
|
164
|
+
- test/test_helpers/fixtures.rb
|
165
|
+
- test/unit/collection_test.rb
|
166
|
+
- test/unit/doc_test.rb
|
167
|
+
- test/unit/server_test.rb
|
168
|
+
- test/unit/storage_test.rb
|
169
|
+
- test/unit/test_case.rb
|
170
|
+
has_rdoc:
|