og 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/CHANGELOG +77 -0
  2. data/INSTALL +3 -0
  3. data/README +5 -3
  4. data/Rakefile +148 -5
  5. data/benchmark/bench.rb +1 -1
  6. data/doc/AUTHORS +4 -4
  7. data/doc/RELEASES +41 -1
  8. data/examples/mock_example.rb +1 -1
  9. data/examples/mysql_to_psql.rb +1 -1
  10. data/examples/run.rb +1 -1
  11. data/install.rb +1 -1
  12. data/lib/og.rb +4 -2
  13. data/lib/og/{adapter.rb → adapters/base.rb} +334 -152
  14. data/lib/og/adapters/filesys.rb +3 -7
  15. data/lib/og/adapters/mysql.rb +5 -9
  16. data/lib/og/adapters/oracle.rb +5 -9
  17. data/lib/og/adapters/psql.rb +5 -9
  18. data/lib/og/adapters/sqlite.rb +5 -9
  19. data/lib/og/adapters/sqlserver.rb +5 -9
  20. data/lib/og/database.rb +13 -11
  21. data/lib/og/enchant.rb +1 -1
  22. data/lib/og/errors.rb +21 -0
  23. data/lib/og/meta.rb +10 -9
  24. data/lib/og/mixins/hierarchical.rb +4 -4
  25. data/lib/og/mixins/orderable.rb +1 -1
  26. data/lib/og/mixins/timestamped.rb +24 -0
  27. data/lib/og/mixins/tree.rb +3 -1
  28. data/lib/og/testing/mock.rb +2 -2
  29. data/lib/og/typemacros.rb +1 -1
  30. data/lib/og/validation.rb +4 -4
  31. data/test/og/{tc_filesys.rb → adapters/tc_filesys.rb} +1 -1
  32. data/test/og/{tc_sqlite.rb → adapters/tc_sqlite.rb} +3 -4
  33. data/test/og/{tc_sqlserver.rb → adapters/tc_sqlserver.rb} +5 -2
  34. data/test/og/mixins/tc_hierarchical.rb +0 -1
  35. data/test/og/mixins/tc_orderable.rb +0 -1
  36. data/test/og/tc_automanage.rb +3 -2
  37. data/test/og/tc_lifecycle.rb +15 -14
  38. data/test/og/tc_many_to_many.rb +0 -1
  39. data/test/og/tc_meta.rb +5 -5
  40. data/test/og/tc_validation.rb +1 -1
  41. data/test/tc_og.rb +0 -20
  42. metadata +33 -34
  43. data/examples/test.db +0 -0
  44. data/lib/og/connection.rb +0 -325
  45. data/lib/og/observer.rb +0 -53
  46. data/test/og/tc_observer.rb +0 -85
data/CHANGELOG CHANGED
@@ -1,5 +1,82 @@
1
+ 16-04-2005 George Moschovitis <gm@navel.gr>
2
+
3
+ * lib/og/mixins/timestamped.rb: implemented with aspects.
4
+
5
+ 15-04-2005 George Moschovitis <gm@navel.gr>
6
+
7
+ * test/og/observer.rb: removed, use Aspects instead.
8
+
9
+ * lib/og/observer.rb: removed, use Aspects instead.
10
+
11
+ 14-04-2005 George Moschovitis <gm@navel.gr>
12
+
13
+ * lb/og/adapters/*: converted to the latest adapter interface.
14
+
15
+ * lib/og/adapters/base.rb (#eval_og_update): use aspects instead of
16
+ callbacks/observers,
17
+ (#eval_og_insert): use aspects,
18
+ set aspects in the base adapter code,
19
+ (#eval_og_read): use aspects.
20
+
21
+ 13-04-2005 George Moschovitis <gm@navel.gr>
22
+
23
+ * lib/og/adapters/*: use klass.allocate instead of klass.new to avoid
24
+ restrictions on initialize methods. [jamesb]
25
+
26
+ * test/og/*: moved adapter test code to the adapters dir.
27
+
28
+ 12-04-2005 George Moschovitis <gm@navel.gr>
29
+
30
+ * Rakefile: updated to support autoupload to Rubyforge. [flgr]
31
+
32
+ 11-04-2005 George Moschovitis <gm@navel.gr>
33
+
34
+ * created new public SVN repository, to allow for easier
35
+ patching by the community.
36
+
37
+ * lib/og/mixins/timestamped.rb: introduced.
38
+
39
+ * lib/og/database.rb: set default connection_count > 1 to avoid
40
+ deadlocks.
41
+
42
+ 10-04-2005 George Moschovitis <gm@navel.gr>
43
+
44
+ * test/*: many changes to make all run again.
45
+
46
+ * lib/og/adapters/sqlserver.rb: fix.
47
+
48
+ * lib/og/database.rb (Og##connect): added helper.
49
+
50
+ * lib/og/meta.rb: small fix.
51
+
52
+ 08-04-2005 George Moschovitis <gm@navel.gr>
53
+
54
+ * hack-fixed dynamic require bug that used to fuckup RDoc.
55
+
56
+ * Rakefile: bumped required ruby version,
57
+ VERSION fix.
58
+
59
+ * code cleanup.
60
+
61
+ * MAJOR: fixed refs to N.
62
+
63
+ 06-04-2005 George Moschovitis <gm@navel.gr>
64
+
65
+ * lib/og/adapters/*: all reuse the base now.
66
+
67
+ * lib/og/connection.rb: removed.
68
+
69
+ * lib/og/adapter.rb: removed.
70
+
71
+ * lib/og/adapters/base.rb: introduced,
72
+ copied code from adapter.rb and connection.rb
73
+
74
+ * lib/og/errors.rb: introduced, moved SqlException here.
75
+
1
76
  04-04-2005 George Moschovitis <gm@navel.gr>
2
77
 
78
+ * --- VERSION 0.15.0 ---
79
+
3
80
  * examples/run.rb: small fix.
4
81
 
5
82
  * test/og/mixins/tc_tree.rb: removed.
data/INSTALL CHANGED
@@ -8,6 +8,9 @@
8
8
 
9
9
  gem install og
10
10
 
11
+ (make sure you have the latest stable versions of Ruby and RubyGems
12
+ installed)
13
+
11
14
  When asked about the dependencies to include, only accept
12
15
  the dependencies for the RDBMS backends you are planning
13
16
  to use.
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = Og 0.15.0
1
+ = Og 0.16.0 README
2
2
 
3
3
  Og (ObjectGraph) is a powerfull object-relational mapping library. Og provides
4
4
  transparent serialization of object graphs to a RDBMS
@@ -35,8 +35,7 @@ The library provides the following features:
35
35
  + Connection pooling.
36
36
  + Thread safety.
37
37
  + SQL transactions.
38
- + Lifecycle callbacks.
39
- + Lifecycle observers.
38
+ + Lifecycle event interception and Observers.
40
39
  + Transparent support for cascading deletes for all backends.
41
40
  + Dynamic db related mixins (Orderable, etc).
42
41
  + Hierarchical structures (nested sets, more coming soon).
@@ -91,6 +90,9 @@ installed RubyGems on your system. Then run the following command:
91
90
 
92
91
  gem install og
93
92
 
93
+ (make sure you have the latest stable versions of Ruby and RubyGems
94
+ installed)
95
+
94
96
  Then try to run the examples in the examples directory.
95
97
 
96
98
  A tar.gz distribution is also available on http://www.rubyforge.com/projects/nitro.
data/Rakefile CHANGED
@@ -1,11 +1,34 @@
1
1
  # * George Moschovitis <gm@navel.gr>
2
- # (c) 2004-2005 Navel, all rights reserved.
2
+ # (c) 2005 Navel, all rights reserved.
3
3
  # $Id$
4
4
 
5
5
  require 'rake/rdoctask'
6
6
  require 'rake/testtask'
7
7
  require 'rake/gempackagetask'
8
8
 
9
+ # Initialize some variables.
10
+
11
+ readme = File.read('README')
12
+ Release = (readme[/^= (.+) README$/, 1] || 'unknown').downcase.tr(" ", "-")
13
+ Name = Release[/\D+/].sub(/\-+$/, '') || 'unknown'
14
+ Version = Release[/[\d.]+/] || 'unknown'
15
+
16
+ AuthorName, AuthorMail = 'George Moschovitis', 'gm@navel.gr'
17
+ RubyVersion = '1.8.2'
18
+
19
+ # Description = (readme[/README\s+(.+?)\n\n/m, 1] || "unknown").gsub(/\s+/, " ")
20
+ # Summary = Description[/^.+?>/] || "unknown"
21
+
22
+ # DocFiles = %w(README NEWS TODO COPYING GPL)
23
+ # RDocFiles = DocFiles - %w(GPL)
24
+ RDocOpts = ["--inline-source", "--line-numbers","--title", Name ]
25
+ # AdditionalFiles = DocFiles + %w(setup.rb)
26
+ VersionFile = MainFile = File.join("lib", Name + '.rb')
27
+
28
+ RubyForgeProject = 'nitro'
29
+ RubyForgeUser = 'gmosx'
30
+ Homepage = "http://#{RubyForgeProject}.rubyforge.org/"
31
+
9
32
  task :default => :package
10
33
 
11
34
  # Run the tests.
@@ -20,7 +43,7 @@ end
20
43
 
21
44
  Rake::RDocTask.new do |rd|
22
45
  rd.main = 'README'
23
- rd.rdoc_dir = 'doc/rdoc'
46
+ rd.rdoc_dir = 'rdoc'
24
47
  rd.rdoc_files.include('README', 'INSTALL', 'doc/config.txt', 'doc/tutorial.txt', 'lib/**/*.rb')
25
48
  rd.options << '--all --inline-source'
26
49
  end
@@ -30,20 +53,20 @@ end
30
53
  spec = Gem::Specification.new do |s|
31
54
  s.name = 'og'
32
55
  if File.read('lib/og.rb') =~ /Version\s+=\s+'(\d+\.\d+\.\d+)'/
33
- VERSION = s.version = $1
56
+ s.version = $1
34
57
  else
35
58
  raise 'No version found'
36
59
  end
37
60
  s.summary = 'Og (ObjectGraph)'
38
61
  s.description = 'An efficient and transparent Object-Relational mapping library'
39
62
 
40
- s.add_dependency 'glue', "= #{VERSION}"
63
+ s.add_dependency 'glue', "= #{s.version}"
41
64
  # s.add_dependency 'postgres-pr', '>= 0.3.0'
42
65
  # s.add_dependency 'postgres', '>= 0.7.1'
43
66
  # s.add_dependency 'sqlite3-ruby', '>= 1.0.0'
44
67
  #s.add_dependency 'mysql', '>= 2.5.1'
45
68
 
46
- s.required_ruby_version = '>= 1.8.1'
69
+ s.required_ruby_version = '>= 1.8.2'
47
70
 
48
71
  s.files = FileList[
49
72
  '[A-Z]*', 'install.rb', '{bin,benchmark,examples,doc,lib,test,vendor}/**/*'
@@ -75,3 +98,123 @@ task :install do
75
98
  ruby 'install.rb'
76
99
  end
77
100
 
101
+ # Release files to Rubyforge.
102
+ # The code for this task provided by Florian Gross.
103
+
104
+ desc "Publish the release files to RubyForge."
105
+ task :publish => [:package] do
106
+ files = ['gem', 'tgz', 'zip'].map { |ext| "dist/#{Release}.#{ext}" }
107
+
108
+ if RubyForgeProject then
109
+ require 'net/http'
110
+ require 'open-uri'
111
+
112
+ changes = ''
113
+ if File.exist?('doc/RELEASES') then
114
+ changes_re = /^== \s+ Version \s+ #{Regexp.quote(Version)} \s*
115
+ (.+?) (?:==|\Z)/mx
116
+ changes = File.read('doc/RELEASES')[changes_re, 1] || ''
117
+ end
118
+
119
+ project_uri = "http://rubyforge.org/projects/#{RubyForgeProject}/"
120
+ project_data = open(project_uri) { |data| data.read }
121
+ group_id = project_data[/[?&]group_id=(\d+)/, 1]
122
+ raise "Couldn't get group id" unless group_id
123
+
124
+ print "#{RubyForgeUser}@rubyforge.org's password: "
125
+ password = STDIN.gets.chomp
126
+
127
+ login_response = Net::HTTP.start('rubyforge.org', 80) do |http|
128
+ data = [
129
+ "login=1",
130
+ "form_loginname=#{RubyForgeUser}",
131
+ "form_pw=#{password}"
132
+ ].join("&")
133
+ http.post('/account/login.php', data)
134
+ end
135
+
136
+ cookie = login_response['set-cookie']
137
+ raise 'Login failed' unless cookie
138
+ headers = { 'Cookie' => cookie }
139
+
140
+ release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
141
+ release_data = open(release_uri, headers) { |data| data.read }
142
+ package_id = release_data[/[?&]package_id=(\d+)/, 1]
143
+ raise "Couldn't get package id" unless package_id
144
+
145
+ first_file = true
146
+ release_id = ""
147
+
148
+ files.each do |filename|
149
+ basename = File.basename(filename)
150
+ file_ext = File.extname(filename)
151
+ file_data = File.open(filename, "rb") { |file| file.read }
152
+
153
+ puts "Releasing #{basename}..."
154
+
155
+ release_response = Net::HTTP.start('rubyforge.org', 80) do |http|
156
+ release_date = Time.now.strftime('%Y-%m-%d %H:%M')
157
+ type_map = {
158
+ '.zip' => '3000',
159
+ '.tgz' => '3110',
160
+ '.gz' => '3110',
161
+ '.gem' => '1400',
162
+ '.md5sum' => '8100'
163
+ }; type_map.default = '9999'
164
+ type = type_map[file_ext]
165
+ boundary = 'rubyqMY6QN9bp6e4kS21H4y0zxcvoor'
166
+
167
+ query_hash = if first_file then
168
+ {
169
+ 'group_id' => group_id,
170
+ 'package_id' => package_id,
171
+ 'release_name' => Release,
172
+ 'release_date' => release_date,
173
+ 'type_id' => type,
174
+ 'processor_id' => '8000', # Any
175
+ 'release_notes' => '',
176
+ 'release_changes' => changes,
177
+ 'preformatted' => '1',
178
+ 'submit' => '1'
179
+ }
180
+ else
181
+ {
182
+ 'group_id' => group_id,
183
+ 'release_id' => release_id,
184
+ 'package_id' => package_id,
185
+ 'step2' => '1',
186
+ 'type_id' => type,
187
+ 'processor_id' => '8000', # Any
188
+ 'submit' => 'Add This File'
189
+ }
190
+ end
191
+
192
+ query = '?' + query_hash.map do |(name, value)|
193
+ [name, URI.encode(value)].join('=')
194
+ end.join('&')
195
+
196
+ data = [
197
+ "--" + boundary,
198
+ "Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
199
+ "Content-Type: application/octet-stream",
200
+ "Content-Transfer-Encoding: binary",
201
+ "", file_data, ""
202
+ ].join("\x0D\x0A")
203
+
204
+ release_headers = headers.merge(
205
+ 'Content-Type' => "multipart/form-data; boundary=#{boundary}"
206
+ )
207
+
208
+ target = first_file ? '/frs/admin/qrs.php' : '/frs/admin/editrelease.php'
209
+ http.post(target + query, data, release_headers)
210
+ end
211
+
212
+ if first_file then
213
+ release_id = release_response.body[/release_id=(\d+)/, 1]
214
+ raise("Couldn't get release id") unless release_id
215
+ end
216
+
217
+ first_file = false
218
+ end
219
+ end
220
+ end
@@ -1,6 +1,6 @@
1
1
  # * George Moschovitis <gm@navel.gr>
2
2
  # (c) 2004-2005 Navel, all rights reserved.
3
- # $Id: bench.rb 288 2005-03-10 12:47:03Z gmosx $
3
+ # $Id: bench.rb 1 2005-04-11 11:04:30Z gmosx $
4
4
 
5
5
  require 'og'; include Og
6
6
 
@@ -1,19 +1,19 @@
1
1
  MAIN DEVELOPER:
2
2
 
3
3
  * George Moschovitis <gm@navel.gr>
4
- Project leader, architecture and design, code,
4
+ Project leader, architecture and design, main coder,
5
5
  documentation, maintainer.
6
6
 
7
7
  IDEAS, ADDITIONAL CODING, SUPPORT:
8
8
 
9
+ * Matt Bowen <matt.bowen@farweststeel.com>
10
+ Additional code and documentation.
11
+
9
12
  * Anastasios Koutoumanos <ak@navel.gr>
10
13
  Design, additional coding.
11
14
 
12
15
  * Michael Neumann <mneumann@ntecs.de>
13
16
  Design, additional coding and bug reports.
14
17
 
15
- * Matt Bowen <matt.bowen@farweststeel.com>
16
- Additional code and documentation.
17
-
18
18
  * Thomas Quas <tquas@yahoo.com>
19
19
  Ideas, bug reports, unit tests.
@@ -1,4 +1,44 @@
1
- == Version 0.15.0 was released on 4/03/2005.
1
+ == Version 0.16.0
2
+
3
+ A snapshot of the latest developments. Many, many subtle improvements,
4
+ new features and a major cleanup of the source code.
5
+
6
+ Most notable attitions:
7
+
8
+ * Aspect Oriented Programming support. This new system
9
+ is used to reimplement features such as Controller filters,
10
+ Og callbacks and Og observers. By using this unified
11
+ system you can now add Observers to controllers and use
12
+ a metalanguage for wraping Og object callbacks:
13
+
14
+ class Controller
15
+ pre :force_login, :where => :prepend
16
+ wrap Benchmark, :on => :index
17
+ post :taraa, :on => login
18
+ end
19
+
20
+ module Timestamped
21
+ pre :on => :og_insert { |this| this.create_time = Time.now }
22
+ pre :on => :og_update { |this| this.update_time = Time.now }
23
+ pre :on => [:og_insert, :og_update] { |this| this.create_time = Time.now }
24
+ end
25
+
26
+ This feature will be used extensivelly in future versions
27
+ to improve logging, the shaders and more.
28
+
29
+ * Major cleanup of the source. Converted the N namespace to
30
+ Nitro.
31
+
32
+ * Add Og Timestamped mixin.
33
+
34
+ * Og improvements.
35
+
36
+ * Improved the Gem installation process.
37
+
38
+ * Fixed all reported bugs.
39
+
40
+
41
+ == Version 0.15.0 was released on 04/04/2005.
2
42
 
3
43
  A great release. Many cool new features and tons of subtle
4
44
  improvements. We also welcome a new core developer, Anastastios
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # * George Moschovitis <gm@navel.gr>
7
7
  # (c) 2004-2005 Navel, all rights reserved.
8
- # $Id: mock_example.rb 280 2005-03-10 11:39:23Z gmosx $
8
+ # $Id: mock_example.rb 1 2005-04-11 11:04:30Z gmosx $
9
9
 
10
10
  require 'rubygems'
11
11
  require 'flexmock'
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # * George Moschovitis <gm@navel.gr>
11
11
  # (c) 2004-2005 Navel, all rights reserved.
12
- # $Id: mysql_to_psql.rb 280 2005-03-10 11:39:23Z gmosx $
12
+ # $Id: mysql_to_psql.rb 1 2005-04-11 11:04:30Z gmosx $
13
13
 
14
14
  raise 'WARNING, this example does not work yet, for the moment ' +
15
15
  'just have a look at the source code.'
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # * George Moschovitis <gm@navel.gr>
4
4
  # (c) 2004 Navel, all rights reserved.
5
- # $Id: run.rb 280 2005-03-10 11:39:23Z gmosx $
5
+ # $Id: run.rb 1 2005-04-11 11:04:30Z gmosx $
6
6
 
7
7
  require 'og'
8
8
 
data/install.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # * George Moschovitis <gm@navel.gr>
4
4
  # (c) 2004-2005 Navel, all rights reserved.
5
- # $Id$
5
+ # $Id: install.rb 1 2005-04-11 11:04:30Z gmosx $
6
6
 
7
7
  require 'rbconfig'
8
8
  require 'ftools'
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 340 2005-04-04 08:26:58Z gmosx $
3
+ # $Id: og.rb 20 2005-04-15 15:18:36Z gmosx $
4
4
 
5
5
  require 'glue'
6
6
  require 'glue/logger'
@@ -10,7 +10,9 @@ require 'glue/array'
10
10
  require 'glue/hash'
11
11
  require 'glue/time'
12
12
  require 'glue/pool'
13
+ require 'glue/inflector'
13
14
  require 'glue/validation'
15
+ require 'glue/aspects'
14
16
 
15
17
  # Og (ObjectGraph) is an efficient, yet simple Object-Relational
16
18
  # mapping library.
@@ -107,7 +109,7 @@ module Og
107
109
 
108
110
  # The version.
109
111
 
110
- Version = '0.15.0'
112
+ Version = '0.16.0'
111
113
 
112
114
  # Library path.
113
115