og 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +183 -0
- data/ChangeLog.1 +2344 -0
- data/README.og +4 -3
- data/RELEASES.og +15 -0
- data/Rakefile +135 -0
- data/examples/og/README +7 -0
- data/examples/og/mock_example.rb +58 -0
- data/examples/og/run.rb +9 -5
- data/lib/glue/property.rb +166 -107
- data/lib/glue/property.rb.old +307 -0
- data/lib/og.rb +17 -6
- data/lib/og/backend.rb +34 -4
- data/lib/og/backends/mysql.rb +3 -17
- data/lib/og/backends/psql.rb +5 -17
- data/lib/og/meta.rb +41 -26
- data/lib/og/mock.rb +223 -0
- data/lib/og/version.rb +2 -2
- data/test/og/tc_lifecycle.rb +107 -0
- data/test/tc_og.rb +31 -4
- metadata +22 -14
@@ -0,0 +1,107 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# vim:sw=2:ai
|
3
|
+
|
4
|
+
# code:
|
5
|
+
# * Thomas Quas <tquas@yahoo.com>
|
6
|
+
# * George Moschovitis <gm@navel.gr>
|
7
|
+
#
|
8
|
+
# $Id$
|
9
|
+
|
10
|
+
$LOAD_PATH.unshift 'lib'
|
11
|
+
|
12
|
+
require "test/unit"
|
13
|
+
require 'glue/logger'
|
14
|
+
require 'og/mock'
|
15
|
+
|
16
|
+
$DBG = false
|
17
|
+
$log = Logger.new( STDERR ) unless $log
|
18
|
+
|
19
|
+
class Dummy
|
20
|
+
prop_accessor :date
|
21
|
+
attr_reader :call_stack
|
22
|
+
|
23
|
+
def og_pre_insert( oid )
|
24
|
+
@call_stack << "pre_insert"
|
25
|
+
end
|
26
|
+
|
27
|
+
def og_post_insert( oid )
|
28
|
+
@call_stack << "post_insert"
|
29
|
+
end
|
30
|
+
|
31
|
+
def og_pre_update( oid )
|
32
|
+
@call_stack << "pre_update"
|
33
|
+
end
|
34
|
+
|
35
|
+
def og_post_update( oid )
|
36
|
+
@call_stack << "post_update"
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.og_pre_delete( conn, oid )
|
40
|
+
raise "undeletable"
|
41
|
+
end
|
42
|
+
|
43
|
+
def initialize
|
44
|
+
@call_stack = []
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Tests the Og managed objects lifecycle.
|
49
|
+
class TC_CallbackTest < ::Test::Unit::TestCase
|
50
|
+
def test_insert
|
51
|
+
obj = Dummy.new
|
52
|
+
obj.save!
|
53
|
+
|
54
|
+
assert( obj.call_stack.shift == "pre_insert" )
|
55
|
+
assert( obj.call_stack.shift == "post_insert" )
|
56
|
+
assert( obj.call_stack.empty? )
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_update
|
60
|
+
obj = Dummy.new
|
61
|
+
obj.save!
|
62
|
+
obj.call_stack.shift
|
63
|
+
obj.call_stack.shift
|
64
|
+
|
65
|
+
obj.date = Time.now
|
66
|
+
obj.save
|
67
|
+
assert( obj.call_stack.shift == "pre_update" )
|
68
|
+
assert( obj.call_stack.shift == "post_update" )
|
69
|
+
assert( obj.call_stack.empty? )
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_delete
|
73
|
+
obj = Dummy.new
|
74
|
+
obj.save!
|
75
|
+
obj.call_stack.shift
|
76
|
+
obj.call_stack.shift
|
77
|
+
|
78
|
+
assert_raise( RuntimeError, "undeletable" ) { obj.delete! }
|
79
|
+
end
|
80
|
+
|
81
|
+
def setup
|
82
|
+
psql = true
|
83
|
+
|
84
|
+
if psql
|
85
|
+
config = {
|
86
|
+
:backend => "psql",
|
87
|
+
:address => "localhost",
|
88
|
+
:database => "test",
|
89
|
+
:user => "postgres",
|
90
|
+
:password => "navelrulez",
|
91
|
+
:connection_count => 1
|
92
|
+
}
|
93
|
+
else
|
94
|
+
config = {
|
95
|
+
:backend => "mysql",
|
96
|
+
:address => "localhost",
|
97
|
+
:database => "test",
|
98
|
+
:user => "root",
|
99
|
+
:password => "navelrulez",
|
100
|
+
:connection_count => 1
|
101
|
+
}
|
102
|
+
end
|
103
|
+
Og::Database.drop_db!( config )
|
104
|
+
$og = Og::Database.new( config )
|
105
|
+
$og.get_connection()
|
106
|
+
end
|
107
|
+
end
|
data/test/tc_og.rb
CHANGED
@@ -46,7 +46,7 @@ class Article
|
|
46
46
|
end
|
47
47
|
|
48
48
|
class Comment
|
49
|
-
belongs_to :article, Test::Article
|
49
|
+
belongs_to :article, Test::Article, :extra_sql => 'NOT NULL'
|
50
50
|
belongs_to :author, Test::User
|
51
51
|
prop_accessor :body, String
|
52
52
|
prop_accessor :create_time, Time
|
@@ -65,6 +65,14 @@ class Comment
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
module MyMixin
|
69
|
+
prop_accessor :title, String
|
70
|
+
end
|
71
|
+
|
72
|
+
class MyClass
|
73
|
+
include Test::MyMixin
|
74
|
+
end
|
75
|
+
|
68
76
|
class TC_N_OG < Test::Unit::TestCase
|
69
77
|
|
70
78
|
def setup
|
@@ -148,16 +156,17 @@ class TC_N_OG < Test::Unit::TestCase
|
|
148
156
|
|
149
157
|
article = Article.new("Title", "Body")
|
150
158
|
article.save!
|
151
|
-
|
159
|
+
|
152
160
|
comment = Comment.new("This is a comment")
|
153
161
|
comment.article = article
|
154
162
|
comment.author = User["gmosx"]
|
155
163
|
comment.save!
|
156
164
|
|
165
|
+
|
166
|
+
# test automatically generated add_commnet
|
157
167
|
comment = Comment.new("This is another comment")
|
158
|
-
comment.article = article.oid
|
159
168
|
comment.author = User["gmosx"]
|
160
|
-
comment
|
169
|
+
article.add_comment(comment)
|
161
170
|
|
162
171
|
assert_equal(article.oid, comment.article_oid)
|
163
172
|
|
@@ -172,6 +181,24 @@ class TC_N_OG < Test::Unit::TestCase
|
|
172
181
|
assert_equal(nil, Comment.all)
|
173
182
|
|
174
183
|
comment.delete!
|
184
|
+
|
185
|
+
# test extra_sql
|
186
|
+
|
187
|
+
for p in Comment.__props
|
188
|
+
if :article_oid == p.symbol
|
189
|
+
assert_equal('NOT NULL', p.meta[:extra_sql])
|
190
|
+
break
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
assert($og.managed_classes.include?(Test::Article))
|
195
|
+
|
196
|
+
# bug: indirectly managed (includes managed Module)
|
197
|
+
assert($og.managed_classes.include?(Test::MyClass))
|
198
|
+
|
199
|
+
# test create
|
200
|
+
article = Article.create("title", "body")
|
201
|
+
assert_equal(3, article.oid)
|
175
202
|
end
|
176
203
|
|
177
204
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.3
|
3
3
|
specification_version: 1
|
4
4
|
name: og
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2004-12-
|
6
|
+
version: 0.7.0
|
7
|
+
date: 2004-12-27
|
8
8
|
summary: Og (ObjectGraph)
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
|
-
author: George Moschovitis
|
12
11
|
email: gm@navel.gr
|
13
12
|
homepage: http://www.navel.gr/og
|
14
13
|
rubyforge_project: og-rml
|
@@ -25,35 +24,44 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
24
|
version: 1.8.1
|
26
25
|
version:
|
27
26
|
platform: ruby
|
27
|
+
authors:
|
28
|
+
- George Moschovitis
|
28
29
|
files:
|
29
30
|
- README.og
|
30
31
|
- RELEASES.og
|
31
32
|
- LICENSE
|
32
33
|
- AUTHORS
|
34
|
+
- Rakefile
|
35
|
+
- ChangeLog.1
|
36
|
+
- ChangeLog
|
33
37
|
- examples/og/run.rb
|
38
|
+
- examples/og/mock_example.rb
|
34
39
|
- examples/og/README
|
35
40
|
- lib/glue.rb
|
41
|
+
- lib/glue/mixins.rb
|
42
|
+
- lib/glue/logger.rb
|
36
43
|
- lib/glue/pool.rb
|
37
|
-
- lib/glue/time.rb
|
38
|
-
- lib/glue/macro.rb
|
39
44
|
- lib/glue/inflector.rb
|
40
|
-
- lib/glue/
|
45
|
+
- lib/glue/hash.rb
|
41
46
|
- lib/glue/number.rb
|
42
|
-
- lib/glue/
|
43
|
-
- lib/glue/mixins.rb
|
47
|
+
- lib/glue/time.rb
|
44
48
|
- lib/glue/property.rb
|
49
|
+
- lib/glue/property.rb.old
|
50
|
+
- lib/glue/macro.rb
|
51
|
+
- lib/glue/cache.rb
|
45
52
|
- lib/glue/string.rb
|
46
|
-
- lib/glue/
|
47
|
-
- lib/glue/logger.rb
|
53
|
+
- lib/glue/array.rb
|
48
54
|
- lib/og/backends
|
55
|
+
- lib/og/version.rb
|
49
56
|
- lib/og/connection.rb
|
50
|
-
- lib/og/
|
57
|
+
- lib/og/mock.rb
|
51
58
|
- lib/og/meta.rb
|
52
|
-
- lib/og/
|
53
|
-
- lib/og/backends/psql.rb
|
59
|
+
- lib/og/backend.rb
|
54
60
|
- lib/og/backends/mysql.rb
|
61
|
+
- lib/og/backends/psql.rb
|
55
62
|
- lib/og.rb
|
56
63
|
- test/tc_og.rb
|
64
|
+
- test/og/tc_lifecycle.rb
|
57
65
|
test_files: []
|
58
66
|
rdoc_options:
|
59
67
|
- "--main"
|