ruby-changes:34736
From: hsbt <ko1@a...>
Date: Tue, 15 Jul 2014 12:08:05 +0900 (JST)
Subject: [ruby-changes:34736] hsbt:r46818 (trunk): * lib/rake.rb, lib/rake/*.rb: Upgrade to rake-10.3.2
hsbt 2014-07-15 12:07:37 +0900 (Tue, 15 Jul 2014) New Revision: 46818 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46818 Log: * lib/rake.rb, lib/rake/*.rb: Upgrade to rake-10.3.2 [fix GH-668] * test/rake/*.rb: ditto. Added files: trunk/lib/rake/cpu_counter.rb trunk/test/rake/test_rake_cpu_counter.rb Removed files: trunk/lib/rake/lib/.document trunk/lib/rake/lib/project.rake Modified files: trunk/ChangeLog trunk/lib/rake/alt_system.rb trunk/lib/rake/application.rb trunk/lib/rake/backtrace.rb trunk/lib/rake/clean.rb trunk/lib/rake/cloneable.rb trunk/lib/rake/contrib/ftptools.rb trunk/lib/rake/contrib/publisher.rb trunk/lib/rake/contrib/rubyforgepublisher.rb trunk/lib/rake/contrib/sshpublisher.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_list.rb trunk/lib/rake/file_task.rb trunk/lib/rake/file_utils.rb trunk/lib/rake/gempackagetask.rb trunk/lib/rake/invocation_chain.rb trunk/lib/rake/linked_list.rb trunk/lib/rake/name_space.rb trunk/lib/rake/packagetask.rb trunk/lib/rake/pathmap.rb trunk/lib/rake/pseudo_status.rb trunk/lib/rake/rake_module.rb trunk/lib/rake/rdoctask.rb trunk/lib/rake/ruby182_test_unit_fix.rb trunk/lib/rake/runtest.rb trunk/lib/rake/scope.rb trunk/lib/rake/task.rb trunk/lib/rake/task_arguments.rb trunk/lib/rake/task_manager.rb trunk/lib/rake/tasklib.rb trunk/lib/rake/testtask.rb trunk/lib/rake/thread_pool.rb trunk/lib/rake/trace_output.rb trunk/lib/rake/version.rb trunk/lib/rake/win32.rb trunk/lib/rake.rb trunk/test/rake/support/rakefile_definitions.rb trunk/test/rake/test_rake_application.rb trunk/test/rake/test_rake_application_options.rb trunk/test/rake/test_rake_backtrace.rb trunk/test/rake/test_rake_clean.rb trunk/test/rake/test_rake_directory_task.rb trunk/test/rake/test_rake_file_task.rb trunk/test/rake/test_rake_functional.rb trunk/test/rake/test_rake_name_space.rb trunk/test/rake/test_rake_path_map.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_manager.rb trunk/test/rake/test_rake_test_task.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 46817) +++ ChangeLog (revision 46818) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Jul 15 12:00:03 2014 SHIBATA Hiroshi <shibata.hiroshi@g...> + + * lib/rake.rb, lib/rake/*.rb: Upgrade to rake-10.3.2 + [fix GH-668] + * test/rake/*.rb: ditto. + Mon Jul 14 19:14:51 2014 Masaki Suketa <masaki.suketa@n...> * ext/win32ole/win32ole.c: modify WIN32OLE class document and Index: lib/rake/trace_output.rb =================================================================== --- lib/rake/trace_output.rb (revision 46817) +++ lib/rake/trace_output.rb (revision 46818) @@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/rake/trace_output.rb#L1 module Rake - module TraceOutput + module TraceOutput # :nodoc: all # Write trace output to output stream +out+. # Index: lib/rake/backtrace.rb =================================================================== --- lib/rake/backtrace.rb (revision 46817) +++ lib/rake/backtrace.rb (revision 46818) @@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/rake/backtrace.rb#L1 module Rake - module Backtrace + module Backtrace # :nodoc: all SYS_KEYS = RbConfig::CONFIG.keys.grep(/(prefix|libdir)/) SYS_PATHS = RbConfig::CONFIG.values_at(*SYS_KEYS).uniq + [ File.join(File.dirname(__FILE__), "..") ] @@ -9,6 +9,9 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/backtrace.rb#L9 map { |f| File.expand_path(f) }. reject { |s| s.nil? || s =~ /^ *$/ } SUPPRESSED_PATHS_RE = SUPPRESSED_PATHS.map { |f| Regexp.quote(f) }.join("|") + SUPPRESSED_PATHS_RE << "|^org\\/jruby\\/\\w+\\.java" if + Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby' + SUPPRESS_PATTERN = %r!(\A(#{SUPPRESSED_PATHS_RE})|bin/rake:\d+)!i def self.collapse(backtrace) Index: lib/rake/clean.rb =================================================================== --- lib/rake/clean.rb (revision 46817) +++ lib/rake/clean.rb (revision 46818) @@ -31,9 +31,30 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/clean.rb#L31 begin rm_r file_name, opts rescue StandardError => ex - puts "Failed to remove #{file_name}: #{ex}" + puts "Failed to remove #{file_name}: #{ex}" unless file_already_gone?(file_name) end end + + def file_already_gone?(file_name) + return false if File.exist?(file_name) + + path = file_name + prev = nil + + while path = File.dirname(path) + return false if cant_be_deleted?(path) + break if [prev, "."].include?(path) + prev = path + end + true + end + private_class_method :file_already_gone? + + def cant_be_deleted?(path_name) + File.exist?(path_name) && + (!File.readable?(path_name) || !File.executable?(path_name)) + end + private_class_method :cant_be_deleted? end end Index: lib/rake/tasklib.rb =================================================================== --- lib/rake/tasklib.rb (revision 46817) +++ lib/rake/tasklib.rb (revision 46818) @@ -14,6 +14,8 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/tasklib.rb#L14 # libraries depend on this so I can't remove it without breaking # other people's code. So for now it stays for backwards # compatibility. BUT DON'T USE IT. + #-- + # TODO: Remove in Rake 11 def paste(a, b) # :nodoc: (a.to_s + b.to_s).intern end Index: lib/rake/pathmap.rb =================================================================== --- lib/rake/pathmap.rb (revision 46817) +++ lib/rake/pathmap.rb (revision 46818) @@ -1 +1,3 @@ +# TODO: Remove in Rake 11 + require 'rake/ext/string' Index: lib/rake/dsl_definition.rb =================================================================== --- lib/rake/dsl_definition.rb (revision 46817) +++ lib/rake/dsl_definition.rb (revision 46818) @@ -6,6 +6,9 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/dsl_definition.rb#L6 ## # DSL is a module that provides #task, #desc, #namespace, etc. Use this # when you'd like to use rake outside the top level scope. + # + # For a Rakefile you run from the comamnd line this module is automatically + # included. module DSL @@ -21,14 +24,45 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/dsl_definition.rb#L24 private - # Declare a basic task. + # :call-seq: + # task task_name + # task task_name: dependencies + # task task_name, arguments => dependencies + # task task_name, argument[, argument ...], :needs: dependencies # - # Example: - # task :clobber => [:clean] do + # Declare a basic task. The +task_name+ is always the first argument. If + # the task name contains a ":" it is defined in that namespace. + # + # The +dependencies+ may be a single task name or an Array of task names. + # The +argument+ (a single name) or +arguments+ (an Array of names) define + # the arguments provided to the task. + # + # The task, argument and dependency names may be either symbols or + # strings. + # + # A task with a single dependency: + # + # task clobber: %w[clean] do # rm_rf "html" # end # - def task(*args, &block) + # A task with an argument and a dependency: + # + # task :package, [:version] => :test do |t, args| + # # ... + # end + # + # To invoke this task from the command line: + # + # $ rake package[1.2.3] + # + # Alternate definition: + # + # task :package, :version, needs: :test do |t, args| + # # ... + # end + # + def task(*args, &block) # :doc: Rake::Task.define_task(*args, &block) end @@ -45,7 +79,7 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/dsl_definition.rb#L79 # end # end # - def file(*args, &block) + def file(*args, &block) # :doc: Rake::FileTask.define_task(*args, &block) end @@ -61,7 +95,7 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/dsl_definition.rb#L95 # Example: # directory "testdata/doc" # - def directory(*args, &block) + def directory(*args, &block) # :doc: result = file_create(*args, &block) dir, _ = *Rake.application.resolve_args(args) Rake.each_dir_parent(dir) do |d| @@ -78,9 +112,9 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/dsl_definition.rb#L112 # about it) # # Example: - # multitask :deploy => [:deploy_gem, :deploy_rdoc] + # multitask deploy: %w[deploy_gem deploy_rdoc] # - def multitask(*args, &block) + def multitask(*args, &block) # :doc: Rake::MultiTask.define_task(*args, &block) end @@ -88,14 +122,22 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/dsl_definition.rb#L122 # block. Returns a NameSpace object that can be used to lookup # tasks defined in the namespace. # - # E.g. + # Example: # # ns = namespace "nested" do + # # the "nested:run" task # task :run # end # task_run = ns[:run] # find :run in the given namespace. # - def namespace(name=nil, &block) + # Tasks can also be defined in a namespace by using a ":" in the task + # name: + # + # task "nested:test" do + # # ... + # end + # + def namespace(name=nil, &block) # :doc: 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? @@ -108,23 +150,22 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/dsl_definition.rb#L150 # # Example: # rule '.o' => '.c' do |t| - # sh %{cc -o #{t.name} #{t.source}} + # sh 'cc', '-o', t.name, t.source # end # - def rule(*args, &block) + def rule(*args, &block) # :doc: Rake::Task.create_rule(*args, &block) end - # Describe the next rake task. - # Duplicate descriptions are discarded. + # Describes the next rake task. Duplicate descriptions are discarded. # # Example: # desc "Run the Unit Tests" - # task :test => [:build] - # runtests + # task test: [:build] + # # ... run tests # end # - def desc(description) + def desc(description) # :doc: Rake.application.last_description = description end @@ -142,7 +183,7 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/dsl_definition.rb#L183 # Example: # import ".depend", "my_rules" # - def import(*fns) + def import(*fns) # :doc: fns.each do |fn| Rake.application.add_import(fn) end Index: lib/rake/ext/time.rb =================================================================== --- lib/rake/ext/time.rb (revision 46817) +++ lib/rake/ext/time.rb (revision 46818) @@ -3,7 +3,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/rake/ext/time.rb#L3 require 'rake/early_time' -class Time +class Time # :nodoc: all alias rake_original_time_compare :<=> def <=>(other) if Rake::EarlyTime === other Index: lib/rake/ext/module.rb =================================================================== --- lib/rake/ext/module.rb (revision 46817) +++ lib/rake/ext/module.rb (revision 46818) @@ -1 +1,2 @@ +# TODO: remove in Rake 11 Index: lib/rake/ext/string.rb =================================================================== --- lib/rake/ext/string.rb (revision 46817) +++ lib/rake/ext/string.rb (revision 46818) @@ -1,8 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/rake/ext/string.rb#L1 require 'rake/ext/core' -###################################################################### -# Rake extension methods for String. -# class String rake_extension("ext") do @@ -11,6 +8,8 @@ class String https://github.com/ruby/ruby/blob/trunk/lib/rake/ext/string.rb#L8 # is not given, or is the empty string, remove any existing extension. # # +ext+ is a user added method for the String class. + # + # This String extension comes from Rake def ext(newext='') return self.dup if ['.', '..'].include? self newext = (newext =~ /^\./) ? newext : ("." + newext) if newext != '' @@ -20,6 +19,8 @@ class String https://github.com/ruby/ruby/blob/trunk/lib/rake/ext/string.rb#L19 rake_extension("pathmap") do # Explode a path into individual components. Used by +pathmap+. + # + # This String extension comes from Rake def pathmap_explode head, tail = File.split(self) return [self] if head == self @@ -32,6 +33,8 @@ class String https://github.com/ruby/ruby/blob/trunk/lib/rake/ext/string.rb#L33 # 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. + # + # This String extension comes from Rake def pathmap_partial(n) dirs = File.dirname(self).pathmap_explode partial_dirs = @@ -48,6 +51,8 @@ class String https://github.com/ruby/ruby/blob/trunk/lib/rake/ext/string.rb#L51 # Preform the pathmap replacement operations on the given path. The # patterns take the form 'pat1,rep1;pat2,rep2...'. + # + # This String extension comes from Rake def pathmap_replace(patterns, &block) result = self patterns.split(';').each do |pair| @@ -69,35 +74,36 @@ class String https://github.com/ruby/ruby/blob/trunk/lib/rake/ext/string.rb#L74 # 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. + # <tt>%p</tt> :: The complete path. + # <tt>%f</tt> :: The base file name of the path, with its file extension, + # but without any directories. + # <tt>%n</tt> :: The file name of the path without its file extension. + # <tt>%d</tt> :: The directory list of the path. + # <tt>%x</tt> :: The file extension of the path. An empty string if there + # is no extension. + # <tt>%X</tt> :: Everything *but* the file extension. + # <tt>%s</tt> :: The alternate file separator if defined, otherwise use # + # the standard file separator. + # <tt>%%</tt> :: A percent sign. + # + # The <tt>%d</tt> 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"). + # Also the <tt>%d</tt>, <tt>%p</tt>, <tt>%f</tt>, <tt>%n</tt>, + # <tt>%x</tt>, and <tt>%X</tt> 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 @@ -106,11 +112,11 @@ class String https://github.com/ruby/ruby/blob/trunk/lib/rake/ext/string.rb#L112 # # For example: # - # "src/org/onestepback/proj/A.java".pathmap("%{^src,bin}X.class") + # "src/org/onestepback/proj/A.java".pathmap("%{^src,class}X.class") # # returns: # - # "bin/org/onestepback/proj/A.class" + # "class/org/onestepback/proj/A.class" # # If the replacement text is '*', then a block may be provided to perform # some arbitrary calculation for the replacement. @@ -125,6 +131,7 @@ class String https://github.com/ruby/ruby/blob/trunk/lib/rake/ext/string.rb#L131 # # "/path/to/file.txt" # + # This String extension comes from Rake def pathmap(spec=nil, &block) return self if spec.nil? result = '' Index: lib/rake/ext/core.rb =================================================================== --- lib/rake/ext/core.rb (revision 46817) +++ lib/rake/ext/core.rb (revision 46818) @@ -1,8 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/rake/ext/core.rb#L1 -###################################################################### -# Core extension library -# class Module - # Check for an existing method in the current class before extending. IF + # 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. @@ -17,7 +14,7 @@ class Module https://github.com/ruby/ruby/blob/trunk/lib/rake/ext/core.rb#L14 # end # end # - def rake_extension(method) + def rake_extension(method) # :nodoc: if method_defined?(method) $stderr.puts "WARNING: Possible conflict with Rake extension: " + "#{self}##{method} already exists" Index: lib/rake/file_utils.rb =================================================================== --- lib/rake/file_utils.rb (revision 46817) +++ lib/rake/file_utils.rb (revision 46818) @@ -14,12 +14,24 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/rake/file_utils.rb#L14 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 + # Run the system command +cmd+. If multiple arguments are given the command + # is run directly (without the shell, same semantics as Kernel::exec and # Kernel::system). # - # Example: - # sh %{ls -ltr} + # It is recommended you use the multiple argument form over interpolating + # user input for both usability and security reasons. With the multiple + # argument form you can easily process files with spaces or other shell + # reserved characters in them. With the multiple argument form your rake + # tasks are not vulnerable to users providing an argument like + # <code>; rm # -rf /</code>. + # + # If a block is given, upon command completion the block is called with an + # OK flag (true on a zero exit status) and a Process::Status object. + # Without a block a RuntimeError is raised when the command exits non-zero. + # + # Examples: + # + # sh 'ls -ltr' # # sh 'ls', 'file with spaces' # Index: lib/rake/file_task.rb =================================================================== --- lib/rake/file_task.rb (revision 46817) +++ lib/rake/file_task.rb (revision 46818) @@ -2,7 +2,7 @@ require 'rake/task.rb' https://github.com/ruby/ruby/blob/trunk/lib/rake/file_task.rb#L2 require 'rake/early_time' module Rake - # ######################################################################### + # A FileTask is a task that includes time based dependencies. If any of a # FileTask's prerequisites have a timestamp that is later than the file # represented by this task, then the file must be rebuilt (using the @@ -13,7 +13,7 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/file_task.rb#L13 # Is this file task needed? Yes if it doesn't exist, or if its time stamp # is out of date. def needed? - ! File.exist?(name) || out_of_date?(timestamp) + ! File.exist?(name) || out_of_date?(timestamp) || @application.options.build_all end # Time stamp for file task. Index: lib/rake/testtask.rb =================================================================== --- lib/rake/testtask.rb (revision 46817) +++ lib/rake/testtask.rb (revision 46818) @@ -1,5 +1,3 @@ https://github.com/ruby/ruby/blob/trunk/lib/rake/testtask.rb#L1 -# Define a task library for running unit tests. - require 'rake' require 'rake/tasklib' @@ -67,6 +65,9 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/testtask.rb#L65 # Array of commandline options to pass to ruby when running test loader. attr_accessor (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/