[前][次][番号順一覧][スレッド一覧]

ruby-changes:8017

From: jim <ko1@a...>
Date: Thu, 25 Sep 2008 16:01:25 +0900 (JST)
Subject: [ruby-changes:8017] Ruby:r19542 (trunk): updated to rake code to rake-0.8.3 source code base

jim	2008-09-25 16:01:07 +0900 (Thu, 25 Sep 2008)

  New Revision: 19542

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19542

  Log:
    updated to rake code to rake-0.8.3 source code base

  Added files:
    trunk/lib/rake/win32.rb
  Modified files:
    trunk/ChangeLog
    trunk/lib/rake.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 19541)
+++ ChangeLog	(revision 19542)
@@ -1,3 +1,11 @@
+2008-09-25  Jim Weirich  <jim@t...>
+
+	* lib/rake.rb: Update rake source to version 0.8.3.  This
+	version includes some fixes for running Rake on windows. (1)
+	better APPDATA/HOMExxx/USERPROFILE integration for system
+	rakefiles, (2) Better handling of the :ruby command when
+	installed in directory containing spaces.
+
 Thu Sep 25 11:22:51 2008
 
 	* lib/rdoc*: Update to RDoc 2.2.1 r185.
Index: lib/rake/win32.rb
===================================================================
--- lib/rake/win32.rb	(revision 0)
+++ lib/rake/win32.rb	(revision 19542)
@@ -0,0 +1,54 @@
+module Rake
+  
+  # Win 32 interface methods for Rake. Windows specific functionality
+  # will be placed here to collect that knowledge in one spot.
+  module Win32
+    
+    # Error indicating a problem in locating the home directory on a
+    # Win32 system.
+    class Win32HomeError < RuntimeError
+    end
+    
+    class << self
+      # True if running on a windows system.
+      def windows?
+        Config::CONFIG['host_os'] =~ /mswin/
+      end
+
+      # Run a command line on windows.
+      def rake_system(*cmd)
+        if cmd.size == 1
+          system("call #{cmd}")
+        else
+          system(*cmd)
+        end
+      end
+      
+      # The standard directory containing system wide rake files on
+      # Win 32 systems. Try the following environment variables (in
+      # order):
+      #
+      # * APPDATA
+      # * HOMEDRIVE + HOMEPATH
+      # * USERPROFILE
+      #
+      # If the above are not defined, the return nil.
+      def win32_system_dir #:nodoc:
+        win32_shared_path = ENV['APPDATA']
+        if win32_shared_path.nil? && ENV['HOMEDRIVE'] && ENV['HOMEPATH']
+          win32_shared_path = ENV['HOMEDRIVE'] + ENV['HOMEPATH']
+        end
+        win32_shared_path ||= ENV['USERPROFILE']
+        raise Win32HomeError, "Unable to determine home path environment variable." if
+          win32_shared_path.nil? or win32_shared_path.empty?
+        normalize(File.join(win32_shared_path, 'Rake'))
+      end
+      
+      # Normalize a win32 path so that the slashes are all forward slashes.
+      def normalize(path)
+        path.gsub(/\\/, '/')
+      end
+      
+    end
+  end
+end
Index: lib/rake.rb
===================================================================
--- lib/rake.rb	(revision 19541)
+++ lib/rake.rb	(revision 19542)
@@ -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 'optparse'
 require 'ostruct'
 
+require 'rake/win32'
+
 ######################################################################
 # Rake extensions to Module.
 #
@@ -72,7 +74,7 @@
 #
 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 @@
     # * <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 @@
     #   '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 @@
     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 @@
 # 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 @@
   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 @@
         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 @@
           $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 @@
     end
     
     def windows?
-      Config::CONFIG['host_os'] =~ /mswin/
+      Win32.windows?
     end
 
     def truncate(string, width)
@@ -2345,7 +2334,7 @@
       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 @@
 
     # 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.

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]