~michaelforrest/use-case-mapper/trunk

« back to all changes in this revision

Viewing changes to vendor/rails/railties/Rakefile

  • Committer: Richard Lee (Canonical)
  • Date: 2010-10-15 15:17:58 UTC
  • mfrom: (190.1.3 use-case-mapper)
  • Revision ID: richard.lee@canonical.com-20101015151758-wcvmfxrexsongf9d
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
require 'rake'
2
 
require 'rake/testtask'
3
 
require 'rake/rdoctask'
4
 
require 'rake/gempackagetask'
5
 
 
6
 
require 'date'
7
 
require 'rbconfig'
8
 
 
9
 
require File.join(File.dirname(__FILE__), 'lib/rails', 'version')
10
 
 
11
 
PKG_BUILD       = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
12
 
PKG_NAME        = 'rails'
13
 
PKG_VERSION     = Rails::VERSION::STRING + PKG_BUILD
14
 
PKG_FILE_NAME   = "#{PKG_NAME}-#{PKG_VERSION}"
15
 
PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
16
 
 
17
 
RELEASE_NAME  = "REL #{PKG_VERSION}"
18
 
 
19
 
RUBY_FORGE_PROJECT = "rails"
20
 
RUBY_FORGE_USER    = "webster132"
21
 
 
22
 
 
23
 
task :default => :test
24
 
 
25
 
## This is required until the regular test task
26
 
## below passes.  It's not ideal, but at least
27
 
## we can see the failures
28
 
task :test do 
29
 
  Dir['test/**/*_test.rb'].all? do |file|
30
 
    ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
31
 
    system(ruby, '-Itest', file)
32
 
  end or raise "Failures"
33
 
end
34
 
 
35
 
Rake::TestTask.new("regular_test") do |t|
36
 
  t.libs << 'test'
37
 
  t.pattern = 'test/**/*_test.rb'
38
 
  t.warning = true
39
 
  t.verbose = true
40
 
end
41
 
 
42
 
 
43
 
BASE_DIRS = %w( 
44
 
  app
45
 
  config/environments
46
 
  config/initializers
47
 
  config/locales
48
 
  db
49
 
  doc
50
 
  log
51
 
  lib
52
 
  lib/tasks
53
 
  public
54
 
  script
55
 
  script/performance
56
 
  test
57
 
  vendor
58
 
  vendor/plugins
59
 
  tmp/sessions
60
 
  tmp/cache
61
 
  tmp/sockets
62
 
  tmp/pids
63
 
)
64
 
 
65
 
APP_DIRS    = %w( models controllers helpers views views/layouts )
66
 
PUBLIC_DIRS = %w( images javascripts stylesheets )
67
 
TEST_DIRS   = %w( fixtures unit functional mocks mocks/development mocks/test )
68
 
 
69
 
LOG_FILES    = %w( server.log development.log test.log production.log )
70
 
HTML_FILES   = %w( 422.html 404.html 500.html index.html robots.txt favicon.ico images/rails.png
71
 
                   javascripts/prototype.js javascripts/application.js
72
 
                   javascripts/effects.js javascripts/dragdrop.js javascripts/controls.js )
73
 
BIN_FILES    = %w( about console destroy generate performance/benchmarker performance/profiler runner server plugin )
74
 
 
75
 
VENDOR_LIBS = %w( actionpack activerecord actionmailer activesupport activeresource railties )
76
 
 
77
 
 
78
 
desc "Generates a fresh Rails package with documentation"
79
 
task :fresh_rails => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_vendor_libraries, :copy_ties_content, :generate_documentation ]
80
 
 
81
 
desc "Generates a fresh Rails package using GEMs with documentation"
82
 
task :fresh_gem_rails => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_ties_content, :copy_gem_environment ]
83
 
 
84
 
desc "Generates a fresh Rails package without documentation (faster)"
85
 
task :fresh_rails_without_docs => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_vendor_libraries, :copy_ties_content ]
86
 
 
87
 
desc "Generates a fresh Rails package without documentation (faster)"
88
 
task :fresh_rails_without_docs_using_links => [ :clean, :make_dir_structure, :initialize_file_stubs, :link_vendor_libraries, :copy_ties_content ]
89
 
 
90
 
desc "Generates minimal Rails package using symlinks"
91
 
task :dev => [ :clean, :make_dir_structure, :initialize_file_stubs, :link_vendor_libraries, :copy_ties_content ]
92
 
 
93
 
desc "Packages the fresh Rails package with documentation"
94
 
task :package => [ :clean, :fresh_rails ] do
95
 
  system %{cd ..; tar -czvf #{PKG_NAME}-#{PKG_VERSION}.tgz #{PKG_NAME}}
96
 
  system %{cd ..; zip -r #{PKG_NAME}-#{PKG_VERSION}.zip #{PKG_NAME}}
97
 
end
98
 
 
99
 
task :clean do
100
 
  rm_rf PKG_DESTINATION
101
 
end
102
 
 
103
 
# Get external spinoffs -------------------------------------------------------------------
104
 
 
105
 
desc "Updates railties to the latest version of the javascript spinoffs"
106
 
task :update_js do
107
 
  for js in %w( prototype controls dragdrop effects )
108
 
    rm "html/javascripts/#{js}.js"
109
 
    cp "./../actionpack/lib/action_view/helpers/javascripts/#{js}.js", "html/javascripts"
110
 
  end
111
 
end
112
 
 
113
 
# Make directory structure ----------------------------------------------------------------
114
 
 
115
 
def make_dest_dirs(dirs, path = '.')
116
 
  mkdir_p dirs.map { |dir| File.join(PKG_DESTINATION, path.to_s, dir) }
117
 
end
118
 
 
119
 
desc "Make the directory structure for the new Rails application"
120
 
task :make_dir_structure => [ :make_base_dirs, :make_app_dirs, :make_public_dirs, :make_test_dirs ]
121
 
 
122
 
task(:make_base_dirs)   { make_dest_dirs BASE_DIRS              }
123
 
task(:make_app_dirs)    { make_dest_dirs APP_DIRS,    'app'     }
124
 
task(:make_public_dirs) { make_dest_dirs PUBLIC_DIRS, 'public'  }
125
 
task(:make_test_dirs)   { make_dest_dirs TEST_DIRS,   'test'    }
126
 
 
127
 
 
128
 
# Initialize file stubs -------------------------------------------------------------------
129
 
 
130
 
desc "Initialize empty file stubs (such as for logging)"
131
 
task :initialize_file_stubs => [ :initialize_log_files ]
132
 
 
133
 
task :initialize_log_files do
134
 
  log_dir = File.join(PKG_DESTINATION, 'log')
135
 
  chmod 0777, log_dir
136
 
  LOG_FILES.each do |log_file|
137
 
    log_path = File.join(log_dir, log_file)
138
 
    touch log_path
139
 
    chmod 0666, log_path
140
 
  end
141
 
end
142
 
 
143
 
 
144
 
# Copy Vendors ----------------------------------------------------------------------------
145
 
 
146
 
desc "Copy in all the Rails packages to vendor"
147
 
task :copy_vendor_libraries do
148
 
  mkdir File.join(PKG_DESTINATION, 'vendor', 'rails')
149
 
  VENDOR_LIBS.each { |dir| cp_r File.join('..', dir), File.join(PKG_DESTINATION, 'vendor', 'rails', dir) }
150
 
  FileUtils.rm_r(Dir.glob(File.join(PKG_DESTINATION, 'vendor', 'rails', "**", ".svn")))
151
 
end
152
 
 
153
 
desc "Link in all the Rails packages to vendor"
154
 
task :link_vendor_libraries do
155
 
  mkdir File.join(PKG_DESTINATION, 'vendor', 'rails')
156
 
  VENDOR_LIBS.each { |dir| ln_s File.join('..', '..', '..', dir), File.join(PKG_DESTINATION, 'vendor', 'rails', dir) }
157
 
end
158
 
 
159
 
 
160
 
# Copy Ties Content -----------------------------------------------------------------------
161
 
 
162
 
desc "Make copies of all the default content of ties"
163
 
task :copy_ties_content => [ 
164
 
  :copy_rootfiles, :copy_dispatches, :copy_html_files, :copy_application,
165
 
  :copy_configs, :copy_binfiles, :copy_test_helpers, :copy_app_doc_readme ]
166
 
 
167
 
task :copy_dispatches do
168
 
  copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.rb")
169
 
  chmod 0755, "#{PKG_DESTINATION}/public/dispatch.rb"
170
 
 
171
 
  copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.cgi")
172
 
  chmod 0755, "#{PKG_DESTINATION}/public/dispatch.cgi"
173
 
 
174
 
  copy_with_rewritten_ruby_path("dispatches/dispatch.fcgi", "#{PKG_DESTINATION}/public/dispatch.fcgi")
175
 
  chmod 0755, "#{PKG_DESTINATION}/public/dispatch.fcgi"
176
 
end
177
 
 
178
 
task :copy_html_files do
179
 
  HTML_FILES.each { |file| cp File.join('html', file), File.join(PKG_DESTINATION, 'public', file) }
180
 
end
181
 
 
182
 
task :copy_application do
183
 
  cp "helpers/application_controller.rb", "#{PKG_DESTINATION}/app/controllers/application_controller.rb"
184
 
  cp "helpers/application_helper.rb", "#{PKG_DESTINATION}/app/helpers/application_helper.rb"
185
 
end
186
 
 
187
 
task :copy_configs do
188
 
  app_name = "rails"
189
 
  socket = nil
190
 
  require 'erb'
191
 
  File.open("#{PKG_DESTINATION}/config/database.yml", 'w') {|f| f.write ERB.new(IO.read("configs/databases/sqlite3.yml"), nil, '-').result(binding)}
192
 
  
193
 
  cp "configs/routes.rb", "#{PKG_DESTINATION}/config/routes.rb"
194
 
 
195
 
  cp "configs/initializers/backtrace_silencers.rb", "#{PKG_DESTINATION}/config/initializers/backtrace_silencers.rb"
196
 
  cp "configs/initializers/inflections.rb",         "#{PKG_DESTINATION}/config/initializers/inflections.rb"
197
 
  cp "configs/initializers/mime_types.rb",          "#{PKG_DESTINATION}/config/initializers/mime_types.rb"
198
 
  cp "configs/initializers/new_rails_defaults.rb",  "#{PKG_DESTINATION}/config/initializers/new_rails_defaults.rb"
199
 
 
200
 
  cp "configs/locales/en.yml", "#{PKG_DESTINATION}/config/locales/en.yml"
201
 
 
202
 
  cp "configs/seeds.rb", "#{PKG_DESTINATION}/db/seeds.rb"
203
 
 
204
 
  cp "environments/boot.rb",        "#{PKG_DESTINATION}/config/boot.rb"
205
 
  File.open("#{PKG_DESTINATION}/config/environment.rb", 'w') {|f| f.write ERB.new(IO.read("environments/environment.rb"), nil, '-').result(binding)}
206
 
  cp "environments/production.rb",  "#{PKG_DESTINATION}/config/environments/production.rb"
207
 
  cp "environments/development.rb", "#{PKG_DESTINATION}/config/environments/development.rb"
208
 
  cp "environments/test.rb",        "#{PKG_DESTINATION}/config/environments/test.rb"
209
 
 
210
 
end
211
 
 
212
 
task :copy_binfiles do
213
 
  BIN_FILES.each do |file|
214
 
    dest_file = File.join(PKG_DESTINATION, 'script', file)
215
 
    copy_with_rewritten_ruby_path(File.join('bin', file), dest_file)
216
 
    chmod 0755, dest_file
217
 
  end
218
 
end
219
 
 
220
 
task :copy_rootfiles do
221
 
  cp "fresh_rakefile", "#{PKG_DESTINATION}/Rakefile"
222
 
  cp "README", "#{PKG_DESTINATION}/README"
223
 
  cp "CHANGELOG", "#{PKG_DESTINATION}/CHANGELOG"
224
 
end
225
 
 
226
 
task :copy_test_helpers do
227
 
  cp "helpers/test_helper.rb", "#{PKG_DESTINATION}/test/test_helper.rb"
228
 
end
229
 
 
230
 
task :copy_app_doc_readme do
231
 
  cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP"
232
 
end
233
 
 
234
 
def copy_with_rewritten_ruby_path(src_file, dest_file)
235
 
  ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
236
 
 
237
 
  File.open(dest_file, 'w') do |df|
238
 
    File.open(src_file) do |sf|
239
 
      line = sf.gets
240
 
      if (line =~ /#!.+ruby\s*/) != nil
241
 
        df.puts("#!#{ruby}")
242
 
      else
243
 
        df.puts(line)
244
 
      end
245
 
      df.write(sf.read)
246
 
    end
247
 
  end
248
 
end
249
 
 
250
 
desc 'Generate guides (for authors), use ONLY=foo to process just "foo.textile"'
251
 
task :generate_guides do
252
 
  ruby "guides/rails_guides.rb"
253
 
end
254
 
 
255
 
 
256
 
# Generate documentation ------------------------------------------------------------------
257
 
 
258
 
desc "Generate documentation for the framework and for the empty application"
259
 
task :generate_documentation => [ :generate_app_doc, :generate_rails_framework_doc ]
260
 
 
261
 
task :generate_rails_framework_doc do
262
 
  system %{cd #{PKG_DESTINATION}; rake doc:rails}
263
 
end
264
 
 
265
 
task :generate_app_doc do
266
 
  cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP"
267
 
  system %{cd #{PKG_DESTINATION}; rake doc:app}
268
 
end
269
 
 
270
 
Rake::RDocTask.new { |rdoc|
271
 
  rdoc.rdoc_dir = 'doc'
272
 
  rdoc.title    = "Railties -- Gluing the Engine to the Rails"
273
 
  rdoc.options << '--line-numbers' << '--inline-source' << '--accessor' << 'cattr_accessor=object'
274
 
  rdoc.options << '--charset' << 'utf-8'
275
 
  rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
276
 
  rdoc.rdoc_files.include('README', 'CHANGELOG')
277
 
  rdoc.rdoc_files.include('lib/*.rb')
278
 
  rdoc.rdoc_files.include('lib/rails/*.rb')
279
 
  rdoc.rdoc_files.include('lib/rails_generator/*.rb')
280
 
  rdoc.rdoc_files.include('lib/commands/**/*.rb')
281
 
}
282
 
 
283
 
# Generate GEM ----------------------------------------------------------------------------
284
 
 
285
 
task :copy_gem_environment do
286
 
  cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb"
287
 
  chmod 0755, dest_file
288
 
end
289
 
 
290
 
 
291
 
PKG_FILES = FileList[
292
 
  '[a-zA-Z]*',
293
 
  'bin/**/*', 
294
 
  'builtin/**/*',
295
 
  'configs/**/*', 
296
 
  'doc/**/*', 
297
 
  'dispatches/**/*', 
298
 
  'environments/**/*', 
299
 
  'guides/**/*', 
300
 
  'helpers/**/*', 
301
 
  'generators/**/*', 
302
 
  'html/**/*', 
303
 
  'lib/**/*'
304
 
] - [ 'test' ]
305
 
 
306
 
spec = Gem::Specification.new do |s|
307
 
  s.platform = Gem::Platform::RUBY
308
 
  s.name = 'rails'
309
 
  s.version = PKG_VERSION
310
 
  s.summary = "Web-application framework with template engine, control-flow layer, and ORM."
311
 
  s.description = <<-EOF
312
 
    Rails is a framework for building web-application using CGI, FCGI, mod_ruby, or WEBrick
313
 
    on top of either MySQL, PostgreSQL, SQLite, DB2, SQL Server, or Oracle with eRuby- or Builder-based templates.
314
 
  EOF
315
 
 
316
 
  s.add_dependency('rake', '>= 0.8.3')
317
 
  s.add_dependency('activesupport',    '= 2.3.5' + PKG_BUILD)
318
 
  s.add_dependency('activerecord',     '= 2.3.5' + PKG_BUILD)
319
 
  s.add_dependency('actionpack',       '= 2.3.5' + PKG_BUILD)
320
 
  s.add_dependency('actionmailer',     '= 2.3.5' + PKG_BUILD)
321
 
  s.add_dependency('activeresource',   '= 2.3.5' + PKG_BUILD)
322
 
 
323
 
  s.rdoc_options << '--exclude' << '.'
324
 
  s.has_rdoc = false
325
 
 
326
 
  s.files = PKG_FILES.to_a.delete_if {|f| f =~ %r{\.svn|guides/output}}
327
 
  s.require_path = 'lib'
328
 
  s.bindir = "bin"                               # Use these for applications.
329
 
  s.executables = ["rails"]
330
 
  s.default_executable = "rails"
331
 
 
332
 
  s.author = "David Heinemeier Hansson"
333
 
  s.email = "david@loudthinking.com"
334
 
  s.homepage = "http://www.rubyonrails.org"
335
 
  s.rubyforge_project = "rails"
336
 
end
337
 
 
338
 
Rake::GemPackageTask.new(spec) do |pkg|
339
 
  pkg.gem_spec = spec
340
 
end
341
 
 
342
 
 
343
 
# Publishing -------------------------------------------------------
344
 
desc "Publish the rails gem"
345
 
task :pgem => [:gem] do 
346
 
  Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
347
 
  `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
348
 
end
349
 
 
350
 
desc "Publish the guides"
351
 
task :pguides => :generate_guides do
352
 
  mkdir_p 'pkg'
353
 
  `tar -czf pkg/guides.gz guides/output`
354
 
  Rake::SshFilePublisher.new("web.rubyonrails.org", "/u/sites/guides.rubyonrails.org/public", "pkg", "guides.gz").upload
355
 
  `ssh web.rubyonrails.org 'cd /u/sites/guides.rubyonrails.org/public/ && tar -xvzf guides.gz && mv guides/output/* . && rm -rf guides*'`
356
 
end
357
 
 
358
 
desc "Publish the release files to RubyForge."
359
 
task :release => [ :package ] do
360
 
  require 'rake/contrib/rubyforgepublisher'
361
 
  require 'rubyforge'
362
 
 
363
 
  packages = %w( gem ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
364
 
 
365
 
  rubyforge = RubyForge.new
366
 
  rubyforge.login
367
 
  rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
368
 
end