og 0.20.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +796 -664
- data/INSTALL +24 -24
- data/README +39 -32
- data/Rakefile +41 -42
- data/benchmark/bench.rb +36 -36
- data/doc/AUTHORS +15 -12
- data/doc/LICENSE +3 -3
- data/doc/RELEASES +311 -243
- data/doc/config.txt +1 -1
- data/examples/mysql_to_psql.rb +15 -15
- data/examples/run.rb +92 -92
- data/install.rb +7 -17
- data/lib/og.rb +76 -75
- data/lib/og/collection.rb +203 -160
- data/lib/og/entity.rb +168 -169
- data/lib/og/errors.rb +5 -5
- data/lib/og/manager.rb +179 -178
- data/lib/og/mixin/hierarchical.rb +107 -107
- data/lib/og/mixin/optimistic_locking.rb +36 -36
- data/lib/og/mixin/orderable.rb +148 -148
- data/lib/og/mixin/timestamped.rb +8 -8
- data/lib/og/mixin/tree.rb +124 -124
- data/lib/og/relation.rb +237 -213
- data/lib/og/relation/belongs_to.rb +5 -5
- data/lib/og/relation/has_many.rb +60 -58
- data/lib/og/relation/joins_many.rb +93 -47
- data/lib/og/relation/refers_to.rb +25 -21
- data/lib/og/store.rb +210 -207
- data/lib/og/store/filesys.rb +79 -79
- data/lib/og/store/kirby.rb +263 -258
- data/lib/og/store/memory.rb +261 -261
- data/lib/og/store/mysql.rb +288 -284
- data/lib/og/store/psql.rb +261 -244
- data/lib/og/store/sql.rb +873 -720
- data/lib/og/store/sqlite.rb +177 -175
- data/lib/og/store/sqlserver.rb +204 -214
- data/lib/og/types.rb +1 -1
- data/lib/og/validation.rb +57 -57
- data/lib/vendor/mysql.rb +376 -376
- data/lib/vendor/mysql411.rb +10 -10
- data/test/og/mixin/tc_hierarchical.rb +59 -59
- data/test/og/mixin/tc_optimistic_locking.rb +40 -40
- data/test/og/mixin/tc_orderable.rb +67 -67
- data/test/og/mixin/tc_timestamped.rb +19 -19
- data/test/og/store/tc_filesys.rb +46 -46
- data/test/og/tc_inheritance.rb +81 -81
- data/test/og/tc_join.rb +67 -0
- data/test/og/tc_polymorphic.rb +49 -49
- data/test/og/tc_relation.rb +57 -30
- data/test/og/tc_select.rb +49 -0
- data/test/og/tc_store.rb +345 -337
- data/test/og/tc_types.rb +11 -11
- metadata +11 -18
data/INSTALL
CHANGED
@@ -2,27 +2,27 @@
|
|
2
2
|
|
3
3
|
1. Download and install RubyGems:
|
4
4
|
|
5
|
-
|
5
|
+
http://rubygems.rubyforge.org
|
6
6
|
|
7
7
|
2. Install the distribution:
|
8
8
|
|
9
|
-
|
9
|
+
gem install og
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
(make sure you have the latest stable versions of Ruby and RubyGems
|
12
|
+
installed)
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
When asked about the dependencies to include, only accept
|
15
|
+
the dependencies for the RDBMS backends you are planning
|
16
|
+
to use.
|
17
17
|
|
18
18
|
3. Set environment variable (required to load RubyGems):
|
19
19
|
|
20
|
-
|
20
|
+
export RUBYOPT=-rubygems
|
21
21
|
|
22
|
-
|
22
|
+
You can add this in you .bashrc in Unix.
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
Alternatively you can run your applications with the -rubygem
|
25
|
+
option:
|
26
26
|
|
27
27
|
ruby -rubygem xxx.rb
|
28
28
|
|
@@ -34,13 +34,13 @@ a standard installation script is provided.
|
|
34
34
|
|
35
35
|
1. Switch to an administrator account
|
36
36
|
|
37
|
-
|
37
|
+
For example in Unix:
|
38
38
|
|
39
|
-
|
39
|
+
$ su -
|
40
40
|
|
41
41
|
2. Run the installation script.
|
42
42
|
|
43
|
-
|
43
|
+
$ ruby install.rb
|
44
44
|
|
45
45
|
This installation script also installs some vendor libraries
|
46
46
|
that you possibly have allready installed. Use with caution.
|
@@ -69,17 +69,17 @@ installs most of them, but here is the complete
|
|
69
69
|
list for your reference:
|
70
70
|
|
71
71
|
* Ruby-psql
|
72
|
-
|
73
|
-
|
72
|
+
http://www.postgresql.jp/interfaces/ruby/archive/ruby-postgres-0.7.1.tar.gz
|
73
|
+
Ruby interface to the PostgreSQL RDBMS.
|
74
74
|
|
75
75
|
* Ruby-mysql
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
http://tmtm.org/ja/ruby/mysql/README_en.html
|
77
|
+
Ruby interface to the MySQL RDBMS.
|
78
|
+
|
79
79
|
* PostgreSQL
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
http://www.postgres.org
|
81
|
+
Used for the Database Backend.
|
82
|
+
|
83
83
|
* MySQL
|
84
|
-
|
85
|
-
|
84
|
+
http://www.mysql.org
|
85
|
+
Used for the Database Backend.
|
data/README
CHANGED
@@ -1,20 +1,23 @@
|
|
1
|
-
= Og 0.
|
2
|
-
|
3
|
-
Og (ObjectGraph) is a
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
= Og 0.21.0 README
|
2
|
+
|
3
|
+
Og (ObjectGraph) is a powerful and elegant object-relational mapping
|
4
|
+
library. Og manages the lifecycle of Ruby objects and provides
|
5
|
+
transparent serialization of object graphs to stores (typically
|
6
|
+
RDBM systems)/.
|
7
|
+
|
8
|
+
Unlike other similar solutions Og maps standard Ruby objects
|
9
|
+
to SQL tables and not vice versa. Og provides a domain specific
|
10
|
+
language to describe the relations between objects, a flexible
|
11
|
+
and intuitive api for querieng the database, raw access to the
|
12
|
+
SQL language if needed (for example to fine tune the automatically
|
13
|
+
generated SQL tables, or for custom queries), provides automatic
|
14
|
+
validation, suports deserialization to Ruby objects or tuples,
|
11
15
|
automatically generates join tables for many_to_many relations
|
12
|
-
and provides a collection of usefull Mixins to synthesize
|
13
|
-
Entities.
|
16
|
+
and provides a collection of usefull Mixins to synthesize
|
17
|
+
common Entities.
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
PostgreSQL, MySQL and SQLite are included.
|
19
|
+
Adapters for PostgreSQL, MySQL, SQLite3, Memory, Filesystem,
|
20
|
+
Oracle and SQL Server are included.
|
18
21
|
|
19
22
|
Og is part of the Nitro project, released as a stand-alone library
|
20
23
|
due to popular demand. You can find the ChangeLog in the Nitro
|
@@ -29,7 +32,11 @@ The library provides the following features:
|
|
29
32
|
* Absolutely no configuration files.
|
30
33
|
* Multiple stores (PostgreSQL, MySQL, SQLite, Oraclei, SqlServer, ..).
|
31
34
|
* Supports non SQL stores.
|
32
|
-
* ActiveRecord-style
|
35
|
+
* ActiveRecord-style domain specific language and db synchronized
|
36
|
+
collections.
|
37
|
+
* Transforms resultsets from arbitrary sql queries to Ruby objects.
|
38
|
+
* Automatically generate join tables for many to many relations.
|
39
|
+
* Can use any Ruby object to join other Ruby objects.
|
33
40
|
* Deserialize to Ruby Objects.
|
34
41
|
* Deserialize sql join queries to Ruby Objects.
|
35
42
|
* Eager associations.
|
@@ -79,30 +86,30 @@ of new features have been added in the meantime.
|
|
79
86
|
Og requires the following applications or libraries:
|
80
87
|
|
81
88
|
* Ruby 1.8.1 and greater
|
82
|
-
|
83
|
-
|
89
|
+
http://www.ruby-lang.org
|
90
|
+
Version 1.8.2 is recomended.
|
84
91
|
|
85
92
|
* Ruby-psql
|
86
|
-
|
87
|
-
|
93
|
+
http://www.postgresql.jp/interfaces/ruby/archive/ruby-postgres-0.7.1.tar.gz
|
94
|
+
Ruby interface to the PostgreSQL RDBMS.
|
88
95
|
|
89
96
|
* Ruby-mysql
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
97
|
+
http://tmtm.org/ja/ruby/mysql/README_en.html
|
98
|
+
Ruby interface to the MySQL RDBMS.
|
99
|
+
Pure Ruby Mysql interface:
|
100
|
+
http://www.tmtm.org/ruby/mysql/
|
101
|
+
|
95
102
|
* PostgreSQL
|
96
|
-
|
97
|
-
|
98
|
-
|
103
|
+
http://www.postgres.org
|
104
|
+
Used for the Database Backend.
|
105
|
+
|
99
106
|
* MySQL
|
100
|
-
|
101
|
-
|
107
|
+
http://www.mysql.org
|
108
|
+
Used for the Database Backend.
|
102
109
|
|
103
110
|
* SQLite
|
104
|
-
|
105
|
-
|
111
|
+
http://www.sqlite.org/download.html
|
112
|
+
WARNING: you need sqlite3-ruby > 1.1.0
|
106
113
|
|
107
114
|
Please install the required applications and libraries before continuing
|
108
115
|
with the installation of Og. Only install the libraries needed for
|
data/Rakefile
CHANGED
@@ -23,64 +23,63 @@ VersionFile = MainFile = File.join("lib", Name + '.rb')
|
|
23
23
|
|
24
24
|
RubyForgeProject = 'nitro'
|
25
25
|
RubyForgeUser = 'gmosx'
|
26
|
-
Homepage = "http
|
26
|
+
Homepage = "http://www.nitrohq.com/"
|
27
27
|
|
28
28
|
task :default => :package
|
29
29
|
|
30
30
|
# Run the tests.
|
31
31
|
|
32
32
|
Rake::TestTask.new do |t|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
t.libs << 'test'
|
34
|
+
t.test_files = FileList['test/**/tc*.rb']
|
35
|
+
t.verbose = true
|
36
36
|
end
|
37
37
|
|
38
38
|
# Generate RDoc documentation.
|
39
39
|
|
40
40
|
Rake::RDocTask.new do |rd|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
rd.main = 'README'
|
42
|
+
rd.rdoc_dir = 'rdoc'
|
43
|
+
rd.rdoc_files.include('README', 'INSTALL', 'doc/tutorial.txt', 'lib/**/*.rb')
|
44
|
+
rd.options << '--all --inline-source'
|
45
45
|
end
|
46
46
|
|
47
47
|
# Build gem.
|
48
48
|
|
49
49
|
spec = Gem::Specification.new do |s|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
s.rubyforge_project = 'nitro'
|
50
|
+
s.name = 'og'
|
51
|
+
if File.read('lib/og.rb') =~ /Version\s+=\s+'(\d+\.\d+\.\d+)'/
|
52
|
+
s.version = $1
|
53
|
+
else
|
54
|
+
raise 'No version found'
|
55
|
+
end
|
56
|
+
s.summary = 'Og (ObjectGraph)'
|
57
|
+
s.description = 'An efficient and transparent Object-Relational mapping library'
|
58
|
+
|
59
|
+
s.add_dependency 'glue', "= #{s.version}"
|
60
|
+
#s.add_dependency 'postgres-pr', '>= 0.3.0'
|
61
|
+
#s.add_dependency 'postgres', '>= 0.7.1'
|
62
|
+
#s.add_dependency 'sqlite3-ruby', '>= 1.0.0'
|
63
|
+
#s.add_dependency 'mysql', '>= 2.5.1'
|
64
|
+
|
65
|
+
s.required_ruby_version = '>= 1.8.2'
|
66
|
+
|
67
|
+
s.files = FileList[
|
68
|
+
'[A-Z]*', 'install.rb', '{bin,benchmark,examples,doc,lib,test,vendor}/**/*'
|
69
|
+
].exclude('.svn/**/*').exclude('**/*.log').to_a
|
70
|
+
|
71
|
+
s.require_path = 'lib'
|
72
|
+
s.autorequire = 'og'
|
73
|
+
|
74
|
+
s.has_rdoc = true
|
75
|
+
s.extra_rdoc_files = FileList['README', 'INSTALL', 'doc/tutorial.txt'].to_a
|
76
|
+
s.rdoc_options << '--main' << 'README' << '--title' << 'Og Documentation'
|
77
|
+
s.rdoc_options << '--all' << '--inline-source'
|
78
|
+
|
79
|
+
s.author = 'George Moschovitis'
|
80
|
+
s.email = 'gm@navel.gr'
|
81
|
+
s.homepage = 'http://www.nitrohq.com'
|
82
|
+
s.rubyforge_project = 'nitro'
|
84
83
|
end
|
85
84
|
|
86
85
|
Rake::GemPackageTask.new(spec) do |pkg|
|
data/benchmark/bench.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: bench.rb
|
3
|
+
# $Id: bench.rb 182 2005-07-22 10:07:50Z gmosx $
|
4
4
|
|
5
5
|
require 'og'; include Og
|
6
6
|
|
7
7
|
|
8
8
|
config = {
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
:adapter => 'sqlite',
|
10
|
+
:database => 'test',
|
11
|
+
:connection_count => 5
|
12
12
|
}
|
13
13
|
|
14
14
|
class Article
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
prop_accessor :title, String
|
16
|
+
prop_accessor :body, String
|
17
|
+
prop_accessor :hits, Fixnum
|
18
|
+
prop_accessor :rate, Fixnum
|
19
|
+
|
20
|
+
def initialize(title = nil, body = nil)
|
21
|
+
@title = title
|
22
|
+
@body = body
|
23
|
+
@hits = rand(5)
|
24
|
+
@rate = rand(100)
|
25
|
+
end
|
26
26
|
end
|
27
27
|
|
28
28
|
Database.drop_db!(config)
|
@@ -34,7 +34,7 @@ db = Database.new(config)
|
|
34
34
|
articles = []
|
35
35
|
|
36
36
|
500.times do |i|
|
37
|
-
|
37
|
+
articles << Article.new("Title#{i}", "Body#{i}")
|
38
38
|
end
|
39
39
|
|
40
40
|
sum = 0
|
@@ -45,26 +45,26 @@ GC.disable
|
|
45
45
|
|
46
46
|
10.times do |i|
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
48
|
+
db.exec "DELETE FROM #{Article::DBTABLE}"
|
49
|
+
|
50
|
+
for article in articles
|
51
|
+
article.oid = nil
|
52
|
+
end
|
53
|
+
|
54
|
+
Article.create("Dummy", "Dummy")
|
55
|
+
|
56
|
+
t1 = Time.now
|
57
|
+
articles.each do |a|
|
58
|
+
a.save!
|
59
|
+
end
|
60
|
+
t2 = Time.now
|
61
|
+
|
62
|
+
d = t2 - t1
|
63
|
+
sum += d
|
64
|
+
min = d if d < min
|
65
|
+
max = d if d > max
|
66
|
+
|
67
|
+
puts "Insert test #{i}: #{d} seconds"
|
68
68
|
|
69
69
|
end
|
70
70
|
|
data/doc/AUTHORS
CHANGED
@@ -1,28 +1,31 @@
|
|
1
1
|
MAIN DEVELOPER:
|
2
2
|
|
3
3
|
* George Moschovitis <gm@navel.gr>
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
Project leader, architecture and design, main coder,
|
5
|
+
documentation, maintainer.
|
6
|
+
|
7
7
|
IDEAS, ADDITIONAL CODING, SUPPORT:
|
8
8
|
|
9
9
|
* Michael Neumann <mneumann@ntecs.de>
|
10
|
-
|
10
|
+
Design, additional coding and bug reports.
|
11
11
|
|
12
12
|
* Anastasios Koutoumanos <ak@navel.gr>
|
13
|
-
|
13
|
+
Design, additional coding.
|
14
14
|
|
15
|
-
*
|
16
|
-
|
15
|
+
* Matt Bowen <matt.bowen@farweststeel.com>
|
16
|
+
Oracle driver, documentation.
|
17
17
|
|
18
|
+
* Ysabel <deb@ysabel.org>
|
19
|
+
Refactoring, patches.
|
20
|
+
|
18
21
|
* Aleksi Niemela <Aleksi.Niemela@cs.helsinki.fi>
|
19
|
-
|
22
|
+
Bug reports and patches.
|
20
23
|
|
21
|
-
*
|
22
|
-
|
24
|
+
* Julien Perrot <jperrot@exosec.fr>
|
25
|
+
Bug reports and patches.
|
23
26
|
|
24
27
|
* Ghislain Mary <gmary@lunacymaze.org>
|
25
|
-
|
28
|
+
Bug reports and patches (sqlite3 driver).
|
26
29
|
|
27
30
|
* Thomas Quas <tquas@yahoo.com>
|
28
|
-
|
31
|
+
Ideas, bug reports, unit tests.
|
data/doc/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The BSD License
|
2
2
|
|
3
|
-
Copyright (c) 2004-2005, George '
|
3
|
+
Copyright (c) 2004-2005, George 'gmosx' Moschovitis. (http://www.gmosx.com)
|
4
4
|
Copyright (c) 2004-2005, Navel Ltd. (http://www.navel.gr)
|
5
5
|
All rights reserved.
|
6
6
|
|
@@ -10,11 +10,11 @@ met:
|
|
10
10
|
|
11
11
|
* Redistributions of source code must retain the above copyright
|
12
12
|
notice, this list of conditions and the following disclaimer.
|
13
|
-
|
13
|
+
|
14
14
|
* Redistributions in binary form must reproduce the above copyright
|
15
15
|
notice, this list of conditions and the following disclaimer in the
|
16
16
|
documentation and/or other materials provided with the distribution.
|
17
|
-
|
17
|
+
|
18
18
|
* Neither the name of Navel nor the names of its contributors may be
|
19
19
|
used to endorse or promote products derived from this software
|
20
20
|
without specific prior written permission.
|