persistence 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/lib/persistence.rb +0 -1
  2. data/lib/persistence/adapter/abstract.rb +1 -1
  3. data/lib/persistence/adapter/abstract/enable_disable.rb +1 -1
  4. data/lib/persistence/adapter/abstract/primary_key/id_property_string.rb +1 -1
  5. data/lib/persistence/adapter/abstract/primary_key/simple.rb +1 -1
  6. data/lib/persistence/adapter/mock/bucket/index/index_interface.rb +1 -1
  7. data/lib/persistence/cursor/atomic.rb +2 -2
  8. data/lib/persistence/object.rb +1 -1
  9. data/lib/persistence/object/autodetermine.rb +5 -4
  10. data/lib/persistence/object/class_instance.rb +12 -8
  11. data/lib/persistence/object/complex.rb +4 -4
  12. data/lib/persistence/object/complex/array.rb +6 -4
  13. data/lib/persistence/object/complex/array/class_instance.rb +1 -1
  14. data/lib/persistence/object/complex/array/object_instance.rb +1 -1
  15. data/lib/persistence/object/complex/attributes/attributes_array.rb +1 -1
  16. data/lib/persistence/object/complex/hash.rb +6 -4
  17. data/lib/persistence/object/complex/hash/class_instance.rb +1 -1
  18. data/lib/persistence/object/complex/hash/object_instance.rb +1 -1
  19. data/lib/persistence/object/complex/object_instance.rb +3 -3
  20. data/lib/persistence/object/flat.rb +6 -5
  21. data/lib/persistence/object/flat/class_instance.rb +2 -2
  22. data/lib/persistence/object/flat/file.rb +4 -3
  23. data/lib/persistence/object/flat/file/class_instance.rb +23 -30
  24. data/lib/persistence/object/flat/file/file_persistence.rb +4 -53
  25. data/lib/persistence/object/flat/file/object_instance.rb +21 -42
  26. data/lib/persistence/object/index.rb +0 -1
  27. data/lib/persistence/object/index_hash.rb +1 -1
  28. data/lib/persistence/object/object_instance.rb +11 -11
  29. data/lib/persistence/object/parse_persistence_args.rb +2 -108
  30. data/lib/persistence/object/parse_persistence_args/class_instance.rb +124 -0
  31. data/lib/persistence/object/parse_persistence_args/object_instance.rb +124 -0
  32. data/lib/persistence/port/bucket/bucket_interface.rb +0 -18
  33. data/lib/persistence/port/port_interface.rb +1 -19
  34. data/lib/requires.rb +10 -9
  35. data/spec/persistence/object/complex/attributes_spec.rb +1 -140
  36. data/spec/persistence/object/flat/bignum_spec.rb +12 -4
  37. data/spec/persistence/object/flat/class_spec.rb +9 -4
  38. data/spec/persistence/object/flat/file/class_instance_spec.rb +0 -1
  39. data/spec/persistence/object/flat/file_spec.rb +6 -9
  40. data/spec/persistence/object/indexes/block_index_spec.rb +1 -1
  41. data/spec/persistence/object/parse_persistence_args/class_instance_spec.rb +61 -0
  42. data/spec/persistence/object/parse_persistence_args/object_instance_spec.rb +63 -0
  43. data/spec/persistence/object_spec.rb +48 -82
  44. data/spec/persistence/port/bucket/index/bucket_index_spec.rb +1 -0
  45. data/spec/{Persistence_spec.rb → persistence_spec.rb} +0 -0
  46. metadata +8 -5
  47. 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
-