summaryrefslogtreecommitdiff
path: root/lib/rake.rb
diff options
context:
space:
mode:
authorjim <jim@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-25 07:01:07 +0000
committerjim <jim@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-25 07:01:07 +0000
commitea94d40f4a44bef1801faf147c469220d1259d4c (patch)
treec43876d57dc14dffd0550f18f8aea8773943f3f0 /lib/rake.rb
parentc5746c45b2f080f0ede4b69c8e94700b4ac83092 (diff)
updated to rake code to rake-0.8.3 source code base
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rake.rb')
-rwxr-xr-xlib/rake.rb81
1 files changed, 28 insertions, 53 deletions
diff --git a/lib/rake.rb b/lib/rake.rb
index caafa5c..313e169 100755
--- a/lib/rake.rb
+++ b/lib/rake.rb
@@ -29,7 +29,7 @@
# as a library via a require statement, but it can be distributed
# independently as an application.
-RAKEVERSION = '0.8.2'
+RAKEVERSION = '0.8.3'
require 'rbconfig'
require 'fileutils'
@@ -38,6 +38,8 @@ require 'monitor'
require 'optparse'
require 'ostruct'
+require 'rake/win32'
+
######################################################################
# Rake extensions to Module.
#
@@ -72,7 +74,7 @@ end # module Module
#
class String
rake_extension("ext") do
- # Replace the file extension with +newext+. If there is no extension on
+ # Replace the file extension with +newext+. If there is no extenson on
# the string, append the new extension to the end. If the new extension
# is not given, or is the empty string, remove any existing extension.
#
@@ -145,7 +147,7 @@ class String
# * <b>%x</b> -- The file extension of the path. An empty string if there
# is no extension.
# * <b>%X</b> -- Everything *but* the file extension.
- # * <b>%s</b> -- The alternate file separator if defined, otherwise use
+ # * <b>%s</b> -- The alternate file separater if defined, otherwise use
# the standard file separator.
# * <b>%%</b> -- A percent sign.
#
@@ -160,8 +162,8 @@ class String
# 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d'
#
# Also the %d, %p, $f, $n, %x, and %X operators can take a
- # pattern/replacement argument to perform simple string substitutions on a
- # particular part of the path. The pattern and replacement are separated
+ # pattern/replacement argument to perform simple string substititions on a
+ # particular part of the path. The pattern and replacement are speparated
# by a comma and are enclosed by curly braces. The replacement spec comes
# after the % character but before the operator letter. (e.g.
# "%{old,new}d"). Muliple replacement specs should be separated by
@@ -261,11 +263,6 @@ module Rake
end
end
- # Error indicating a problem in locating the home directory on a
- # Win32 system.
- class Win32HomeError < RuntimeError
- end
-
# --------------------------------------------------------------------------
# Rake module singleton methods.
#
@@ -942,7 +939,8 @@ end
# added to the FileUtils utility functions.
#
module FileUtils
- RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
+ RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).
+ sub(/.*\s.*/m, '"\&"')
OPT_TABLE['sh'] = %w(noop verbose)
OPT_TABLE['ruby'] = %w(noop verbose)
@@ -988,23 +986,14 @@ module FileUtils
end
def rake_system(*cmd)
- if Rake.application.windows?
- rake_win32_system(*cmd)
+ if Rake::Win32.windows?
+ Rake::Win32.rake_system(*cmd)
else
system(*cmd)
end
end
private :rake_system
- def rake_win32_system(*cmd)
- if cmd.size == 1
- system("call #{cmd}")
- else
- system(*cmd)
- end
- end
- private :rake_win32_system
-
# Run a Ruby interpreter with the given arguments.
#
# Example:
@@ -2047,10 +2036,10 @@ module Rake
yield
rescue SystemExit => ex
# Exit silently with current status
- raise
- rescue OptionParser::InvalidOption => ex
+ exit(ex.status)
+ rescue SystemExit, OptionParser::InvalidOption => ex
# Exit silently
- exit(false)
+ exit(1)
rescue Exception => ex
# Exit with error message
$stderr.puts "rake aborted!"
@@ -2061,7 +2050,7 @@ module Rake
$stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
$stderr.puts "(See full trace by running task with --trace)"
end
- exit(false)
+ exit(1)
end
end
@@ -2144,7 +2133,7 @@ module Rake
end
def windows?
- Config::CONFIG['host_os'] =~ /mswin/
+ Win32.windows?
end
def truncate(string, width)
@@ -2345,7 +2334,7 @@ module Rake
rakefile, location = find_rakefile_location
if (! options.ignore_system) &&
(options.load_system || rakefile.nil?) &&
- directory?(system_dir)
+ system_dir && File.directory?(system_dir)
puts "(in #{Dir.pwd})" unless options.silent
glob("#{system_dir}/*.rake") do |name|
add_import name
@@ -2374,38 +2363,24 @@ module Rake
# The directory path containing the system wide rakefiles.
def system_dir
- if ENV['RAKE_SYSTEM']
- ENV['RAKE_SYSTEM']
- elsif windows?
- win32_system_dir
- else
- standard_system_dir
- end
+ @system_dir ||=
+ begin
+ if ENV['RAKE_SYSTEM']
+ ENV['RAKE_SYSTEM']
+ elsif Win32.windows?
+ Win32.win32_system_dir
+ else
+ standard_system_dir
+ end
+ end
end
-
+
# The standard directory containing system wide rake files.
def standard_system_dir #:nodoc:
File.join(File.expand_path('~'), '.rake')
end
private :standard_system_dir
- # The standard directory containing system wide rake files on Win
- # 32 systems.
- def win32_system_dir #:nodoc:
- win32home = File.join(ENV['APPDATA'], 'Rake')
- unless directory?(win32home)
- raise Win32HomeError, "Unable to determine home path environment variable."
- else
- win32home
- end
- end
- private :win32_system_dir
-
- def directory?(path)
- File.directory?(path)
- end
- private :directory?
-
# Collect the list of tasks on the command line. If no tasks are
# given, return a list containing only the default task.
# Environmental assignments are processed at this time as well.