og 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +114 -0
- data/INSTALL +22 -0
- data/README +1 -1
- data/Rakefile +2 -2
- data/doc/RELEASES +17 -1
- data/lib/og.rb +9 -3
- data/lib/og/adapter.rb +13 -2
- data/lib/og/adapters/mysql.rb +13 -7
- data/lib/og/adapters/oracle.rb +12 -9
- data/lib/og/adapters/psql.rb +9 -7
- data/lib/og/adapters/sqlite.rb +14 -7
- data/lib/og/connection.rb +26 -5
- data/lib/og/database.rb +33 -27
- data/lib/og/enchant.rb +28 -4
- data/lib/og/meta.rb +30 -5
- data/lib/og/mixins/list.rb +158 -0
- data/lib/og/mixins/tree.rb +228 -0
- data/lib/og/{mock.rb → testing/mock.rb} +0 -0
- data/test/og/mixins/tc_list.rb +104 -0
- data/test/og/mixins/tc_tree.rb +59 -0
- data/test/og/tc_automanage.rb +45 -0
- data/test/tc_og.rb +29 -0
- metadata +13 -5
data/CHANGELOG
CHANGED
@@ -1,5 +1,119 @@
|
|
1
|
+
28-03-2005 George Moschovitis <gm@navel.gr>
|
2
|
+
|
3
|
+
* test/og/mixins/tc_list.rb: implemented tests.
|
4
|
+
|
5
|
+
* lib/og/connection.rb (#delete): passs obj_or_oid to the callback.
|
6
|
+
|
7
|
+
* lib/og/enchant.rb (#update/#update_all): fixed stupid bug.
|
8
|
+
(#delete!): pass self.
|
9
|
+
|
10
|
+
* lib/og/mixins/list.rb: set the position property for the
|
11
|
+
enchanted object,
|
12
|
+
(#move_to_top): fixed.
|
13
|
+
(#increment_position_of*/dec*): fixed,
|
14
|
+
fixed scope interpolation.
|
15
|
+
|
16
|
+
27-03-2005 George Moschovitis <gm@navel.gr>
|
17
|
+
|
18
|
+
* lib/og/database.rb: wrap transaction.
|
19
|
+
|
20
|
+
* lib/og/enchant.rb (#each): fixed.
|
21
|
+
|
22
|
+
* lib/og/meta.rb (#has_many): added :order and :sql options.
|
23
|
+
include Og::List by default to Module.
|
24
|
+
|
25
|
+
* lib/og/mixins/list.rb: added some code,
|
26
|
+
(#decrement_position_of..): added,
|
27
|
+
add callbacks to enchanted object,
|
28
|
+
made compatible with meta,
|
29
|
+
use pre_insert,
|
30
|
+
many, many small fixes to make this work.
|
31
|
+
|
32
|
+
* test/og/mixins/tc_list.rb: introduced.
|
33
|
+
|
34
|
+
24-03-2005 George Moschovitis <gm@navel.gr>
|
35
|
+
|
36
|
+
* lib/og/adapters/*: rescue binding require. [drak]
|
37
|
+
|
38
|
+
* lib/og/enchant.rb: fixed many bugs to make this run again.
|
39
|
+
|
40
|
+
23-03-2005 George Moschovitis <gm@navel.gr>
|
41
|
+
|
42
|
+
* lib/og/testing: introduced.
|
43
|
+
|
44
|
+
* test/mixins/tc_list.rb: introduced.
|
45
|
+
|
46
|
+
* test/mixins: introduced.
|
47
|
+
|
48
|
+
* lib/og/mixins/list.rb: introduced.
|
49
|
+
(#move_higher/lower): implemented.
|
50
|
+
(#increment/decrement_position): implemented.
|
51
|
+
implemented many methods.
|
52
|
+
|
53
|
+
* INSTALL: updated, added ref to required libs. [dyoder]
|
54
|
+
|
55
|
+
* lib/og/adapter.rb (SqlException): introduced.
|
56
|
+
|
57
|
+
* lib/og/connection.rb (#handle_db_exception): factored out,
|
58
|
+
update_property alias.
|
59
|
+
|
60
|
+
* lib/og/adapters/* (#exec/query): return :error on error
|
61
|
+
and add support for raising exceptions,
|
62
|
+
use handle_db_exception,
|
63
|
+
added get_row helper method.
|
64
|
+
|
65
|
+
* lib/og.rb: added raise_db_exceptions flag. [mneumann]
|
66
|
+
|
67
|
+
* test/tc_og.rb: added tests.
|
68
|
+
|
69
|
+
* lib/og/enchant.rb (#reload): implemented [mneumann],
|
70
|
+
update_property alias.
|
71
|
+
(#set_property): introduced.
|
72
|
+
(#update_all): implemented.
|
73
|
+
(#transaction): implemented.
|
74
|
+
|
75
|
+
* lib/og/adapter.rb (#og_read): tupple defualt is 0.
|
76
|
+
|
77
|
+
22-03-2005 George Moschovitis <gm@navel.gr>
|
78
|
+
|
79
|
+
* lib/og/adapter.rb (#create_db): set create_schema = true. [danjover]
|
80
|
+
|
81
|
+
* lib/og/meta.rb (#has_many): accepts tree option.
|
82
|
+
|
83
|
+
* lib/og/tree.rb (TreeTraversal): introduced.
|
84
|
+
|
85
|
+
* test/og/tc_tree.rb: introduced.
|
86
|
+
|
87
|
+
21-03-2005 George Moschovitis <gm@navel.gr>
|
88
|
+
|
89
|
+
* lib/og/tree.rb: Introduced Tree mixin.
|
90
|
+
|
91
|
+
20-03-2005 George Moschovitis <gm@navel.gr>
|
92
|
+
|
93
|
+
* lib/og/meta.rb: experimented with const_missing hack.
|
94
|
+
|
95
|
+
* test/og/tc_automanage.rb: implemented.
|
96
|
+
|
97
|
+
* lib/og/database.rb (#auto_manage_classes): added, to automanage
|
98
|
+
classes defined after Database definition. [james_b]
|
99
|
+
|
100
|
+
19-03-2005 George Moschovitis <gm@navel.gr>
|
101
|
+
|
102
|
+
* lib/og/database.rb (#initialize): handle drop_db config parameter.
|
103
|
+
|
104
|
+
* lib/og/tree.rb: implemented nested intervals tree traversal
|
105
|
+
helper methods,
|
106
|
+
fix in parent,
|
107
|
+
yeah! the hierarchy is stored.
|
108
|
+
|
109
|
+
18-03-2005 George Moschovitis <gm@navel.gr>
|
110
|
+
|
111
|
+
* Research about nested interval sql tree traversal.
|
112
|
+
|
1
113
|
17-03-2005 George Moschovitis <gm@navel.gr>
|
2
114
|
|
115
|
+
* --- VERSION 0.13.0 ---
|
116
|
+
|
3
117
|
* Rakefile: updated.
|
4
118
|
|
5
119
|
* test/*: changes to make the tests pass again.
|
data/INSTALL
CHANGED
@@ -42,6 +42,7 @@ a standard installation script is provided.
|
|
42
42
|
This installation script also installs some vendor libraries
|
43
43
|
that you possibly have allready installed. Use with caution.
|
44
44
|
|
45
|
+
|
45
46
|
= Manual installation.
|
46
47
|
|
47
48
|
Uncompress your distribution (Unix example):
|
@@ -54,3 +55,24 @@ Put the libray dir in the Ruby path (Unix example):
|
|
54
55
|
$ export RUBYOPT='-I path/to/og/lib'
|
55
56
|
|
56
57
|
|
58
|
+
= Additional libraries
|
59
|
+
|
60
|
+
Og uses a number of additional libraries. RubyGems
|
61
|
+
installs most of them, but here is the complete
|
62
|
+
list for your reference:
|
63
|
+
|
64
|
+
* Ruby-psql
|
65
|
+
http://www.postgresql.jp/interfaces/ruby/archive/ruby-postgres-0.7.1.tar.gz
|
66
|
+
Ruby interface to the PostgreSQL RDBMS.
|
67
|
+
|
68
|
+
* Ruby-mysql
|
69
|
+
http://tmtm.org/ja/ruby/mysql/README_en.html
|
70
|
+
Ruby interface to the MySQL RDBMS.
|
71
|
+
|
72
|
+
* PostgreSQL
|
73
|
+
http://www.postgres.org
|
74
|
+
Used for the Database Backend.
|
75
|
+
|
76
|
+
* MySQL
|
77
|
+
http://www.mysql.org
|
78
|
+
Used for the Database Backend.
|
data/README
CHANGED
data/Rakefile
CHANGED
@@ -30,14 +30,14 @@ end
|
|
30
30
|
spec = Gem::Specification.new do |s|
|
31
31
|
s.name = 'og'
|
32
32
|
if File.read('lib/og.rb') =~ /Version\s+=\s+'(\d+\.\d+\.\d+)'/
|
33
|
-
s.version = $1
|
33
|
+
VERSION = s.version = $1
|
34
34
|
else
|
35
35
|
raise 'No version found'
|
36
36
|
end
|
37
37
|
s.summary = 'Og (ObjectGraph)'
|
38
38
|
s.description = 'An efficient and transparent Object-Relational mapping library'
|
39
39
|
|
40
|
-
s.add_dependency 'glue',
|
40
|
+
s.add_dependency 'glue', "= #{VERSION}"
|
41
41
|
# s.add_dependency 'postgres-pr', '>= 0.3.0'
|
42
42
|
# s.add_dependency 'postgres', '>= 0.7.1'
|
43
43
|
# s.add_dependency 'sqlite3-ruby', '>= 1.0.0'
|
data/doc/RELEASES
CHANGED
@@ -1,8 +1,24 @@
|
|
1
|
+
== Version 0.14.0 was released on 18/03/2005.
|
2
|
+
|
3
|
+
Many many important fixes, and many small additions
|
4
|
+
and improvements. Og mixins are introduced with
|
5
|
+
an experimental List mixin implementation.
|
6
|
+
|
7
|
+
Most notable addition:
|
8
|
+
|
9
|
+
* Support for objects that participate in list
|
10
|
+
(ordering/removal etc)
|
11
|
+
|
12
|
+
* Add useful new enchant methods.
|
13
|
+
|
14
|
+
* Fixed all user reported bugs.
|
15
|
+
|
16
|
+
|
1
17
|
== Version 0.13.0 was released on 17/03/2005.
|
2
18
|
|
3
19
|
A maintenance release.
|
4
20
|
|
5
|
-
Most notable
|
21
|
+
Most notable additions:
|
6
22
|
|
7
23
|
* Better separated from Nitro.
|
8
24
|
|
data/lib/og.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: og.rb
|
3
|
+
# $Id: og.rb 326 2005-03-28 11:07:17Z gmosx $
|
4
4
|
|
5
5
|
require 'glue'
|
6
6
|
require 'glue/logger'
|
@@ -107,7 +107,7 @@ module Og
|
|
107
107
|
|
108
108
|
# The version.
|
109
109
|
|
110
|
-
Version = '0.
|
110
|
+
Version = '0.14.0'
|
111
111
|
|
112
112
|
# Library path.
|
113
113
|
|
@@ -159,6 +159,12 @@ module Og
|
|
159
159
|
|
160
160
|
mattr_accessor :create_schema, true
|
161
161
|
|
162
|
+
# If true raises exceptions on database errors, usefull when
|
163
|
+
# debugging. For production environments it should probably be
|
164
|
+
# set to false to make the application more fault tolerant.
|
165
|
+
|
166
|
+
mattr_accessor :raise_db_exceptions, true
|
167
|
+
|
162
168
|
# The active database. Og allows you to access multiple
|
163
169
|
# databases from a single application.
|
164
170
|
|
@@ -177,7 +183,7 @@ module Og
|
|
177
183
|
@@db.adapter
|
178
184
|
end
|
179
185
|
|
180
|
-
# Marker module. If included
|
186
|
+
# Marker module. If included in a class, the Og automanager
|
181
187
|
# ignores this class.
|
182
188
|
|
183
189
|
module Unmanageable; end
|
data/lib/og/adapter.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: adapter.rb
|
3
|
+
# $Id: adapter.rb 323 2005-03-24 09:43:52Z gmosx $
|
4
4
|
|
5
5
|
require 'yaml'
|
6
6
|
require 'singleton'
|
@@ -9,6 +9,16 @@ require 'og/connection'
|
|
9
9
|
|
10
10
|
module Og
|
11
11
|
|
12
|
+
# Encapsulates a lower lever adapter SQL excpetion.
|
13
|
+
|
14
|
+
class SqlException < Exception
|
15
|
+
attr_accessor :adapter_exception, :sql
|
16
|
+
|
17
|
+
def initialize(adapter_exception, sql = nil)
|
18
|
+
@adapter_exception, @sql = adapter_exception, sql
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
12
22
|
# An adapter communicates with the backend datastore.
|
13
23
|
# The adapters for all supported datastores extend this
|
14
24
|
# class. Typically, an RDBMS is used to implement a
|
@@ -115,6 +125,7 @@ class Adapter
|
|
115
125
|
|
116
126
|
def create_db(database, user = nil, password = nil)
|
117
127
|
Logger.info "Creating database '#{database}'."
|
128
|
+
Og.create_schema = true
|
118
129
|
end
|
119
130
|
|
120
131
|
# Drop the database.
|
@@ -500,7 +511,7 @@ class Adapter
|
|
500
511
|
end
|
501
512
|
|
502
513
|
klass.class_eval %{
|
503
|
-
def og_read(res, tuple =
|
514
|
+
def og_read(res, tuple = 0)
|
504
515
|
#{pre_cb}
|
505
516
|
#{code.join('; ')}
|
506
517
|
#{post_cb}
|
data/lib/og/adapters/mysql.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: mysql.rb
|
3
|
+
# $Id: mysql.rb 326 2005-03-28 11:07:17Z gmosx $
|
4
4
|
|
5
|
-
|
5
|
+
begin
|
6
|
+
require 'mysql'
|
7
|
+
rescue Object => ex
|
8
|
+
Logger.error 'Ruby-Mysql bindings are not installed!'
|
9
|
+
Logger.error ex
|
10
|
+
end
|
6
11
|
|
7
12
|
require 'og/adapter'
|
8
13
|
require 'og/connection'
|
@@ -275,9 +280,7 @@ class MysqlConnection < Connection
|
|
275
280
|
@store.query_with_result = true
|
276
281
|
return @store.query(sql)
|
277
282
|
rescue => ex
|
278
|
-
|
279
|
-
Logger.error ex.backtrace.join("\n")
|
280
|
-
return nil
|
283
|
+
handle_db_exception(ex, sql)
|
281
284
|
end
|
282
285
|
end
|
283
286
|
|
@@ -287,8 +290,7 @@ class MysqlConnection < Connection
|
|
287
290
|
@store.query_with_result = false
|
288
291
|
@store.query(sql)
|
289
292
|
rescue => ex
|
290
|
-
|
291
|
-
Logger.error ex.backtrace.join("\n")
|
293
|
+
handle_db_exception(ex, sql)
|
292
294
|
end
|
293
295
|
end
|
294
296
|
|
@@ -343,6 +345,10 @@ class MysqlConnection < Connection
|
|
343
345
|
return val
|
344
346
|
end
|
345
347
|
|
348
|
+
def get_row(res)
|
349
|
+
res.fetch_row
|
350
|
+
end
|
351
|
+
|
346
352
|
end
|
347
353
|
|
348
354
|
end
|
data/lib/og/adapters/oracle.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
# * Matt Bowen <matt.bowen@farweststeel.com>
|
2
2
|
# * George Moschovitis <gm@navel.gr>
|
3
3
|
# (c) 2004-2005 Navel, all rights reserved.
|
4
|
-
# $Id: oracle.rb
|
4
|
+
# $Id: oracle.rb 326 2005-03-28 11:07:17Z gmosx $
|
5
5
|
|
6
|
-
|
6
|
+
begin
|
7
|
+
require 'oracle'
|
8
|
+
rescue
|
9
|
+
Logger.error 'Ruby-Oracle bindings are not installed!'
|
10
|
+
Logger.error ex
|
11
|
+
end
|
7
12
|
|
8
13
|
require 'og/adapter'
|
9
14
|
require 'og/connection'
|
@@ -299,10 +304,7 @@ class OracleConnection < Connection
|
|
299
304
|
begin
|
300
305
|
return @store.exec(sql)
|
301
306
|
rescue Exception => ex
|
302
|
-
|
303
|
-
Logger.error ex.backtrace.join("\n")
|
304
|
-
raise
|
305
|
-
# return nil
|
307
|
+
handle_db_exception(ex, sql)
|
306
308
|
end
|
307
309
|
end
|
308
310
|
|
@@ -311,9 +313,7 @@ class OracleConnection < Connection
|
|
311
313
|
begin
|
312
314
|
@store.exec(sql)
|
313
315
|
rescue Exception => ex
|
314
|
-
|
315
|
-
Logger.error ex.backtrace.join("\n")
|
316
|
-
raise
|
316
|
+
handle_db_exception(ex, sql)
|
317
317
|
end
|
318
318
|
end
|
319
319
|
|
@@ -370,6 +370,9 @@ class OracleConnection < Connection
|
|
370
370
|
return val
|
371
371
|
end
|
372
372
|
|
373
|
+
def get_row(res)
|
374
|
+
res.fetch
|
375
|
+
end
|
373
376
|
end
|
374
377
|
|
375
378
|
end
|
data/lib/og/adapters/psql.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: psql.rb
|
3
|
+
# $Id: psql.rb 326 2005-03-28 11:07:17Z gmosx $
|
4
4
|
|
5
|
-
|
5
|
+
begin
|
6
|
+
require 'postgres'
|
7
|
+
rescue Object => ex
|
8
|
+
Logger.error 'Ruby-Postgresql bindings are not installed!'
|
9
|
+
Logger.error ex
|
10
|
+
end
|
6
11
|
|
7
12
|
require 'og/adapter'
|
8
13
|
require 'og/connection'
|
@@ -219,9 +224,7 @@ class PsqlConnection < Connection
|
|
219
224
|
begin
|
220
225
|
return @store.exec(sql)
|
221
226
|
rescue => ex
|
222
|
-
|
223
|
-
Logger.error ex.backtrace.join("\n")
|
224
|
-
return nil
|
227
|
+
handle_db_exception(ex, sql)
|
225
228
|
end
|
226
229
|
end
|
227
230
|
|
@@ -230,8 +233,7 @@ class PsqlConnection < Connection
|
|
230
233
|
begin
|
231
234
|
@store.exec(sql).clear
|
232
235
|
rescue => ex
|
233
|
-
|
234
|
-
Logger.error ex.backtrace.join("\n")
|
236
|
+
handle_db_exception(ex, sql)
|
235
237
|
end
|
236
238
|
end
|
237
239
|
|
data/lib/og/adapters/sqlite.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: sqlite.rb
|
3
|
+
# $Id: sqlite.rb 326 2005-03-28 11:07:17Z gmosx $
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'sqlite3'
|
7
|
+
rescue Object => ex
|
8
|
+
Logger.error 'Ruby-Sqlite3 bindings are not installed!'
|
9
|
+
Logger.error ex
|
10
|
+
end
|
4
11
|
|
5
|
-
require 'sqlite3'
|
6
12
|
require 'fileutils'
|
7
13
|
|
8
14
|
require 'og/adapter'
|
@@ -193,9 +199,7 @@ class SqliteConnection < Connection
|
|
193
199
|
begin
|
194
200
|
return @store.query(sql)
|
195
201
|
rescue => ex
|
196
|
-
|
197
|
-
Logger.error ex.backtrace.join("\n")
|
198
|
-
return nil
|
202
|
+
handle_db_exception(ex, sql)
|
199
203
|
end
|
200
204
|
end
|
201
205
|
|
@@ -204,8 +208,7 @@ class SqliteConnection < Connection
|
|
204
208
|
begin
|
205
209
|
@store.query(sql).close
|
206
210
|
rescue => ex
|
207
|
-
|
208
|
-
Logger.error ex.backtrace.join("\n")
|
211
|
+
handle_db_exception(ex, sql)
|
209
212
|
end
|
210
213
|
end
|
211
214
|
|
@@ -257,6 +260,10 @@ class SqliteConnection < Connection
|
|
257
260
|
return val
|
258
261
|
end
|
259
262
|
|
263
|
+
def get_row(res)
|
264
|
+
res.next
|
265
|
+
end
|
266
|
+
|
260
267
|
end
|
261
268
|
|
262
269
|
end
|