Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 263 lines (213 sloc) 8.089 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'
8
9 PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
10 PKG_NAME = 'activerecord'
daaa525 @dhh Fixed documentation and prepared for 0.11.0 release
dhh authored
11 PKG_VERSION = '1.9.0' + PKG_BUILD
db045db @dhh Initial
dhh authored
12 PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
13
065cb2a @dhh Made ready for better release automation
dhh authored
14 RELEASE_NAME = "REL #{PKG_VERSION}"
15
16 RUBY_FORGE_PROJECT = "activerecord"
17 RUBY_FORGE_USER = "webster132"
18
db045db @dhh Initial
dhh authored
19 PKG_FILES = FileList[
20 "lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "[A-Z]*", "install.rb", "rakefile"
21 ].exclude(/\bCVS\b|~$/)
22
23
24 desc "Default Task"
a133f3e @dhh Added SQLite3 compatibility through the sqlite3-ruby adapter by Jamis…
dhh authored
25 task :default => [ :test_ruby_mysql, :test_mysql_ruby, :test_sqlite, :test_sqlite3, :test_postgresql ]
db045db @dhh Initial
dhh authored
26
27 # Run the unit tests
28
29 Rake::TestTask.new("test_ruby_mysql") { |t|
30 t.libs << "test" << "test/connections/native_mysql"
31 t.pattern = 'test/*_test.rb'
32 t.verbose = true
33 }
34
35 Rake::TestTask.new("test_mysql_ruby") { |t|
36 t.libs << "test" << "test/connections/native_mysql"
37 t.pattern = 'test/*_test.rb'
38 t.verbose = true
39 }
40
41 Rake::TestTask.new("test_postgresql") { |t|
42 t.libs << "test" << "test/connections/native_postgresql"
43 t.pattern = 'test/*_test.rb'
44 t.verbose = true
45 }
46
47 Rake::TestTask.new("test_sqlite") { |t|
48 t.libs << "test" << "test/connections/native_sqlite"
49 t.pattern = 'test/*_test.rb'
50 t.verbose = true
51 }
52
a133f3e @dhh Added SQLite3 compatibility through the sqlite3-ruby adapter by Jamis…
dhh authored
53 Rake::TestTask.new("test_sqlite3") { |t|
54 t.libs << "test" << "test/connections/native_sqlite3"
55 t.pattern = 'test/*_test.rb'
56 t.verbose = true
57 }
58
a6fefad @dhh Added the final touches to the Microsoft SQL Server adapter by DeLynn…
dhh authored
59 Rake::TestTask.new("test_sqlserver") { |t|
60 t.libs << "test" << "test/connections/native_sqlserver"
61 t.pattern = 'test/*_test.rb'
62 t.verbose = true
63 }
64
daf3e92 @dhh Added a db2 adapter that only depends on the Ruby/DB2 bindings (http:…
dhh authored
65 Rake::TestTask.new("test_db2") { |t|
66 t.libs << "test" << "test/connections/native_db2"
67 t.pattern = 'test/*_test.rb'
68 t.verbose = true
69 }
70
336c2cb @dhh Added an Oracle adapter that works with the Oracle bindings by Yoshid…
dhh authored
71 Rake::TestTask.new("test_oracle") { |t|
72 t.libs << "test" << "test/connections/native_oracle"
73 t.pattern = 'test/*_test.rb'
74 t.verbose = true
75 }
76
10d458b @dhh Added a OCI8-based Oracle adapter that has been verified to work with…
dhh authored
77 Rake::TestTask.new("test_oci") { |t|
78 t.libs << "test" << "test/connections/native_oci"
79 t.pattern = 'test/*_test.rb'
80 t.verbose = true
81 }
82
db045db @dhh Initial
dhh authored
83 # Generate the RDoc documentation
84
85 Rake::RDocTask.new { |rdoc|
86 rdoc.rdoc_dir = 'doc'
87 rdoc.title = "Active Record -- Object-relation mapping put on rails"
88 rdoc.options << '--line-numbers --inline-source --accessor cattr_accessor=object'
89 rdoc.rdoc_files.include('README', 'RUNNING_UNIT_TESTS', 'CHANGELOG')
90 rdoc.rdoc_files.include('lib/**/*.rb')
91 rdoc.rdoc_files.exclude('lib/active_record/vendor/*')
92 rdoc.rdoc_files.include('dev-utils/*.rb')
93 }
94
95
96 # Create compressed packages
97
98 dist_dirs = [ "lib", "test", "examples", "dev-utils" ]
99
100 spec = Gem::Specification.new do |s|
101 s.name = PKG_NAME
102 s.version = PKG_VERSION
103 s.summary = "Implements the ActiveRecord pattern for ORM."
104 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.}
105
106 s.files = [ "rakefile", "install.rb", "README", "RUNNING_UNIT_TESTS", "CHANGELOG" ]
107 dist_dirs.each do |dir|
4370466 @dhh Dont include svn directories in packages
dhh authored
108 s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
db045db @dhh Initial
dhh authored
109 end
dc3d6eb @dhh Moved Active Support into its own gem
dhh authored
110
daaa525 @dhh Fixed documentation and prepared for 0.11.0 release
dhh authored
111 s.add_dependency('activesupport', '= 1.0.2' + PKG_BUILD)
dc3d6eb @dhh Moved Active Support into its own gem
dhh authored
112
db045db @dhh Initial
dhh authored
113 s.files.delete "test/fixtures/fixture_database.sqlite"
a133f3e @dhh Added SQLite3 compatibility through the sqlite3-ruby adapter by Jamis…
dhh authored
114 s.files.delete "test/fixtures/fixture_database_2.sqlite"
115 s.files.delete "test/fixtures/fixture_database.sqlite3"
116 s.files.delete "test/fixtures/fixture_database_2.sqlite3"
db045db @dhh Initial
dhh authored
117 s.require_path = 'lib'
118 s.autorequire = 'active_record'
119
120 s.has_rdoc = true
121 s.extra_rdoc_files = %w( README )
122 s.rdoc_options.concat ['--main', 'README']
123
124 s.author = "David Heinemeier Hansson"
125 s.email = "david@loudthinking.com"
d9168fd @dhh Made ready for 0.10.0 release
dhh authored
126 s.homepage = "http://www.rubyonrails.org"
db045db @dhh Initial
dhh authored
127 s.rubyforge_project = "activerecord"
128 end
129
130 Rake::GemPackageTask.new(spec) do |p|
131 p.gem_spec = spec
132 p.need_tar = true
133 p.need_zip = true
134 end
135
136
065cb2a @dhh Made ready for better release automation
dhh authored
137 # Publishing ------------------------------------------------------
db045db @dhh Initial
dhh authored
138
065cb2a @dhh Made ready for better release automation
dhh authored
139 desc "Publish the beta gem"
140 task :pgem => [:package] do
141 Rake::SshFilePublisher.new("davidhh@comox.textdrive.com", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
142 `ssh davidhh@comox.textdrive.com './gemupdate.sh'`
143 end
144
145 desc "Publish the API documentation"
146 task :pdoc => [:rdoc] do
147 Rake::SshDirPublisher.new("davidhh@comox.textdrive.com", "public_html/ar", "doc").upload
db045db @dhh Initial
dhh authored
148 end
065cb2a @dhh Made ready for better release automation
dhh authored
149
150 desc "Publish the release files to RubyForge."
151 task :release => [:package] do
152 files = ["gem", "tgz", "zip"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
153
154 if RUBY_FORGE_PROJECT then
155 require 'net/http'
156 require 'open-uri'
157
158 project_uri = "http://rubyforge.org/projects/#{RUBY_FORGE_PROJECT}/"
159 project_data = open(project_uri) { |data| data.read }
160 group_id = project_data[/[?&]group_id=(\d+)/, 1]
161 raise "Couldn't get group id" unless group_id
162
163 # This echos password to shell which is a bit sucky
164 if ENV["RUBY_FORGE_PASSWORD"]
165 password = ENV["RUBY_FORGE_PASSWORD"]
166 else
167 print "#{RUBY_FORGE_USER}@rubyforge.org's password: "
168 password = STDIN.gets.chomp
169 end
170
171 login_response = Net::HTTP.start("rubyforge.org", 80) do |http|
172 data = [
173 "login=1",
174 "form_loginname=#{RUBY_FORGE_USER}",
175 "form_pw=#{password}"
176 ].join("&")
177 http.post("/account/login.php", data)
178 end
179
180 cookie = login_response["set-cookie"]
181 raise "Login failed" unless cookie
182 headers = { "Cookie" => cookie }
183
184 release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
185 release_data = open(release_uri, headers) { |data| data.read }
186 package_id = release_data[/[?&]package_id=(\d+)/, 1]
187 raise "Couldn't get package id" unless package_id
188
189 first_file = true
190 release_id = ""
191
192 files.each do |filename|
193 basename = File.basename(filename)
194 file_ext = File.extname(filename)
195 file_data = File.open(filename, "rb") { |file| file.read }
196
197 puts "Releasing #{basename}..."
198
199 release_response = Net::HTTP.start("rubyforge.org", 80) do |http|
200 release_date = Time.now.strftime("%Y-%m-%d %H:%M")
201 type_map = {
202 ".zip" => "3000",
203 ".tgz" => "3110",
204 ".gz" => "3110",
205 ".gem" => "1400"
206 }; type_map.default = "9999"
207 type = type_map[file_ext]
208 boundary = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
209
210 query_hash = if first_file then
211 {
212 "group_id" => group_id,
213 "package_id" => package_id,
214 "release_name" => RELEASE_NAME,
215 "release_date" => release_date,
216 "type_id" => type,
217 "processor_id" => "8000", # Any
218 "release_notes" => "",
219 "release_changes" => "",
220 "preformatted" => "1",
221 "submit" => "1"
222 }
223 else
224 {
225 "group_id" => group_id,
226 "release_id" => release_id,
227 "package_id" => package_id,
228 "step2" => "1",
229 "type_id" => type,
230 "processor_id" => "8000", # Any
231 "submit" => "Add This File"
232 }
233 end
234
235 query = "?" + query_hash.map do |(name, value)|
236 [name, URI.encode(value)].join("=")
237 end.join("&")
238
239 data = [
240 "--" + boundary,
241 "Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
242 "Content-Type: application/octet-stream",
243 "Content-Transfer-Encoding: binary",
244 "", file_data, ""
245 ].join("\x0D\x0A")
246
247 release_headers = headers.merge(
248 "Content-Type" => "multipart/form-data; boundary=#{boundary}"
249 )
250
251 target = first_file ? "/frs/admin/qrs.php" : "/frs/admin/editrelease.php"
252 http.post(target + query, data, release_headers)
253 end
254
255 if first_file then
256 release_id = release_response.body[/release_id=(\d+)/, 1]
257 raise("Couldn't get release id") unless release_id
258 end
259
260 first_file = false
261 end
262 end
263 end
Something went wrong with that request. Please try again.