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

A
Aaron Patterson 已提交
3
require 'rdoc/task'
4
require 'net/http'
5

6 7 8 9 10 11 12
$:.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 已提交
13
task :release => "all:release"
14

C
Carlhuda 已提交
15
PROJECTS = %w(activesupport activemodel actionpack actionmailer activeresource activerecord railties)
16 17

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

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

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

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

J
Jeremy Kemper 已提交
50
desc "Generate documentation for the Rails framework"
A
Aaron Patterson 已提交
51
RDoc::Task.new do |rdoc|
52 53 54 55 56 57 58 59 60 61 62 63
  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 已提交
64 65
  rdoc.rdoc_dir = 'doc/rdoc'
  rdoc.title    = "Ruby on Rails Documentation"
J
Jeremy Kemper 已提交
66

A
Aaron Patterson 已提交
67
  rdoc.options << '-f' << 'horo'
68
  rdoc.options << '-c' << 'utf-8'
69
  rdoc.options << '-m' << RDOC_MAIN
J
Jeremy Kemper 已提交
70 71 72

  rdoc.rdoc_files.include('railties/CHANGELOG')
  rdoc.rdoc_files.include('railties/MIT-LICENSE')
73
  rdoc.rdoc_files.include('railties/README.rdoc')
74 75
  rdoc.rdoc_files.include('railties/lib/**/*.rb')
  rdoc.rdoc_files.exclude('railties/lib/rails/generators/**/templates/*')
J
Jeremy Kemper 已提交
76

77
  rdoc.rdoc_files.include('activerecord/README.rdoc')
J
Jeremy Kemper 已提交
78 79 80 81
  rdoc.rdoc_files.include('activerecord/CHANGELOG')
  rdoc.rdoc_files.include('activerecord/lib/active_record/**/*.rb')
  rdoc.rdoc_files.exclude('activerecord/lib/active_record/vendor/*')

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

87
  rdoc.rdoc_files.include('actionpack/README.rdoc')
J
Jeremy Kemper 已提交
88
  rdoc.rdoc_files.include('actionpack/CHANGELOG')
89
  rdoc.rdoc_files.include('actionpack/lib/abstract_controller/**/*.rb')
J
Jeremy Kemper 已提交
90
  rdoc.rdoc_files.include('actionpack/lib/action_controller/**/*.rb')
91
  rdoc.rdoc_files.include('actionpack/lib/action_dispatch/**/*.rb')
J
Jeremy Kemper 已提交
92 93 94
  rdoc.rdoc_files.include('actionpack/lib/action_view/**/*.rb')
  rdoc.rdoc_files.exclude('actionpack/lib/action_controller/vendor/*')

95
  rdoc.rdoc_files.include('actionmailer/README.rdoc')
J
Jeremy Kemper 已提交
96 97
  rdoc.rdoc_files.include('actionmailer/CHANGELOG')
  rdoc.rdoc_files.include('actionmailer/lib/action_mailer/base.rb')
98
  rdoc.rdoc_files.include('actionmailer/lib/action_mailer/mail_helper.rb')
J
Jeremy Kemper 已提交
99 100
  rdoc.rdoc_files.exclude('actionmailer/lib/action_mailer/vendor/*')

101
  rdoc.rdoc_files.include('activesupport/README.rdoc')
J
Jeremy Kemper 已提交
102 103 104
  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 已提交
105

106
  rdoc.rdoc_files.include('activemodel/README.rdoc')
X
Xavier Noria 已提交
107 108
  rdoc.rdoc_files.include('activemodel/CHANGELOG')
  rdoc.rdoc_files.include('activemodel/lib/active_model/**/*.rb')
J
Jeremy Kemper 已提交
109 110 111 112
end

# Enhance rdoc task to copy referenced images also
task :rdoc do
J
Jeremy Kemper 已提交
113 114
  FileUtils.mkdir_p "doc/rdoc/files/examples/"
  FileUtils.copy "activerecord/examples/associations.png", "doc/rdoc/files/examples/associations.png"
J
Jeremy Kemper 已提交
115 116
end

117
desc 'Bump all versions to match version.rb'
118
task :update_versions do
119 120 121 122 123 124
  require File.dirname(__FILE__) + "/version"

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

125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
  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
145 146 147 148 149 150 151 152 153 154 155 156

#
# 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 已提交
157
# We publish a new version by tagging, and pushing a tag does not trigger
158 159 160 161 162 163 164 165 166 167 168
# 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