Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/tags/rel_0-11-1/actionpack/Rakefile

Revision 1026, 6.5 kB (checked in by david, 4 years ago)

Tagged the 0.11.1 release

  • Property svn:executable set to *
Line 
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      = 'actionpack'
11 PKG_VERSION   = '1.7.0' + PKG_BUILD
12 PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
13
14 RELEASE_NAME  = "REL #{PKG_VERSION}"
15
16 RUBY_FORGE_PROJECT = "actionpack"
17 RUBY_FORGE_USER    = "webster132"
18
19 desc "Default Task"
20 task :default => [ :test ]
21
22 # Run the unit tests
23
24 Rake::TestTask.new { |t|
25   t.libs << "test"
26 # make sure we include the controller tests (c*) first as on some systems
27 # this will not happen automatically and the tests (as a whole) will error
28   t.test_files=Dir.glob( "test/c*/*_test.rb" ) + Dir.glob( "test/[ft]*/*_test.rb" )
29 #  t.pattern = 'test/*/*_test.rb'
30   t.verbose = true
31 }
32
33
34 # Genereate the RDoc documentation
35
36 Rake::RDocTask.new { |rdoc|
37   rdoc.rdoc_dir = 'doc'
38   rdoc.title    = "Action Pack -- On rails from request to response"
39   rdoc.options << '--line-numbers --inline-source --main README'
40   rdoc.template = "#{ENV['template']}.rb" if ENV['template']
41   rdoc.rdoc_files.include('README', 'RUNNING_UNIT_TESTS', 'CHANGELOG')
42   rdoc.rdoc_files.include('lib/**/*.rb')
43 }
44
45
46 # Create compressed packages
47 dist_dirs = [ "lib", "test", "examples" ]
48
49 spec = Gem::Specification.new do |s|
50   s.platform = Gem::Platform::RUBY
51   s.name = PKG_NAME
52   s.version = PKG_VERSION
53   s.summary = "Web-flow and rendering framework putting the VC in MVC."
54   s.description = %q{Eases web-request routing, handling, and response as a half-way front, half-way page controller. Implemented with specific emphasis on enabling easy unit/integration testing that doesn't require a browser.} #'
55
56   s.author = "David Heinemeier Hansson"
57   s.email = "david@loudthinking.com"
58   s.rubyforge_project = "actionpack"
59   s.homepage = "http://www.rubyonrails.org"
60
61   s.has_rdoc = true
62   s.requirements << 'none'
63
64   s.add_dependency('activesupport', '= 1.0.3' + PKG_BUILD)
65
66   s.require_path = 'lib'
67   s.autorequire = 'action_controller'
68
69   s.files = [ "rakefile", "install.rb", "README", "RUNNING_UNIT_TESTS", "CHANGELOG", "MIT-LICENSE", "examples/.htaccess" ]
70   dist_dirs.each do |dir|
71     s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
72   end
73   s.files.delete "examples/benchmark.rb"
74   s.files.delete "examples/benchmark_with_ar.fcgi"
75 end
76  
77 Rake::GemPackageTask.new(spec) do |p|
78   p.gem_spec = spec
79   p.need_tar = true
80   p.need_zip = true
81 end
82
83
84 # Publishing ------------------------------------------------------
85
86 desc "Publish the API documentation"
87 task :pgem => [:package] do
88   Rake::SshFilePublisher.new("davidhh@comox.textdrive.com", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
89   `ssh davidhh@comox.textdrive.com './gemupdate.sh'`
90 end
91
92 desc "Publish the API documentation"
93 task :pdoc => [:rdoc] do
94   Rake::SshDirPublisher.new("davidhh@comox.textdrive.com", "public_html/ap", "doc").upload
95 end
96
97 desc "Publish the release files to RubyForge."
98 task :release => [:package] do
99   files = ["gem", "tgz", "zip"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
100
101   if RUBY_FORGE_PROJECT then
102     require 'net/http'
103     require 'open-uri'
104
105     project_uri = "http://rubyforge.org/projects/#{RUBY_FORGE_PROJECT}/"
106     project_data = open(project_uri) { |data| data.read }
107     group_id = project_data[/[?&]group_id=(\d+)/, 1]
108     raise "Couldn't get group id" unless group_id
109
110     # This echos password to shell which is a bit sucky
111     if ENV["RUBY_FORGE_PASSWORD"]
112       password = ENV["RUBY_FORGE_PASSWORD"]
113     else
114       print "#{RUBY_FORGE_USER}@rubyforge.org's password: "
115       password = STDIN.gets.chomp
116     end
117
118     login_response = Net::HTTP.start("rubyforge.org", 80) do |http|
119       data = [
120         "login=1",
121         "form_loginname=#{RUBY_FORGE_USER}",
122         "form_pw=#{password}"
123       ].join("&")
124       http.post("/account/login.php", data)
125     end
126
127     cookie = login_response["set-cookie"]
128     raise "Login failed" unless cookie
129     headers = { "Cookie" => cookie }
130
131     release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
132     release_data = open(release_uri, headers) { |data| data.read }
133     package_id = release_data[/[?&]package_id=(\d+)/, 1]
134     raise "Couldn't get package id" unless package_id
135
136     first_file = true
137     release_id = ""
138
139     files.each do |filename|
140       basename  = File.basename(filename)
141       file_ext  = File.extname(filename)
142       file_data = File.open(filename, "rb") { |file| file.read }
143
144       puts "Releasing #{basename}..."
145
146       release_response = Net::HTTP.start("rubyforge.org", 80) do |http|
147         release_date = Time.now.strftime("%Y-%m-%d %H:%M")
148         type_map = {
149           ".zip"    => "3000",
150           ".tgz"    => "3110",
151           ".gz"     => "3110",
152           ".gem"    => "1400"
153         }; type_map.default = "9999"
154         type = type_map[file_ext]
155         boundary = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
156
157         query_hash = if first_file then
158           {
159             "group_id" => group_id,
160             "package_id" => package_id,
161             "release_name" => RELEASE_NAME,
162             "release_date" => release_date,
163             "type_id" => type,
164             "processor_id" => "8000", # Any
165             "release_notes" => "",
166             "release_changes" => "",
167             "preformatted" => "1",
168             "submit" => "1"
169           }
170         else
171           {
172             "group_id" => group_id,
173             "release_id" => release_id,
174             "package_id" => package_id,
175             "step2" => "1",
176             "type_id" => type,
177             "processor_id" => "8000", # Any
178             "submit" => "Add This File"
179           }
180         end
181
182         query = "?" + query_hash.map do |(name, value)|
183           [name, URI.encode(value)].join("=")
184         end.join("&")
185
186         data = [
187           "--" + boundary,
188           "Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
189           "Content-Type: application/octet-stream",
190           "Content-Transfer-Encoding: binary",
191           "", file_data, ""
192           ].join("\x0D\x0A")
193
194         release_headers = headers.merge(
195           "Content-Type" => "multipart/form-data; boundary=#{boundary}"
196         )
197
198         target = first_file ? "/frs/admin/qrs.php" : "/frs/admin/editrelease.php"
199         http.post(target + query, data, release_headers)
200       end
201
202       if first_file then
203         release_id = release_response.body[/release_id=(\d+)/, 1]
204         raise("Couldn't get release id") unless release_id
205       end
206
207       first_file = false
208     end
209   end
210 end
Note: See TracBrowser for help on using the browser.