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

ruby-changes:20169

From: drbrain <ko1@a...>
Date: Fri, 24 Jun 2011 07:12:35 +0900 (JST)
Subject: [ruby-changes:20169] drbrain:r32217 (trunk): * lib/rake: Import Rake 0.9.2

drbrain	2011-06-24 07:11:55 +0900 (Fri, 24 Jun 2011)

  New Revision: 32217

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

  Log:
    * lib/rake: Import Rake 0.9.2

  Added directories:
    trunk/lib/rake/ext/
    trunk/lib/rake/lib/
  Added files:
    trunk/lib/rake/alt_system.rb
    trunk/lib/rake/application.rb
    trunk/lib/rake/cloneable.rb
    trunk/lib/rake/contrib/sys.rb
    trunk/lib/rake/default_loader.rb
    trunk/lib/rake/dsl_definition.rb
    trunk/lib/rake/early_time.rb
    trunk/lib/rake/ext/core.rb
    trunk/lib/rake/ext/module.rb
    trunk/lib/rake/ext/string.rb
    trunk/lib/rake/ext/time.rb
    trunk/lib/rake/file_creation_task.rb
    trunk/lib/rake/file_list.rb
    trunk/lib/rake/file_task.rb
    trunk/lib/rake/file_utils.rb
    trunk/lib/rake/file_utils_ext.rb
    trunk/lib/rake/invocation_chain.rb
    trunk/lib/rake/invocation_exception_mixin.rb
    trunk/lib/rake/lib/project.rake
    trunk/lib/rake/multi_task.rb
    trunk/lib/rake/name_space.rb
    trunk/lib/rake/pathmap.rb
    trunk/lib/rake/pseudo_status.rb
    trunk/lib/rake/rake_module.rb
    trunk/lib/rake/ruby182_test_unit_fix.rb
    trunk/lib/rake/rule_recursion_overflow_error.rb
    trunk/lib/rake/task.rb
    trunk/lib/rake/task_argument_error.rb
    trunk/lib/rake/task_arguments.rb
    trunk/lib/rake/task_manager.rb
    trunk/lib/rake/version.rb
    trunk/test/rake/file_creation.rb
    trunk/test/rake/helper.rb
    trunk/test/rake/test_rake_application.rb
    trunk/test/rake/test_rake_application_options.rb
    trunk/test/rake/test_rake_clean.rb
    trunk/test/rake/test_rake_definitions.rb
    trunk/test/rake/test_rake_directory_task.rb
    trunk/test/rake/test_rake_dsl.rb
    trunk/test/rake/test_rake_early_time.rb
    trunk/test/rake/test_rake_extension.rb
    trunk/test/rake/test_rake_file_creation_task.rb
    trunk/test/rake/test_rake_file_list.rb
    trunk/test/rake/test_rake_file_list_path_map.rb
    trunk/test/rake/test_rake_file_task.rb
    trunk/test/rake/test_rake_file_utils.rb
    trunk/test/rake/test_rake_ftp_file.rb
    trunk/test/rake/test_rake_functional.rb
    trunk/test/rake/test_rake_invocation_chain.rb
    trunk/test/rake/test_rake_makefile_loader.rb
    trunk/test/rake/test_rake_multi_task.rb
    trunk/test/rake/test_rake_name_space.rb
    trunk/test/rake/test_rake_package_task.rb
    trunk/test/rake/test_rake_path_map.rb
    trunk/test/rake/test_rake_path_map_explode.rb
    trunk/test/rake/test_rake_path_map_partial.rb
    trunk/test/rake/test_rake_pseudo_status.rb
    trunk/test/rake/test_rake_rdoc_task.rb
    trunk/test/rake/test_rake_require.rb
    trunk/test/rake/test_rake_rules.rb
    trunk/test/rake/test_rake_task.rb
    trunk/test/rake/test_rake_task_argument_parsing.rb
    trunk/test/rake/test_rake_task_arguments.rb
    trunk/test/rake/test_rake_task_lib.rb
    trunk/test/rake/test_rake_task_manager.rb
    trunk/test/rake/test_rake_task_manager_argument_resolution.rb
    trunk/test/rake/test_rake_task_with_arguments.rb
    trunk/test/rake/test_rake_test_task.rb
    trunk/test/rake/test_rake_top_level_functions.rb
    trunk/test/rake/test_rake_win32.rb
    trunk/test/rake/test_sys.rb
  Removed files:
    trunk/test/rake/capture_stdout.rb
    trunk/test/rake/check_expansion.rb
    trunk/test/rake/check_no_expansion.rb
    trunk/test/rake/contrib/test_ftp.rb
    trunk/test/rake/data/chains/Rakefile
    trunk/test/rake/data/default/Rakefile
    trunk/test/rake/data/dryrun/Rakefile
    trunk/test/rake/data/file_creation_task/Rakefile
    trunk/test/rake/data/imports/Rakefile
    trunk/test/rake/data/imports/deps.mf
    trunk/test/rake/data/multidesc/Rakefile
    trunk/test/rake/data/namespace/Rakefile
    trunk/test/rake/data/rakelib/test1.rake
    trunk/test/rake/data/rbext/rakefile.rb
    trunk/test/rake/data/sample.mf
    trunk/test/rake/data/statusreturn/Rakefile
    trunk/test/rake/data/unittest/Rakefile
    trunk/test/rake/data/unittest/subdir/.gitignore
    trunk/test/rake/filecreation.rb
    trunk/test/rake/in_environment.rb
    trunk/test/rake/rake_test_setup.rb
    trunk/test/rake/reqfile.rb
    trunk/test/rake/reqfile2.rb
    trunk/test/rake/reqfile3.rb
    trunk/test/rake/shellcommand.rb
    trunk/test/rake/test_application.rb
    trunk/test/rake/test_clean.rb
    trunk/test/rake/test_definitions.rb
    trunk/test/rake/test_earlytime.rb
    trunk/test/rake/test_extension.rb
    trunk/test/rake/test_file_creation_task.rb
    trunk/test/rake/test_file_task.rb
    trunk/test/rake/test_filelist.rb
    trunk/test/rake/test_fileutils.rb
    trunk/test/rake/test_invocation_chain.rb
    trunk/test/rake/test_makefile_loader.rb
    trunk/test/rake/test_multitask.rb
    trunk/test/rake/test_namespace.rb
    trunk/test/rake/test_package_task.rb
    trunk/test/rake/test_pathmap.rb
    trunk/test/rake/test_pseudo_status.rb
    trunk/test/rake/test_require.rb
    trunk/test/rake/test_rules.rb
    trunk/test/rake/test_task_arguments.rb
    trunk/test/rake/test_task_manager.rb
    trunk/test/rake/test_tasklib.rb
    trunk/test/rake/test_tasks.rb
    trunk/test/rake/test_test_task.rb
    trunk/test/rake/test_top_level_functions.rb
    trunk/test/rake/test_win32.rb
  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/lib/rake/classic_namespace.rb
    trunk/lib/rake/contrib/compositepublisher.rb
    trunk/lib/rake/contrib/ftptools.rb
    trunk/lib/rake/contrib/publisher.rb
    trunk/lib/rake/contrib/sshpublisher.rb
    trunk/lib/rake/gempackagetask.rb
    trunk/lib/rake/loaders/makefile.rb
    trunk/lib/rake/packagetask.rb
    trunk/lib/rake/rake_test_loader.rb
    trunk/lib/rake/rdoctask.rb
    trunk/lib/rake/runtest.rb
    trunk/lib/rake/tasklib.rb
    trunk/lib/rake/testtask.rb
    trunk/lib/rake/win32.rb
    trunk/lib/rake.rb
    trunk/test/rake/test_rake.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 32216)
+++ ChangeLog	(revision 32217)
@@ -1,3 +1,7 @@
+Fri Jun 24 07:11:37 2011  Eric Hodel  <drbrain@s...>
+
+	* lib/rake: Import Rake 0.9.2
+
 Fri Jun 24 00:44:15 2011  Tadayoshi Funaba  <tadf@d...>
 
 	* ext/date/date_core.c (c_valid_{julian,gregorian}_p): fixed the range of month.
Index: lib/rake/loaders/makefile.rb
===================================================================
--- lib/rake/loaders/makefile.rb	(revision 32216)
+++ lib/rake/loaders/makefile.rb	(revision 32217)
@@ -2,11 +2,13 @@
 
   # Makefile loader to be used with the import file loader.
   class MakefileLoader
+    include Rake::DSL
+
     SPACE_MARK = "\0"
 
     # Load the makefile dependencies in +fn+.
     def load(fn)
-      lines = open(fn) {|mf| mf.read}
+      lines = File.read fn
       lines.gsub!(/\\ /, SPACE_MARK)
       lines.gsub!(/#[^\n]*\n/m, "")
       lines.gsub!(/\\\n/, ' ')
@@ -21,7 +23,7 @@
     def process_line(line)
       file_tasks, args = line.split(':', 2)
       return if args.nil?
-      dependents = args.split.map {|arg| respace(arg)}
+      dependents = args.split.map { |d| respace(d) }
       file_tasks.scan(/\S+/) do |file_task|
         file_task = respace(file_task)
         file file_task => dependents
@@ -29,7 +31,7 @@
     end
 
     def respace(str)
-      str.tr(SPACE_MARK, ' ')
+      str.tr SPACE_MARK, ' '
     end
   end
 
Index: lib/rake/tasklib.rb
===================================================================
--- lib/rake/tasklib.rb	(revision 32216)
+++ lib/rake/tasklib.rb	(revision 32217)
@@ -5,6 +5,7 @@
   # Base class for Task Libraries.
   class TaskLib
     include Cloneable
+    include Rake::DSL
 
     # Make a symbol by pasting two strings together.
     #
Index: lib/rake/pathmap.rb
===================================================================
--- lib/rake/pathmap.rb	(revision 0)
+++ lib/rake/pathmap.rb	(revision 32217)
@@ -0,0 +1 @@
+require 'rake/ext/string'

Property changes on: lib/rake/pathmap.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: lib/rake/dsl_definition.rb
===================================================================
--- lib/rake/dsl_definition.rb	(revision 0)
+++ lib/rake/dsl_definition.rb	(revision 32217)
@@ -0,0 +1,167 @@
+# Rake DSL functions.
+require 'rake/file_utils_ext'
+
+module Rake
+  module DSL
+
+    # Include the FileUtils file manipulation functions in the top
+    # level module, but mark them private so that they don't
+    # unintentionally define methods on other objects.
+
+    include FileUtilsExt
+    private(*FileUtils.instance_methods(false))
+    private(*FileUtilsExt.instance_methods(false))
+
+    private
+
+    # Declare a basic task.
+    #
+    # Example:
+    #   task :clobber => [:clean] do
+    #     rm_rf "html"
+    #   end
+    #
+    def task(*args, &block)
+      Rake::Task.define_task(*args, &block)
+    end
+
+
+    # Declare a file task.
+    #
+    # Example:
+    #   file "config.cfg" => ["config.template"] do
+    #     open("config.cfg", "w") do |outfile|
+    #       open("config.template") do |infile|
+    #         while line = infile.gets
+    #           outfile.puts line
+    #         end
+    #       end
+    #     end
+    #  end
+    #
+    def file(*args, &block)
+      Rake::FileTask.define_task(*args, &block)
+    end
+
+    # Declare a file creation task.
+    # (Mainly used for the directory command).
+    def file_create(args, &block)
+      Rake::FileCreationTask.define_task(args, &block)
+    end
+
+    # Declare a set of files tasks to create the given directories on
+    # demand.
+    #
+    # Example:
+    #   directory "testdata/doc"
+    #
+    def directory(dir)
+      Rake.each_dir_parent(dir) do |d|
+        file_create d do |t|
+          mkdir_p t.name if ! File.exist?(t.name)
+        end
+      end
+    end
+
+    # Declare a task that performs its prerequisites in
+    # parallel. Multitasks does *not* guarantee that its prerequisites
+    # will execute in any given order (which is obvious when you think
+    # about it)
+    #
+    # Example:
+    #   multitask :deploy => [:deploy_gem, :deploy_rdoc]
+    #
+    def multitask(args, &block)
+      Rake::MultiTask.define_task(args, &block)
+    end
+
+    # Create a new rake namespace and use it for evaluating the given
+    # block.  Returns a NameSpace object that can be used to lookup
+    # tasks defined in the namespace.
+    #
+    # E.g.
+    #
+    #   ns = namespace "nested" do
+    #     task :run
+    #   end
+    #   task_run = ns[:run] # find :run in the given namespace.
+    #
+    def namespace(name=nil, &block)
+      name = name.to_s if name.kind_of?(Symbol)
+      name = name.to_str if name.respond_to?(:to_str)
+      unless name.kind_of?(String) || name.nil?
+        raise ArgumentError, "Expected a String or Symbol for a namespace name"
+      end
+      Rake.application.in_namespace(name, &block)
+    end
+
+    # Declare a rule for auto-tasks.
+    #
+    # Example:
+    #  rule '.o' => '.c' do |t|
+    #    sh %{cc -o #{t.name} #{t.source}}
+    #  end
+    #
+    def rule(*args, &block)
+      Rake::Task.create_rule(*args, &block)
+    end
+
+    # Describe the next rake task.
+    #
+    # Example:
+    #   desc "Run the Unit Tests"
+    #   task :test => [:build]
+    #     runtests
+    #   end
+    #
+    def desc(description)
+      Rake.application.last_description = description
+    end
+
+    # Import the partial Rakefiles +fn+.  Imported files are loaded
+    # _after_ the current file is completely loaded.  This allows the
+    # import statement to appear anywhere in the importing file, and yet
+    # allowing the imported files to depend on objects defined in the
+    # importing file.
+    #
+    # A common use of the import statement is to include files
+    # containing dependency declarations.
+    #
+    # See also the --rakelibdir command line option.
+    #
+    # Example:
+    #   import ".depend", "my_rules"
+    #
+    def import(*fns)
+      fns.each do |fn|
+        Rake.application.add_import(fn)
+      end
+    end
+  end
+
+  module DeprecatedObjectDSL
+    Commands = Object.new.extend DSL
+    DSL.private_instance_methods(false).each do |name|
+      line = __LINE__+1
+      class_eval %{
+        def #{name}(*args, &block)
+          unless Rake.application.options.ignore_deprecate
+            unless @rake_dsl_warning
+              $stderr.puts "WARNING: Global access to Rake DSL methods is deprecated.  Please include"
+              $stderr.puts "    ...  Rake::DSL into classes and modules which use the Rake DSL methods."
+              @rake_dsl_warning = true
+            end
+            $stderr.puts "WARNING: DSL method \#{self.class}##{name} called at \#{caller.first}"
+          end
+          Rake::DeprecatedObjectDSL::Commands.send(:#{name}, *args, &block)
+          end
+        private :#{name}
+      }, __FILE__, line
+    end
+  end
+
+  extend FileUtilsExt
+end
+
+self.extend Rake::DSL
+include Rake::DeprecatedObjectDSL

Property changes on: lib/rake/dsl_definition.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: lib/rake/invocation_exception_mixin.rb
===================================================================
--- lib/rake/invocation_exception_mixin.rb	(revision 0)
+++ lib/rake/invocation_exception_mixin.rb	(revision 32217)
@@ -0,0 +1,16 @@
+module Rake
+  module InvocationExceptionMixin
+    # Return the invocation chain (list of Rake tasks) that were in
+    # effect when this exception was detected by rake.  May be null if
+    # no tasks were active.
+    def chain
+      @rake_invocation_chain ||= nil
+    end
+
+    # Set the invocation chain in effect when this exception was
+    # detected.
+    def chain=(value)
+      @rake_invocation_chain = value
+    end
+  end
+end

Property changes on: lib/rake/invocation_exception_mixin.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: lib/rake/rule_recursion_overflow_error.rb
===================================================================
--- lib/rake/rule_recursion_overflow_error.rb	(revision 0)
+++ lib/rake/rule_recursion_overflow_error.rb	(revision 32217)
@@ -0,0 +1,20 @@
+
+module Rake
+
+  # Error indicating a recursion overflow error in task selection.
+  class RuleRecursionOverflowError < StandardError
+    def initialize(*args)
+      super
+      @targets = []
+    end
+
+    def add_target(target)
+      @targets << target
+    end
+
+    def message
+      super + ": [" + @targets.reverse.join(' => ') + "]"
+    end
+  end
+
+end

Property changes on: lib/rake/rule_recursion_overflow_error.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: lib/rake/ext/time.rb
===================================================================
--- lib/rake/ext/time.rb	(revision 0)
+++ lib/rake/ext/time.rb	(revision 32217)
@@ -0,0 +1,14 @@
+# ###########################################################################
+# Extensions to time to allow comparisons with an early time class.
+#
+class Time
+  alias rake_original_time_compare :<=>
+  def <=>(other)
+    if Rake::EarlyTime === other
+      - other.<=>(self)
+    else
+      rake_original_time_compare(other)
+    end
+  end
+end # class Time
+

Property changes on: lib/rake/ext/time.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: lib/rake/ext/module.rb
===================================================================
--- lib/rake/ext/module.rb	(revision 0)
+++ lib/rake/ext/module.rb	(revision 32217)
@@ -0,0 +1,39 @@
+require 'rake/ext/core'
+require 'rake/task'
+require 'rake/file_task'
+require 'rake/file_creation_task'
+require 'rake/application'
+require 'rake/task_manager'
+
+######################################################################
+# Rake extensions to Module.
+#
+class Module
+
+  # Rename the original handler to make it available.
+  alias :rake_original_const_missing :const_missing
+
+  # Check for deprecated uses of top level (i.e. in Object) uses of
+  # Rake class names.  If someone tries to reference the constant
+  # name, display a warning and return the proper object.  Using the
+  # --classic-namespace command line option will define these
+  # constants in Object and avoid this handler.
+  def const_missing(const_name)
+    case const_name
+    when :Task
+      Rake.application.const_warning(const_name)
+      Rake::Task
+    when :FileTask
+      Rake.application.const_warning(const_name)
+      Rake::FileTask
+    when :FileCreationTask
+      Rake.application.const_warning(const_name)
+      Rake::FileCreationTask
+    when :RakeApp
+      Rake.application.const_warning(const_name)
+      Rake::Application
+    else
+      rake_original_const_missing(const_name)
+    end
+  end
+end

Property changes on: lib/rake/ext/module.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: lib/rake/ext/string.rb
===================================================================
--- lib/rake/ext/string.rb	(revision 0)
+++ lib/rake/ext/string.rb	(revision 32217)
@@ -0,0 +1,167 @@
+require 'rake/ext/core'
+
+######################################################################
+# Rake extension methods for String.
+#
+class String
+  rake_extension("ext") do
+    # Replace the file extension with +newext+.  If there is no extension 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.
+    #
+    # +ext+ is a user added method for the String class.
+    def ext(newext='')
+      return self.dup if ['.', '..'].include? self
+      if newext != ''
+        newext = (newext =~ /^\./) ? newext : ("." + newext)
+      end
+      self.chomp(File.extname(self)) << newext
+    end
+  end
+
+  rake_extension("pathmap") do
+    # Explode a path into individual components.  Used by +pathmap+.
+    def pathmap_explode
+      head, tail = File.split(self)
+      return [self] if head == self
+      return [tail] if head == '.' || tail == '/'
+      return [head, tail] if head == '/'
+      return head.pathmap_explode + [tail]
+    end
+    protected :pathmap_explode
+
+    # Extract a partial path from the path.  Include +n+ directories from the
+    # front end (left hand side) if +n+ is positive.  Include |+n+|
+    # directories from the back end (right hand side) if +n+ is negative.
+    def pathmap_partial(n)
+      dirs = File.dirname(self).pathmap_explode
+      partial_dirs =
+        if n > 0
+          dirs[0...n]
+        elsif n < 0
+          dirs.reverse[0...-n].reverse
+        else
+          "."
+        end
+      File.join(partial_dirs)
+    end
+    protected :pathmap_partial
+
+    # Preform the pathmap replacement operations on the given path. The
+    # patterns take the form 'pat1,rep1;pat2,rep2...'.
+    def pathmap_replace(patterns, &block)
+      result = self
+      patterns.split(';').each do |pair|
+        pattern, replacement = pair.split(',')
+        pattern = Regexp.new(pattern)
+        if replacement == '*' && block_given?
+          result = result.sub(pattern, &block)
+        elsif replacement
+          result = result.sub(pattern, replacement)
+        else
+          result = result.sub(pattern, '')
+        end
+      end
+      result
+    end
+    protected :pathmap_replace
+
+    # Map the path according to the given specification.  The specification
+    # controls the details of the mapping.  The following special patterns are
+    # recognized:
+    #
+    # * <b>%p</b> -- The complete path.
+    # * <b>%f</b> -- The base file name of the path, with its file extension,
+    #   but without any directories.
+    # * <b>%n</b> -- The file name of the path without its file extension.
+    # * <b>%d</b> -- The directory list of the path.
+    # * <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
+    #   the standard file separator.
+    # * <b>%%</b> -- A percent sign.
+    #
+    # The %d specifier can also have a numeric prefix (e.g. '%2d'). If the
+    # number is positive, only return (up to) +n+ directories in the path,
+    # starting from the left hand side.  If +n+ is negative, return (up to)
+    # |+n+| directories from the right hand side of the path.
+    #
+    # Examples:
+    #
+    #   'a/b/c/d/file.txt'.pathmap("%2d")   => 'a/b'
+    #   '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
+    # 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").  Multiple replacement specs should be separated by
+    # semi-colons (e.g. "%{old,new;src,bin}d").
+    #
+    # Regular expressions may be used for the pattern, and back refs may be
+    # used in the replacement text.  Curly braces, commas and semi-colons are
+    # excluded from both the pattern and replacement text (let's keep parsing
+    # reasonable).
+    #
+    # For example:
+    #
+    #    "src/org/onestepback/proj/A.java".pathmap("%{^src,bin}X.class")
+    #
+    # returns:
+    #
+    #    "bin/org/onestepback/proj/A.class"
+    #
+    # If the replacement text is '*', then a block may be provided to perform
+    # some arbitrary calculation for the replacement.
+    #
+    # For example:
+    #
+    #   "/path/to/file.TXT".pathmap("%X%{.*,*}x") { |ext|
+    #      ext.downcase
+    #   }
+    #
+    # Returns:
+    #
+    #  "/path/to/file.txt"
+    #
+    def pathmap(spec=nil, &block)
+      return self if spec.nil?
+      result = ''
+      spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag|
+        case frag
+        when '%f'
+          result << File.basename(self)
+        when '%n'
+          result << File.basename(self).ext
+        when '%d'
+          result << File.dirname(self)
+        when '%x'
+          result << File.extname(self)
+        when '%X'
+          result << self.ext
+        when '%p'
+          result << self
+        when '%s'
+          result << (File::ALT_SEPARATOR || File::SEPARATOR)
+        when '%-'
+          # do nothing
+        when '%%'
+          result << "%"
+        when /%(-?\d+)d/
+          result << pathmap_partial($1.to_i)
+        when /^%\{([^}]*)\}(\d*[dpfnxX])/
+          patterns, operator = $1, $2
+          result << pathmap('%' + operator).pathmap_replace(patterns, &block)
+        when /^%/
+          fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'"
+        else
+          result << frag
+        end
+      end
+      result
+    end
+  end
+end # class String
+

Property changes on: lib/rake/ext/string.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: lib/rake/ext/core.rb
===================================================================
--- lib/rake/ext/core.rb	(revision 0)
+++ lib/rake/ext/core.rb	(revision 32217)
@@ -0,0 +1,27 @@
+######################################################################
+# Core extension library
+#
+class Module
+  # Check for an existing method in the current class before extending.  IF
+  # the method already exists, then a warning is printed and the extension is
+  # not added.  Otherwise the block is yielded and any definitions in the
+  # block will take effect.
+  #
+  # Usage:
+  #
+  #   class String
+  #     rake_extension("xyz") do
+  #       def xyz
+  #         ...
+  #       end
+  #     end
+  #   end
+  #
+  def rake_extension(method)
+    if method_defined?(method)
+      $stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists"
+    else
+      yield
+    end
+  end
+end

Property changes on: lib/rake/ext/core.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: lib/rake/file_utils.rb
===================================================================
--- lib/rake/file_utils.rb	(revision 0)
+++ lib/rake/file_utils.rb	(revision 32217)
@@ -0,0 +1,112 @@
+require 'rbconfig'
+require 'fileutils'
+
+# ###########################################################################
+# This a FileUtils extension that defines several additional commands to be
+# added to the FileUtils utility functions.
+#
+module FileUtils
+  # Path to the currently running Ruby program
+  RUBY = File.join(
+    RbConfig::CONFIG['bindir'],
+    RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']).
+    sub(/.*\s.*/m, '"\&"')
+
+  OPT_TABLE['sh']  = %w(noop verbose)
+  OPT_TABLE['ruby'] = %w(noop verbose)
+
+  # Run the system command +cmd+. If multiple arguments are given the command
+  # is not run with the shell (same semantics as Kernel::exec and
+  # Kernel::system).
+  #
+  # Example:
+  #   sh %{ls -ltr}
+  #
+  #   sh 'ls', 'file with spaces'
+  #
+  #   # check exit status after command runs
+  #   sh %{grep pattern file} do |ok, res|
+  #     if ! ok
+  #       puts "pattern not found (status = #{res.exitstatus})"
+  #     end
+  #   end
+  #
+  def sh(*cmd, &block)
+    options = (Hash === cmd.last) ? cmd.pop : {}
+    shell_runner = block_given? ? block : create_shell_runner(cmd)
+    set_verbose_option(options)
+    options[:noop] ||= Rake::FileUtilsEx (... truncated)

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

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