aqua 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +7 -0
- data/Aqua.gemspec +121 -0
- data/LICENCE_COUCHREST +176 -0
- data/LICENSE +20 -0
- data/README.rdoc +105 -0
- data/Rakefile +83 -0
- data/VERSION +1 -0
- data/lib/aqua.rb +101 -0
- data/lib/aqua/object/config.rb +43 -0
- data/lib/aqua/object/extensions/ar_convert.rb +0 -0
- data/lib/aqua/object/extensions/ar_style.rb +0 -0
- data/lib/aqua/object/extensions/property.rb +0 -0
- data/lib/aqua/object/extensions/validation.rb +0 -0
- data/lib/aqua/object/pack.rb +306 -0
- data/lib/aqua/object/query.rb +18 -0
- data/lib/aqua/object/stub.rb +122 -0
- data/lib/aqua/object/tank.rb +54 -0
- data/lib/aqua/object/unpack.rb +253 -0
- data/lib/aqua/store/couch_db/attachments.rb +183 -0
- data/lib/aqua/store/couch_db/couch_db.rb +151 -0
- data/lib/aqua/store/couch_db/database.rb +186 -0
- data/lib/aqua/store/couch_db/design_document.rb +57 -0
- data/lib/aqua/store/couch_db/http_client/adapter/rest_client.rb +53 -0
- data/lib/aqua/store/couch_db/http_client/rest_api.rb +62 -0
- data/lib/aqua/store/couch_db/server.rb +103 -0
- data/lib/aqua/store/couch_db/storage_methods.rb +405 -0
- data/lib/aqua/store/storage.rb +59 -0
- data/lib/aqua/support/initializers.rb +216 -0
- data/lib/aqua/support/mash.rb +144 -0
- data/lib/aqua/support/set.rb +23 -0
- data/lib/aqua/support/string_extensions.rb +121 -0
- data/spec/aqua_spec.rb +19 -0
- data/spec/object/config_spec.rb +58 -0
- data/spec/object/object_fixtures/array_udder.rb +5 -0
- data/spec/object/object_fixtures/canned_hash.rb +5 -0
- data/spec/object/object_fixtures/gerbilmiester.rb +18 -0
- data/spec/object/object_fixtures/grounded.rb +13 -0
- data/spec/object/object_fixtures/log.rb +19 -0
- data/spec/object/object_fixtures/persistent.rb +12 -0
- data/spec/object/object_fixtures/sugar.rb +4 -0
- data/spec/object/object_fixtures/user.rb +38 -0
- data/spec/object/pack_spec.rb +607 -0
- data/spec/object/query_spec.rb +27 -0
- data/spec/object/stub_spec.rb +51 -0
- data/spec/object/tank_spec.rb +61 -0
- data/spec/object/unpack_spec.rb +361 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/store/couchdb/attachments_spec.rb +164 -0
- data/spec/store/couchdb/couch_db_spec.rb +104 -0
- data/spec/store/couchdb/database_spec.rb +161 -0
- data/spec/store/couchdb/design_document_spec.rb +43 -0
- data/spec/store/couchdb/fixtures_and_data/document_fixture.rb +3 -0
- data/spec/store/couchdb/fixtures_and_data/image_attach.png +0 -0
- data/spec/store/couchdb/server_spec.rb +96 -0
- data/spec/store/couchdb/storage_methods_spec.rb +408 -0
- data/utils/code_statistics.rb +134 -0
- data/utils/console +11 -0
- metadata +136 -0
data/.document
ADDED
data/.gitignore
ADDED
data/Aqua.gemspec
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{aqua}
|
8
|
+
s.version = "0.1.6"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Kane Baccigalupi"]
|
12
|
+
s.date = %q{2009-10-08}
|
13
|
+
s.description = %q{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.}
|
14
|
+
s.email = %q{baccigalupi@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"Aqua.gemspec",
|
23
|
+
"LICENCE_COUCHREST",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"lib/aqua.rb",
|
29
|
+
"lib/aqua/object/config.rb",
|
30
|
+
"lib/aqua/object/extensions/ar_convert.rb",
|
31
|
+
"lib/aqua/object/extensions/ar_style.rb",
|
32
|
+
"lib/aqua/object/extensions/property.rb",
|
33
|
+
"lib/aqua/object/extensions/validation.rb",
|
34
|
+
"lib/aqua/object/pack.rb",
|
35
|
+
"lib/aqua/object/query.rb",
|
36
|
+
"lib/aqua/object/stub.rb",
|
37
|
+
"lib/aqua/object/tank.rb",
|
38
|
+
"lib/aqua/object/unpack.rb",
|
39
|
+
"lib/aqua/store/couch_db/attachments.rb",
|
40
|
+
"lib/aqua/store/couch_db/couch_db.rb",
|
41
|
+
"lib/aqua/store/couch_db/database.rb",
|
42
|
+
"lib/aqua/store/couch_db/design_document.rb",
|
43
|
+
"lib/aqua/store/couch_db/http_client/adapter/rest_client.rb",
|
44
|
+
"lib/aqua/store/couch_db/http_client/rest_api.rb",
|
45
|
+
"lib/aqua/store/couch_db/server.rb",
|
46
|
+
"lib/aqua/store/couch_db/storage_methods.rb",
|
47
|
+
"lib/aqua/store/storage.rb",
|
48
|
+
"lib/aqua/support/initializers.rb",
|
49
|
+
"lib/aqua/support/mash.rb",
|
50
|
+
"lib/aqua/support/set.rb",
|
51
|
+
"lib/aqua/support/string_extensions.rb",
|
52
|
+
"spec/aqua_spec.rb",
|
53
|
+
"spec/object/config_spec.rb",
|
54
|
+
"spec/object/object_fixtures/array_udder.rb",
|
55
|
+
"spec/object/object_fixtures/canned_hash.rb",
|
56
|
+
"spec/object/object_fixtures/gerbilmiester.rb",
|
57
|
+
"spec/object/object_fixtures/grounded.rb",
|
58
|
+
"spec/object/object_fixtures/log.rb",
|
59
|
+
"spec/object/object_fixtures/persistent.rb",
|
60
|
+
"spec/object/object_fixtures/sugar.rb",
|
61
|
+
"spec/object/object_fixtures/user.rb",
|
62
|
+
"spec/object/pack_spec.rb",
|
63
|
+
"spec/object/query_spec.rb",
|
64
|
+
"spec/object/stub_spec.rb",
|
65
|
+
"spec/object/tank_spec.rb",
|
66
|
+
"spec/object/unpack_spec.rb",
|
67
|
+
"spec/spec.opts",
|
68
|
+
"spec/spec_helper.rb",
|
69
|
+
"spec/store/couchdb/attachments_spec.rb",
|
70
|
+
"spec/store/couchdb/couch_db_spec.rb",
|
71
|
+
"spec/store/couchdb/database_spec.rb",
|
72
|
+
"spec/store/couchdb/design_document_spec.rb",
|
73
|
+
"spec/store/couchdb/fixtures_and_data/document_fixture.rb",
|
74
|
+
"spec/store/couchdb/fixtures_and_data/image_attach.png",
|
75
|
+
"spec/store/couchdb/server_spec.rb",
|
76
|
+
"spec/store/couchdb/storage_methods_spec.rb",
|
77
|
+
"utils/code_statistics.rb",
|
78
|
+
"utils/console"
|
79
|
+
]
|
80
|
+
s.has_rdoc = true
|
81
|
+
s.homepage = %q{http://github.com/baccigalupi/aqua}
|
82
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
83
|
+
s.require_paths = ["lib"]
|
84
|
+
s.rubygems_version = %q{1.3.1}
|
85
|
+
s.summary = %q{Aqua: A Ruby Object Database ... just add water (and CouchDB)}
|
86
|
+
s.test_files = [
|
87
|
+
"spec/aqua_spec.rb",
|
88
|
+
"spec/object/config_spec.rb",
|
89
|
+
"spec/object/object_fixtures/array_udder.rb",
|
90
|
+
"spec/object/object_fixtures/canned_hash.rb",
|
91
|
+
"spec/object/object_fixtures/gerbilmiester.rb",
|
92
|
+
"spec/object/object_fixtures/grounded.rb",
|
93
|
+
"spec/object/object_fixtures/log.rb",
|
94
|
+
"spec/object/object_fixtures/persistent.rb",
|
95
|
+
"spec/object/object_fixtures/sugar.rb",
|
96
|
+
"spec/object/object_fixtures/user.rb",
|
97
|
+
"spec/object/pack_spec.rb",
|
98
|
+
"spec/object/query_spec.rb",
|
99
|
+
"spec/object/stub_spec.rb",
|
100
|
+
"spec/object/tank_spec.rb",
|
101
|
+
"spec/object/unpack_spec.rb",
|
102
|
+
"spec/spec_helper.rb",
|
103
|
+
"spec/store/couchdb/attachments_spec.rb",
|
104
|
+
"spec/store/couchdb/couch_db_spec.rb",
|
105
|
+
"spec/store/couchdb/database_spec.rb",
|
106
|
+
"spec/store/couchdb/design_document_spec.rb",
|
107
|
+
"spec/store/couchdb/fixtures_and_data/document_fixture.rb",
|
108
|
+
"spec/store/couchdb/server_spec.rb",
|
109
|
+
"spec/store/couchdb/storage_methods_spec.rb"
|
110
|
+
]
|
111
|
+
|
112
|
+
if s.respond_to? :specification_version then
|
113
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
114
|
+
s.specification_version = 2
|
115
|
+
|
116
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
117
|
+
else
|
118
|
+
end
|
119
|
+
else
|
120
|
+
end
|
121
|
+
end
|
data/LICENCE_COUCHREST
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Kane Baccigalupi
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
= Aqua
|
2
|
+
|
3
|
+
Aqua: A Ruby Object Database ... just add water (and CouchDB).
|
4
|
+
|
5
|
+
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.
|
6
|
+
|
7
|
+
Currently Aqua is in pre-alpha testing, with the following big things left to implement:
|
8
|
+
* A data query syntax and implementation (yeah, ouch!)
|
9
|
+
* Class and code storage to allow the sharing and persistence of classes with their data
|
10
|
+
* Other storage systems, most notably a filestore, so that users can try Aqua out without having to install CouchDb
|
11
|
+
* Data storage amenity add-ons including: validation, callbacks, AR-styled syntax, and properties that automate some of the object typing, validation, and searchability option.
|
12
|
+
|
13
|
+
Aqua aims to be lean and modular, in addition to transparent. Currently it weighs in at < 1200 lines of code with half of that for the CouchDB storage engine.
|
14
|
+
|
15
|
+
== Usage
|
16
|
+
|
17
|
+
Aqua persists a Ruby instance's state through its instance variables, and in the case of primitives like arrays and hashes, through their core data. The first step towards working in Aqua is shedding the limitations of ORMs and other storage classes, and get back to pure Ruby. Once you have an Ruby class, the simple declaration +aquatic+ in the class will allow you to #commit and #reload the object.
|
18
|
+
|
19
|
+
Currently, Aqua uses CouchDB for its storage. Make sure you have CouchDB installed and running before you start storing objects. If your CouchDB installation is running at a non-standard url, visit the documentation to learn how to configure Aqua for your setup.
|
20
|
+
|
21
|
+
require 'rubygems'
|
22
|
+
require 'aqua'
|
23
|
+
|
24
|
+
class User
|
25
|
+
aquatic # adds persistence methods to your object
|
26
|
+
|
27
|
+
attr_accessor :name, # An array of strings or a hash of strings
|
28
|
+
:created_at, # Time
|
29
|
+
:dob, # Date
|
30
|
+
:username, # simple string
|
31
|
+
:name, # Array, Hash, Name Object?
|
32
|
+
:password, # hidden value
|
33
|
+
:credentials # hash with salt and encrypted password, or ...
|
34
|
+
|
35
|
+
hide_attributes :password # Aqua can hide certain instance variables that you would prefer not save
|
36
|
+
|
37
|
+
# possible way to initialize your data ...
|
38
|
+
def initialize( hash={} )
|
39
|
+
hash.each do |key, value|
|
40
|
+
send( "#{key}=", value )
|
41
|
+
end
|
42
|
+
self.created_at = Time.now
|
43
|
+
end
|
44
|
+
|
45
|
+
# lots more user code here as you see fit ...
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
user = User.new(
|
50
|
+
:username => 'kane',
|
51
|
+
:name =>{:first => 'Kane', :last => 'Baccigalupi'},
|
52
|
+
:dob => Date.parse( '12/23/1969' ),
|
53
|
+
:password => 'ubber_secret!'
|
54
|
+
)
|
55
|
+
|
56
|
+
user.commit! # ! makes it raise an exception on failure
|
57
|
+
puts user.inspect
|
58
|
+
# #<User:0x103e818 @dob=#<Date: 4881157/2,0,2299161>, @name={:first=>"Kane", :last=>"Baccigalupi"}, @__pack=nil, @created_at=Fri Aug 21 12:03:45 -0700 2009, @_store=nil, @password="ubber_secret!", @username="kane", @_rev="1-1789597473", @id="8e770a31107741f4bdcd325de30e1d67">
|
59
|
+
|
60
|
+
user.name = ['Kane', 'Baccigalupi']
|
61
|
+
user.commit # will return false on failure, otherwise returns its saved self
|
62
|
+
puts user.inspect
|
63
|
+
# #<User:0x103e818 @dob=#<Date: 4881157/2,0,2299161>, @name=["Kane", "Baccigalupi"], @__pack=nil, @created_at=Fri Aug 21 12:03:45 -0700 2009, @_store=nil, @password="ubber_secret!", @username="kane", @_rev="2-2449437616", @id="8e770a31107741f4bdcd325de30e1d67">
|
64
|
+
|
65
|
+
user.reload # retrieves the latest saved version of the object
|
66
|
+
u = User.load( user.id ) # returns your persisted user object, like you just added water!
|
67
|
+
puts u.inspect
|
68
|
+
# #<User:0x1a16480 @name=["Kane", "Baccigalupi"], @created_at=Fri Aug 21 12:07:39 -0700 2009, @_store=nil, @username="kane", @dob=#<Date: 4881157/2,0,2299161>, @id="c664770982b92e9fa802e0ed664a9846">
|
69
|
+
|
70
|
+
# woot!
|
71
|
+
|
72
|
+
== Installation
|
73
|
+
|
74
|
+
Aqua is so young that it hasn't made it over to the established land of rubyforge. So for now you can install the gem by including github as a source, and then do a sudo gem install
|
75
|
+
|
76
|
+
gem sources -a http://gems.github.com
|
77
|
+
sudo gem install 'baccigalupi-aqua'
|
78
|
+
|
79
|
+
Also, beware that Aqua has an unstated dependency: httpclient. The CouchDB engine was built with flexibility and speed in mind. The http_client gem seems like the best thing since sliced bread now, but may become outdated or slow comparatively. Developers are encouraged to build adapters to their preferred http clients. To do this please fork the project and request a pull once you have your adapter built and tested.
|
80
|
+
|
81
|
+
Meanwhile, you will want to make sure that http_client is available to Aqua.
|
82
|
+
|
83
|
+
sudo gem install http-client
|
84
|
+
|
85
|
+
== More Info
|
86
|
+
|
87
|
+
Twitter: http://twitter.com/rubyaqua
|
88
|
+
|
89
|
+
Rdocs: http://ruby-aqua.org
|
90
|
+
|
91
|
+
Pivotal Tracker: http://www.pivotaltracker.com/projects/26677
|
92
|
+
|
93
|
+
== Contributing
|
94
|
+
|
95
|
+
Bug fixes and features are welcome.
|
96
|
+
|
97
|
+
* Fork the project.
|
98
|
+
* Make your feature addition or bug fix.
|
99
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
100
|
+
* Commit, do not mess with rakefile, version, or history.(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
101
|
+
* Send me a pull request. Bonus points for topic branches.
|
102
|
+
|
103
|
+
== Copyright
|
104
|
+
|
105
|
+
Copyright (c) 2009 Kane Baccigalupi. See LICENSE for details. Some parts of the CouchDB storage engine were derived from CouchRest. Their LICENSE is also included and will apply.
|
data/Rakefile
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'yard'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |gem|
|
8
|
+
gem.name = "aqua"
|
9
|
+
gem.summary = %Q{Aqua: A Ruby Object Database ... just add water (and CouchDB)}
|
10
|
+
gem.description = %Q{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. }
|
11
|
+
gem.email = "baccigalupi@gmail.com"
|
12
|
+
gem.homepage = "http://github.com/baccigalupi/aqua"
|
13
|
+
gem.authors = ["Kane Baccigalupi"]
|
14
|
+
end
|
15
|
+
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'spec/rake/spectask'
|
21
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
22
|
+
spec.libs << 'lib' << 'spec'
|
23
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
24
|
+
end
|
25
|
+
|
26
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
28
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
29
|
+
spec.rcov = true
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
task :default => :spec
|
34
|
+
|
35
|
+
require 'rake/rdoctask'
|
36
|
+
Rake::RDocTask.new do |rdoc|
|
37
|
+
if File.exist?('VERSION')
|
38
|
+
version = File.read('VERSION')
|
39
|
+
else
|
40
|
+
version = ""
|
41
|
+
end
|
42
|
+
|
43
|
+
rdoc.rdoc_dir = 'rdoc'
|
44
|
+
rdoc.title = "Aqua #{version}"
|
45
|
+
rdoc.rdoc_files.include('README*')
|
46
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
# Statistics ====================================
|
51
|
+
AQUA_DIRECTORIES = [
|
52
|
+
%w(Aqua::Store lib/aqua/store),
|
53
|
+
%w(Aqua::Object lib/aqua/object),
|
54
|
+
%w(Aqua/Support lib/aqua/support),
|
55
|
+
%w(Aqua::Store/Specs spec/store),
|
56
|
+
%w(Aqua::Object/Specs spec/object)
|
57
|
+
].collect { |name, dir| [ name, "#{File.dirname(__FILE__)}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
|
58
|
+
|
59
|
+
COUCHREST_DIRECTORIES = [
|
60
|
+
%w(CouchRest utils/couchrest/lib),
|
61
|
+
%w(Specs utils/couchrest/spec/couchrest)
|
62
|
+
].collect { |name, dir| [ name, "#{File.dirname(__FILE__)}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
|
63
|
+
|
64
|
+
AR_DIRECTORIES = [
|
65
|
+
%w(ActiveRecord utils/rails/activerecord/lib),
|
66
|
+
%w(Specs utils/rails/activerecord/test)
|
67
|
+
].collect { |name, dir| [ name, "#{File.dirname(__FILE__)}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
|
68
|
+
|
69
|
+
desc "Report code statistics (KLOCs, etc) on the gem"
|
70
|
+
task :stats do
|
71
|
+
require File.dirname(__FILE__) + '/utils/code_statistics'
|
72
|
+
CodeStatistics.new(*AQUA_DIRECTORIES).to_s
|
73
|
+
CodeStatistics.new(*COUCHREST_DIRECTORIES).to_s if File.exists?( File.dirname(__FILE__) + '/utils/couchrest/lib')
|
74
|
+
CodeStatistics.new(*AR_DIRECTORIES).to_s if File.exists?( File.dirname(__FILE__) + '/utils/rails/activerecord')
|
75
|
+
end
|
76
|
+
|
77
|
+
# YARDing up some documentation
|
78
|
+
# YARD::Tags::Library.define_tag("API", :api)
|
79
|
+
# YARD::Tags::Library.defind_tag("Inteface Specifications", :interface_level)
|
80
|
+
YARD::Rake::YardocTask.new do |t|
|
81
|
+
t.files = ['lib/aqua/**/*.rb']
|
82
|
+
end
|
83
|
+
|