Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 263 lines (205 sloc) 8.684 kb
db045db @dhh Initial
dhh authored
1 require 'rubygems'
2 require 'rake'
3 require 'rake/testtask'
4 require 'rake/rdoctask'
5 require 'rake/packagetask'
6 require 'rake/gempackagetask'
39814fc @jeremy Merge branch 'ar-test-cleanup' of git://git.geeksomnia.com/rails
jeremy authored
7
08fbdc1 @jamis move lib/version.rb to lib/active_record/version.rb
jamis authored
8 require File.join(File.dirname(__FILE__), 'lib', 'active_record', 'version')
39814fc @jeremy Merge branch 'ar-test-cleanup' of git://git.geeksomnia.com/rails
jeremy authored
9 require File.expand_path(File.dirname(__FILE__)) + "/test/config"
db045db @dhh Initial
dhh authored
10
11 PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
12 PKG_NAME = 'activerecord'
5cb2aa7 Rename Version constant to VERSION. Closes #2802.
Marcel Molina authored
13 PKG_VERSION = ActiveRecord::VERSION::STRING + PKG_BUILD
db045db @dhh Initial
dhh authored
14 PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
15
065cb2a @dhh Made ready for better release automation
dhh authored
16 RELEASE_NAME = "REL #{PKG_VERSION}"
17
18 RUBY_FORGE_PROJECT = "activerecord"
19 RUBY_FORGE_USER = "webster132"
20
f386676 @ssoroka Use the rails user when creating and dropping the database rather than f...
ssoroka authored
21 MYSQL_DB_USER = 'rails'
22
db045db @dhh Initial
dhh authored
23 PKG_FILES = FileList[
34a7f66 Not all file systems are case sensitive. Things like 'rake gem' were fa...
Scott Barron authored
24 "lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "[A-Z]*", "install.rb", "Rakefile"
db045db @dhh Initial
dhh authored
25 ].exclude(/\bCVS\b|~$/)
26
27
bfe85ae @jeremy Add explicit test task
jeremy authored
28 desc 'Run mysql, sqlite, and postgresql tests by default'
29 task :default => :test
db045db @dhh Initial
dhh authored
30
bfe85ae @jeremy Add explicit test task
jeremy authored
31 desc 'Run mysql, sqlite, and postgresql tests'
49afe58 @jeremy Test jdbc adapters by default on jruby
jeremy authored
32 task :test => defined?(JRUBY_VERSION) ?
33 %w(test_jdbcmysql test_jdbcsqlite3 test_jdbcpostgresql) :
34 %w(test_mysql test_sqlite3 test_postgresql)
db045db @dhh Initial
dhh authored
35
fa5da8a @jeremy isolated_test task
jeremy authored
36 %w( mysql postgresql sqlite sqlite3 firebird db2 oracle sybase openbase frontbase jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb ).each do |adapter|
04c7e82 @dhh Made ready for the release of 0.11.1
dhh authored
37 Rake::TestTask.new("test_#{adapter}") { |t|
fa5da8a @jeremy isolated_test task
jeremy authored
38 connection_path = "test/connections/#{adapter =~ /jdbc/ ? 'jdbc' : 'native'}_#{adapter}"
a722b48 @NZKoz Ensure copy table test runs for sqlite and sqlite3. [mislav] Cllosoes #8...
NZKoz authored
39 adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z]+/]
fa5da8a @jeremy isolated_test task
jeremy authored
40 t.libs << "test" << connection_path
029fc2f @NZKoz Sort test cases to make test runs deterministic
NZKoz authored
41 t.test_files=Dir.glob( "test/cases/**/*_test{,_#{adapter_short}}.rb" ).sort
04c7e82 @dhh Made ready for the release of 0.11.1
dhh authored
42 t.verbose = true
43 }
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
44
fa5da8a @jeremy isolated_test task
jeremy authored
45 task "isolated_test_#{adapter}" do
46 connection_path = "test/connections/#{adapter =~ /jdbc/ ? 'jdbc' : 'native'}_#{adapter}"
47 adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z]+/]
48 puts [adapter, adapter_short, connection_path].inspect
49 ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
50 Dir["test/cases/**/*_test{,_#{adapter_short}}.rb"].all? do |file|
51 system(ruby, "-Ilib:test:#{connection_path}", file)
52 end or raise "Failures"
53 end
54
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
55 namespace adapter do
56 task :test => "test_#{adapter}"
fa5da8a @jeremy isolated_test task
jeremy authored
57 task :isolated_test => "isolated_test_#{adapter}"
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
58 end
04c7e82 @dhh Made ready for the release of 0.11.1
dhh authored
59 end
336c2cb @dhh Added an Oracle adapter that works with the Oracle bindings by Yoshida (...
dhh authored
60
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
61 namespace :mysql do
62 desc 'Build the MySQL test databases'
63 task :build_databases do
f386676 @ssoroka Use the rails user when creating and dropping the database rather than f...
ssoroka authored
64 %x( mysqladmin --user=#{MYSQL_DB_USER} create activerecord_unittest )
65 %x( mysqladmin --user=#{MYSQL_DB_USER} create activerecord_unittest2 )
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
66 end
67
68 desc 'Drop the MySQL test databases'
69 task :drop_databases do
f386676 @ssoroka Use the rails user when creating and dropping the database rather than f...
ssoroka authored
70 %x( mysqladmin --user=#{MYSQL_DB_USER} -f drop activerecord_unittest )
71 %x( mysqladmin --user=#{MYSQL_DB_USER} -f drop activerecord_unittest2 )
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
72 end
f18463f Add tasks to create, drop and rebuild the MySQL and PostgreSQL test dat...
Marcel Molina authored
73
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
74 desc 'Rebuild the MySQL test databases'
75 task :rebuild_databases => [:drop_databases, :build_databases]
f18463f Add tasks to create, drop and rebuild the MySQL and PostgreSQL test dat...
Marcel Molina authored
76 end
77
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
78 task :build_mysql_databases => 'mysql:build_databases'
79 task :drop_mysql_databases => 'mysql:drop_databases'
5d3e724 @jeremy Add build/drop/rebuild tasks for SQL Server. Closes #9588 [lawrence]
jeremy authored
80 task :rebuild_mysql_databases => 'mysql:rebuild_databases'
f18463f Add tasks to create, drop and rebuild the MySQL and PostgreSQL test dat...
Marcel Molina authored
81
82
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
83 namespace :postgresql do
84 desc 'Build the PostgreSQL test databases'
85 task :build_databases do
921752c @NZKoz Remove reference to 'postgres' user in the connection and Rakefiles. Al...
NZKoz authored
86 %x( createdb activerecord_unittest )
87 %x( createdb activerecord_unittest2 )
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
88 end
89
90 desc 'Drop the PostgreSQL test databases'
91 task :drop_databases do
921752c @NZKoz Remove reference to 'postgres' user in the connection and Rakefiles. Al...
NZKoz authored
92 %x( dropdb activerecord_unittest )
93 %x( dropdb activerecord_unittest2 )
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
94 end
95
96 desc 'Rebuild the PostgreSQL test databases'
97 task :rebuild_databases => [:drop_databases, :build_databases]
f18463f Add tasks to create, drop and rebuild the MySQL and PostgreSQL test dat...
Marcel Molina authored
98 end
99
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
100 task :build_postgresql_databases => 'postgresql:build_databases'
101 task :drop_postgresql_databases => 'postgresql:drop_databases'
5d3e724 @jeremy Add build/drop/rebuild tasks for SQL Server. Closes #9588 [lawrence]
jeremy authored
102 task :rebuild_postgresql_databases => 'postgresql:rebuild_databases'
10d458b @dhh Added a OCI8-based Oracle adapter that has been verified to work with Or...
dhh authored
103
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adapter...
Marcel Molina authored
104
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
105 namespace :frontbase do
106 desc 'Build the FrontBase test databases'
107 task :build_databases => :rebuild_frontbase_databases
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adapter...
Marcel Molina authored
108
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
109 desc 'Rebuild the FrontBase test databases'
110 task :rebuild_databases do
111 build_frontbase_database = Proc.new do |db_name, sql_definition_file|
112 %(
113 STOP DATABASE #{db_name};
114 DELETE DATABASE #{db_name};
115 CREATE DATABASE #{db_name};
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adapter...
Marcel Molina authored
116
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
117 CONNECT TO #{db_name} AS SESSION_NAME USER _SYSTEM;
118 SET COMMIT FALSE;
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adapter...
Marcel Molina authored
119
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
120 CREATE USER RAILS;
121 CREATE SCHEMA RAILS AUTHORIZATION RAILS;
122 COMMIT;
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adapter...
Marcel Molina authored
123
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
124 SET SESSION AUTHORIZATION RAILS;
125 SCRIPT '#{sql_definition_file}';
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adapter...
Marcel Molina authored
126
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
127 COMMIT;
128
129 DISCONNECT ALL;
130 )
131 end
39814fc @jeremy Merge branch 'ar-test-cleanup' of git://git.geeksomnia.com/rails
jeremy authored
132 create_activerecord_unittest = build_frontbase_database['activerecord_unittest', File.join(SCHEMA_ROOT, 'frontbase.sql')]
133 create_activerecord_unittest2 = build_frontbase_database['activerecord_unittest2', File.join(SCHEMA_ROOT, 'frontbase2.sql')]
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
134 execute_frontbase_sql = Proc.new do |sql|
135 system(<<-SHELL)
136 /Library/FrontBase/bin/sql92 <<-SQL
137 #{sql}
138 SQL
139 SHELL
140 end
141 execute_frontbase_sql[create_activerecord_unittest]
142 execute_frontbase_sql[create_activerecord_unittest2]
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adapter...
Marcel Molina authored
143 end
144 end
145
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
146 task :build_frontbase_databases => 'frontbase:build_databases'
147 task :rebuild_frontbase_databases => 'frontbase:rebuild_databases'
148
149
db045db @dhh Initial
dhh authored
150 # Generate the RDoc documentation
151
152 Rake::RDocTask.new { |rdoc|
153 rdoc.rdoc_dir = 'doc'
154 rdoc.title = "Active Record -- Object-relation mapping put on rails"
0e37e66 @dhh Documentation fixes (closes #3838)
dhh authored
155 rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
d8b67f7 @jeremy Generate rdoc with utf-8 charset. Closes #7188 [manfred, jferris]
jeremy authored
156 rdoc.options << '--charset' << 'utf-8'
a02d672 @jeremy Horo rdoc template
jeremy authored
157 rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
db045db @dhh Initial
dhh authored
158 rdoc.rdoc_files.include('README', 'RUNNING_UNIT_TESTS', 'CHANGELOG')
159 rdoc.rdoc_files.include('lib/**/*.rb')
160 rdoc.rdoc_files.exclude('lib/active_record/vendor/*')
161 rdoc.rdoc_files.include('dev-utils/*.rb')
162 }
163
b921b5d @dhh Fixed association picture reference
dhh authored
164 # Enhance rdoc task to copy referenced images also
165 task :rdoc do
166 FileUtils.mkdir_p "doc/files/examples/"
167 FileUtils.copy "examples/associations.png", "doc/files/examples/associations.png"
168 end
169
db045db @dhh Initial
dhh authored
170
171 # Create compressed packages
172
250f871 @dhh Removed outdated benchmarks and examples
dhh authored
173 dist_dirs = [ "lib", "test", "examples" ]
db045db @dhh Initial
dhh authored
174
175 spec = Gem::Specification.new do |s|
7f53d04 @jeremy RubyGems 0.9.5 compat: always set the gem platform
jeremy authored
176 s.platform = Gem::Platform::RUBY
db045db @dhh Initial
dhh authored
177 s.name = PKG_NAME
178 s.version = PKG_VERSION
179 s.summary = "Implements the ActiveRecord pattern for ORM."
180 s.description = %q{Implements the ActiveRecord pattern (Fowler, PoEAA) for ORM. It ties database tables and classes together for business objects, like Customer or Subscription, that can find, save, and destroy themselves without resorting to manual SQL.}
181
34a7f66 Not all file systems are case sensitive. Things like 'rake gem' were fa...
Scott Barron authored
182 s.files = [ "Rakefile", "install.rb", "README", "RUNNING_UNIT_TESTS", "CHANGELOG" ]
db045db @dhh Initial
dhh authored
183 dist_dirs.each do |dir|
4370466 @dhh Dont include svn directories in packages
dhh authored
184 s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
db045db @dhh Initial
dhh authored
185 end
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
186
73fc42c @dhh Prepare for final 2.3 release
dhh authored
187 s.add_dependency('activesupport', '= 2.3.2' + PKG_BUILD)
dc3d6eb @dhh Moved Active Support into its own gem
dhh authored
188
39814fc @jeremy Merge branch 'ar-test-cleanup' of git://git.geeksomnia.com/rails
jeremy authored
189 s.files.delete FIXTURES_ROOT + "/fixture_database.sqlite"
190 s.files.delete FIXTURES_ROOT + "/fixture_database_2.sqlite"
191 s.files.delete FIXTURES_ROOT + "/fixture_database.sqlite3"
192 s.files.delete FIXTURES_ROOT + "/fixture_database_2.sqlite3"
db045db @dhh Initial
dhh authored
193 s.require_path = 'lib'
194 s.autorequire = 'active_record'
195
196 s.has_rdoc = true
197 s.extra_rdoc_files = %w( README )
198 s.rdoc_options.concat ['--main', 'README']
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
199
db045db @dhh Initial
dhh authored
200 s.author = "David Heinemeier Hansson"
201 s.email = "david@loudthinking.com"
d9168fd @dhh Made ready for 0.10.0 release
dhh authored
202 s.homepage = "http://www.rubyonrails.org"
db045db @dhh Initial
dhh authored
203 s.rubyforge_project = "activerecord"
204 end
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
205
db045db @dhh Initial
dhh authored
206 Rake::GemPackageTask.new(spec) do |p|
207 p.gem_spec = spec
208 p.need_tar = true
209 p.need_zip = true
210 end
211
e0a2dab @dhh Added KLOC counter for AR and AP. Combined theyre at ~9KLOC
dhh authored
212 task :lines do
213 lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
214
215 for file_name in FileList["lib/active_record/**/*.rb"]
216 next if file_name =~ /vendor/
217 f = File.open(file_name)
218
219 while line = f.gets
220 lines += 1
221 next if line =~ /^\s*$/
222 next if line =~ /^\s*#/
223 codelines += 1
224 end
225 puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
226
e0a2dab @dhh Added KLOC counter for AR and AP. Combined theyre at ~9KLOC
dhh authored
227 total_lines += lines
228 total_codelines += codelines
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
229
e0a2dab @dhh Added KLOC counter for AR and AP. Combined theyre at ~9KLOC
dhh authored
230 lines, codelines = 0, 0
231 end
232
233 puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
234 end
235
db045db @dhh Initial
dhh authored
236
065cb2a @dhh Made ready for better release automation
dhh authored
237 # Publishing ------------------------------------------------------
db045db @dhh Initial
dhh authored
238
065cb2a @dhh Made ready for better release automation
dhh authored
239 desc "Publish the beta gem"
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
240 task :pgem => [:package] do
dc9f53b @jeremy Selectively require rake sshpublisher so full gem isn't required
jeremy authored
241 require 'rake/contrib/sshpublisher'
eec6e0c @dhh Push to new gem server
dhh authored
242 Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
5366e61 @dhh Proper update call for gem server
dhh authored
243 `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
065cb2a @dhh Made ready for better release automation
dhh authored
244 end
245
246 desc "Publish the API documentation"
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
247 task :pdoc => [:rdoc] do
dc9f53b @jeremy Selectively require rake sshpublisher so full gem isn't required
jeremy authored
248 require 'rake/contrib/sshpublisher'
231c2c5 @jeremy Update Rakefiles to connect to wrath as current user. Use ssh config to ...
jeremy authored
249 Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ar", "doc").upload
db045db @dhh Initial
dhh authored
250 end
065cb2a @dhh Made ready for better release automation
dhh authored
251
252 desc "Publish the release files to RubyForge."
98634e7 @dhh Use Aras RubyForge uploader
dhh authored
253 task :release => [ :package ] do
635c7f4 @dhh Run with the latest versions so beta gems will work
dhh authored
254 require 'rubyforge'
f7f0e7b @jeremy Remove toplevel rubyforgepublisher require for new Rake
jeremy authored
255 require 'rake/contrib/rubyforgepublisher'
065cb2a @dhh Made ready for better release automation
dhh authored
256
635c7f4 @dhh Run with the latest versions so beta gems will work
dhh authored
257 packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
258
259 rubyforge = RubyForge.new
260 rubyforge.login
261 rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
a722b48 @NZKoz Ensure copy table test runs for sqlite and sqlite3. [mislav] Cllosoes #8...
NZKoz authored
262 end
Something went wrong with that request. Please try again.