persistence 0.0.1.alpha → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. data/CHANGELOG.md +4 -0
  2. data/README.md +260 -17
  3. data/lib/namespaces.rb +55 -0
  4. data/lib/persistence.rb +38 -3
  5. data/lib/persistence/adapter/abstract.rb +22 -0
  6. data/lib/persistence/adapter/abstract/enable_disable.rb +107 -0
  7. data/lib/persistence/adapter/abstract/primary_key/id_property_string.rb +33 -0
  8. data/lib/persistence/adapter/abstract/primary_key/simple.rb +29 -0
  9. data/lib/persistence/adapter/mock.rb +9 -0
  10. data/lib/persistence/adapter/mock/adapter_interface.rb +102 -0
  11. data/lib/persistence/adapter/mock/bucket.rb +9 -0
  12. data/lib/persistence/adapter/mock/bucket/bucket_interface.rb +260 -0
  13. data/lib/persistence/adapter/mock/bucket/index.rb +9 -0
  14. data/lib/persistence/adapter/mock/bucket/index/index_interface.rb +155 -0
  15. data/lib/persistence/adapter/mock/cursor.rb +9 -0
  16. data/lib/persistence/adapter/mock/cursor/cursor_interface.rb +238 -0
  17. data/lib/persistence/cursor.rb +11 -0
  18. data/lib/persistence/cursor/atomic.rb +110 -0
  19. data/lib/persistence/cursor/cursor_interface.rb +337 -0
  20. data/lib/persistence/exception/block_required.rb +7 -0
  21. data/lib/persistence/exception/conflicting_index_already_declared.rb +7 -0
  22. data/lib/persistence/exception/duplicate_violates_unique_index.rb +7 -0
  23. data/lib/persistence/exception/explicit_index_required.rb +7 -0
  24. data/lib/persistence/exception/indexing_block_failed_to_generate_keys.rb +7 -0
  25. data/lib/persistence/exception/indexing_object_requires_keys.rb +7 -0
  26. data/lib/persistence/exception/key_value_required.rb +7 -0
  27. data/lib/persistence/exception/no_port_enabled.rb +7 -0
  28. data/lib/persistence/object.rb +21 -0
  29. data/lib/persistence/object/autodetermine.rb +74 -0
  30. data/lib/persistence/object/class_instance.rb +1884 -0
  31. data/lib/persistence/object/complex.rb +17 -0
  32. data/lib/persistence/object/complex/array.rb +14 -0
  33. data/lib/persistence/object/complex/array/class_instance.rb +37 -0
  34. data/lib/persistence/object/complex/array/object_instance.rb +54 -0
  35. data/lib/persistence/object/complex/attributes.rb +1808 -0
  36. data/lib/persistence/object/complex/attributes/attributes_array.rb +32 -0
  37. data/lib/persistence/object/complex/attributes/attributes_hash.rb +187 -0
  38. data/lib/persistence/object/complex/attributes/default_atomic_non_atomic.rb +102 -0
  39. data/lib/persistence/object/complex/attributes/hash_to_port.rb +40 -0
  40. data/lib/persistence/object/complex/class_and_object_instance.rb +132 -0
  41. data/lib/persistence/object/complex/class_instance.rb +267 -0
  42. data/lib/persistence/object/complex/complex_object.rb +111 -0
  43. data/lib/persistence/object/complex/hash.rb +14 -0
  44. data/lib/persistence/object/complex/hash/class_instance.rb +40 -0
  45. data/lib/persistence/object/complex/hash/object_instance.rb +63 -0
  46. data/lib/persistence/object/complex/index/attribute_index.rb +10 -0
  47. data/lib/persistence/object/complex/index/attribute_index/attribute_index_interface.rb +43 -0
  48. data/lib/persistence/object/complex/object_instance.rb +469 -0
  49. data/lib/persistence/object/flat.rb +17 -0
  50. data/lib/persistence/object/flat/class_instance.rb +34 -0
  51. data/lib/persistence/object/flat/file.rb +14 -0
  52. data/lib/persistence/object/flat/file/class_instance.rb +122 -0
  53. data/lib/persistence/object/flat/file/contents.rb +7 -0
  54. data/lib/persistence/object/flat/file/file_persistence.rb +147 -0
  55. data/lib/persistence/object/flat/file/object_instance.rb +116 -0
  56. data/lib/persistence/object/flat/file/path.rb +9 -0
  57. data/lib/persistence/object/flat/object_instance.rb +24 -0
  58. data/lib/persistence/object/index.rb +479 -0
  59. data/lib/persistence/object/index/block_index.rb +10 -0
  60. data/lib/persistence/object/index/block_index/block_index_interface.rb +110 -0
  61. data/lib/persistence/object/index/explicit_index.rb +10 -0
  62. data/lib/persistence/object/index/explicit_index/explicit_index_interface.rb +57 -0
  63. data/lib/persistence/object/index_hash.rb +40 -0
  64. data/lib/persistence/object/object_instance.rb +322 -0
  65. data/lib/persistence/object/parse_persistence_args.rb +145 -0
  66. data/lib/persistence/port.rb +9 -0
  67. data/lib/persistence/port/bucket.rb +9 -0
  68. data/lib/persistence/port/bucket/bucket_index.rb +9 -0
  69. data/lib/persistence/port/bucket/bucket_interface.rb +685 -0
  70. data/lib/persistence/port/controller.rb +263 -0
  71. data/lib/persistence/port/port_interface.rb +417 -0
  72. data/lib/requires.rb +146 -0
  73. data/spec/Integration_spec.rb +53 -0
  74. data/spec/Persistence_spec.rb +175 -0
  75. data/spec/example_objects.rb +6 -0
  76. data/spec/example_objects/complex_object.rb +7 -0
  77. data/spec/example_objects/complex_object/array_object.rb +7 -0
  78. data/spec/example_objects/complex_object/hash_object.rb +7 -0
  79. data/spec/example_objects/flat_object.rb +7 -0
  80. data/spec/example_objects/flat_object/file_object.rb +7 -0
  81. data/spec/persistence/adapter/enable_disable_spec.rb +29 -0
  82. data/spec/persistence/adapter/mock/cursor_spec.rb +64 -0
  83. data/spec/persistence/adapter/mock_helpers.rb +27 -0
  84. data/spec/persistence/adapter/mock_helpers/bucket.rb +10 -0
  85. data/spec/persistence/adapter/mock_helpers/integration/dictionary_hash.rb +4 -0
  86. data/spec/persistence/adapter/mock_helpers/integration/note.rb +18 -0
  87. data/spec/persistence/adapter/mock_helpers/integration/notes_array.rb +4 -0
  88. data/spec/persistence/adapter/mock_helpers/integration/user.rb +44 -0
  89. data/spec/persistence/adapter/mock_helpers/integration/user/address.rb +18 -0
  90. data/spec/persistence/adapter/mock_helpers/integration/user/dictionary_entry.rb +12 -0
  91. data/spec/persistence/adapter/mock_helpers/integration/user/sub_account.rb +15 -0
  92. data/spec/persistence/adapter/mock_helpers/object.rb +87 -0
  93. data/spec/persistence/adapter/mock_helpers/port.rb +21 -0
  94. data/spec/persistence/adapter/mock_spec.rb +211 -0
  95. data/spec/persistence/adapter/primary_key/id_property_string_spec.rb +27 -0
  96. data/spec/persistence/adapter/primary_key/simple_spec.rb +19 -0
  97. data/spec/persistence/adapter/spec_abstract/adapter_spec.rb +223 -0
  98. data/spec/persistence/adapter/spec_abstract/cursor_spec.rb +116 -0
  99. data/spec/persistence/cursor/atomic_spec.rb +86 -0
  100. data/spec/persistence/cursor/object_and_class_instance_spec.rb +73 -0
  101. data/spec/persistence/cursor_spec.rb +128 -0
  102. data/spec/persistence/object/complex/attributes/persistence_hash/array_instance_spec.rb +51 -0
  103. data/spec/persistence/object/complex/attributes/persistence_hash/hash_instance_spec.rb +56 -0
  104. data/spec/persistence/object/complex/attributes_spec.rb +1717 -0
  105. data/spec/persistence/object/complex/complex_spec.rb +922 -0
  106. data/spec/persistence/object/complex/index/attribute_index_spec.rb +76 -0
  107. data/spec/persistence/object/flat/bignum_spec.rb +33 -0
  108. data/spec/persistence/object/flat/class_instance_spec.rb +30 -0
  109. data/spec/persistence/object/flat/class_spec.rb +38 -0
  110. data/spec/persistence/object/flat/complex_spec.rb +36 -0
  111. data/spec/persistence/object/flat/false_class_spec.rb +34 -0
  112. data/spec/persistence/object/flat/file/class_instance_spec.rb +54 -0
  113. data/spec/persistence/object/flat/file/object_instance_spec.rb +143 -0
  114. data/spec/persistence/object/flat/file_spec.rb +64 -0
  115. data/spec/persistence/object/flat/fixnum_spec.rb +32 -0
  116. data/spec/persistence/object/flat/float_spec.rb +32 -0
  117. data/spec/persistence/object/flat/indexing_spec.rb +38 -0
  118. data/spec/persistence/object/flat/rational_spec.rb +33 -0
  119. data/spec/persistence/object/flat/regexp_spec.rb +32 -0
  120. data/spec/persistence/object/flat/string_spec.rb +34 -0
  121. data/spec/persistence/object/flat/symbol_spec.rb +32 -0
  122. data/spec/persistence/object/flat/true_class_spec.rb +32 -0
  123. data/spec/persistence/object/indexes/block_index_spec.rb +119 -0
  124. data/spec/persistence/object/indexes/explicit_index_spec.rb +112 -0
  125. data/spec/persistence/object/parse_persistence_args_spec.rb +65 -0
  126. data/spec/persistence/object_spec.rb +310 -0
  127. data/spec/persistence/port/bucket/bucket_interface_spec.rb +146 -0
  128. data/spec/persistence/port/bucket/index/bucket_index_spec.rb +67 -0
  129. data/spec/persistence/port/bucket_spec.rb +20 -0
  130. data/spec/persistence/port/controller_spec.rb +60 -0
  131. data/spec/persistence/port/port_interface_spec.rb +105 -0
  132. metadata +178 -21
  133. data/.gitignore +0 -17
  134. data/Gemfile +0 -4
  135. data/LICENSE +0 -22
  136. data/Rakefile +0 -2
  137. data/lib/persistence/version.rb +0 -3
  138. data/persistence.gemspec +0 -17
@@ -0,0 +1,146 @@
1
+
2
+ require_relative '../../../../lib/persistence.rb'
3
+
4
+ describe ::Persistence::Port::Bucket::BucketInterface do
5
+
6
+ before :all do
7
+ ::Persistence.enable_port( :mock, ::Persistence::Adapter::Mock.new )
8
+ end
9
+
10
+ after :all do
11
+ ::Persistence.disable_port( :mock )
12
+ end
13
+
14
+ ################
15
+ # initialize #
16
+ ################
17
+
18
+ it 'can initialize with an adapter and bucket name' do
19
+ class ::Persistence::Port::Bucket::BucketInterface::Mock
20
+ include ::Persistence::Port::Bucket::BucketInterface
21
+ end
22
+ instance_two = ::Persistence::Port::Bucket::BucketInterface::Mock.new( :mock, :some_bucket )
23
+ instance_two.parent_port.should == ::Persistence.port( :mock )
24
+ instance_two.adapter_bucket.name.should == :some_bucket
25
+ end
26
+
27
+ #####################
28
+ # put_object! #
29
+ # count #
30
+ # get_object #
31
+ # get_flat_object #
32
+ # delete_object! #
33
+ #####################
34
+
35
+ it 'can serve as an adapter to a persistence bucket instance in an adapter instance' do
36
+ module ::Persistence::Port::Bucket::BucketInterface::PutGetDeleteObjectMock
37
+
38
+ class ::Persistence::Port::Bucket::BucketInterface::Mock
39
+ include ::Persistence::Port::Bucket::BucketInterface
40
+ end
41
+ class ::Persistence::Port::Bucket::BucketInterface::MockClass
42
+ attr_accessor :persistence_port, :persistence_id
43
+ def instance_variable_hash
44
+ persistence_hash = { }
45
+ instance_variables.each do |this_variable|
46
+ persistence_hash[ this_variable ] = instance_variable_get( this_variable )
47
+ end
48
+ return persistence_hash
49
+ end
50
+ alias_method :persistence_hash_to_port, :instance_variable_hash
51
+ def load_persistence_hash( port, persistence_hash )
52
+ self.persistence_port = port
53
+ persistence_hash.each do |this_variable, this_value|
54
+ instance_variable_set( this_variable, this_value )
55
+ end
56
+ return self
57
+ end
58
+ def self.instance_persistence_bucket
59
+ return @bucket ||= ::Persistence::Port::Bucket.new( :mock, self.to_s )
60
+ end
61
+ def persistence_bucket
62
+ return self.class.instance_persistence_bucket
63
+ end
64
+ def self.non_atomic_attribute_readers
65
+ return [ ]
66
+ end
67
+ end
68
+ instance = ::Persistence::Port::Bucket::BucketInterface::Mock.new( :mock, :some_bucket )
69
+ object = ::Persistence::Port::Bucket::BucketInterface::MockClass.new
70
+ instance.put_object!( object )
71
+ object.persistence_id.should_not == nil
72
+ instance.count.should == 1
73
+ instance.get_object( object.persistence_id ).instance_variable_hash.should == object.instance_variable_hash
74
+ instance.delete_object!( object.persistence_id )
75
+ instance.get_object( object.persistence_id ).should == nil
76
+ class StringMock < String
77
+ attr_accessor :persistence_id
78
+ def self.instance_persistence_bucket
79
+ return @bucket ||= ::Persistence::Port::Bucket.new( :mock, self.to_s )
80
+ end
81
+ def persistence_bucket
82
+ return self.class.instance_persistence_bucket
83
+ end
84
+ def persistence_hash_to_port
85
+ return { self.class.to_s => self }
86
+ end
87
+ end
88
+ string_object = StringMock.new( 'some string' )
89
+ instance.put_object!( string_object )
90
+ instance.get_flat_object( string_object.persistence_id ).should == string_object
91
+ instance.delete_object!( string_object.persistence_id )
92
+
93
+ end
94
+ end
95
+
96
+ ###################################
97
+ # delete_cascades? #
98
+ # get_attribute #
99
+ # put_attribute! #
100
+ # delete_attribute! #
101
+ # primary_key_for_attribute_name #
102
+ ###################################
103
+
104
+ it 'can serve as an adapter to a persistence bucket instance in an adapter instance' do
105
+ class ::Persistence::Port::Bucket::BucketInterface::Mock
106
+ include ::Persistence::Port::Bucket::BucketInterface
107
+ end
108
+ class ::Persistence::Port::Bucket::BucketInterface::MockClass
109
+ include ::CascadingConfiguration::Hash
110
+ attr_accessor :persistence_port, :persistence_bucket, :persistence_id
111
+ def persistence_hash_to_port
112
+ persistence_hash = { :simple_var => @simple_var }
113
+ return persistence_hash
114
+ end
115
+ def load_persistence_hash( port, persistence_hash )
116
+ self.persistence_port = port
117
+ persistence_hash.each do |this_variable, this_value|
118
+ instance_variable_set( this_variable, this_value )
119
+ end
120
+ return self
121
+ end
122
+ end
123
+ instance = ::Persistence::Port::Bucket::BucketInterface::Mock.new( :mock, :some_bucket )
124
+ sub_object = ::Persistence::Port::Bucket::BucketInterface::MockClass.new.instance_eval do
125
+ @simple_var = :value
126
+ self
127
+ end
128
+ sub_object.persistence_port = ::Persistence.port( :mock )
129
+ sub_object.persistence_bucket = instance
130
+ object = ::Persistence::Port::Bucket::BucketInterface::MockClass.new.instance_eval do
131
+ @simple_var = :some_value
132
+ self
133
+ end
134
+ object.persistence_port = ::Persistence.port( :mock )
135
+ object.persistence_bucket = instance
136
+ object.persistence_port.persistence_bucket( :some_bucket ).put_object!( object )
137
+ object.persistence_id.should_not == nil
138
+ instance.get_attribute( object, :simple_var ).should == :some_value
139
+ instance.put_attribute!( object, :simple_var, sub_object )
140
+ instance.get_attribute( object, :simple_var ).persistence_hash_to_port.should == sub_object.persistence_hash_to_port
141
+ instance.delete_attribute!( object, :simple_var )
142
+ instance.get_attribute( object, :simple_var ).should == nil
143
+ instance.primary_key_for_attribute_name( object, :simple_var ).should == :simple_var
144
+ end
145
+
146
+ end
@@ -0,0 +1,67 @@
1
+
2
+ require_relative '../../../../../lib/persistence.rb'
3
+
4
+ describe ::Persistence::Port::Bucket::BucketIndex do
5
+
6
+ it 'is a block index that runs on all inserts into a bucket' do
7
+ class ::Persistence::Port::Bucket::BucketIndex::Mock
8
+ include ::Persistence::Object
9
+ attr_accessor :some_value
10
+ end
11
+
12
+ object = ::Persistence::Port::Bucket::BucketIndex::Mock.new
13
+
14
+ ::Persistence.enable_port( :mock, ::Persistence::Adapter::Mock.new )
15
+
16
+ index_instance = object.persistence_bucket.create_index( :bucket_index ) do |object|
17
+ object.some_value
18
+ end
19
+
20
+ index_instance.is_a?( ::Persistence::Port::Bucket::BucketIndex ).should == true
21
+
22
+ ::Persistence.disable_port( :mock )
23
+
24
+ end
25
+
26
+ ##################
27
+ # create_index #
28
+ # has_index? #
29
+ # count #
30
+ # index #
31
+ ##################
32
+
33
+ it 'can create an index and then separately retrieve that index' do
34
+ # before port is open
35
+ class ::Persistence::Port::Bucket::BucketIndex::Mock
36
+ include ::Persistence::Object
37
+ attr_atomic_accessor :some_value, :some_other_value
38
+ end
39
+
40
+ bucket = ::Persistence::Port::Bucket::BucketIndex::Mock.instance_persistence_bucket
41
+ index_instance = bucket.create_index( :index ) do |object|
42
+ object.some_value
43
+ end
44
+ Proc.new { index_instance.adapter_index }.should raise_error
45
+ bucket.index( :index ).should == index_instance
46
+
47
+ # after port is open
48
+ ::Persistence.enable_port( :mock, ::Persistence::Adapter::Mock.new )
49
+ index_instance_two = bucket.create_index_with_duplicates( :other_index ) do |object|
50
+ object.some_other_value
51
+ end
52
+ index_instance_two.adapter_index.should_not == nil
53
+ bucket.index( :other_index ).should == index_instance_two
54
+
55
+ instance = ::Persistence::Port::Bucket::BucketIndex::Mock.new
56
+ instance.some_value = :a_value
57
+ bucket.put_object!( instance )
58
+ bucket.index( :index ).index_object( instance )
59
+ bucket.count.should == 1
60
+ bucket.index( :index ).count.should == 1
61
+ bucket.index( :other_index ).count.should == 0
62
+
63
+ ::Persistence.disable_port( :mock )
64
+
65
+ end
66
+
67
+ end
@@ -0,0 +1,20 @@
1
+
2
+ require_relative '../../../lib/persistence.rb'
3
+
4
+ describe ::Persistence::Port::Bucket do
5
+
6
+ before :all do
7
+ ::Persistence.enable_port( :mock, ::Persistence::Adapter::Mock.new )
8
+ end
9
+
10
+ after :all do
11
+ ::Persistence.disable_port( :mock )
12
+ end
13
+
14
+ it 'is a module cluster' do
15
+ ::Persistence::Port::Bucket.new( :mock, :some_bucket ).instance_eval do
16
+ is_a?( ::Persistence::Port::Bucket::BucketInterface ).should == true
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,60 @@
1
+
2
+ require_relative '../../../lib/persistence.rb'
3
+
4
+ describe ::Persistence::Port::Controller do
5
+
6
+ ###########################
7
+ # enable_port #
8
+ # port #
9
+ # current_port #
10
+ # disable_port #
11
+ # set_current_port #
12
+ # port_for_name_or_port #
13
+ ###########################
14
+
15
+ it 'can enable a port with an adapter instance, get it by name or as the current port, disable it, and re-enable it later' do
16
+ class ::Persistence::Port::Controller::Mock
17
+ extend ::Persistence::Port::Controller
18
+ mock_adapter_instance = ::Persistence::Adapter::Mock.new
19
+ first_port = enable_port( :mock_adapter, mock_adapter_instance )
20
+ mock_adapter_instance.enabled?.should == true
21
+ port( :mock_adapter ).should == first_port
22
+ first_port.enabled?.should == true
23
+ current_port.should == first_port
24
+ disable_port( :mock_adapter )
25
+ current_port.should == nil
26
+ mock_adapter_instance.disabled?.should == true
27
+ second_mock_adapter_instance = ::Persistence::Adapter::Mock.new
28
+ second_port = enable_port( :second_mock_adapter, second_mock_adapter_instance )
29
+ port( :second_mock_adapter ).should == second_port
30
+ second_port.enabled?.should == true
31
+ current_port.should == second_port
32
+ set_current_port( :mock_adapter )
33
+ current_port.should == first_port
34
+ current_port.disabled?.should == true
35
+ set_current_port( nil )
36
+ current_port.should == nil
37
+ disable_port( :mock_adapter )
38
+ disable_port( :second_mock_adapter )
39
+ end
40
+ end
41
+
42
+ ############################
43
+ # create_pending_buckets #
44
+ # pending_bucket #
45
+ ############################
46
+
47
+ it 'can allow a bucket to be initialized before its port is open' do
48
+ bucket_instance = ::Persistence.pending_bucket( ::Persistence::Port::Controller, :some_bucket )
49
+ ::Persistence.instance_eval do
50
+ pending_buckets.should == { ::Persistence::Port::Controller => bucket_instance }
51
+ end
52
+ ::Persistence.enable_port( :mock, ::Persistence::Adapter::Mock.new )
53
+ ::Persistence.instance_eval do
54
+ pending_buckets.should == {}
55
+ end
56
+ bucket_instance.parent_port.should == ::Persistence.port( :mock )
57
+ ::Persistence.disable_port( :mock )
58
+ end
59
+
60
+ end
@@ -0,0 +1,105 @@
1
+
2
+ require_relative '../../../lib/persistence.rb'
3
+
4
+ require_relative '../adapter/mock_helpers.rb'
5
+
6
+ describe ::Persistence::Port::PortInterface do
7
+
8
+ before :all do
9
+
10
+ class ::Persistence::Port::PortInterface::Mock
11
+ include ::Persistence::Port::PortInterface
12
+ end
13
+
14
+ @adapter = ::Persistence::Adapter::Mock.new
15
+ @port_interface = ::Persistence::Port::PortInterface::Mock.new( :port_name, @adapter )
16
+ @port_interface.enable
17
+
18
+ end
19
+
20
+ ################
21
+ # initialize #
22
+ ################
23
+
24
+ it 'can initialize with a port name and adapter instance' do
25
+ @port_interface.instance_eval do
26
+ name.should == :port_name
27
+ end
28
+ end
29
+
30
+ ###############
31
+ # enable #
32
+ # enabled? #
33
+ # disabled? #
34
+ # disable #
35
+ ###############
36
+
37
+ it 'can be enabled, disabled, and report whether it is enabled or not' do
38
+ @port_interface.instance_eval do
39
+ enable
40
+ enabled?.should == true
41
+ disabled?.should == false
42
+ disable
43
+ enabled?.should == false
44
+ disabled?.should == true
45
+ enable
46
+ end
47
+ end
48
+
49
+ ########################
50
+ # persistence_bucket #
51
+ ########################
52
+
53
+ it 'can return a persistence bucket instance linked to the bucket instance in the adapter' do
54
+ @port_interface.persistence_bucket( :some_bucket ).is_a?( ::Persistence::Port::Bucket ).should == true
55
+ end
56
+
57
+ ###################################
58
+ # put_object! #
59
+ # get_bucket_name_for_object_id #
60
+ # get_class_for_object_id #
61
+ # get_object #
62
+ # get_object #
63
+ # delete_object! #
64
+ # get_flat_object #
65
+ ###################################
66
+
67
+ it 'can interface with the adapter' do
68
+ @object = ::Persistence::Adapter::Abstract::Mock::Object.new
69
+ @object.class.instance_persistence_port = @port_interface
70
+ bucket = @port_interface.persistence_bucket( :some_bucket )
71
+ bucket.initialize_for_port( @port_interface )
72
+ @object.class.instance_persistence_bucket = bucket
73
+ @object.class.non_atomic_attribute_readers.push( :some_value, :other_value )
74
+ @object.instance_eval do
75
+ @some_value = :value
76
+ @other_value = :other_value
77
+ end
78
+ @port_interface.put_object!( @object )
79
+ @object.persistence_id.should_not == nil
80
+
81
+ @port_interface.get_bucket_name_for_object_id( @object.persistence_id ).should == @object.persistence_bucket.name
82
+ @port_interface.get_class_for_object_id( @object.persistence_id ).should == @object.class
83
+
84
+ persisted_object = @port_interface.get_object( @object.persistence_id )
85
+ persisted_object.persistence_id.should == @object.persistence_id
86
+ @port_interface.delete_object!( @object.persistence_id )
87
+ @port_interface.get_object( @object.persistence_id ).should == nil
88
+ class String
89
+ attr_accessor :persistence_id
90
+ def self.instance_persistence_bucket
91
+ return @bucket ||= ::Persistence::Adapter::Abstract::Mock::Object.instance_persistence_bucket
92
+ end
93
+ def persistence_bucket
94
+ return self.class.instance_persistence_bucket
95
+ end
96
+ def persistence_hash_to_port
97
+ return { self.class.to_s => self }
98
+ end
99
+ end
100
+ some_string = 'some string'
101
+ @port_interface.put_object!( some_string )
102
+ @port_interface.get_flat_object( some_string.persistence_id ).should == some_string
103
+ end
104
+
105
+ end
metadata CHANGED
@@ -1,32 +1,187 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: persistence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha
5
- prerelease: 6
4
+ version: 0.0.1
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - Joe Sak
8
+ - Asher
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-26 00:00:00.000000000 Z
13
- dependencies: []
14
- description: An attempt at abstracting the ORM layer from domain objects
15
- email:
16
- - joe@joesak.com
12
+ date: 2012-06-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: module-cluster
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
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'
30
+ - !ruby/object:Gem::Dependency
31
+ name: cascading-configuration
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
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: '0'
46
+ description: Store and retrieve Ruby objects without thinking twice about how they
47
+ are stored. Designed for maximum in flexibility and intuitive interface.
48
+ email: asher@ridiculouspower.com
17
49
  executables: []
18
50
  extensions: []
19
51
  extra_rdoc_files: []
20
52
  files:
21
- - .gitignore
22
- - Gemfile
23
- - LICENSE
24
- - README.md
25
- - Rakefile
53
+ - lib/namespaces.rb
54
+ - lib/persistence/adapter/abstract/enable_disable.rb
55
+ - lib/persistence/adapter/abstract/primary_key/id_property_string.rb
56
+ - lib/persistence/adapter/abstract/primary_key/simple.rb
57
+ - lib/persistence/adapter/abstract.rb
58
+ - lib/persistence/adapter/mock/adapter_interface.rb
59
+ - lib/persistence/adapter/mock/bucket/bucket_interface.rb
60
+ - lib/persistence/adapter/mock/bucket/index/index_interface.rb
61
+ - lib/persistence/adapter/mock/bucket/index.rb
62
+ - lib/persistence/adapter/mock/bucket.rb
63
+ - lib/persistence/adapter/mock/cursor/cursor_interface.rb
64
+ - lib/persistence/adapter/mock/cursor.rb
65
+ - lib/persistence/adapter/mock.rb
66
+ - lib/persistence/cursor/atomic.rb
67
+ - lib/persistence/cursor/cursor_interface.rb
68
+ - lib/persistence/cursor.rb
69
+ - lib/persistence/exception/block_required.rb
70
+ - lib/persistence/exception/conflicting_index_already_declared.rb
71
+ - lib/persistence/exception/duplicate_violates_unique_index.rb
72
+ - lib/persistence/exception/explicit_index_required.rb
73
+ - lib/persistence/exception/indexing_block_failed_to_generate_keys.rb
74
+ - lib/persistence/exception/indexing_object_requires_keys.rb
75
+ - lib/persistence/exception/key_value_required.rb
76
+ - lib/persistence/exception/no_port_enabled.rb
77
+ - lib/persistence/object/autodetermine.rb
78
+ - lib/persistence/object/class_instance.rb
79
+ - lib/persistence/object/complex/array/class_instance.rb
80
+ - lib/persistence/object/complex/array/object_instance.rb
81
+ - lib/persistence/object/complex/array.rb
82
+ - lib/persistence/object/complex/attributes/attributes_array.rb
83
+ - lib/persistence/object/complex/attributes/attributes_hash.rb
84
+ - lib/persistence/object/complex/attributes/default_atomic_non_atomic.rb
85
+ - lib/persistence/object/complex/attributes/hash_to_port.rb
86
+ - lib/persistence/object/complex/attributes.rb
87
+ - lib/persistence/object/complex/class_and_object_instance.rb
88
+ - lib/persistence/object/complex/class_instance.rb
89
+ - lib/persistence/object/complex/complex_object.rb
90
+ - lib/persistence/object/complex/hash/class_instance.rb
91
+ - lib/persistence/object/complex/hash/object_instance.rb
92
+ - lib/persistence/object/complex/hash.rb
93
+ - lib/persistence/object/complex/index/attribute_index/attribute_index_interface.rb
94
+ - lib/persistence/object/complex/index/attribute_index.rb
95
+ - lib/persistence/object/complex/object_instance.rb
96
+ - lib/persistence/object/complex.rb
97
+ - lib/persistence/object/flat/class_instance.rb
98
+ - lib/persistence/object/flat/file/class_instance.rb
99
+ - lib/persistence/object/flat/file/contents.rb
100
+ - lib/persistence/object/flat/file/file_persistence.rb
101
+ - lib/persistence/object/flat/file/object_instance.rb
102
+ - lib/persistence/object/flat/file/path.rb
103
+ - lib/persistence/object/flat/file.rb
104
+ - lib/persistence/object/flat/object_instance.rb
105
+ - lib/persistence/object/flat.rb
106
+ - lib/persistence/object/index/block_index/block_index_interface.rb
107
+ - lib/persistence/object/index/block_index.rb
108
+ - lib/persistence/object/index/explicit_index/explicit_index_interface.rb
109
+ - lib/persistence/object/index/explicit_index.rb
110
+ - lib/persistence/object/index.rb
111
+ - lib/persistence/object/index_hash.rb
112
+ - lib/persistence/object/object_instance.rb
113
+ - lib/persistence/object/parse_persistence_args.rb
114
+ - lib/persistence/object.rb
115
+ - lib/persistence/port/bucket/bucket_index.rb
116
+ - lib/persistence/port/bucket/bucket_interface.rb
117
+ - lib/persistence/port/bucket.rb
118
+ - lib/persistence/port/controller.rb
119
+ - lib/persistence/port/port_interface.rb
120
+ - lib/persistence/port.rb
26
121
  - lib/persistence.rb
27
- - lib/persistence/version.rb
28
- - persistence.gemspec
29
- homepage: ''
122
+ - lib/requires.rb
123
+ - spec/example_objects/complex_object/array_object.rb
124
+ - spec/example_objects/complex_object/hash_object.rb
125
+ - spec/example_objects/complex_object.rb
126
+ - spec/example_objects/flat_object/file_object.rb
127
+ - spec/example_objects/flat_object.rb
128
+ - spec/example_objects.rb
129
+ - spec/Integration_spec.rb
130
+ - spec/persistence/adapter/enable_disable_spec.rb
131
+ - spec/persistence/adapter/mock/cursor_spec.rb
132
+ - spec/persistence/adapter/mock_helpers/bucket.rb
133
+ - spec/persistence/adapter/mock_helpers/integration/dictionary_hash.rb
134
+ - spec/persistence/adapter/mock_helpers/integration/note.rb
135
+ - spec/persistence/adapter/mock_helpers/integration/notes_array.rb
136
+ - spec/persistence/adapter/mock_helpers/integration/user/address.rb
137
+ - spec/persistence/adapter/mock_helpers/integration/user/dictionary_entry.rb
138
+ - spec/persistence/adapter/mock_helpers/integration/user/sub_account.rb
139
+ - spec/persistence/adapter/mock_helpers/integration/user.rb
140
+ - spec/persistence/adapter/mock_helpers/object.rb
141
+ - spec/persistence/adapter/mock_helpers/port.rb
142
+ - spec/persistence/adapter/mock_helpers.rb
143
+ - spec/persistence/adapter/mock_spec.rb
144
+ - spec/persistence/adapter/primary_key/id_property_string_spec.rb
145
+ - spec/persistence/adapter/primary_key/simple_spec.rb
146
+ - spec/persistence/adapter/spec_abstract/adapter_spec.rb
147
+ - spec/persistence/adapter/spec_abstract/cursor_spec.rb
148
+ - spec/persistence/cursor/atomic_spec.rb
149
+ - spec/persistence/cursor/object_and_class_instance_spec.rb
150
+ - spec/persistence/cursor_spec.rb
151
+ - spec/persistence/object/complex/attributes/persistence_hash/array_instance_spec.rb
152
+ - spec/persistence/object/complex/attributes/persistence_hash/hash_instance_spec.rb
153
+ - spec/persistence/object/complex/attributes_spec.rb
154
+ - spec/persistence/object/complex/complex_spec.rb
155
+ - spec/persistence/object/complex/index/attribute_index_spec.rb
156
+ - spec/persistence/object/flat/bignum_spec.rb
157
+ - spec/persistence/object/flat/class_instance_spec.rb
158
+ - spec/persistence/object/flat/class_spec.rb
159
+ - spec/persistence/object/flat/complex_spec.rb
160
+ - spec/persistence/object/flat/false_class_spec.rb
161
+ - spec/persistence/object/flat/file/class_instance_spec.rb
162
+ - spec/persistence/object/flat/file/object_instance_spec.rb
163
+ - spec/persistence/object/flat/file_spec.rb
164
+ - spec/persistence/object/flat/fixnum_spec.rb
165
+ - spec/persistence/object/flat/float_spec.rb
166
+ - spec/persistence/object/flat/indexing_spec.rb
167
+ - spec/persistence/object/flat/rational_spec.rb
168
+ - spec/persistence/object/flat/regexp_spec.rb
169
+ - spec/persistence/object/flat/string_spec.rb
170
+ - spec/persistence/object/flat/symbol_spec.rb
171
+ - spec/persistence/object/flat/true_class_spec.rb
172
+ - spec/persistence/object/indexes/block_index_spec.rb
173
+ - spec/persistence/object/indexes/explicit_index_spec.rb
174
+ - spec/persistence/object/parse_persistence_args_spec.rb
175
+ - spec/persistence/object_spec.rb
176
+ - spec/persistence/port/bucket/bucket_interface_spec.rb
177
+ - spec/persistence/port/bucket/index/bucket_index_spec.rb
178
+ - spec/persistence/port/bucket_spec.rb
179
+ - spec/persistence/port/controller_spec.rb
180
+ - spec/persistence/port/port_interface_spec.rb
181
+ - spec/Persistence_spec.rb
182
+ - README.md
183
+ - CHANGELOG.md
184
+ homepage: http://rubygems.org/gems/persistence
30
185
  licenses: []
31
186
  post_install_message:
32
187
  rdoc_options: []
@@ -41,13 +196,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
41
196
  required_rubygems_version: !ruby/object:Gem::Requirement
42
197
  none: false
43
198
  requirements:
44
- - - ! '>'
199
+ - - ! '>='
45
200
  - !ruby/object:Gem::Version
46
- version: 1.3.1
201
+ version: '0'
47
202
  requirements: []
48
- rubyforge_project:
49
- rubygems_version: 1.8.16
203
+ rubyforge_project: persistence
204
+ rubygems_version: 1.8.23
50
205
  signing_key:
51
206
  specification_version: 3
52
- summary: There is no summary
207
+ summary: Persistence layer designed to take advantage of Ruby's object model. The
208
+ back-end is abstracted so that many different adapters can be created.
53
209
  test_files: []
210
+ has_rdoc: