persistence 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/persistence.rb +0 -1
- data/lib/persistence/adapter/abstract.rb +1 -1
- data/lib/persistence/adapter/abstract/enable_disable.rb +1 -1
- data/lib/persistence/adapter/abstract/primary_key/id_property_string.rb +1 -1
- data/lib/persistence/adapter/abstract/primary_key/simple.rb +1 -1
- data/lib/persistence/adapter/mock/bucket/index/index_interface.rb +1 -1
- data/lib/persistence/cursor/atomic.rb +2 -2
- data/lib/persistence/object.rb +1 -1
- data/lib/persistence/object/autodetermine.rb +5 -4
- data/lib/persistence/object/class_instance.rb +12 -8
- data/lib/persistence/object/complex.rb +4 -4
- data/lib/persistence/object/complex/array.rb +6 -4
- data/lib/persistence/object/complex/array/class_instance.rb +1 -1
- data/lib/persistence/object/complex/array/object_instance.rb +1 -1
- data/lib/persistence/object/complex/attributes/attributes_array.rb +1 -1
- data/lib/persistence/object/complex/hash.rb +6 -4
- data/lib/persistence/object/complex/hash/class_instance.rb +1 -1
- data/lib/persistence/object/complex/hash/object_instance.rb +1 -1
- data/lib/persistence/object/complex/object_instance.rb +3 -3
- data/lib/persistence/object/flat.rb +6 -5
- data/lib/persistence/object/flat/class_instance.rb +2 -2
- data/lib/persistence/object/flat/file.rb +4 -3
- data/lib/persistence/object/flat/file/class_instance.rb +23 -30
- data/lib/persistence/object/flat/file/file_persistence.rb +4 -53
- data/lib/persistence/object/flat/file/object_instance.rb +21 -42
- data/lib/persistence/object/index.rb +0 -1
- data/lib/persistence/object/index_hash.rb +1 -1
- data/lib/persistence/object/object_instance.rb +11 -11
- data/lib/persistence/object/parse_persistence_args.rb +2 -108
- data/lib/persistence/object/parse_persistence_args/class_instance.rb +124 -0
- data/lib/persistence/object/parse_persistence_args/object_instance.rb +124 -0
- data/lib/persistence/port/bucket/bucket_interface.rb +0 -18
- data/lib/persistence/port/port_interface.rb +1 -19
- data/lib/requires.rb +10 -9
- data/spec/persistence/object/complex/attributes_spec.rb +1 -140
- data/spec/persistence/object/flat/bignum_spec.rb +12 -4
- data/spec/persistence/object/flat/class_spec.rb +9 -4
- data/spec/persistence/object/flat/file/class_instance_spec.rb +0 -1
- data/spec/persistence/object/flat/file_spec.rb +6 -9
- data/spec/persistence/object/indexes/block_index_spec.rb +1 -1
- data/spec/persistence/object/parse_persistence_args/class_instance_spec.rb +61 -0
- data/spec/persistence/object/parse_persistence_args/object_instance_spec.rb +63 -0
- data/spec/persistence/object_spec.rb +48 -82
- data/spec/persistence/port/bucket/index/bucket_index_spec.rb +1 -0
- data/spec/{Persistence_spec.rb → persistence_spec.rb} +0 -0
- metadata +8 -5
- data/spec/persistence/object/parse_persistence_args_spec.rb +0 -65
@@ -1,65 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative '../../../lib/persistence.rb'
|
3
|
-
|
4
|
-
describe ::Persistence::Object::ParsePersistenceArgs do
|
5
|
-
|
6
|
-
before :all do
|
7
|
-
::Persistence.enable_port( :mock1, ::Persistence::Adapter::Mock.new )
|
8
|
-
class ::Persistence::Object::ParsePersistenceArgs::Mock
|
9
|
-
include ::Persistence::Object::Flat::File
|
10
|
-
attr_accessor :indexes
|
11
|
-
class IndexMock
|
12
|
-
end
|
13
|
-
def indexes
|
14
|
-
return { :index => IndexMock }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
after :all do
|
20
|
-
::Persistence.disable_port( :mock1 )
|
21
|
-
end
|
22
|
-
|
23
|
-
######################
|
24
|
-
# process_file_key #
|
25
|
-
######################
|
26
|
-
|
27
|
-
it 'can process a file key for flat persistence' do
|
28
|
-
file_instance = File.open( __FILE__ )
|
29
|
-
instance = ::Persistence::Object::ParsePersistenceArgs::Mock.new
|
30
|
-
instance.persistence_port.persist_files_by_path!
|
31
|
-
instance.process_file_key( file_instance ).should == file_instance.path
|
32
|
-
instance.persistence_port.persists_files_by_content!
|
33
|
-
instance.process_file_key( file_instance ).should == file_instance.readlines.join
|
34
|
-
end
|
35
|
-
|
36
|
-
#########################################
|
37
|
-
# parse_args_for_index_value_no_value #
|
38
|
-
#########################################
|
39
|
-
|
40
|
-
it 'can parse args for indexed or non-indexed processing' do
|
41
|
-
instance = ::Persistence::Object::ParsePersistenceArgs::Mock.new
|
42
|
-
lambda { instance.parse_args_for_index_value_no_value( [], true ) }.should raise_error( ::Persistence::Exception::KeyValueRequired )
|
43
|
-
# 0 args
|
44
|
-
args = []
|
45
|
-
instance.parse_args_for_index_value_no_value( args ).should == [ nil, nil, true ]
|
46
|
-
# 1 arg: index
|
47
|
-
args = [ :index ]
|
48
|
-
instance.parse_args_for_index_value_no_value( args ).should == [ ::Persistence::Object::ParsePersistenceArgs::Mock::IndexMock, nil, true ]
|
49
|
-
# 2 args: index, key
|
50
|
-
args = [ :index, :key ]
|
51
|
-
instance.parse_args_for_index_value_no_value( args ).should == [ ::Persistence::Object::ParsePersistenceArgs::Mock::IndexMock, :key, false ]
|
52
|
-
# 2 args: no index, global id
|
53
|
-
args = [ nil, 0 ]
|
54
|
-
instance.parse_args_for_index_value_no_value( args ).should == [ nil, 0, false ]
|
55
|
-
# test special case: file key
|
56
|
-
file_instance = File.open( __FILE__ )
|
57
|
-
args = [ :index, file_instance ]
|
58
|
-
instance.persistence_port.persist_files_by_path!
|
59
|
-
instance.parse_args_for_index_value_no_value( args ).should == [ ::Persistence::Object::ParsePersistenceArgs::Mock::IndexMock, ::Persistence::Object::Flat::File::Path.new( file_instance.path ), false ]
|
60
|
-
instance.persistence_port.persists_files_by_content!
|
61
|
-
instance.parse_args_for_index_value_no_value( args ).should == [ ::Persistence::Object::ParsePersistenceArgs::Mock::IndexMock, ::Persistence::Object::Flat::File::Contents.new( file_instance.readlines.join ), false ]
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|