2004-11-23 20:04:44 -05:00
|
|
|
require 'rake'
|
|
|
|
require 'rake/testtask'
|
|
|
|
require 'rake/rdoctask'
|
|
|
|
require 'rake/gempackagetask'
|
|
|
|
require 'rake/contrib/rubyforgepublisher'
|
|
|
|
|
|
|
|
require 'date'
|
2005-01-01 13:10:10 -05:00
|
|
|
require 'rbconfig'
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
|
|
|
PKG_NAME = 'rails'
|
2005-04-19 13:18:36 -04:00
|
|
|
PKG_VERSION = '0.12.1' + PKG_BUILD
|
2004-11-23 20:04:44 -05:00
|
|
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
|
|
|
PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
|
|
|
|
|
2005-03-27 08:33:54 -05:00
|
|
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
|
|
|
|
|
|
|
RUBY_FORGE_PROJECT = "rails"
|
|
|
|
RUBY_FORGE_USER = "webster132"
|
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
|
2005-02-20 08:58:03 -05:00
|
|
|
BASE_DIRS = %w( app config/environments components db doc log lib public script test vendor )
|
2005-02-18 05:58:25 -05:00
|
|
|
APP_DIRS = %w( apis models controllers helpers views views/layouts )
|
2005-02-24 07:26:30 -05:00
|
|
|
PUBLIC_DIRS = %w( images javascripts stylesheets )
|
2005-02-27 15:43:08 -05:00
|
|
|
TEST_DIRS = %w( fixtures unit functional mocks mocks/development mocks/test )
|
2004-11-25 11:27:59 -05:00
|
|
|
|
2005-02-20 18:51:06 -05:00
|
|
|
LOG_FILES = %w( server.log development.log test.log production.log )
|
2005-06-26 08:07:30 -04:00
|
|
|
HTML_FILES = %w( 404.html 500.html index.html favicon.ico javascripts/prototype.js javascripts/effects.js javascripts/dragdrop.js javascripts/controls.js )
|
2005-04-30 11:37:45 -04:00
|
|
|
BIN_FILES = %w( generate destroy breakpointer console server update runner profiler benchmarker )
|
2004-11-25 11:27:59 -05:00
|
|
|
|
2005-02-19 18:22:01 -05:00
|
|
|
VENDOR_LIBS = %w( actionpack activerecord actionmailer activesupport actionwebservice railties )
|
2004-11-25 11:27:59 -05:00
|
|
|
|
|
|
|
|
2004-11-23 20:04:44 -05:00
|
|
|
desc "Default Task"
|
|
|
|
task :default => [ :fresh_rails ]
|
|
|
|
|
|
|
|
desc "Generates a fresh Rails package with documentation"
|
2004-11-25 11:27:59 -05:00
|
|
|
task :fresh_rails => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_vendor_libraries, :copy_ties_content, :generate_documentation ]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
desc "Generates a fresh Rails package using GEMs with documentation"
|
2004-11-25 11:27:59 -05:00
|
|
|
task :fresh_gem_rails => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_ties_content, :copy_gem_environment ]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
desc "Generates a fresh Rails package without documentation (faster)"
|
2004-11-25 11:27:59 -05:00
|
|
|
task :fresh_rails_without_docs => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_vendor_libraries, :copy_ties_content ]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
2005-01-13 10:49:26 -05:00
|
|
|
desc "Generates a fresh Rails package without documentation (faster)"
|
|
|
|
task :fresh_rails_without_docs_using_links => [ :clean, :make_dir_structure, :initialize_file_stubs, :link_vendor_libraries, :copy_ties_content ]
|
|
|
|
|
2005-02-15 10:57:44 -05:00
|
|
|
desc "Generates minimal Rails package using symlinks"
|
|
|
|
task :dev => [ :clean, :make_dir_structure, :initialize_file_stubs, :link_vendor_libraries, :copy_ties_content ]
|
|
|
|
|
2004-11-23 20:04:44 -05:00
|
|
|
desc "Packages the fresh Rails package with documentation"
|
|
|
|
task :package => [ :clean, :fresh_rails ] do
|
|
|
|
system %{cd ..; tar -czvf #{PKG_NAME}-#{PKG_VERSION}.tgz #{PKG_NAME}}
|
|
|
|
system %{cd ..; zip -r #{PKG_NAME}-#{PKG_VERSION}.zip #{PKG_NAME}}
|
|
|
|
end
|
|
|
|
|
|
|
|
task :clean do
|
2004-11-25 11:27:59 -05:00
|
|
|
rm_rf PKG_DESTINATION
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
2005-07-02 02:23:35 -04:00
|
|
|
# Get external spinoffs -------------------------------------------------------------------
|
|
|
|
|
|
|
|
task :update_scriptaculous do
|
|
|
|
system("svn export --force http://dev.rubyonrails.org/svn/rails/spinoffs/scriptaculous/src/ #{File.dirname(__FILE__)}/html/javascripts")
|
|
|
|
end
|
|
|
|
|
|
|
|
task :update_prototype do
|
|
|
|
system("svn export --force http://dev.rubyonrails.org/svn/rails/trunk/actionpack/lib/action_view/helpers/javascripts/prototype.js #{File.dirname(__FILE__)}/html/javascripts/prototype.js")
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Updates railties to the latest version of the javascript spinoffs"
|
|
|
|
task :update_js => [:update_scriptaculous, :update_prototype]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
# Make directory structure ----------------------------------------------------------------
|
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
def make_dest_dirs(dirs, path = nil)
|
|
|
|
mkdir_p dirs.map { |dir| File.join(PKG_DESTINATION, path, dir) }
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
desc "Make the directory structure for the new Rails application"
|
|
|
|
task :make_dir_structure => [ :make_base_dirs, :make_app_dirs, :make_public_dirs, :make_test_dirs ]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
task(:make_base_dirs) { make_dest_dirs BASE_DIRS }
|
|
|
|
task(:make_app_dirs) { make_dest_dirs APP_DIRS, 'app' }
|
|
|
|
task(:make_public_dirs) { make_dest_dirs PUBLIC_DIRS, 'public' }
|
|
|
|
task(:make_test_dirs) { make_dest_dirs TEST_DIRS, 'test' }
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
|
|
|
|
# Initialize file stubs -------------------------------------------------------------------
|
|
|
|
|
|
|
|
desc "Initialize empty file stubs (such as for logging)"
|
2004-11-25 11:27:59 -05:00
|
|
|
task :initialize_file_stubs => [ :initialize_log_files ]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
task :initialize_log_files do
|
2004-11-25 11:27:59 -05:00
|
|
|
log_dir = File.join(PKG_DESTINATION, 'log')
|
|
|
|
chmod 0777, log_dir
|
|
|
|
LOG_FILES.each do |log_file|
|
|
|
|
log_path = File.join(log_dir, log_file)
|
|
|
|
touch log_path
|
2005-01-15 12:28:01 -05:00
|
|
|
chmod 0666, log_path
|
2004-11-25 11:27:59 -05:00
|
|
|
end
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Copy Vendors ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
desc "Copy in all the Rails packages to vendor"
|
2004-11-25 11:27:59 -05:00
|
|
|
task :copy_vendor_libraries do
|
2005-03-20 17:41:35 -05:00
|
|
|
mkdir File.join(PKG_DESTINATION, 'vendor', 'rails')
|
2005-03-20 19:16:14 -05:00
|
|
|
VENDOR_LIBS.each { |dir| cp_r File.join('..', dir), File.join(PKG_DESTINATION, 'vendor', 'rails', dir) }
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
2005-01-13 10:49:26 -05:00
|
|
|
desc "Link in all the Rails packages to vendor"
|
|
|
|
task :link_vendor_libraries do
|
2005-03-20 19:16:14 -05:00
|
|
|
mkdir File.join(PKG_DESTINATION, 'vendor', 'rails')
|
|
|
|
VENDOR_LIBS.each { |dir| ln_s File.join('..', '..', '..', dir), File.join(PKG_DESTINATION, 'vendor', 'rails', dir) }
|
2005-01-13 10:49:26 -05:00
|
|
|
end
|
|
|
|
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
# Copy Ties Content -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
# :link_apache_config
|
|
|
|
desc "Make copies of all the default content of ties"
|
|
|
|
task :copy_ties_content => [
|
2004-12-15 06:30:09 -05:00
|
|
|
:copy_rootfiles, :copy_dispatches, :copy_html_files, :copy_application,
|
2005-02-24 07:28:26 -05:00
|
|
|
:copy_configs, :copy_binfiles, :copy_test_helpers, :copy_app_doc_readme ]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
task :copy_dispatches do
|
2005-01-01 13:10:10 -05:00
|
|
|
copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.rb")
|
2004-11-23 20:04:44 -05:00
|
|
|
chmod 0755, "#{PKG_DESTINATION}/public/dispatch.rb"
|
|
|
|
|
2005-01-01 13:10:10 -05:00
|
|
|
copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.cgi")
|
2004-11-23 20:04:44 -05:00
|
|
|
chmod 0755, "#{PKG_DESTINATION}/public/dispatch.cgi"
|
|
|
|
|
2005-01-01 13:10:10 -05:00
|
|
|
copy_with_rewritten_ruby_path("dispatches/dispatch.fcgi", "#{PKG_DESTINATION}/public/dispatch.fcgi")
|
2004-11-23 20:04:44 -05:00
|
|
|
chmod 0755, "#{PKG_DESTINATION}/public/dispatch.fcgi"
|
|
|
|
end
|
|
|
|
|
|
|
|
task :copy_html_files do
|
2005-03-26 06:34:11 -05:00
|
|
|
HTML_FILES.each { |file| cp File.join('html', file), File.join(PKG_DESTINATION, 'public', file) }
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
2004-12-15 06:30:09 -05:00
|
|
|
task :copy_application do
|
|
|
|
cp "helpers/application.rb", "#{PKG_DESTINATION}/app/controllers/application.rb"
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "helpers/application_helper.rb", "#{PKG_DESTINATION}/app/helpers/application_helper.rb"
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
task :copy_configs do
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "configs/database.yml", "#{PKG_DESTINATION}/config/database.yml"
|
2005-02-14 20:45:35 -05:00
|
|
|
cp "configs/routes.rb", "#{PKG_DESTINATION}/config/routes.rb"
|
2004-11-23 20:04:44 -05:00
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "configs/apache.conf", "#{PKG_DESTINATION}/public/.htaccess"
|
2004-11-23 20:04:44 -05:00
|
|
|
|
2005-03-20 17:41:35 -05:00
|
|
|
cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb"
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "environments/production.rb", "#{PKG_DESTINATION}/config/environments/production.rb"
|
|
|
|
cp "environments/development.rb", "#{PKG_DESTINATION}/config/environments/development.rb"
|
|
|
|
cp "environments/test.rb", "#{PKG_DESTINATION}/config/environments/test.rb"
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
2004-12-09 12:20:00 -05:00
|
|
|
task :copy_binfiles do
|
|
|
|
BIN_FILES.each do |file|
|
|
|
|
dest_file = File.join(PKG_DESTINATION, 'script', file)
|
2005-01-01 13:10:10 -05:00
|
|
|
copy_with_rewritten_ruby_path(File.join('bin', file), dest_file)
|
2004-12-09 12:20:00 -05:00
|
|
|
chmod 0755, dest_file
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2004-11-23 20:04:44 -05:00
|
|
|
task :copy_rootfiles do
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "fresh_rakefile", "#{PKG_DESTINATION}/Rakefile"
|
|
|
|
cp "README", "#{PKG_DESTINATION}/README"
|
2004-12-17 13:59:12 -05:00
|
|
|
cp "CHANGELOG", "#{PKG_DESTINATION}/CHANGELOG"
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
task :copy_test_helpers do
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "helpers/test_helper.rb", "#{PKG_DESTINATION}/test/test_helper.rb"
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
task :copy_app_doc_readme do
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP"
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
task :link_apache_config do
|
2004-11-25 11:27:59 -05:00
|
|
|
chdir(File.join(PKG_DESTINATION, 'config')) {
|
|
|
|
ln_s "../public/.htaccess", "apache.conf"
|
|
|
|
}
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
2005-01-01 13:10:10 -05:00
|
|
|
def copy_with_rewritten_ruby_path(src_file, dest_file)
|
|
|
|
ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
|
|
|
|
|
|
|
File.open(dest_file, 'w') do |df|
|
|
|
|
File.open(src_file) do |sf|
|
|
|
|
line = sf.gets
|
|
|
|
if (line =~ /#!.+ruby\s*/) != nil
|
|
|
|
df.puts("#!#{ruby}")
|
|
|
|
else
|
|
|
|
df.puts(line)
|
|
|
|
end
|
|
|
|
df.write(sf.read)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
# Generate documentation ------------------------------------------------------------------
|
|
|
|
|
|
|
|
desc "Generate documentation for the framework and for the empty application"
|
2004-11-25 11:27:59 -05:00
|
|
|
task :generate_documentation => [ :generate_app_doc, :generate_rails_framework_doc ]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
task :generate_rails_framework_doc do
|
|
|
|
system %{cd #{PKG_DESTINATION}; rake apidoc}
|
|
|
|
end
|
|
|
|
|
|
|
|
task :generate_app_doc do
|
|
|
|
File.cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP"
|
|
|
|
system %{cd #{PKG_DESTINATION}; rake appdoc}
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Generate GEM ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
task :copy_gem_environment do
|
2005-03-20 17:41:35 -05:00
|
|
|
cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb"
|
2005-01-24 06:59:22 -05:00
|
|
|
dest_file = File.join(PKG_DESTINATION, 'script', 'breakpointer')
|
|
|
|
copy_with_rewritten_ruby_path(File.join('bin', 'breakpointer_for_gem'), dest_file)
|
|
|
|
chmod 0755, dest_file
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PKG_FILES = FileList[
|
|
|
|
'[a-zA-Z]*',
|
|
|
|
'bin/**/*',
|
|
|
|
'configs/**/*',
|
|
|
|
'doc/**/*',
|
|
|
|
'dispatches/**/*',
|
|
|
|
'environments/**/*',
|
|
|
|
'helpers/**/*',
|
2004-12-16 08:12:10 -05:00
|
|
|
'generators/**/*',
|
2004-11-23 20:04:44 -05:00
|
|
|
'html/**/*',
|
|
|
|
'lib/**/*'
|
|
|
|
]
|
|
|
|
|
|
|
|
spec = Gem::Specification.new do |s|
|
|
|
|
s.name = 'rails'
|
|
|
|
s.version = PKG_VERSION
|
|
|
|
s.summary = "Web-application framework with template engine, control-flow layer, and ORM."
|
|
|
|
s.description = <<-EOF
|
|
|
|
Rails is a framework for building web-application using CGI, FCGI, mod_ruby, or WEBrick
|
|
|
|
on top of either MySQL, PostgreSQL, or SQLite with eRuby-based templates.
|
|
|
|
EOF
|
|
|
|
|
2005-04-18 16:10:11 -04:00
|
|
|
s.add_dependency('rake', '>= 0.5.3')
|
|
|
|
s.add_dependency('activesupport', '= 1.0.4' + PKG_BUILD)
|
2005-04-19 12:34:44 -04:00
|
|
|
s.add_dependency('activerecord', '= 1.10.1' + PKG_BUILD)
|
|
|
|
s.add_dependency('actionpack', '= 1.8.1' + PKG_BUILD)
|
|
|
|
s.add_dependency('actionmailer', '= 0.9.1' + PKG_BUILD)
|
|
|
|
s.add_dependency('actionwebservice', '= 0.7.1' + PKG_BUILD)
|
2004-11-23 20:04:44 -05:00
|
|
|
|
2005-02-15 11:46:53 -05:00
|
|
|
s.rdoc_options << '--exclude' << '.'
|
2004-12-16 12:58:29 -05:00
|
|
|
s.has_rdoc = false
|
|
|
|
|
2004-12-15 07:04:50 -05:00
|
|
|
s.files = PKG_FILES.to_a.delete_if {|f| f.include?('.svn')}
|
2004-11-23 20:04:44 -05:00
|
|
|
s.require_path = 'lib'
|
|
|
|
|
|
|
|
s.bindir = "bin" # Use these for applications.
|
|
|
|
s.executables = ["rails"]
|
|
|
|
s.default_executable = "rails"
|
|
|
|
|
|
|
|
s.author = "David Heinemeier Hansson"
|
|
|
|
s.email = "david@loudthinking.com"
|
|
|
|
s.homepage = "http://www.rubyonrails.org"
|
|
|
|
s.rubyforge_project = "rails"
|
|
|
|
end
|
|
|
|
|
|
|
|
Rake::GemPackageTask.new(spec) do |pkg|
|
|
|
|
end
|
|
|
|
|
2005-03-27 08:33:54 -05:00
|
|
|
|
|
|
|
# Publishing -------------------------------------------------------
|
2004-11-23 20:04:44 -05:00
|
|
|
desc "Publish the API documentation"
|
|
|
|
task :pgem => [:gem] do
|
2005-05-19 12:42:47 -04:00
|
|
|
Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
|
|
|
|
`ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'`
|
2005-03-27 08:33:54 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Publish the release files to RubyForge."
|
2005-03-27 10:07:27 -05:00
|
|
|
task :release => [:gem] do
|
2005-03-27 08:33:54 -05:00
|
|
|
files = ["gem"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
|
|
|
|
|
|
|
|
if RUBY_FORGE_PROJECT then
|
|
|
|
require 'net/http'
|
|
|
|
require 'open-uri'
|
|
|
|
|
|
|
|
project_uri = "http://rubyforge.org/projects/#{RUBY_FORGE_PROJECT}/"
|
|
|
|
project_data = open(project_uri) { |data| data.read }
|
|
|
|
group_id = project_data[/[?&]group_id=(\d+)/, 1]
|
|
|
|
raise "Couldn't get group id" unless group_id
|
|
|
|
|
|
|
|
# This echos password to shell which is a bit sucky
|
|
|
|
if ENV["RUBY_FORGE_PASSWORD"]
|
|
|
|
password = ENV["RUBY_FORGE_PASSWORD"]
|
|
|
|
else
|
|
|
|
print "#{RUBY_FORGE_USER}@rubyforge.org's password: "
|
|
|
|
password = STDIN.gets.chomp
|
|
|
|
end
|
|
|
|
|
|
|
|
login_response = Net::HTTP.start("rubyforge.org", 80) do |http|
|
|
|
|
data = [
|
|
|
|
"login=1",
|
|
|
|
"form_loginname=#{RUBY_FORGE_USER}",
|
|
|
|
"form_pw=#{password}"
|
|
|
|
].join("&")
|
|
|
|
http.post("/account/login.php", data)
|
|
|
|
end
|
|
|
|
|
|
|
|
cookie = login_response["set-cookie"]
|
|
|
|
raise "Login failed" unless cookie
|
|
|
|
headers = { "Cookie" => cookie }
|
|
|
|
|
|
|
|
release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
|
|
|
|
release_data = open(release_uri, headers) { |data| data.read }
|
|
|
|
package_id = release_data[/[?&]package_id=(\d+)/, 1]
|
|
|
|
raise "Couldn't get package id" unless package_id
|
|
|
|
|
|
|
|
first_file = true
|
|
|
|
release_id = ""
|
|
|
|
|
|
|
|
files.each do |filename|
|
|
|
|
basename = File.basename(filename)
|
|
|
|
file_ext = File.extname(filename)
|
|
|
|
file_data = File.open(filename, "rb") { |file| file.read }
|
|
|
|
|
|
|
|
puts "Releasing #{basename}..."
|
|
|
|
|
|
|
|
release_response = Net::HTTP.start("rubyforge.org", 80) do |http|
|
|
|
|
release_date = Time.now.strftime("%Y-%m-%d %H:%M")
|
|
|
|
type_map = {
|
|
|
|
".zip" => "3000",
|
|
|
|
".tgz" => "3110",
|
|
|
|
".gz" => "3110",
|
|
|
|
".gem" => "1400"
|
|
|
|
}; type_map.default = "9999"
|
|
|
|
type = type_map[file_ext]
|
|
|
|
boundary = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
|
|
|
|
|
|
|
|
query_hash = if first_file then
|
|
|
|
{
|
|
|
|
"group_id" => group_id,
|
|
|
|
"package_id" => package_id,
|
|
|
|
"release_name" => RELEASE_NAME,
|
|
|
|
"release_date" => release_date,
|
|
|
|
"type_id" => type,
|
|
|
|
"processor_id" => "8000", # Any
|
|
|
|
"release_notes" => "",
|
|
|
|
"release_changes" => "",
|
|
|
|
"preformatted" => "1",
|
|
|
|
"submit" => "1"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
"group_id" => group_id,
|
|
|
|
"release_id" => release_id,
|
|
|
|
"package_id" => package_id,
|
|
|
|
"step2" => "1",
|
|
|
|
"type_id" => type,
|
|
|
|
"processor_id" => "8000", # Any
|
|
|
|
"submit" => "Add This File"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
query = "?" + query_hash.map do |(name, value)|
|
|
|
|
[name, URI.encode(value)].join("=")
|
|
|
|
end.join("&")
|
|
|
|
|
|
|
|
data = [
|
|
|
|
"--" + boundary,
|
|
|
|
"Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
|
|
|
|
"Content-Type: application/octet-stream",
|
|
|
|
"Content-Transfer-Encoding: binary",
|
|
|
|
"", file_data, ""
|
|
|
|
].join("\x0D\x0A")
|
|
|
|
|
|
|
|
release_headers = headers.merge(
|
|
|
|
"Content-Type" => "multipart/form-data; boundary=#{boundary}"
|
|
|
|
)
|
|
|
|
|
|
|
|
target = first_file ? "/frs/admin/qrs.php" : "/frs/admin/editrelease.php"
|
|
|
|
http.post(target + query, data, release_headers)
|
|
|
|
end
|
|
|
|
|
|
|
|
if first_file then
|
|
|
|
release_id = release_response.body[/release_id=(\d+)/, 1]
|
|
|
|
raise("Couldn't get release id") unless release_id
|
|
|
|
end
|
|
|
|
|
|
|
|
first_file = false
|
|
|
|
end
|
|
|
|
end
|
2005-04-30 11:37:45 -04:00
|
|
|
end
|