Skip to content

HTTPS clone URL

Subversion checkout URL

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