simply_stored 0.3.9 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +38 -0
- data/README.md +45 -24
- data/lib/simply_stored/couch/association_property.rb +27 -0
- data/lib/simply_stored/couch/belongs_to.rb +5 -7
- data/lib/simply_stored/couch/finders.rb +5 -1
- data/lib/simply_stored/couch/has_and_belongs_to_many.rb +202 -0
- data/lib/simply_stored/couch/has_many.rb +6 -51
- data/lib/simply_stored/couch/has_one.rb +4 -29
- data/lib/simply_stored/couch/properties.rb +11 -0
- data/lib/simply_stored/couch.rb +38 -2
- data/lib/simply_stored/instance_methods.rb +68 -29
- data/lib/simply_stored.rb +3 -1
- data/test/{couchdb/couch_active_model_compatibility_test.rb → active_model_compatibility_test.rb} +2 -2
- data/test/{couchdb/couch_belongs_to_test.rb → belongs_to_test.rb} +13 -3
- data/test/{couchdb/couch_conflict_handling_test.rb → conflict_handling_test.rb} +3 -3
- data/test/{couchdb/couch_finder_test.rb → finder_test.rb} +8 -3
- data/test/fixtures/couch.rb +55 -0
- data/test/has_and_belongs_to_many_test.rb +639 -0
- data/test/{couchdb/couch_has_many_test.rb → has_many_test.rb} +13 -3
- data/test/{couchdb/couch_has_one_test.rb → has_one_test.rb} +13 -3
- data/test/{couchdb/couch_instance_lifecycle_test.rb → instance_lifecycle_test.rb} +3 -3
- data/test/{couchdb/couch_mass_assignment_protection_test.rb → mass_assignment_protection_test.rb} +3 -3
- data/test/{couchdb/couch_s3_test.rb → s3_test.rb} +3 -3
- data/test/{couchdb/couch_soft_deletable_test.rb → soft_deletable_test.rb} +3 -3
- data/test/test_helper.rb +1 -5
- data/test/{couchdb/couch_validations_test.rb → validations_test.rb} +3 -3
- data/test/{couchdb/custom_views_test.rb → views_test.rb} +3 -3
- metadata +36 -234
- data/lib/simply_stored/simpledb/associations.rb +0 -215
- data/lib/simply_stored/simpledb/attributes.rb +0 -173
- data/lib/simply_stored/simpledb/storag.rb +0 -85
- data/lib/simply_stored/simpledb/validations.rb +0 -88
- data/lib/simply_stored/simpledb.rb +0 -216
- data/test/fixtures/simpledb/item.rb +0 -11
- data/test/fixtures/simpledb/item_daddy.rb +0 -8
- data/test/fixtures/simpledb/log_item.rb +0 -3
- data/test/fixtures/simpledb/namespace_bar.rb +0 -5
- data/test/fixtures/simpledb/namespace_foo.rb +0 -7
- data/test/fixtures/simpledb/protected_item.rb +0 -3
- data/test/simply_stored_simpledb_test.rb +0 -1376
- data/test/vendor/dhaka-2.2.1/lib/dhaka/dot/dot.rb +0 -29
- data/test/vendor/dhaka-2.2.1/lib/dhaka/evaluator/evaluator.rb +0 -133
- data/test/vendor/dhaka-2.2.1/lib/dhaka/grammar/closure_hash.rb +0 -15
- data/test/vendor/dhaka-2.2.1/lib/dhaka/grammar/grammar.rb +0 -240
- data/test/vendor/dhaka-2.2.1/lib/dhaka/grammar/grammar_symbol.rb +0 -27
- data/test/vendor/dhaka-2.2.1/lib/dhaka/grammar/precedence.rb +0 -19
- data/test/vendor/dhaka-2.2.1/lib/dhaka/grammar/production.rb +0 -36
- data/test/vendor/dhaka-2.2.1/lib/dhaka/lexer/accept_actions.rb +0 -36
- data/test/vendor/dhaka-2.2.1/lib/dhaka/lexer/alphabet.rb +0 -21
- data/test/vendor/dhaka-2.2.1/lib/dhaka/lexer/compiled_lexer.rb +0 -46
- data/test/vendor/dhaka-2.2.1/lib/dhaka/lexer/dfa.rb +0 -121
- data/test/vendor/dhaka-2.2.1/lib/dhaka/lexer/lexeme.rb +0 -32
- data/test/vendor/dhaka-2.2.1/lib/dhaka/lexer/lexer.rb +0 -70
- data/test/vendor/dhaka-2.2.1/lib/dhaka/lexer/lexer_run.rb +0 -78
- data/test/vendor/dhaka-2.2.1/lib/dhaka/lexer/regex_grammar.rb +0 -392
- data/test/vendor/dhaka-2.2.1/lib/dhaka/lexer/regex_parser.rb +0 -2010
- data/test/vendor/dhaka-2.2.1/lib/dhaka/lexer/regex_tokenizer.rb +0 -14
- data/test/vendor/dhaka-2.2.1/lib/dhaka/lexer/specification.rb +0 -96
- data/test/vendor/dhaka-2.2.1/lib/dhaka/lexer/state.rb +0 -68
- data/test/vendor/dhaka-2.2.1/lib/dhaka/lexer/state_machine.rb +0 -37
- data/test/vendor/dhaka-2.2.1/lib/dhaka/parser/action.rb +0 -55
- data/test/vendor/dhaka-2.2.1/lib/dhaka/parser/channel.rb +0 -58
- data/test/vendor/dhaka-2.2.1/lib/dhaka/parser/compiled_parser.rb +0 -51
- data/test/vendor/dhaka-2.2.1/lib/dhaka/parser/conflict.rb +0 -54
- data/test/vendor/dhaka-2.2.1/lib/dhaka/parser/item.rb +0 -42
- data/test/vendor/dhaka-2.2.1/lib/dhaka/parser/parse_result.rb +0 -50
- data/test/vendor/dhaka-2.2.1/lib/dhaka/parser/parse_tree.rb +0 -66
- data/test/vendor/dhaka-2.2.1/lib/dhaka/parser/parser.rb +0 -165
- data/test/vendor/dhaka-2.2.1/lib/dhaka/parser/parser_methods.rb +0 -11
- data/test/vendor/dhaka-2.2.1/lib/dhaka/parser/parser_run.rb +0 -39
- data/test/vendor/dhaka-2.2.1/lib/dhaka/parser/parser_state.rb +0 -74
- data/test/vendor/dhaka-2.2.1/lib/dhaka/parser/token.rb +0 -22
- data/test/vendor/dhaka-2.2.1/lib/dhaka/runtime.rb +0 -51
- data/test/vendor/dhaka-2.2.1/lib/dhaka/tokenizer/tokenizer.rb +0 -190
- data/test/vendor/dhaka-2.2.1/lib/dhaka.rb +0 -62
- data/test/vendor/dhaka-2.2.1/test/all_tests.rb +0 -5
- data/test/vendor/dhaka-2.2.1/test/arithmetic/arithmetic_evaluator.rb +0 -64
- data/test/vendor/dhaka-2.2.1/test/arithmetic/arithmetic_evaluator_test.rb +0 -43
- data/test/vendor/dhaka-2.2.1/test/arithmetic/arithmetic_grammar.rb +0 -41
- data/test/vendor/dhaka-2.2.1/test/arithmetic/arithmetic_grammar_test.rb +0 -9
- data/test/vendor/dhaka-2.2.1/test/arithmetic/arithmetic_test_methods.rb +0 -9
- data/test/vendor/dhaka-2.2.1/test/arithmetic/arithmetic_tokenizer.rb +0 -39
- data/test/vendor/dhaka-2.2.1/test/arithmetic/arithmetic_tokenizer_test.rb +0 -38
- data/test/vendor/dhaka-2.2.1/test/arithmetic_precedence/arithmetic_precedence_evaluator.rb +0 -43
- data/test/vendor/dhaka-2.2.1/test/arithmetic_precedence/arithmetic_precedence_grammar.rb +0 -24
- data/test/vendor/dhaka-2.2.1/test/arithmetic_precedence/arithmetic_precedence_grammar_test.rb +0 -30
- data/test/vendor/dhaka-2.2.1/test/arithmetic_precedence/arithmetic_precedence_lexer_specification.rb +0 -23
- data/test/vendor/dhaka-2.2.1/test/arithmetic_precedence/arithmetic_precedence_parser_test.rb +0 -33
- data/test/vendor/dhaka-2.2.1/test/brackets/bracket_grammar.rb +0 -23
- data/test/vendor/dhaka-2.2.1/test/brackets/bracket_tokenizer.rb +0 -22
- data/test/vendor/dhaka-2.2.1/test/brackets/brackets_test.rb +0 -28
- data/test/vendor/dhaka-2.2.1/test/chittagong/chittagong_driver.rb +0 -46
- data/test/vendor/dhaka-2.2.1/test/chittagong/chittagong_driver_test.rb +0 -276
- data/test/vendor/dhaka-2.2.1/test/chittagong/chittagong_evaluator.rb +0 -284
- data/test/vendor/dhaka-2.2.1/test/chittagong/chittagong_evaluator_test.rb +0 -38
- data/test/vendor/dhaka-2.2.1/test/chittagong/chittagong_grammar.rb +0 -104
- data/test/vendor/dhaka-2.2.1/test/chittagong/chittagong_lexer.rb +0 -109
- data/test/vendor/dhaka-2.2.1/test/chittagong/chittagong_lexer_specification.rb +0 -37
- data/test/vendor/dhaka-2.2.1/test/chittagong/chittagong_lexer_test.rb +0 -58
- data/test/vendor/dhaka-2.2.1/test/chittagong/chittagong_parser.rb +0 -879
- data/test/vendor/dhaka-2.2.1/test/chittagong/chittagong_parser_test.rb +0 -55
- data/test/vendor/dhaka-2.2.1/test/chittagong/chittagong_test.rb +0 -170
- data/test/vendor/dhaka-2.2.1/test/core/another_lalr_but_not_slr_grammar.rb +0 -20
- data/test/vendor/dhaka-2.2.1/test/core/compiled_parser_test.rb +0 -44
- data/test/vendor/dhaka-2.2.1/test/core/dfa_test.rb +0 -170
- data/test/vendor/dhaka-2.2.1/test/core/evaluator_test.rb +0 -22
- data/test/vendor/dhaka-2.2.1/test/core/grammar_test.rb +0 -83
- data/test/vendor/dhaka-2.2.1/test/core/lalr_but_not_slr_grammar.rb +0 -19
- data/test/vendor/dhaka-2.2.1/test/core/lexer_test.rb +0 -139
- data/test/vendor/dhaka-2.2.1/test/core/malformed_grammar.rb +0 -7
- data/test/vendor/dhaka-2.2.1/test/core/malformed_grammar_test.rb +0 -8
- data/test/vendor/dhaka-2.2.1/test/core/nullable_grammar.rb +0 -21
- data/test/vendor/dhaka-2.2.1/test/core/parse_result_test.rb +0 -44
- data/test/vendor/dhaka-2.2.1/test/core/parser_state_test.rb +0 -24
- data/test/vendor/dhaka-2.2.1/test/core/parser_test.rb +0 -131
- data/test/vendor/dhaka-2.2.1/test/core/precedence_grammar.rb +0 -17
- data/test/vendor/dhaka-2.2.1/test/core/precedence_grammar_test.rb +0 -9
- data/test/vendor/dhaka-2.2.1/test/core/rr_conflict_grammar.rb +0 -21
- data/test/vendor/dhaka-2.2.1/test/core/simple_grammar.rb +0 -22
- data/test/vendor/dhaka-2.2.1/test/core/sr_conflict_grammar.rb +0 -16
- data/test/vendor/dhaka-2.2.1/test/dhaka_test_helper.rb +0 -17
- data/test/vendor/dhaka-2.2.1/test/fake_logger.rb +0 -17
- data/test/vendor/simplerdb-0.2/lib/simplerdb/client_exception.rb +0 -10
- data/test/vendor/simplerdb-0.2/lib/simplerdb/db.rb +0 -146
- data/test/vendor/simplerdb-0.2/lib/simplerdb/query_language.rb +0 -266
- data/test/vendor/simplerdb-0.2/lib/simplerdb/server.rb +0 -33
- data/test/vendor/simplerdb-0.2/lib/simplerdb/servlet.rb +0 -191
- data/test/vendor/simplerdb-0.2/lib/simplerdb.rb +0 -3
- data/test/vendor/simplerdb-0.2/test/functional_test.rb +0 -81
- data/test/vendor/simplerdb-0.2/test/query_evaluator_test.rb +0 -73
- data/test/vendor/simplerdb-0.2/test/query_parser_test.rb +0 -64
- data/test/vendor/simplerdb-0.2/test/simplerdb_test.rb +0 -80
@@ -1,64 +0,0 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
require 'simplerdb/query_language'
|
3
|
-
|
4
|
-
# Tests the query parser
|
5
|
-
class QueryParserTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
# Taken from an AWS forum post
|
8
|
-
VALID = <<END
|
9
|
-
['attrR' = 'random']
|
10
|
-
['attrR' != 'random']
|
11
|
-
['attrR' < 'random']
|
12
|
-
['attrR' <= 'random']
|
13
|
-
['attrR' starts-with 'random']
|
14
|
-
['attrR' starts-with '0000009000']
|
15
|
-
['attrR' = 'random1' or 'attrR' = 'random2']
|
16
|
-
not ['attrR'='random' or 'attrR'='random']
|
17
|
-
not ['attrR'='random']
|
18
|
-
['attrR1' = 'random1'] union ['attrR2' = 'random2']
|
19
|
-
['attrR1' = 'random1'] union ['attrR2' < 'random2']
|
20
|
-
['attrR1' = 'random1'] union not ['attrR2' = 'random2']
|
21
|
-
['attrR1' = 'random1'] intersection ['attrR2' = 'random2']
|
22
|
-
['attrR1' = 'random1'] intersection not ['attrR2' = 'random2']
|
23
|
-
['attrR1' = 'random1'] intersection ['attrR2' < 'random2']
|
24
|
-
['attrR1' starts-with '0000009000'] intersection ['attrR2' >= 'random2']
|
25
|
-
['attrR1' > '0000000100'] intersection ['attrR2' < '0000200000'] intersection ['attrR3' > '0000000200']
|
26
|
-
['attrR1' = 'random1'] union ['attrR2' = 'random2'] intersection ['attrR3' = 'random3']
|
27
|
-
['attrR1' = 'random1'] intersection ['attrR2' = 'random2'] intersection ['attrR3' = 'random3']
|
28
|
-
['attrR1' = 'random1'] intersection ['attrR2' = 'random2'] intersection ['attrR3' = 'random3']
|
29
|
-
['attrR1' = 'random1'] union ['attrR2' = 'random2'] union ['attrR3' = 'random3']
|
30
|
-
['attrR1' > '0000000100'] intersection ['attrR2' < '0000200000'] intersection ['attrR3' > '0000000200']
|
31
|
-
END
|
32
|
-
|
33
|
-
INVALID = <<END
|
34
|
-
['attrR' == 'random']
|
35
|
-
['attrR' - 'random']
|
36
|
-
['attrR' < 'random]
|
37
|
-
['attrR' <= 'rand'om']
|
38
|
-
['attrR' starts with 'random']
|
39
|
-
['attrR' union '0000009000']
|
40
|
-
['attrR' = 'random1' or 'attrR' = 'random2'] foo ['foo' = 'bar']
|
41
|
-
[]
|
42
|
-
['bar']
|
43
|
-
['']
|
44
|
-
END
|
45
|
-
|
46
|
-
def setup
|
47
|
-
@lexer = Dhaka::Lexer.new(SimplerDB::QueryLexerSpec)
|
48
|
-
@parser = Dhaka::Parser.new(SimplerDB::QueryGrammar)
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_valid_queries
|
52
|
-
VALID.each do |query|
|
53
|
-
result = @parser.parse(@lexer.lex(query.strip!))
|
54
|
-
assert result.is_a?(Dhaka::ParseSuccessResult), query
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_invalid_queries
|
59
|
-
INVALID.each do |query|
|
60
|
-
result = @parser.parse(@lexer.lex(query.strip!))
|
61
|
-
assert !result.is_a?(Dhaka::ParseSuccessResult), query
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
require 'simplerdb/db'
|
3
|
-
|
4
|
-
class SimplerDBTest < Test::Unit::TestCase
|
5
|
-
include SimplerDB
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@db = DB.instance
|
9
|
-
end
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
@db.reset
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_create_list_domains
|
16
|
-
%w| a b c c c |.each { |d| @db.create_domain(d) }
|
17
|
-
assert @db.list_domains[0].size == 3
|
18
|
-
|
19
|
-
domains,token = @db.list_domains(1)
|
20
|
-
assert domains.size == 1
|
21
|
-
assert token == 1
|
22
|
-
|
23
|
-
domains,token = @db.list_domains(1, 1)
|
24
|
-
assert domains.size == 1
|
25
|
-
assert token == 2
|
26
|
-
|
27
|
-
domains,token = @db.list_domains(10,2)
|
28
|
-
assert domains.size == 1
|
29
|
-
assert token.nil?
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_delete_domain
|
33
|
-
%w| a b c |.each { |d| @db.create_domain(d) }
|
34
|
-
@db.delete_domain('b')
|
35
|
-
domains,token = @db.list_domains
|
36
|
-
assert domains.size == 2
|
37
|
-
assert domains[0] == 'a' && domains[1] == 'c'
|
38
|
-
|
39
|
-
@db.delete_domain('xxxxx')
|
40
|
-
assert domains.size == 2
|
41
|
-
assert domains[0] == 'a' && domains[1] == 'c'
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_put_get_attributes
|
45
|
-
@db.create_domain("test")
|
46
|
-
|
47
|
-
attrs = [AttributeParam.new("a1", "v1"), AttributeParam.new("a1", "v2"), AttributeParam.new("a2", "v1")]
|
48
|
-
@db.put_attributes("test", "item1", attrs)
|
49
|
-
assert @db.get_attributes("test", "item1").size == 3
|
50
|
-
assert @db.get_attributes("test", "item1", "a2").size == 1
|
51
|
-
assert @db.get_attributes("test", "item1", "a1").size == 2
|
52
|
-
|
53
|
-
attrs = [AttributeParam.new("a1", "v3")]
|
54
|
-
@db.put_attributes("test", "item1", attrs)
|
55
|
-
assert @db.get_attributes("test", "item1", "a1").size == 3
|
56
|
-
|
57
|
-
assert @db.get_attributes("test", "itemXXXXX", "a2").size == 0
|
58
|
-
|
59
|
-
# Replacement
|
60
|
-
attrs = [AttributeParam.new("a1", "v1"), AttributeParam.new("a1", "v2"), AttributeParam.new("a1", "v3")]
|
61
|
-
@db.put_attributes("test", "item_repl", attrs)
|
62
|
-
assert @db.get_attributes("test", "item_repl", "a1").size == 3
|
63
|
-
attrs = [AttributeParam.new("a1", "v4", true)]
|
64
|
-
@db.put_attributes("test", "item_repl", attrs)
|
65
|
-
assert @db.get_attributes("test", "item_repl", "a1").size == 1
|
66
|
-
@db.get_attributes("test", "item_repl", "a1")[0].value == "v4"
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_delete_attributes
|
70
|
-
@db.create_domain("test")
|
71
|
-
|
72
|
-
attrs = [AttributeParam.new("a1", "v1"), AttributeParam.new("a1", "v2"), AttributeParam.new("a2", "v1")]
|
73
|
-
@db.put_attributes("test", "item1", attrs)
|
74
|
-
@db.delete_attributes("test", "item1", [AttributeParam.new("a1", "v1")])
|
75
|
-
assert @db.get_attributes("test", "item1").size == 2
|
76
|
-
@db.delete_attributes("test", "item1", [AttributeParam.new("a1", "v1")])
|
77
|
-
assert @db.get_attributes("test", "item1").size == 2
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|