Rakefile in rake-0.8.7 vs Rakefile in rake-0.9.0.beta.0
- old
+ new
@@ -4,21 +4,32 @@
# All rights reserved.
# This file may be distributed under an MIT style license. See
# MIT-LICENSE for details.
-begin
- require 'rubygems'
- require 'rake/gempackagetask'
-rescue Exception
- nil
+require 'rbconfig'
+require 'rubygems'
+
+system_rake = File.join RbConfig::CONFIG['rubylibdir'], 'rake.rb'
+
+# Use our rake, not the installed rake from system
+if $".include? system_rake then
+ exec Gem.ruby, '-Ilib', 'bin/rake', *ARGV
end
+
+require 'rubygems/package_task'
+
require 'rake/clean'
require 'rake/testtask'
-require 'rake/rdoctask'
-CLEAN.include('**/*.o', '*.dot', '**/.*.rbc')
+begin
+ gem 'rdoc'
+ require 'rdoc/task'
+rescue Gem::LoadError
+end
+
+CLEAN.include('**/*.o', '*.dot', '**/*.rbc')
CLOBBER.include('doc/example/main', 'testdata')
CLOBBER.include('test/data/**/temp_*')
CLOBBER.include('test/data/chains/play.*')
CLOBBER.include('test/data/file_creation_task/build')
CLOBBER.include('test/data/file_creation_task/src')
@@ -32,11 +43,11 @@
STDERR.puts msg
end
# Determine the current version of the software
-if `ruby -Ilib ./bin/rake --version` =~ /rake, version ([0-9.]+)$/
+if `ruby -Ilib ./bin/rake --version` =~ /rake, version ([0-9a-z.]+)$/
CURRENT_VERSION = $1
else
CURRENT_VERSION = "0.0.0"
end
@@ -45,77 +56,84 @@
SRC_RB = FileList['lib/**/*.rb']
# The default task is run if rake is given no explicit arguments.
desc "Default Task"
-task :default => :test_all
+task :default => "test:all"
# Test Tasks ---------------------------------------------------------
-task :dbg do |t|
- puts "Arguments are: #{t.args.join(', ')}"
-end
# Common Abbreviations ...
-task :ta => :test_all
-task :tf => :test_functional
-task :tu => :test_units
-task :tc => :test_contribs
-task :test => :test_units
+task :ta => "test:all"
+task :tf => "test:functional"
+task :tu => "test:units"
+task :tc => "test:contribs"
+task :test => "test:units"
-Rake::TestTask.new(:test_all) do |t|
- t.test_files = FileList[
- 'test/test*.rb',
- 'test/contrib/test*.rb',
- 'test/fun*.rb'
- ]
- t.warning = true
- t.verbose = false
+module TestFiles
+ UNIT = FileList['test/lib/*_test.rb']
+ FUNCTIONAL = FileList['test/functional/*_test.rb']
+ CONTRIB = FileList['test/contrib/test*.rb']
+ TOP = FileList['test/*_test.rb']
+ ALL = TOP + UNIT + FUNCTIONAL + CONTRIB
end
-Rake::TestTask.new(:test_units) do |t|
- t.test_files = FileList['test/test*.rb']
- t.warning = true
- t.verbose = false
-end
+namespace :test do
+ Rake::TestTask.new(:all) do |t|
+ t.test_files = TestFiles::ALL
+ t.libs << "."
+ t.warning = true
+ end
-Rake::TestTask.new(:test_functional) do |t|
- t.test_files = FileList['test/fun*.rb']
- t.warning = true
- t.verbose = false
-end
+ Rake::TestTask.new(:units) do |t|
+ t.test_files = TestFiles::UNIT
+ t.libs << "."
+ t.warning = true
+ end
-Rake::TestTask.new(:test_contribs) do |t|
- t.test_files = FileList['test/contrib/test*.rb']
- t.warning = true
- t.verbose = false
+ Rake::TestTask.new(:functional) do |t|
+ t.test_files = TestFiles::FUNCTIONAL
+ t.libs << "."
+ t.warning = true
+ end
+
+ Rake::TestTask.new(:contribs) do |t|
+ t.test_files = TestFiles::CONTRIB
+ t.libs << "."
+ t.warning = true
+ end
end
begin
require 'rcov/rcovtask'
Rcov::RcovTask.new do |t|
t.libs << "test"
- dot_rakes =
+ dot_rakes =
t.rcov_opts = [
'-xRakefile', '-xrakefile', '-xpublish.rf',
- '-xlib/rake/contrib', '-x/Library',
+ '-xlib/rake/contrib', '-x/Library',
'--text-report',
'--sort coverage'
] + FileList['rakelib/*.rake'].pathmap("-x%p")
t.test_files = FileList[
- 'test/test*.rb', 'test/functional.rb'
+ 'test/lib/*_test.rb',
+ 'test/contrib/*_test.rb',
+ 'test/functional/*_test.rb'
]
t.output_dir = 'coverage'
t.verbose = true
end
rescue LoadError
- puts "RCov is not available"
+ task :rcov do
+ puts "RCov is not available"
+ end
end
directory 'testdata'
-[:test_all, :test_units, :test_contribs, :test_functional].each do |t|
+["test:all", :test_units, :test_contribs, :test_functional].each do |t|
task t => ['testdata']
end
# CVS Tasks ----------------------------------------------------------
@@ -126,44 +144,40 @@
ruby "install.rb"
end
# Create a task to build the RDOC documentation tree.
-begin
- require 'darkfish-rdoc'
- DARKFISH_ENABLED = true
-rescue LoadError => ex
- DARKFISH_ENABLED = false
-end
-
BASE_RDOC_OPTIONS = [
- '--line-numbers',
- '--main', 'README',
- '--title', 'Rake -- Ruby Make',
+ '--line-numbers', '--show-hash',
+ '--main', 'README.rdoc',
+ '--title', 'Rake -- Ruby Make'
]
-rd = Rake::RDocTask.new("rdoc") do |rdoc|
- rdoc.rdoc_dir = 'html'
- rdoc.template = 'doc/jamis.rb'
- rdoc.title = "Rake -- Ruby Make"
- rdoc.options = BASE_RDOC_OPTIONS.dup
- rdoc.options << '-SHN' << '-f' << 'darkfish' if DARKFISH_ENABLED
-
- rdoc.rdoc_files.include('README', 'MIT-LICENSE', 'TODO', 'CHANGES')
- rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
- rdoc.rdoc_files.exclude(/\bcontrib\b/)
+if defined?(RDoc::Task) then
+ RDoc::Task.new do |rdoc|
+ rdoc.rdoc_dir = 'html'
+ rdoc.title = "Rake -- Ruby Make"
+ rdoc.options = BASE_RDOC_OPTIONS.dup
+
+ rdoc.rdoc_files.include('README.rdoc', 'MIT-LICENSE', 'TODO', 'CHANGES')
+ rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
+ rdoc.rdoc_files.exclude(/\bcontrib\b/)
+ end
+else
+ warn "RDoc 2.4.2+ is required to build documentation"
end
# ====================================================================
# Create a task that will package the Rake software into distributable
# tar, zip and gem files.
PKG_FILES = FileList[
+ '.gemtest',
'install.rb',
'[A-Z]*',
- 'bin/**/*',
- 'lib/**/*.rb',
+ 'bin/**/*',
+ 'lib/**/*.rb',
'test/**/*.rb',
'test/**/*.rf',
'test/**/*.mf',
'test/**/Rakefile',
'test/**/subdir',
@@ -175,25 +189,26 @@
if ! defined?(Gem)
puts "Package Target requires RubyGEMs"
else
SPEC = Gem::Specification.new do |s|
-
+
#### Basic information.
s.name = 'rake'
s.version = $package_version
s.summary = "Ruby based make-like utility."
s.description = <<-EOF
Rake is a Make-like program implemented in Ruby. Tasks
- and dependencies are specified in standard Ruby syntax.
+ and dependencies are specified in standard Ruby syntax.
EOF
#### Dependencies and requirements.
- #s.add_dependency('log4r', '> 1.0.4')
- #s.requirements << ""
+ s.required_rubygems_version = '>= 1.3.2'
+ s.add_development_dependency 'session', '~> 2.4'
+ s.add_development_dependency 'flexmock', '~> 0.8.11'
#### Which files are to be included in this gem? Everything! (Except CVS directories.)
s.files = PKG_FILES.to_a
@@ -209,12 +224,18 @@
s.executables = ["rake"]
s.default_executable = "rake"
#### Documentation and testing.
- s.has_rdoc = true
- s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
+ s.extra_rdoc_files = FileList[
+ 'README.rdoc',
+ 'MIT-LICENSE',
+ 'TODO',
+ 'CHANGES',
+ 'doc/**/*.rdoc'
+ ]
+
s.rdoc_options = BASE_RDOC_OPTIONS
#### Author and project details.
s.author = "Jim Weirich"
@@ -225,11 +246,11 @@
# s.signing_key = File.join(ENV['CERT_DIR'], 'gem-private_key.pem')
# s.cert_chain = [File.join(ENV['CERT_DIR'], 'gem-public_cert.pem')]
# end
end
- package_task = Rake::GemPackageTask.new(SPEC) do |pkg|
+ package_task = Gem::PackageTask.new(SPEC) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
end
file "rake.gemspec" => ["Rakefile", "lib/rake.rb"] do |t|
@@ -287,32 +308,17 @@
desc "Look for TODO and FIXME tags in the code"
task :todo do
RUBY_FILES.egrep(/#.*(FIXME|TODO|TBD)/)
end
-desc "Look for Debugging print lines"
-task :dbg do
- RUBY_FILES.egrep(/\bDBG|\bbreakpoint\b/)
-end
-
desc "List all ruby files"
-task :rubyfiles do
+task :rubyfiles do
puts RUBY_FILES
puts FileList['bin/*'].exclude('bin/*.rb')
end
task :rf => :rubyfiles
-desc "Create a TAGS file"
-task :tags => "TAGS"
-
-TAGS = 'xctags -e'
-
-file "TAGS" => RUBY_FILES do
- puts "Makings TAGS"
- sh "#{TAGS} #{RUBY_FILES}", :verbose => false
-end
-
# --------------------------------------------------------------------
# Creating a release
def plugin(plugin_name)
require "rake/plugins/#{plugin_name}"
@@ -324,32 +330,32 @@
desc "Make a new release"
task :release, :rel, :reuse, :reltest,
:needs => [
:prerelease,
:clobber,
- :test_all,
+ "test:all",
:update_version,
:package,
:tag
] do
- announce
+ announce
announce "**************************************************************"
announce "* Release #{$package_version} Complete."
announce "* Packages ready to upload."
announce "**************************************************************"
- announce
+ announce
end
# Validate that everything is ready to go for a release.
task :prerelease, :rel, :reuse, :reltest do |t, args|
$package_version = args.rel
- announce
+ announce
announce "**************************************************************"
announce "* Making RubyGem Release #{$package_version}"
announce "* (current version #{CURRENT_VERSION})"
announce "**************************************************************"
- announce
+ announce
# Is a release number supplied?
unless args.rel
fail "Usage: rake release[X.Y.Z] [REUSE=tag_suffix]"
end
@@ -379,17 +385,17 @@
announce "No version change ... skipping version update"
else
announce "Updating Rake version to #{args.rel}"
open("lib/rake.rb") do |rakein|
open("lib/rake.rb.new", "w") do |rakeout|
- rakein.each do |line|
- if line =~ /^RAKEVERSION\s*=\s*/
- rakeout.puts "RAKEVERSION = '#{args.rel}'"
- else
- rakeout.puts line
- end
- end
+ rakein.each do |line|
+ if line =~ /^RAKEVERSION\s*=\s*/
+ rakeout.puts "RAKEVERSION = '#{args.rel}'"
+ else
+ rakeout.puts line
+ end
+ end
end
end
mv "lib/rake.rb.new", "lib/rake.rb"
if args.reltest
announce "Release Task Testing, skipping commiting of new version"
@@ -410,21 +416,18 @@
else
sh %{svn copy svn+ssh://rubyforge.org/var/svn/rake/trunk svn+ssh://rubyforge.org/var/svn/rake/tags/#{reltag} -m 'Commiting release #{reltag}'} ###'
end
end
-desc "Install the jamis RDoc template"
-task :install_jamis_template do
- require 'rbconfig'
- dest_dir = File.join(Config::CONFIG['rubylibdir'], "rdoc/generators/template/html")
- fail "Unabled to write to #{dest_dir}" unless File.writable?(dest_dir)
- install "doc/jamis.rb", dest_dir, :verbose => true
-end
-
# Require experimental XForge/Metaproject support.
load 'xforge.rf' if File.exist?('xforge.rf')
desc "Where is the current directory. This task displays\nthe current rake directory"
task :where_am_i do
puts Rake.original_dir
+end
+
+task :failure => :really_fail
+task :really_fail do
+ fail "oops"
end