root/trunk/vendor/railties/Rakefile @ 1

Revision 1, 9.3 KB (checked in by dema, 8 years ago)

Initial import

Line 
1require 'rake'
2require 'rake/testtask'
3require 'rake/rdoctask'
4require 'rake/gempackagetask'
5require 'rake/contrib/rubyforgepublisher'
6
7require 'date'
8require 'rbconfig'
9
10PKG_BUILD       = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
11PKG_NAME        = 'rails'
12PKG_VERSION     = '0.11.0' + PKG_BUILD
13PKG_FILE_NAME   = "#{PKG_NAME}-#{PKG_VERSION}"
14PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
15
16
17BASE_DIRS   = %w( app config/environments components db doc log lib public script test vendor )
18APP_DIRS    = %w( apis models controllers helpers views views/layouts )
19PUBLIC_DIRS = %w( images javascripts stylesheets )
20TEST_DIRS   = %w( fixtures unit functional mocks mocks/development mocks/test )
21
22LOG_FILES    = %w( server.log development.log test.log production.log )
23HTML_FILES   = %w( 404.html 500.html index.html favicon.ico javascripts/prototype.js )
24BIN_FILES    = %w( generate destroy breakpointer console server update runner )
25
26VENDOR_LIBS = %w( actionpack activerecord actionmailer activesupport actionwebservice railties )
27
28
29desc "Default Task"
30task :default => [ :fresh_rails ]
31
32desc "Generates a fresh Rails package with documentation"
33task :fresh_rails => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_vendor_libraries, :copy_ties_content, :generate_documentation ]
34
35desc "Generates a fresh Rails package using GEMs with documentation"
36task :fresh_gem_rails => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_ties_content, :copy_gem_environment ]
37
38desc "Generates a fresh Rails package without documentation (faster)"
39task :fresh_rails_without_docs => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_vendor_libraries, :copy_ties_content ]
40
41desc "Generates a fresh Rails package without documentation (faster)"
42task :fresh_rails_without_docs_using_links => [ :clean, :make_dir_structure, :initialize_file_stubs, :link_vendor_libraries, :copy_ties_content ]
43
44desc "Generates minimal Rails package using symlinks"
45task :dev => [ :clean, :make_dir_structure, :initialize_file_stubs, :link_vendor_libraries, :copy_ties_content ]
46
47desc "Packages the fresh Rails package with documentation"
48task :package => [ :clean, :fresh_rails ] do
49  system %{cd ..; tar -czvf #{PKG_NAME}-#{PKG_VERSION}.tgz #{PKG_NAME}}
50  system %{cd ..; zip -r #{PKG_NAME}-#{PKG_VERSION}.zip #{PKG_NAME}}
51end
52
53task :clean do
54  rm_rf PKG_DESTINATION
55end
56
57
58# Make directory structure ----------------------------------------------------------------
59
60def make_dest_dirs(dirs, path = nil)
61  mkdir_p dirs.map { |dir| File.join(PKG_DESTINATION, path, dir) }
62end
63
64desc "Make the directory structure for the new Rails application"
65task :make_dir_structure => [ :make_base_dirs, :make_app_dirs, :make_public_dirs, :make_test_dirs ]
66
67task(:make_base_dirs)   { make_dest_dirs BASE_DIRS              }
68task(:make_app_dirs)    { make_dest_dirs APP_DIRS,    'app'     }
69task(:make_public_dirs) { make_dest_dirs PUBLIC_DIRS, 'public'  }
70task(:make_test_dirs)   { make_dest_dirs TEST_DIRS,   'test'    }
71
72
73# Initialize file stubs -------------------------------------------------------------------
74
75desc "Initialize empty file stubs (such as for logging)"
76task :initialize_file_stubs => [ :initialize_log_files ]
77
78task :initialize_log_files do
79  log_dir = File.join(PKG_DESTINATION, 'log')
80  chmod 0777, log_dir
81  LOG_FILES.each do |log_file|
82    log_path = File.join(log_dir, log_file)
83    touch log_path
84    chmod 0666, log_path
85  end
86end
87
88
89# Copy Vendors ----------------------------------------------------------------------------
90
91desc "Copy in all the Rails packages to vendor"
92task :copy_vendor_libraries do
93  mkdir File.join(PKG_DESTINATION, 'vendor', 'rails')
94  VENDOR_LIBS.each { |dir| cp_r File.join('..', dir), File.join(PKG_DESTINATION, 'vendor', 'rails', dir) }
95end
96
97desc "Link in all the Rails packages to vendor"
98task :link_vendor_libraries do
99  mkdir File.join(PKG_DESTINATION, 'vendor', 'rails')
100  VENDOR_LIBS.each { |dir| ln_s File.join('..', '..', '..', dir), File.join(PKG_DESTINATION, 'vendor', 'rails', dir) }
101end
102
103
104# Copy Ties Content -----------------------------------------------------------------------
105
106# :link_apache_config
107desc "Make copies of all the default content of ties"
108task :copy_ties_content => [
109  :copy_rootfiles, :copy_dispatches, :copy_html_files, :copy_application,
110  :copy_configs, :copy_binfiles, :copy_test_helpers, :copy_app_doc_readme ]
111
112task :copy_dispatches do
113  copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.rb")
114  chmod 0755, "#{PKG_DESTINATION}/public/dispatch.rb"
115
116  copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.cgi")
117  chmod 0755, "#{PKG_DESTINATION}/public/dispatch.cgi"
118
119  copy_with_rewritten_ruby_path("dispatches/dispatch.fcgi", "#{PKG_DESTINATION}/public/dispatch.fcgi")
120  chmod 0755, "#{PKG_DESTINATION}/public/dispatch.fcgi"
121end
122
123task :copy_html_files do
124  cp HTML_FILES.map { |dir| File.join('html', dir) },
125     File.join(PKG_DESTINATION, 'public')
126end
127
128task :copy_application do
129  cp "helpers/application.rb", "#{PKG_DESTINATION}/app/controllers/application.rb"
130  cp "helpers/application_helper.rb", "#{PKG_DESTINATION}/app/helpers/application_helper.rb"
131end
132
133task :copy_configs do
134  cp "configs/database.yml", "#{PKG_DESTINATION}/config/database.yml"
135  cp "configs/routes.rb", "#{PKG_DESTINATION}/config/routes.rb"
136
137  cp "configs/apache.conf", "#{PKG_DESTINATION}/public/.htaccess"
138
139  cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb"
140  cp "environments/production.rb", "#{PKG_DESTINATION}/config/environments/production.rb"
141  cp "environments/development.rb", "#{PKG_DESTINATION}/config/environments/development.rb"
142  cp "environments/test.rb", "#{PKG_DESTINATION}/config/environments/test.rb"
143end
144
145task :copy_binfiles do
146  BIN_FILES.each do |file|
147    dest_file = File.join(PKG_DESTINATION, 'script', file)
148    copy_with_rewritten_ruby_path(File.join('bin', file), dest_file)
149    chmod 0755, dest_file
150  end
151end
152
153task :copy_rootfiles do
154  cp "fresh_rakefile", "#{PKG_DESTINATION}/Rakefile"
155  cp "README", "#{PKG_DESTINATION}/README"
156  cp "CHANGELOG", "#{PKG_DESTINATION}/CHANGELOG"
157end
158
159task :copy_test_helpers do
160  cp "helpers/test_helper.rb", "#{PKG_DESTINATION}/test/test_helper.rb"
161end
162
163task :copy_app_doc_readme do
164  cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP"
165end
166
167task :link_apache_config do
168  chdir(File.join(PKG_DESTINATION, 'config')) {
169    ln_s "../public/.htaccess", "apache.conf"
170  }
171end
172
173def copy_with_rewritten_ruby_path(src_file, dest_file)
174  ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
175
176  File.open(dest_file, 'w') do |df|
177    File.open(src_file) do |sf|
178      line = sf.gets
179      if (line =~ /#!.+ruby\s*/) != nil
180        df.puts("#!#{ruby}")
181      else
182        df.puts(line)
183      end
184      df.write(sf.read)
185    end
186  end
187end
188
189
190# Generate documentation ------------------------------------------------------------------
191
192desc "Generate documentation for the framework and for the empty application"
193task :generate_documentation => [ :generate_app_doc, :generate_rails_framework_doc ]
194
195task :generate_rails_framework_doc do
196  system %{cd #{PKG_DESTINATION}; rake apidoc}
197end
198
199task :generate_app_doc do
200  File.cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP"
201  system %{cd #{PKG_DESTINATION}; rake appdoc}
202end
203
204
205# Generate GEM ----------------------------------------------------------------------------
206
207task :copy_gem_environment do
208  cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb"
209  dest_file = File.join(PKG_DESTINATION, 'script', 'breakpointer')
210  copy_with_rewritten_ruby_path(File.join('bin', 'breakpointer_for_gem'), dest_file)
211  chmod 0755, dest_file
212end
213
214
215PKG_FILES = FileList[
216  '[a-zA-Z]*',
217  'bin/**/*',
218  'configs/**/*',
219  'doc/**/*',
220  'dispatches/**/*',
221  'environments/**/*',
222  'helpers/**/*',
223  'generators/**/*',
224  'html/**/*',
225  'lib/**/*'
226]
227
228spec = Gem::Specification.new do |s|
229  s.name = 'rails'
230  s.version = PKG_VERSION
231  s.summary = "Web-application framework with template engine, control-flow layer, and ORM."
232  s.description = <<-EOF
233    Rails is a framework for building web-application using CGI, FCGI, mod_ruby, or WEBrick
234    on top of either MySQL, PostgreSQL, or SQLite with eRuby-based templates.
235  EOF
236
237  s.add_dependency('rake', '>= 0.4.15')
238  s.add_dependency('activesupport',    '= 1.0.2' + PKG_BUILD)
239  s.add_dependency('activerecord',     '= 1.9.0' + PKG_BUILD)
240  s.add_dependency('actionpack',       '= 1.6.0' + PKG_BUILD)
241  s.add_dependency('actionmailer',     '= 0.8.0' + PKG_BUILD)
242  s.add_dependency('actionwebservice', '= 0.6.1' + PKG_BUILD)
243
244  s.rdoc_options << '--exclude' << '.'
245  s.has_rdoc = false
246
247  s.files = PKG_FILES.to_a.delete_if {|f| f.include?('.svn')}
248  s.require_path = 'lib'
249
250  s.bindir = "bin"                               # Use these for applications.
251  s.executables = ["rails"]
252  s.default_executable = "rails"
253
254  s.author = "David Heinemeier Hansson"
255  s.email = "david@loudthinking.com"
256  s.homepage = "http://www.rubyonrails.org"
257  s.rubyforge_project = "rails"
258end
259
260Rake::GemPackageTask.new(spec) do |pkg|
261end
262
263# Publish beta gem
264desc "Publish the API documentation"
265task :pgem => [:gem] do
266  Rake::SshFilePublisher.new("davidhh@comox.textdrive.com", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
267  `ssh davidhh@comox.textdrive.com './gemupdate.sh'`
268end
Note: See TracBrowser for help on using the browser.