Rakefile 5.7 KB
Newer Older
1
#!/usr/bin/env rake
2

3 4 5 6 7 8

begin
  require 'rdoc/task'
rescue LoadError
  require 'rake/rdoctask'
end
9
require 'net/http'
10

11 12 13 14 15 16 17
$:.unshift File.expand_path('..', __FILE__)
require "tasks/release"

desc "Build gem files for all projects"
task :build => "all:build"

desc "Release all gems to gemcutter and create a tag"
C
Carl Lerche 已提交
18
task :release => "all:release"
19

C
Carlhuda 已提交
20
PROJECTS = %w(activesupport activemodel actionpack actionmailer activeresource activerecord railties)
21 22

desc 'Run all tests by default'
23
task :default => %w(test test:isolated)
24

25
%w(test test:isolated package gem).each do |task_name|
26 27
  desc "Run #{task_name} task for all projects"
  task task_name do
28
    errors = []
29
    PROJECTS.each do |project|
30
      system(%(cd #{project} && #{$0} #{task_name})) || errors << project
31
    end
32
    fail("Errors in #{errors.join(', ')}") unless errors.empty?
33 34
  end
end
J
Jeremy Kemper 已提交
35

36 37 38
desc "Smoke-test all projects"
task :smoke do
  (PROJECTS - %w(activerecord)).each do |project|
39
    system %(cd #{project} && #{$0} test:isolated)
40
  end
41
  system %(cd activerecord && #{$0} sqlite3:isolated_test)
42
end
C
Carlhuda 已提交
43

J
José Valim 已提交
44
desc "Install gems for all projects."
45
task :install => :gem do
46
  version = File.read("RAILS_VERSION").strip
47
  (PROJECTS - ["railties"]).each do |project|
C
Carlhuda 已提交
48
    puts "INSTALLING #{project}"
49
    system("gem install #{project}/pkg/#{project}-#{version}.gem --no-ri --no-rdoc")
50
  end
51 52
  system("gem install railties/pkg/railties-#{version}.gem --no-ri --no-rdoc")
  system("gem install pkg/rails-#{version}.gem --no-ri --no-rdoc")
53 54
end

J
Jeremy Kemper 已提交
55
desc "Generate documentation for the Rails framework"
A
Aaron Patterson 已提交
56
RDoc::Task.new do |rdoc|
57 58 59 60 61 62 63 64 65 66 67 68
  RDOC_MAIN = 'RDOC_MAIN.rdoc'

  rdoc.before_running_rdoc do
    rdoc_main = File.read('README.rdoc')
    rdoc_main.gsub!(/\b(?=Rails)\b/) { '\\' }
    File.open(RDOC_MAIN, 'w') do |f|
      f.write(rdoc_main)
    end

    rdoc.rdoc_files.include(RDOC_MAIN)
  end

J
Jeremy Kemper 已提交
69 70
  rdoc.rdoc_dir = 'doc/rdoc'
  rdoc.title    = "Ruby on Rails Documentation"
J
Jeremy Kemper 已提交
71

A
Aaron Patterson 已提交
72
  rdoc.options << '-f' << 'horo'
73
  rdoc.options << '-c' << 'utf-8'
74
  rdoc.options << '-m' << RDOC_MAIN
J
Jeremy Kemper 已提交
75 76 77

  rdoc.rdoc_files.include('railties/CHANGELOG')
  rdoc.rdoc_files.include('railties/MIT-LICENSE')
78
  rdoc.rdoc_files.include('railties/README.rdoc')
79 80
  rdoc.rdoc_files.include('railties/lib/**/*.rb')
  rdoc.rdoc_files.exclude('railties/lib/rails/generators/**/templates/*')
J
Jeremy Kemper 已提交
81

82
  rdoc.rdoc_files.include('activerecord/README.rdoc')
J
Jeremy Kemper 已提交
83 84 85 86
  rdoc.rdoc_files.include('activerecord/CHANGELOG')
  rdoc.rdoc_files.include('activerecord/lib/active_record/**/*.rb')
  rdoc.rdoc_files.exclude('activerecord/lib/active_record/vendor/*')

87
  rdoc.rdoc_files.include('activeresource/README.rdoc')
J
Jeremy Kemper 已提交
88 89 90 91
  rdoc.rdoc_files.include('activeresource/CHANGELOG')
  rdoc.rdoc_files.include('activeresource/lib/active_resource.rb')
  rdoc.rdoc_files.include('activeresource/lib/active_resource/*')

92
  rdoc.rdoc_files.include('actionpack/README.rdoc')
J
Jeremy Kemper 已提交
93
  rdoc.rdoc_files.include('actionpack/CHANGELOG')
94
  rdoc.rdoc_files.include('actionpack/lib/abstract_controller/**/*.rb')
J
Jeremy Kemper 已提交
95
  rdoc.rdoc_files.include('actionpack/lib/action_controller/**/*.rb')
96
  rdoc.rdoc_files.include('actionpack/lib/action_dispatch/**/*.rb')
J
Jeremy Kemper 已提交
97 98 99
  rdoc.rdoc_files.include('actionpack/lib/action_view/**/*.rb')
  rdoc.rdoc_files.exclude('actionpack/lib/action_controller/vendor/*')

100
  rdoc.rdoc_files.include('actionmailer/README.rdoc')
J
Jeremy Kemper 已提交
101 102
  rdoc.rdoc_files.include('actionmailer/CHANGELOG')
  rdoc.rdoc_files.include('actionmailer/lib/action_mailer/base.rb')
103
  rdoc.rdoc_files.include('actionmailer/lib/action_mailer/mail_helper.rb')
J
Jeremy Kemper 已提交
104 105
  rdoc.rdoc_files.exclude('actionmailer/lib/action_mailer/vendor/*')

106
  rdoc.rdoc_files.include('activesupport/README.rdoc')
J
Jeremy Kemper 已提交
107 108 109
  rdoc.rdoc_files.include('activesupport/CHANGELOG')
  rdoc.rdoc_files.include('activesupport/lib/active_support/**/*.rb')
  rdoc.rdoc_files.exclude('activesupport/lib/active_support/vendor/*')
X
Xavier Noria 已提交
110

111
  rdoc.rdoc_files.include('activemodel/README.rdoc')
X
Xavier Noria 已提交
112 113
  rdoc.rdoc_files.include('activemodel/CHANGELOG')
  rdoc.rdoc_files.include('activemodel/lib/active_model/**/*.rb')
J
Jeremy Kemper 已提交
114 115 116 117
end

# Enhance rdoc task to copy referenced images also
task :rdoc do
J
Jeremy Kemper 已提交
118 119
  FileUtils.mkdir_p "doc/rdoc/files/examples/"
  FileUtils.copy "activerecord/examples/associations.png", "doc/rdoc/files/examples/associations.png"
J
Jeremy Kemper 已提交
120 121
end

122
desc 'Bump all versions to match version.rb'
123
task :update_versions do
124 125 126 127 128 129
  require File.dirname(__FILE__) + "/version"

  File.open("RAILS_VERSION", "w") do |f|
    f.write Rails::VERSION::STRING + "\n"
  end

130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
  constants = {
    "activesupport"   => "ActiveSupport",
    "activemodel"     => "ActiveModel",
    "actionpack"      => "ActionPack",
    "actionmailer"    => "ActionMailer",
    "activeresource"  => "ActiveResource",
    "activerecord"    => "ActiveRecord",
    "railties"        => "Rails"
  }

  version_file = File.read("version.rb")

  PROJECTS.each do |project|
    Dir["#{project}/lib/*/version.rb"].each do |file|
      File.open(file, "w") do |f|
        f.write version_file.gsub(/Rails/, constants[project])
      end
    end
  end
end
150 151 152 153 154 155 156 157 158 159 160 161

#
# We have a webhook configured in Github that gets invoked after pushes.
# This hook triggers the following tasks:
#
#   * updates the local checkout
#   * updates Rails Contributors
#   * generates and publishes edge docs
#   * if there's a new stable tag, generates and publishes stable docs
#
# Everything is automated and you do NOT need to run this task normally.
#
S
Santiago Pastorino 已提交
162
# We publish a new version by tagging, and pushing a tag does not trigger
163 164 165 166 167 168 169 170 171 172 173
# that webhook. Stable docs would be updated by any subsequent regular
# push, but if you want that to happen right away just run this.
#
desc 'Publishes docs, run this AFTER a new stable tag has been pushed'
task :publish_docs do
  Net::HTTP.new('rails-hooks.hashref.com').start do |http|
    request  = Net::HTTP::Post.new('/rails-master-hook')
    response = http.request(request)
    puts response.body
  end
end