og 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +77 -0
- data/INSTALL +3 -0
- data/README +5 -3
- data/Rakefile +148 -5
- data/benchmark/bench.rb +1 -1
- data/doc/AUTHORS +4 -4
- data/doc/RELEASES +41 -1
- data/examples/mock_example.rb +1 -1
- data/examples/mysql_to_psql.rb +1 -1
- data/examples/run.rb +1 -1
- data/install.rb +1 -1
- data/lib/og.rb +4 -2
- data/lib/og/{adapter.rb → adapters/base.rb} +334 -152
- data/lib/og/adapters/filesys.rb +3 -7
- data/lib/og/adapters/mysql.rb +5 -9
- data/lib/og/adapters/oracle.rb +5 -9
- data/lib/og/adapters/psql.rb +5 -9
- data/lib/og/adapters/sqlite.rb +5 -9
- data/lib/og/adapters/sqlserver.rb +5 -9
- data/lib/og/database.rb +13 -11
- data/lib/og/enchant.rb +1 -1
- data/lib/og/errors.rb +21 -0
- data/lib/og/meta.rb +10 -9
- data/lib/og/mixins/hierarchical.rb +4 -4
- data/lib/og/mixins/orderable.rb +1 -1
- data/lib/og/mixins/timestamped.rb +24 -0
- data/lib/og/mixins/tree.rb +3 -1
- data/lib/og/testing/mock.rb +2 -2
- data/lib/og/typemacros.rb +1 -1
- data/lib/og/validation.rb +4 -4
- data/test/og/{tc_filesys.rb → adapters/tc_filesys.rb} +1 -1
- data/test/og/{tc_sqlite.rb → adapters/tc_sqlite.rb} +3 -4
- data/test/og/{tc_sqlserver.rb → adapters/tc_sqlserver.rb} +5 -2
- data/test/og/mixins/tc_hierarchical.rb +0 -1
- data/test/og/mixins/tc_orderable.rb +0 -1
- data/test/og/tc_automanage.rb +3 -2
- data/test/og/tc_lifecycle.rb +15 -14
- data/test/og/tc_many_to_many.rb +0 -1
- data/test/og/tc_meta.rb +5 -5
- data/test/og/tc_validation.rb +1 -1
- data/test/tc_og.rb +0 -20
- metadata +33 -34
- data/examples/test.db +0 -0
- data/lib/og/connection.rb +0 -325
- data/lib/og/observer.rb +0 -53
- data/test/og/tc_observer.rb +0 -85
@@ -1,6 +1,6 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: hierarchical.rb
|
3
|
+
# $Id: hierarchical.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
4
|
|
5
5
|
require 'glue/dynamic_include'
|
6
6
|
|
@@ -17,8 +17,8 @@ module NestedSets
|
|
17
17
|
:right => 'rgt',
|
18
18
|
:type => Fixnum,
|
19
19
|
:scope => '"1 = 1"',
|
20
|
-
:parent =>
|
21
|
-
:children =>
|
20
|
+
:parent => Inflector.name(base),
|
21
|
+
:children => Inflector.plural_name(base)
|
22
22
|
}
|
23
23
|
c.update(options) if options
|
24
24
|
|
@@ -26,7 +26,7 @@ module NestedSets
|
|
26
26
|
left = c[:left]
|
27
27
|
right = c[:right]
|
28
28
|
children = c[:children]
|
29
|
-
child =
|
29
|
+
child = Inflector.singularize(children)
|
30
30
|
|
31
31
|
if c[:scope].is_a?(Symbol) && c[:scope].to_s !~ /_oid$/
|
32
32
|
c[:scope] = "#{c[:scope]}_oid".intern
|
data/lib/og/mixins/orderable.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
# * George Moschovitis <gm@navel.gr>
|
2
|
+
# (c) 2005 Navel, all rights reserved.
|
3
|
+
# $Id: timestamped.rb 23 2005-04-16 18:20:00Z gmosx $
|
4
|
+
|
5
|
+
module Og
|
6
|
+
|
7
|
+
# Adds timestamping functionality.
|
8
|
+
|
9
|
+
module Timestamped
|
10
|
+
|
11
|
+
property :create_time, Time
|
12
|
+
property :update_time, Time
|
13
|
+
property :access_time, Time
|
14
|
+
|
15
|
+
pre "@create_time = @update_time = Time.now", :on => :og_insert
|
16
|
+
pre "@update_time = Time.now", :on => :og_update
|
17
|
+
|
18
|
+
def touch!
|
19
|
+
@access_time = Time.now
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/lib/og/mixins/tree.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: tree.rb
|
3
|
+
# $Id: tree.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
4
|
|
5
5
|
# NOT WORKING YET !!!
|
6
6
|
|
7
|
+
raise 'This is not working yet, do not require this file.'
|
8
|
+
|
7
9
|
require 'glue/attribute'
|
8
10
|
|
9
11
|
module Og
|
data/lib/og/testing/mock.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# * Thomas Quas <tquas@yahoo.com>
|
3
3
|
# (c) 2004-2005 Navel, all rights reserved.
|
4
|
-
# $Id$
|
4
|
+
# $Id: mock.rb 1 2005-04-11 11:04:30Z gmosx $
|
5
5
|
|
6
6
|
require 'flexmock'
|
7
7
|
|
@@ -51,7 +51,7 @@ class MockDatabase < ::FlexMock
|
|
51
51
|
# Initialize FlexMock
|
52
52
|
super
|
53
53
|
|
54
|
-
@managed_classes =
|
54
|
+
@managed_classes = SafeHash.new
|
55
55
|
|
56
56
|
Logger.info "Using mock database."
|
57
57
|
|
data/lib/og/typemacros.rb
CHANGED
data/lib/og/validation.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: validation.rb
|
3
|
+
# $Id: validation.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
4
|
|
5
5
|
require 'glue/validation'
|
6
6
|
|
7
|
-
module
|
7
|
+
module Glue
|
8
8
|
|
9
9
|
# Extend the Validation methods defined in glue/validation.rb with
|
10
10
|
# extra db related options.
|
@@ -34,7 +34,7 @@ module Validation
|
|
34
34
|
|
35
35
|
def validate_unique(*params)
|
36
36
|
c = {
|
37
|
-
:msg =>
|
37
|
+
:msg => Glue::Validation::Errors.not_unique,
|
38
38
|
:on => :save
|
39
39
|
}
|
40
40
|
c.update(params.pop) if params.last.is_a?(Hash)
|
@@ -57,7 +57,7 @@ module Validation
|
|
57
57
|
|
58
58
|
def validate_related(*params)
|
59
59
|
c = {
|
60
|
-
:msg =>
|
60
|
+
:msg => Glue::Validation::Errors.invalid_relation,
|
61
61
|
:on => :save
|
62
62
|
}
|
63
63
|
c.update(params.pop) if params.last.is_a?(Hash)
|
@@ -1,15 +1,14 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
2
2
|
|
3
|
-
=begin
|
4
|
-
|
5
3
|
require 'test/unit'
|
6
4
|
require 'ostruct'
|
7
5
|
|
8
6
|
require 'og'
|
9
7
|
require 'og/adapters/sqlite'
|
10
8
|
|
9
|
+
if defined?(SQLite3)
|
10
|
+
|
11
11
|
class TC_OgSqlite3 < Test::Unit::TestCase # :nodoc: all
|
12
|
-
include N
|
13
12
|
|
14
13
|
# Forward declaration.
|
15
14
|
|
@@ -84,4 +83,4 @@ class TC_OgSqlite3 < Test::Unit::TestCase # :nodoc: all
|
|
84
83
|
|
85
84
|
end
|
86
85
|
|
87
|
-
|
86
|
+
end
|
@@ -4,10 +4,11 @@ require 'test/unit'
|
|
4
4
|
require 'ostruct'
|
5
5
|
|
6
6
|
require 'og'
|
7
|
-
|
7
|
+
require 'og/adapters/sqlserver'
|
8
|
+
|
9
|
+
if defined?(DBI)
|
8
10
|
|
9
11
|
class TC_OgSqlserver < Test::Unit::TestCase # :nodoc: all
|
10
|
-
include N
|
11
12
|
|
12
13
|
# Forward declaration.
|
13
14
|
|
@@ -91,3 +92,5 @@ class TC_OgSqlserver < Test::Unit::TestCase # :nodoc: all
|
|
91
92
|
end
|
92
93
|
|
93
94
|
end
|
95
|
+
|
96
|
+
end
|
data/test/og/tc_automanage.rb
CHANGED
@@ -14,15 +14,16 @@ $og = Og::Database.new(
|
|
14
14
|
)
|
15
15
|
|
16
16
|
class TestCaseOgObserver < Test::Unit::TestCase # :nodoc: all
|
17
|
-
include N
|
18
17
|
|
19
18
|
# Define a class after the Database is created.
|
20
19
|
|
20
|
+
class Article; end
|
21
|
+
|
21
22
|
class User
|
22
23
|
property :name
|
23
24
|
|
24
25
|
# auto forward ref.
|
25
|
-
has_many :articles,
|
26
|
+
has_many :articles, Article
|
26
27
|
end
|
27
28
|
|
28
29
|
class Article
|
data/test/og/tc_lifecycle.rb
CHANGED
@@ -3,35 +3,35 @@
|
|
3
3
|
|
4
4
|
# * Thomas Quas <tquas@yahoo.com>
|
5
5
|
# * George Moschovitis <gm@navel.gr>
|
6
|
-
# $Id$
|
6
|
+
# $Id: tc_lifecycle.rb 17 2005-04-14 16:03:40Z gmosx $
|
7
7
|
|
8
8
|
$LOAD_PATH.unshift 'lib'
|
9
9
|
|
10
10
|
require 'test/unit'
|
11
11
|
require 'glue/logger'
|
12
|
-
require 'og/mock'
|
12
|
+
require 'og/testing/mock'
|
13
13
|
|
14
14
|
$DBG = false
|
15
15
|
|
16
16
|
class Dummy
|
17
|
-
|
18
|
-
attr_reader :call_stack
|
17
|
+
include Aspects
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
end
|
19
|
+
prop_accessor :date, Time
|
20
|
+
attr_accessor :call_stack
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
end
|
22
|
+
pre(:on => :og_insert) { |this| this.call_stack << 'pre_insert' }
|
23
|
+
post(:on => :og_insert) { |this| this.call_stack << 'post_insert' }
|
27
24
|
|
28
|
-
def og_pre_update
|
25
|
+
def og_pre_update
|
29
26
|
@call_stack << 'pre_update'
|
30
27
|
end
|
28
|
+
pre :og_pre_update, :on => :og_update
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
post(:on => :og_update) { |this| this.call_stack << 'post_update' }
|
31
|
+
|
32
|
+
# faster :)
|
33
|
+
|
34
|
+
post "@call_stack << 'post_update2'", :on => :og_update
|
35
35
|
|
36
36
|
def self.og_pre_delete( conn, oid )
|
37
37
|
raise 'undeletable'
|
@@ -63,6 +63,7 @@ class TC_CallbackTest < ::Test::Unit::TestCase
|
|
63
63
|
obj.save
|
64
64
|
assert( obj.call_stack.shift == "pre_update" )
|
65
65
|
assert( obj.call_stack.shift == "post_update" )
|
66
|
+
assert( obj.call_stack.shift == "post_update2" )
|
66
67
|
assert( obj.call_stack.empty? )
|
67
68
|
end
|
68
69
|
|
data/test/og/tc_many_to_many.rb
CHANGED
data/test/og/tc_meta.rb
CHANGED
@@ -6,7 +6,7 @@ require 'ostruct'
|
|
6
6
|
require 'og'
|
7
7
|
|
8
8
|
class TC_OgMeta < Test::Unit::TestCase # :nodoc: all
|
9
|
-
include
|
9
|
+
include Og
|
10
10
|
|
11
11
|
# Forward declaration.
|
12
12
|
|
@@ -40,13 +40,13 @@ class TC_OgMeta < Test::Unit::TestCase # :nodoc: all
|
|
40
40
|
def test_all
|
41
41
|
par = Article.__meta[:props_and_relations]
|
42
42
|
assert_equal 3, par.size
|
43
|
-
assert_equal
|
44
|
-
assert_equal
|
43
|
+
assert_equal Property, par[1].class
|
44
|
+
assert_equal HasMany, par[2].class
|
45
45
|
|
46
46
|
par = Comment.__meta[:props_and_relations]
|
47
47
|
assert_equal 3, par.size
|
48
|
-
assert_equal
|
49
|
-
assert_equal
|
48
|
+
assert_equal Property, par[0].class
|
49
|
+
assert_equal BelongsTo, par[1].class
|
50
50
|
assert_equal 'article_oid', par[1].meta[:property].to_s
|
51
51
|
assert_equal String, par[0].klass
|
52
52
|
assert_equal Article, par[1].foreign_class
|
data/test/og/tc_validation.rb
CHANGED
data/test/tc_og.rb
CHANGED
@@ -48,18 +48,6 @@ class Article
|
|
48
48
|
@body = body
|
49
49
|
@options = {"hello" => "world"}
|
50
50
|
end
|
51
|
-
|
52
|
-
def og_pre_insert(conn)
|
53
|
-
puts "-- PRE INSERT CALLED FOR ARTICLE"
|
54
|
-
end
|
55
|
-
|
56
|
-
def og_post_insert_update(conn)
|
57
|
-
puts "-- POST INSERT UPDATE CALLED FOR ARTICLE"
|
58
|
-
end
|
59
|
-
|
60
|
-
def og_post_update(conn)
|
61
|
-
puts "-- POST UPDATE CALLED FOR ARTICLE"
|
62
|
-
end
|
63
51
|
end
|
64
52
|
|
65
53
|
class Comment
|
@@ -72,14 +60,6 @@ class Comment
|
|
72
60
|
@create_time = Time.now
|
73
61
|
@body = body
|
74
62
|
end
|
75
|
-
|
76
|
-
def og_pre_insert(conn)
|
77
|
-
puts "-- PRE INSERT CALLED FOR COMMENT"
|
78
|
-
end
|
79
|
-
|
80
|
-
def og_post_insert(conn)
|
81
|
-
puts "-- POST INSERT CALLED FOR COMMENT"
|
82
|
-
end
|
83
63
|
end
|
84
64
|
|
85
65
|
module MyMixin
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
4
4
|
name: og
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2005-04-
|
6
|
+
version: 0.16.0
|
7
|
+
date: 2005-04-18
|
8
8
|
summary: Og (ObjectGraph)
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -21,67 +21,66 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
21
21
|
-
|
22
22
|
- ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 1.8.
|
24
|
+
version: 1.8.2
|
25
25
|
version:
|
26
26
|
platform: ruby
|
27
27
|
authors:
|
28
28
|
- George Moschovitis
|
29
29
|
files:
|
30
|
+
- CHANGELOG
|
30
31
|
- Rakefile
|
31
32
|
- INSTALL
|
32
|
-
- CHANGELOG
|
33
33
|
- README
|
34
34
|
- install.rb
|
35
|
-
- benchmark/sqlite-prepare.2.txt
|
36
|
-
- benchmark/sqlite-no-prepare.2.txt
|
37
|
-
- benchmark/sqlite-no-prepare.1.txt
|
38
35
|
- benchmark/bench.rb
|
36
|
+
- benchmark/sqlite-no-prepare.1.txt
|
37
|
+
- benchmark/sqlite-no-prepare.2.txt
|
39
38
|
- benchmark/sqlite-prepare.1.txt
|
40
|
-
-
|
41
|
-
- examples/mysql_to_psql.rb
|
42
|
-
- examples/run.rb
|
39
|
+
- benchmark/sqlite-prepare.2.txt
|
43
40
|
- examples/mock_example.rb
|
41
|
+
- examples/run.rb
|
42
|
+
- examples/mysql_to_psql.rb
|
44
43
|
- examples/README
|
45
|
-
- doc/
|
44
|
+
- doc/tutorial.txt
|
46
45
|
- doc/LICENSE
|
47
|
-
- doc/
|
46
|
+
- doc/config.txt
|
48
47
|
- doc/RELEASES
|
49
|
-
- doc/
|
48
|
+
- doc/AUTHORS
|
50
49
|
- lib/og
|
51
50
|
- lib/og.rb
|
52
|
-
- lib/og/adapter.rb
|
53
|
-
- lib/og/testing
|
54
|
-
- lib/og/mixins
|
55
51
|
- lib/og/adapters
|
52
|
+
- lib/og/mixins
|
53
|
+
- lib/og/testing
|
54
|
+
- lib/og/typemacros.rb
|
56
55
|
- lib/og/enchant.rb
|
57
|
-
- lib/og/connection.rb
|
58
|
-
- lib/og/observer.rb
|
59
56
|
- lib/og/database.rb
|
60
57
|
- lib/og/meta.rb
|
61
58
|
- lib/og/validation.rb
|
62
|
-
- lib/og/
|
63
|
-
- lib/og/testing/mock.rb
|
64
|
-
- lib/og/mixins/hierarchical.rb
|
65
|
-
- lib/og/mixins/orderable.rb
|
66
|
-
- lib/og/mixins/tree.rb
|
67
|
-
- lib/og/adapters/oracle.rb
|
59
|
+
- lib/og/errors.rb
|
68
60
|
- lib/og/adapters/filesys.rb
|
69
|
-
- lib/og/adapters/
|
61
|
+
- lib/og/adapters/psql.rb
|
70
62
|
- lib/og/adapters/sqlite.rb
|
63
|
+
- lib/og/adapters/mysql.rb
|
64
|
+
- lib/og/adapters/oracle.rb
|
71
65
|
- lib/og/adapters/sqlserver.rb
|
72
|
-
- lib/og/adapters/
|
73
|
-
-
|
66
|
+
- lib/og/adapters/base.rb
|
67
|
+
- lib/og/mixins/hierarchical.rb
|
68
|
+
- lib/og/mixins/tree.rb
|
69
|
+
- lib/og/mixins/orderable.rb
|
70
|
+
- lib/og/mixins/timestamped.rb
|
71
|
+
- lib/og/testing/mock.rb
|
74
72
|
- test/og
|
73
|
+
- test/tc_og.rb
|
74
|
+
- test/og/adapters
|
75
75
|
- test/og/mixins
|
76
|
-
- test/og/
|
76
|
+
- test/og/tc_many_to_many.rb
|
77
77
|
- test/og/tc_validation.rb
|
78
|
-
- test/og/
|
78
|
+
- test/og/tc_lifecycle.rb
|
79
79
|
- test/og/tc_automanage.rb
|
80
|
-
- test/og/tc_filesys.rb
|
81
|
-
- test/og/tc_sqlserver.rb
|
82
80
|
- test/og/tc_meta.rb
|
83
|
-
- test/og/
|
84
|
-
- test/og/
|
81
|
+
- test/og/adapters/tc_filesys.rb
|
82
|
+
- test/og/adapters/tc_sqlite.rb
|
83
|
+
- test/og/adapters/tc_sqlserver.rb
|
85
84
|
- test/og/mixins/tc_hierarchical.rb
|
86
85
|
- test/og/mixins/tc_orderable.rb
|
87
86
|
test_files: []
|
@@ -109,5 +108,5 @@ dependencies:
|
|
109
108
|
-
|
110
109
|
- "="
|
111
110
|
- !ruby/object:Gem::Version
|
112
|
-
version: 0.
|
111
|
+
version: 0.16.0
|
113
112
|
version:
|