aqua 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/.gitignore +2 -1
  2. data/Aqua.gemspec +14 -11
  3. data/Rakefile +1 -1
  4. data/VERSION +1 -1
  5. data/lib/aqua.rb +5 -7
  6. data/lib/aqua/object/config.rb +2 -3
  7. data/lib/aqua/object/initializers.rb +309 -0
  8. data/lib/aqua/object/pack.rb +56 -132
  9. data/lib/aqua/object/query.rb +30 -2
  10. data/lib/aqua/object/stub.rb +60 -95
  11. data/lib/aqua/object/tank.rb +1 -0
  12. data/lib/aqua/object/translator.rb +313 -0
  13. data/lib/aqua/object/unpack.rb +26 -227
  14. data/lib/aqua/store/couch_db/couch_db.rb +1 -0
  15. data/lib/aqua/store/couch_db/database.rb +1 -1
  16. data/lib/aqua/store/couch_db/design_document.rb +126 -2
  17. data/lib/aqua/store/couch_db/result_set.rb +36 -0
  18. data/lib/aqua/store/couch_db/storage_methods.rb +182 -17
  19. data/lib/aqua/store/storage.rb +4 -48
  20. data/lib/aqua/support/mash.rb +2 -3
  21. data/lib/aqua/support/set.rb +4 -16
  22. data/spec/object/object_fixtures/array_udder.rb +1 -1
  23. data/spec/object/object_fixtures/persistent.rb +0 -2
  24. data/spec/object/pack_spec.rb +137 -517
  25. data/spec/object/query_spec.rb +36 -6
  26. data/spec/object/stub_spec.rb +10 -9
  27. data/spec/object/translator_packing_spec.rb +402 -0
  28. data/spec/object/translator_unpacking_spec.rb +262 -0
  29. data/spec/object/unpack_spec.rb +162 -320
  30. data/spec/spec_helper.rb +18 -0
  31. data/spec/store/couchdb/design_document_spec.rb +148 -7
  32. data/spec/store/couchdb/result_set_spec.rb +95 -0
  33. data/spec/store/couchdb/storage_methods_spec.rb +150 -10
  34. metadata +13 -9
  35. data/lib/aqua/support/initializers.rb +0 -216
  36. data/spec/object/object_fixtures/grounded.rb +0 -13
  37. data/spec/object/object_fixtures/sugar.rb +0 -4
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aqua
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kane Baccigalupi
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-08 00:00:00 -07:00
12
+ date: 2009-11-18 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: "Even with ORMs like ActiveRecord, DataMapper which ease the pain of relational data storage, considerable developer effort goes into wrangling Ruby objects into their databases. Document-oriented databases have made it possible to store nested data structures that easily map to Ruby objects. Aqua (http://github.com/baccigalupi/aqua) is a new Ruby library that aims to painlessly persists objects, allowing developers to focus more on object oriented code and less on storage. Currently Aqua is in pre-alpha testing, with the following big things left to implement: A data query DSL and implementation; Support of all objects in the Standard Library; Class and code storage to allow the sharing and persistence of classes with their data."
16
+ description: "A Ruby Object Database ... just add water (and CouchDB). Even with ORMs like ActiveRecord, DataMapper which ease the pain of relational data storage, considerable developer effort goes into wrangling Ruby objects into their databases. Document-oriented databases have made it possible to store nested data structures that easily map to Ruby objects. Aqua (http://github.com/baccigalupi/aqua) is a new Ruby library that aims to painlessly persists objects, allowing developers to focus more on object oriented code and less on storage. Currently Aqua is in pre-alpha testing, with the following big things left to implement: A data query DSL and implementation; Support of all objects in the Standard Library; Class and code storage to allow the sharing and persistence of classes with their data. "
17
17
  email: baccigalupi@gmail.com
18
18
  executables: []
19
19
 
@@ -37,10 +37,12 @@ files:
37
37
  - lib/aqua/object/extensions/ar_style.rb
38
38
  - lib/aqua/object/extensions/property.rb
39
39
  - lib/aqua/object/extensions/validation.rb
40
+ - lib/aqua/object/initializers.rb
40
41
  - lib/aqua/object/pack.rb
41
42
  - lib/aqua/object/query.rb
42
43
  - lib/aqua/object/stub.rb
43
44
  - lib/aqua/object/tank.rb
45
+ - lib/aqua/object/translator.rb
44
46
  - lib/aqua/object/unpack.rb
45
47
  - lib/aqua/store/couch_db/attachments.rb
46
48
  - lib/aqua/store/couch_db/couch_db.rb
@@ -48,10 +50,10 @@ files:
48
50
  - lib/aqua/store/couch_db/design_document.rb
49
51
  - lib/aqua/store/couch_db/http_client/adapter/rest_client.rb
50
52
  - lib/aqua/store/couch_db/http_client/rest_api.rb
53
+ - lib/aqua/store/couch_db/result_set.rb
51
54
  - lib/aqua/store/couch_db/server.rb
52
55
  - lib/aqua/store/couch_db/storage_methods.rb
53
56
  - lib/aqua/store/storage.rb
54
- - lib/aqua/support/initializers.rb
55
57
  - lib/aqua/support/mash.rb
56
58
  - lib/aqua/support/set.rb
57
59
  - lib/aqua/support/string_extensions.rb
@@ -60,15 +62,15 @@ files:
60
62
  - spec/object/object_fixtures/array_udder.rb
61
63
  - spec/object/object_fixtures/canned_hash.rb
62
64
  - spec/object/object_fixtures/gerbilmiester.rb
63
- - spec/object/object_fixtures/grounded.rb
64
65
  - spec/object/object_fixtures/log.rb
65
66
  - spec/object/object_fixtures/persistent.rb
66
- - spec/object/object_fixtures/sugar.rb
67
67
  - spec/object/object_fixtures/user.rb
68
68
  - spec/object/pack_spec.rb
69
69
  - spec/object/query_spec.rb
70
70
  - spec/object/stub_spec.rb
71
71
  - spec/object/tank_spec.rb
72
+ - spec/object/translator_packing_spec.rb
73
+ - spec/object/translator_unpacking_spec.rb
72
74
  - spec/object/unpack_spec.rb
73
75
  - spec/spec.opts
74
76
  - spec/spec_helper.rb
@@ -78,6 +80,7 @@ files:
78
80
  - spec/store/couchdb/design_document_spec.rb
79
81
  - spec/store/couchdb/fixtures_and_data/document_fixture.rb
80
82
  - spec/store/couchdb/fixtures_and_data/image_attach.png
83
+ - spec/store/couchdb/result_set_spec.rb
81
84
  - spec/store/couchdb/server_spec.rb
82
85
  - spec/store/couchdb/storage_methods_spec.rb
83
86
  - utils/code_statistics.rb
@@ -108,7 +111,7 @@ requirements: []
108
111
  rubyforge_project:
109
112
  rubygems_version: 1.3.5
110
113
  signing_key:
111
- specification_version: 2
114
+ specification_version: 3
112
115
  summary: "Aqua: A Ruby Object Database ... just add water (and CouchDB)"
113
116
  test_files:
114
117
  - spec/aqua_spec.rb
@@ -116,15 +119,15 @@ test_files:
116
119
  - spec/object/object_fixtures/array_udder.rb
117
120
  - spec/object/object_fixtures/canned_hash.rb
118
121
  - spec/object/object_fixtures/gerbilmiester.rb
119
- - spec/object/object_fixtures/grounded.rb
120
122
  - spec/object/object_fixtures/log.rb
121
123
  - spec/object/object_fixtures/persistent.rb
122
- - spec/object/object_fixtures/sugar.rb
123
124
  - spec/object/object_fixtures/user.rb
124
125
  - spec/object/pack_spec.rb
125
126
  - spec/object/query_spec.rb
126
127
  - spec/object/stub_spec.rb
127
128
  - spec/object/tank_spec.rb
129
+ - spec/object/translator_packing_spec.rb
130
+ - spec/object/translator_unpacking_spec.rb
128
131
  - spec/object/unpack_spec.rb
129
132
  - spec/spec_helper.rb
130
133
  - spec/store/couchdb/attachments_spec.rb
@@ -132,5 +135,6 @@ test_files:
132
135
  - spec/store/couchdb/database_spec.rb
133
136
  - spec/store/couchdb/design_document_spec.rb
134
137
  - spec/store/couchdb/fixtures_and_data/document_fixture.rb
138
+ - spec/store/couchdb/result_set_spec.rb
135
139
  - spec/store/couchdb/server_spec.rb
136
140
  - spec/store/couchdb/storage_methods_spec.rb
@@ -1,216 +0,0 @@
1
- # AQUA INITIALIZATION
2
- # Some object store state in a fundamental way, not in instance variables, that needs to be initialized.
3
- # Examples: Array, Numeric types, Hashes, Time ...
4
- # You can make any object requiring this initialization savable to aqua by
5
- # * including the Aqua::To module and extending the Aqua::From module
6
- # * building your own methods for #to_aqua, #to_aqua_init, MyClass.aqua_init
7
- # See set.rb in this file for more an example
8
- module Aqua
9
- module Initializers
10
- def self.included( klass )
11
- klass.class_eval do
12
- include InstanceMethods
13
- extend ClassMethods
14
-
15
- unless methods.include?( :hide_attributes )
16
- include Aqua::Pack::HiddenAttributes
17
- end
18
- end
19
- end
20
-
21
- module InstanceMethods
22
- def to_aqua( base_object )
23
- hash = {
24
- 'class' => to_aqua_class,
25
- 'init' => to_aqua_init( base_object )
26
- }
27
- ivars = _pack_instance_vars( base_object )
28
- hash.merge!( ivars ) if ivars
29
- hash
30
- end
31
-
32
- def to_aqua_class
33
- self.class.to_s
34
- end
35
-
36
- def _pack_instance_vars( base_object )
37
- { 'ivars' => base_object._pack_ivars( self ) } if instance_variables.size > 0
38
- end
39
-
40
- def to_aqua_init( base_object )
41
- self.to_s
42
- end
43
- end # InstanceMethods
44
-
45
- module ClassMethods
46
- def aqua_init( init )
47
- new( init )
48
- end
49
- end # ClassMethods
50
-
51
- end # Initializers
52
-
53
- end
54
-
55
- [ TrueClass, FalseClass, Time, Date, Fixnum, Bignum, Float, Rational, Hash, Array, OpenStruct, Range, File, Tempfile].each do |klass|
56
- klass.class_eval { include Aqua::Initializers }
57
- end
58
-
59
- class TrueClass
60
- def self.aqua_init( init )
61
- true
62
- end
63
-
64
- def to_aqua( base_object )
65
- true
66
- end
67
- end
68
-
69
- class FalseClass
70
- def self.aqua_init( init )
71
- false
72
- end
73
-
74
- def to_aqua( base_object )
75
- false
76
- end
77
- end
78
-
79
- class Date
80
- hide_attributes :sg, :of, :ajd
81
-
82
- def self.aqua_init( init )
83
- parse( init )
84
- end
85
- end
86
-
87
- class Time
88
- def self.aqua_init( init )
89
- parse( init )
90
- end
91
- end
92
-
93
- class Fixnum
94
- def self.aqua_init( init )
95
- init.to_i
96
- end
97
- end
98
-
99
- class Bignum
100
- def self.aqua_init( init )
101
- init.to_i
102
- end
103
- end
104
-
105
- class Float
106
- def self.aqua_init( init )
107
- init.to_f
108
- end
109
- end
110
-
111
- class Range
112
- def self.aqua_init( init )
113
- eval( init )
114
- end
115
- end
116
-
117
- class Rational
118
- def to_aqua_init( base_object )
119
- self.to_s.match(/(\d*)\/(\d*)/).to_a.slice(1,2)
120
- end
121
-
122
- def self.aqua_init( init )
123
- Rational( init[0].to_i, init[1].to_i )
124
- end
125
- end
126
-
127
- class Hash
128
- def to_aqua_init( base_object )
129
- return_hash = {}
130
- self.each do |raw_key, value|
131
- key_class = raw_key.class
132
- if key_class == Symbol
133
- key = ":#{raw_key.to_s}"
134
- elsif key_class == String
135
- key = raw_key
136
- else
137
- index = base_object._build_object_key( raw_key )
138
- key = "/OBJECT_#{index}"
139
- end
140
- return_hash[key] = base_object._pack_object( value )
141
- end
142
- return_hash
143
- end
144
-
145
- def self.aqua_init( init )
146
- new.replace( init )
147
- end
148
- end
149
-
150
- class Array
151
- def to_aqua_init( base_object )
152
- return_arr = []
153
- self.each do |obj|
154
- return_arr << base_object._pack_object( obj )
155
- end
156
- return_arr
157
- end
158
-
159
- def self.aqua_init( init )
160
- new.replace( init )
161
- end
162
- end
163
-
164
- class OpenStruct
165
- hide_attributes :table
166
-
167
- def to_aqua_init( base_object )
168
- instance_variable_get("@table").to_aqua_init( base_object )
169
- end
170
- end
171
-
172
- module Aqua
173
- module FileInitializations
174
- def to_aqua( base_object )
175
- hash = {
176
- 'class' => to_aqua_class,
177
- 'init' => to_aqua_init( base_object ),
178
- 'methods' => {
179
- 'content_type' => MIME::Types.type_for( path ).first,
180
- 'content_length' => stat.size
181
- }
182
- }
183
- ivars = _pack_instance_vars( base_object )
184
- hash.merge!( ivars ) if ivars
185
- hash
186
- end
187
-
188
- def to_aqua_class
189
- 'Aqua::FileStub'
190
- end
191
-
192
- def filename
193
- path.match(/([^\/]*)\z/).to_s
194
- end
195
-
196
- def to_aqua_init( base_object )
197
- name = filename
198
- base_object._pack_file(name, self)
199
- "/FILE_#{name}"
200
- end
201
- end # FileInitializations
202
- end # Aqua
203
-
204
- class File
205
- include Aqua::FileInitializations
206
- end
207
-
208
- class Tempfile
209
- include Aqua::FileInitializations
210
-
211
- hide_attributes :clean_proc, :data, :tmpname, :tmpfile, :_dc_obj
212
-
213
- def filename
214
- path.match(/([^\/]*)\.\d*\.\d*\z/).captures.first
215
- end
216
- end
@@ -1,13 +0,0 @@
1
- require 'ostruct'
2
- # this is a non-aquatic object
3
- class Grounded
4
- def initialize( hash = {} )
5
- hash.each do |key, value|
6
- send( "#{key}=", value )
7
- end
8
- end
9
-
10
- attr_accessor :hash_up, # a hash
11
- :arraynged, # an array
12
- :openly_structured # an ostruct
13
- end
@@ -1,4 +0,0 @@
1
- class Sugar
2
- aquatic # configured to :emded => false by default
3
- attr_accessor :sweetness
4
- end