Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 249 lines (193 sloc) 8.206 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'
7 require 'rake/contrib/rubyforgepublisher'
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')
db045db @dhh Initial
dhh authored
9
10 PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
11 PKG_NAME = 'activerecord'
5cb2aa7 Rename Version constant to VERSION. Closes #2802.
Marcel Molina authored
12 PKG_VERSION = ActiveRecord::VERSION::STRING + PKG_BUILD
db045db @dhh Initial
dhh authored
13 PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
14
065cb2a @dhh Made ready for better release automation
dhh authored
15 RELEASE_NAME = "REL #{PKG_VERSION}"
16
17 RUBY_FORGE_PROJECT = "activerecord"
18 RUBY_FORGE_USER = "webster132"
19
db045db @dhh Initial
dhh authored
20 PKG_FILES = FileList[
34a7f66 Not all file systems are case sensitive. Things like 'rake gem' were…
Scott Barron authored
21 "lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "[A-Z]*", "install.rb", "Rakefile"
db045db @dhh Initial
dhh authored
22 ].exclude(/\bCVS\b|~$/)
23
24
25 desc "Default Task"
b6171e7 @jeremy SQLite: count(distinct) queries supported in >= 3.2.6, fix calculatio…
jeremy authored
26 task :default => [ :test_mysql, :test_sqlite, :test_sqlite3, :test_postgresql ]
db045db @dhh Initial
dhh authored
27
28 # Run the unit tests
29
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adap…
Marcel Molina authored
30 for adapter in %w( mysql postgresql sqlite sqlite3 firebird sqlserver sqlserver_odbc db2 oracle sybase openbase frontbase )
04c7e82 @dhh Made ready for the release of 0.11.1
dhh authored
31 Rake::TestTask.new("test_#{adapter}") { |t|
32 t.libs << "test" << "test/connections/native_#{adapter}"
a722b48 @NZKoz Ensure copy table test runs for sqlite and sqlite3. [mislav] Cllosoes…
NZKoz authored
33 adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z]+/]
34 t.pattern = "test/**/*_test{,_#{adapter_short}}.rb"
04c7e82 @dhh Made ready for the release of 0.11.1
dhh authored
35 t.verbose = true
36 }
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
37
38 namespace adapter do
39 task :test => "test_#{adapter}"
40 end
04c7e82 @dhh Made ready for the release of 0.11.1
dhh authored
41 end
336c2cb @dhh Added an Oracle adapter that works with the Oracle bindings by Yoshid…
dhh authored
42
f18463f Add tasks to create, drop and rebuild the MySQL and PostgreSQL test …
Marcel Molina authored
43 SCHEMA_PATH = File.join(File.dirname(__FILE__), *%w(test fixtures db_definitions))
44
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
45 namespace :mysql do
46 desc 'Build the MySQL test databases'
47 task :build_databases do
48 %x( mysqladmin create activerecord_unittest )
49 %x( mysqladmin create activerecord_unittest2 )
50 %x( mysql -e "grant all on activerecord_unittest.* to rails@localhost" )
51 %x( mysql -e "grant all on activerecord_unittest2.* to rails@localhost" )
52 %x( mysql activerecord_unittest < #{File.join(SCHEMA_PATH, 'mysql.sql')} )
53 %x( mysql activerecord_unittest2 < #{File.join(SCHEMA_PATH, 'mysql2.sql')} )
54 end
55
56 desc 'Drop the MySQL test databases'
57 task :drop_databases do
58 %x( mysqladmin -f drop activerecord_unittest )
59 %x( mysqladmin -f drop activerecord_unittest2 )
60 end
f18463f Add tasks to create, drop and rebuild the MySQL and PostgreSQL test …
Marcel Molina authored
61
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
62 desc 'Rebuild the MySQL test databases'
63 task :rebuild_databases => [:drop_databases, :build_databases]
f18463f Add tasks to create, drop and rebuild the MySQL and PostgreSQL test …
Marcel Molina authored
64 end
65
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
66 task :build_mysql_databases => 'mysql:build_databases'
67 task :drop_mysql_databases => 'mysql:drop_databases'
f18463f Add tasks to create, drop and rebuild the MySQL and PostgreSQL test …
Marcel Molina authored
68 task :rebuild_mysql_databases => [:drop_mysql_databases, :build_mysql_databases]
69
70
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
71 namespace :postgresql do
72 desc 'Build the PostgreSQL test databases'
73 task :build_databases do
74 %x( createdb -U postgres activerecord_unittest )
75 %x( createdb -U postgres activerecord_unittest2 )
76 %x( psql activerecord_unittest -f #{File.join(SCHEMA_PATH, 'postgresql.sql')} postgres )
77 %x( psql activerecord_unittest2 -f #{File.join(SCHEMA_PATH, 'postgresql2.sql')} postgres )
78 end
79
80 desc 'Drop the PostgreSQL test databases'
81 task :drop_databases do
82 %x( dropdb -U postgres activerecord_unittest )
83 %x( dropdb -U postgres activerecord_unittest2 )
84 end
85
86 desc 'Rebuild the PostgreSQL test databases'
87 task :rebuild_databases => [:drop_databases, :build_databases]
f18463f Add tasks to create, drop and rebuild the MySQL and PostgreSQL test …
Marcel Molina authored
88 end
89
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
90 task :build_postgresql_databases => 'postgresql:build_databases'
91 task :drop_postgresql_databases => 'postgresql:drop_databases'
f18463f Add tasks to create, drop and rebuild the MySQL and PostgreSQL test …
Marcel Molina authored
92 task :rebuild_postgresql_databases => [:drop_postgresql_databases, :build_postgresql_databases]
10d458b @dhh Added a OCI8-based Oracle adapter that has been verified to work with…
dhh authored
93
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adap…
Marcel Molina authored
94
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
95 namespace :frontbase do
96 desc 'Build the FrontBase test databases'
97 task :build_databases => :rebuild_frontbase_databases
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adap…
Marcel Molina authored
98
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
99 desc 'Rebuild the FrontBase test databases'
100 task :rebuild_databases do
101 build_frontbase_database = Proc.new do |db_name, sql_definition_file|
102 %(
103 STOP DATABASE #{db_name};
104 DELETE DATABASE #{db_name};
105 CREATE DATABASE #{db_name};
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adap…
Marcel Molina authored
106
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
107 CONNECT TO #{db_name} AS SESSION_NAME USER _SYSTEM;
108 SET COMMIT FALSE;
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adap…
Marcel Molina authored
109
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
110 CREATE USER RAILS;
111 CREATE SCHEMA RAILS AUTHORIZATION RAILS;
112 COMMIT;
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adap…
Marcel Molina authored
113
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
114 SET SESSION AUTHORIZATION RAILS;
115 SCRIPT '#{sql_definition_file}';
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adap…
Marcel Molina authored
116
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
117 COMMIT;
118
119 DISCONNECT ALL;
120 )
121 end
122 create_activerecord_unittest = build_frontbase_database['activerecord_unittest', File.join(SCHEMA_PATH, 'frontbase.sql')]
123 create_activerecord_unittest2 = build_frontbase_database['activerecord_unittest2', File.join(SCHEMA_PATH, 'frontbase2.sql')]
124 execute_frontbase_sql = Proc.new do |sql|
125 system(<<-SHELL)
126 /Library/FrontBase/bin/sql92 <<-SQL
127 #{sql}
128 SQL
129 SHELL
130 end
131 execute_frontbase_sql[create_activerecord_unittest]
132 execute_frontbase_sql[create_activerecord_unittest2]
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adap…
Marcel Molina authored
133 end
134 end
135
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
136 task :build_frontbase_databases => 'frontbase:build_databases'
137 task :rebuild_frontbase_databases => 'frontbase:rebuild_databases'
138
139
db045db @dhh Initial
dhh authored
140 # Generate the RDoc documentation
141
142 Rake::RDocTask.new { |rdoc|
143 rdoc.rdoc_dir = 'doc'
144 rdoc.title = "Active Record -- Object-relation mapping put on rails"
0e37e66 @dhh Documentation fixes (closes #3838)
dhh authored
145 rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
d8b67f7 @jeremy Generate rdoc with utf-8 charset. Closes #7188 [manfred, jferris]
jeremy authored
146 rdoc.options << '--charset' << 'utf-8'
04c7e82 @dhh Made ready for the release of 0.11.1
dhh authored
147 rdoc.template = "#{ENV['template']}.rb" if ENV['template']
db045db @dhh Initial
dhh authored
148 rdoc.rdoc_files.include('README', 'RUNNING_UNIT_TESTS', 'CHANGELOG')
149 rdoc.rdoc_files.include('lib/**/*.rb')
150 rdoc.rdoc_files.exclude('lib/active_record/vendor/*')
151 rdoc.rdoc_files.include('dev-utils/*.rb')
152 }
153
b921b5d @dhh Fixed association picture reference
dhh authored
154 # Enhance rdoc task to copy referenced images also
155 task :rdoc do
156 FileUtils.mkdir_p "doc/files/examples/"
157 FileUtils.copy "examples/associations.png", "doc/files/examples/associations.png"
158 end
159
db045db @dhh Initial
dhh authored
160
161 # Create compressed packages
162
250f871 @dhh Removed outdated benchmarks and examples
dhh authored
163 dist_dirs = [ "lib", "test", "examples" ]
db045db @dhh Initial
dhh authored
164
165 spec = Gem::Specification.new do |s|
166 s.name = PKG_NAME
167 s.version = PKG_VERSION
168 s.summary = "Implements the ActiveRecord pattern for ORM."
169 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.}
170
34a7f66 Not all file systems are case sensitive. Things like 'rake gem' were…
Scott Barron authored
171 s.files = [ "Rakefile", "install.rb", "README", "RUNNING_UNIT_TESTS", "CHANGELOG" ]
db045db @dhh Initial
dhh authored
172 dist_dirs.each do |dir|
4370466 @dhh Dont include svn directories in packages
dhh authored
173 s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
db045db @dhh Initial
dhh authored
174 end
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
175
335c150 @jeremy Bump versions for 1.2.4 release.
jeremy authored
176 s.add_dependency('activesupport', '= 1.4.3' + PKG_BUILD)
dc3d6eb @dhh Moved Active Support into its own gem
dhh authored
177
db045db @dhh Initial
dhh authored
178 s.files.delete "test/fixtures/fixture_database.sqlite"
a133f3e @dhh Added SQLite3 compatibility through the sqlite3-ruby adapter by Jamis…
dhh authored
179 s.files.delete "test/fixtures/fixture_database_2.sqlite"
180 s.files.delete "test/fixtures/fixture_database.sqlite3"
181 s.files.delete "test/fixtures/fixture_database_2.sqlite3"
db045db @dhh Initial
dhh authored
182 s.require_path = 'lib'
183 s.autorequire = 'active_record'
184
185 s.has_rdoc = true
186 s.extra_rdoc_files = %w( README )
187 s.rdoc_options.concat ['--main', 'README']
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
188
db045db @dhh Initial
dhh authored
189 s.author = "David Heinemeier Hansson"
190 s.email = "david@loudthinking.com"
d9168fd @dhh Made ready for 0.10.0 release
dhh authored
191 s.homepage = "http://www.rubyonrails.org"
db045db @dhh Initial
dhh authored
192 s.rubyforge_project = "activerecord"
193 end
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
194
db045db @dhh Initial
dhh authored
195 Rake::GemPackageTask.new(spec) do |p|
196 p.gem_spec = spec
197 p.need_tar = true
198 p.need_zip = true
199 end
200
e0a2dab @dhh Added KLOC counter for AR and AP. Combined theyre at ~9KLOC
dhh authored
201 task :lines do
202 lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
203
204 for file_name in FileList["lib/active_record/**/*.rb"]
205 next if file_name =~ /vendor/
206 f = File.open(file_name)
207
208 while line = f.gets
209 lines += 1
210 next if line =~ /^\s*$/
211 next if line =~ /^\s*#/
212 codelines += 1
213 end
214 puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
215
e0a2dab @dhh Added KLOC counter for AR and AP. Combined theyre at ~9KLOC
dhh authored
216 total_lines += lines
217 total_codelines += codelines
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
218
e0a2dab @dhh Added KLOC counter for AR and AP. Combined theyre at ~9KLOC
dhh authored
219 lines, codelines = 0, 0
220 end
221
222 puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
223 end
224
db045db @dhh Initial
dhh authored
225
065cb2a @dhh Made ready for better release automation
dhh authored
226 # Publishing ------------------------------------------------------
db045db @dhh Initial
dhh authored
227
065cb2a @dhh Made ready for better release automation
dhh authored
228 desc "Publish the beta gem"
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
229 task :pgem => [:package] do
6ea6a72 @dhh Push to .org instead
dhh authored
230 Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
231 `ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'`
065cb2a @dhh Made ready for better release automation
dhh authored
232 end
233
234 desc "Publish the API documentation"
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
235 task :pdoc => [:rdoc] do
6ea6a72 @dhh Push to .org instead
dhh authored
236 Rake::SshDirPublisher.new("davidhh@wrath.rubyonrails.org", "public_html/ar", "doc").upload
db045db @dhh Initial
dhh authored
237 end
065cb2a @dhh Made ready for better release automation
dhh authored
238
239 desc "Publish the release files to RubyForge."
98634e7 @dhh Use Aras RubyForge uploader
dhh authored
240 task :release => [ :package ] do
635c7f4 @dhh Run with the latest versions so beta gems will work
dhh authored
241 require 'rubyforge'
065cb2a @dhh Made ready for better release automation
dhh authored
242
635c7f4 @dhh Run with the latest versions so beta gems will work
dhh authored
243 packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
244
245 rubyforge = RubyForge.new
246 rubyforge.login
247 rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
a722b48 @NZKoz Ensure copy table test runs for sqlite and sqlite3. [mislav] Cllosoes…
NZKoz authored
248 end
Something went wrong with that request. Please try again.