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

ruby-changes:35351

From: hsbt <ko1@a...>
Date: Sat, 6 Sep 2014 18:31:55 +0900 (JST)
Subject: [ruby-changes:35351] hsbt:r47433 (trunk): * lib/rake.rb, lib/rake/*, test/rake/*: Update latest rake master(e47d023)

hsbt	2014-09-06 18:31:37 +0900 (Sat, 06 Sep 2014)

  New Revision: 47433

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

  Log:
    * lib/rake.rb, lib/rake/*, test/rake/*: Update latest rake master(e47d023)

  Added files:
    trunk/lib/rake/contrib/.document
    trunk/lib/rake/ext/pathname.rb
    trunk/test/rake/test_rake_pathname_extensions.rb
  Modified files:
    trunk/ChangeLog
    trunk/lib/rake/cloneable.rb
    trunk/lib/rake/cpu_counter.rb
    trunk/lib/rake/dsl_definition.rb
    trunk/lib/rake/ext/string.rb
    trunk/lib/rake/file_list.rb
    trunk/lib/rake/file_task.rb
    trunk/lib/rake/task_manager.rb
    trunk/test/rake/helper.rb
    trunk/test/rake/test_rake_directory_task.rb
    trunk/test/rake/test_rake_file_list.rb
    trunk/test/rake/test_rake_file_task.rb
    trunk/test/rake/test_rake_task_argument_parsing.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47432)
+++ ChangeLog	(revision 47433)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Sep  6 18:31:32 2014  SHIBATA Hiroshi  <shibata.hiroshi@g...>
+
+	* lib/rake.rb, lib/rake/*, test/rake/*: Update latest rake master(e47d023)
+
 Sat Sep  6 16:38:08 2014  Masaki Suketa <masaki.suketa@n...>
 
 	* ext/win32ole/win32ole_variant.c (ole_val2variant_err,
Index: lib/rake/dsl_definition.rb
===================================================================
--- lib/rake/dsl_definition.rb	(revision 47432)
+++ lib/rake/dsl_definition.rb	(revision 47433)
@@ -98,6 +98,7 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/dsl_definition.rb#L98
     def directory(*args, &block) # :doc:
       result = file_create(*args, &block)
       dir, _ = *Rake.application.resolve_args(args)
+      dir = Rake.from_pathname(dir)
       Rake.each_dir_parent(dir) do |d|
         file_create d do |t|
           mkdir_p t.name unless File.exist?(t.name)
Index: lib/rake/ext/pathname.rb
===================================================================
--- lib/rake/ext/pathname.rb	(revision 0)
+++ lib/rake/ext/pathname.rb	(revision 47433)
@@ -0,0 +1,25 @@ https://github.com/ruby/ruby/blob/trunk/lib/rake/ext/pathname.rb#L1
+require 'rake/ext/core'
+require 'pathname'
+
+class Pathname
+
+  rake_extension("ext") do
+    # Return a new Pathname with <tt>String#ext</tt> applied to it.
+    #
+    # This Pathname extension comes from Rake
+    def ext(newext='')
+      Pathname.new(Rake.from_pathname(self).ext(newext))
+    end
+  end
+
+  rake_extension("pathmap") do
+    # Apply the pathmap spec to the Pathname, returning a
+    # new Pathname with the modified paths.  (See String#pathmap for
+    # details.)
+    #
+    # This Pathname extension comes from Rake
+    def pathmap(spec=nil, &block)
+      Pathname.new(Rake.from_pathname(self).pathmap(spec, &block))
+    end
+  end
+end
Index: lib/rake/ext/string.rb
===================================================================
--- lib/rake/ext/string.rb	(revision 47432)
+++ lib/rake/ext/string.rb	(revision 47433)
@@ -49,7 +49,7 @@ class String https://github.com/ruby/ruby/blob/trunk/lib/rake/ext/string.rb#L49
     end
     protected :pathmap_partial
 
-    # Preform the pathmap replacement operations on the given path. The
+    # Perform the pathmap replacement operations on the given path. The
     # patterns take the form 'pat1,rep1;pat2,rep2...'.
     #
     # This String extension comes from Rake
Index: lib/rake/file_task.rb
===================================================================
--- lib/rake/file_task.rb	(revision 47432)
+++ lib/rake/file_task.rb	(revision 47433)
@@ -39,7 +39,7 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/file_task.rb#L39
       # Apply the scope to the task name according to the rules for this kind
       # of task.  File based tasks ignore the scope when creating the name.
       def scope_name(scope, task_name)
-        task_name
+        Rake.from_pathname(task_name)
       end
     end
   end
Index: lib/rake/cloneable.rb
===================================================================
--- lib/rake/cloneable.rb	(revision 47432)
+++ lib/rake/cloneable.rb	(revision 47433)
@@ -3,7 +3,7 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/cloneable.rb#L3
   # Mixin for creating easily cloned objects.
 
   module Cloneable # :nodoc:
-    # The hook that invoked by 'clone' and 'dup' methods.
+    # The hook that is invoked by 'clone' and 'dup' methods.
     def initialize_copy(source)
       super
       source.instance_variables.each do |var|
Index: lib/rake/cpu_counter.rb
===================================================================
--- lib/rake/cpu_counter.rb	(revision 47432)
+++ lib/rake/cpu_counter.rb	(revision 47433)
@@ -38,7 +38,8 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/cpu_counter.rb#L38
           count_via_win32 ||
             count_via_sysctl ||
             count_via_hwprefs_thread_count ||
-            count_via_hwprefs_cpu_count
+            count_via_hwprefs_cpu_count ||
+            count_via_cpuinfo
         end
       end
     end
Index: lib/rake/task_manager.rb
===================================================================
--- lib/rake/task_manager.rb	(revision 47432)
+++ lib/rake/task_manager.rb	(revision 47433)
@@ -35,7 +35,7 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/task_manager.rb#L35
 
       task_name = task_class.scope_name(@scope, task_name)
       deps = [deps] unless deps.respond_to?(:to_ary)
-      deps = deps.map { |d| d.to_s }
+      deps = deps.map { |d| Rake.from_pathname(d).to_s }
       task = intern(task_class, task_name)
       task.set_arg_names(arg_names) unless arg_names.empty?
       if Rake::TaskManager.record_task_metadata
Index: lib/rake/contrib/.document
===================================================================
Index: lib/rake/file_list.rb
===================================================================
--- lib/rake/file_list.rb	(revision 47432)
+++ lib/rake/file_list.rb	(revision 47433)
@@ -49,7 +49,7 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/file_list.rb#L49
 
     # List of methods that should not be delegated here (we define special
     # versions of them explicitly below).
-    MUST_NOT_DEFINE = %w[to_a to_ary partition *]
+    MUST_NOT_DEFINE = %w[to_a to_ary partition * <<]
 
     # List of delegated methods that return new array values which need
     # wrapping.
@@ -119,7 +119,7 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/file_list.rb#L119
         if fn.respond_to? :to_ary
           include(*fn.to_ary)
         else
-          @pending_add << fn
+          @pending_add << Rake.from_pathname(fn)
         end
       end
       @pending = true
@@ -149,7 +149,7 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/file_list.rb#L149
     #
     def exclude(*patterns, &block)
       patterns.each do |pat|
-        @exclude_patterns << pat
+        @exclude_patterns << Rake.from_pathname(pat)
       end
       @exclude_procs << block if block_given?
       resolve_exclude unless @pending
@@ -196,6 +196,12 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/file_list.rb#L196
       end
     end
 
+    def <<(obj)
+      resolve
+      @items << Rake.from_pathname(obj)
+      self
+    end
+
     # Resolve all the pending adds now.
     def resolve
       if @pending
@@ -346,7 +352,7 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/file_list.rb#L352
 
     # Should the given file name be excluded from the list?
     #
-    # NOTE: This method was formally named "exclude?", but Rails
+    # NOTE: This method was formerly named "exclude?", but Rails
     # introduced an exclude? method as an array method and setup a
     # conflict with file list. We renamed the method to avoid
     # confusion. If you were using "FileList#exclude?" in your user
@@ -410,5 +416,13 @@ module Rake https://github.com/ruby/ruby/blob/trunk/lib/rake/file_list.rb#L416
         dir = File.dirname(dir)
       end
     end
+
+    # Convert Pathname and Pathname-like objects to strings;
+    # leave everything else alone
+    def from_pathname(path)    # :nodoc:
+      path = path.to_path if path.respond_to?(:to_path)
+      path = path.to_str if path.respond_to?(:to_str)
+      path
+    end
   end
 end # module Rake
Index: test/rake/test_rake_directory_task.rb
===================================================================
--- test/rake/test_rake_directory_task.rb	(revision 47432)
+++ test/rake/test_rake_directory_task.rb	(revision 47433)
@@ -1,5 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/test/rake/test_rake_directory_task.rb#L1
 require File.expand_path('../helper', __FILE__)
 require 'fileutils'
+require 'pathname'
 
 class TestRakeDirectoryTask < Rake::TestCase
   include Rake
@@ -60,4 +61,16 @@ class TestRakeDirectoryTask < Rake::Test https://github.com/ruby/ruby/blob/trunk/test/rake/test_rake_directory_task.rb#L61
     assert_equal ["t2", "a/b/c"], runlist
     assert File.directory?("a/b/c")
   end
+
+  def test_can_use_pathname
+    directory Pathname.new "a/b/c"
+
+    assert_equal FileCreationTask, Task["a/b/c"].class
+
+    verbose(false) {
+      Task['a/b/c'].invoke
+    }
+
+    assert File.directory?("a/b/c")
+  end
 end
Index: test/rake/test_rake_file_list.rb
===================================================================
--- test/rake/test_rake_file_list.rb	(revision 47432)
+++ test/rake/test_rake_file_list.rb	(revision 47433)
@@ -1,4 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/test/rake/test_rake_file_list.rb#L1
 require File.expand_path('../helper', __FILE__)
+require 'pathname'
 
 class TestRakeFileList < Rake::TestCase
   FileList = Rake::FileList
@@ -46,6 +47,12 @@ class TestRakeFileList < Rake::TestCase https://github.com/ruby/ruby/blob/trunk/test/rake/test_rake_file_list.rb#L47
       fl.sort
   end
 
+  def test_create_with_pathname
+    fl = FileList.new(Pathname.new("*.c"))
+    assert_equal ["abc.c", "x.c", "xyz.c"].sort,
+                 fl.sort
+  end
+
   def test_create_with_block
     fl = FileList.new { |f| f.include("x") }
     assert_equal ["x"], fl.resolve
@@ -74,12 +81,24 @@ class TestRakeFileList < Rake::TestCase https://github.com/ruby/ruby/blob/trunk/test/rake/test_rake_file_list.rb#L81
       fl.sort
   end
 
+  def test_include_with_pathname
+    fl = FileList.new.include(Pathname.new("*.c"))
+    assert_equal ["abc.c", "x.c", "xyz.c"].sort,
+      fl.sort
+  end
+
   def test_append
     fl = FileList.new
     fl << "a.rb" << "b.rb"
     assert_equal ['a.rb', 'b.rb'], fl
   end
 
+  def test_append_pathname
+    fl = FileList.new
+    fl << Pathname.new("a.rb")
+    assert_equal ['a.rb'], fl
+  end
+
   def test_add_many
     fl = FileList.new
     fl.include %w(a d c)
@@ -163,6 +182,15 @@ class TestRakeFileList < Rake::TestCase https://github.com/ruby/ruby/blob/trunk/test/rake/test_rake_file_list.rb#L182
     assert_equal [], fl
   end
 
+  def test_exclude_pathname
+    fl = FileList['x.c', 'abc.c', 'other']
+    fl.each { |fn| touch fn, :verbose => false }
+
+    fl.exclude(Pathname.new('*.c'))
+
+    assert_equal ['other'], fl
+  end
+
   def test_excluding_via_block
     fl = FileList['a.c', 'b.c', 'xyz.c']
     fl.exclude { |fn| fn.pathmap('%n') == 'xyz' }
Index: test/rake/test_rake_pathname_extensions.rb
===================================================================
--- test/rake/test_rake_pathname_extensions.rb	(revision 0)
+++ test/rake/test_rake_pathname_extensions.rb	(revision 47433)
@@ -0,0 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/test/rake/test_rake_pathname_extensions.rb#L1
+require File.expand_path('../helper', __FILE__)
+require 'rake/ext/pathname'
+
+class TestRakePathnameExtensions < Rake::TestCase
+  def test_ext_works_on_pathnames
+    pathname = Pathname.new("abc.foo")
+    assert_equal Pathname.new("abc.bar"), pathname.ext("bar")
+  end
+
+  def test_path_map_works_on_pathnames
+    pathname = Pathname.new("this/is/a/dir/abc.rb")
+    assert_equal Pathname.new("abc.rb"), pathname.pathmap("%f")
+    assert_equal Pathname.new("this/is/a/dir"), pathname.pathmap("%d")
+  end
+end
Index: test/rake/helper.rb
===================================================================
--- test/rake/helper.rb	(revision 47432)
+++ test/rake/helper.rb	(revision 47433)
@@ -2,7 +2,7 @@ require 'rubygems' https://github.com/ruby/ruby/blob/trunk/test/rake/helper.rb#L2
 $:.unshift File.expand_path('../../lib', __FILE__)
 
 begin
-  gem 'minitest'
+  gem 'minitest', '~> 4'
 rescue Gem::LoadError
 end
 
@@ -11,13 +11,15 @@ require 'rake' https://github.com/ruby/ruby/blob/trunk/test/rake/helper.rb#L11
 require 'tmpdir'
 require File.expand_path('../file_creation', __FILE__)
 
-require_relative 'support/ruby_runner'
-require_relative 'support/rakefile_definitions'
 
 begin
   require_relative '../ruby/envutil'
+  require_relative 'support/ruby_runner'
+  require_relative 'support/rakefile_definitions'
 rescue NoMethodError, LoadError
-  # for ruby trunk
+  # ruby 1.8
+  require 'test/support/ruby_runner'
+  require 'test/support/rakefile_definitions'
 end
 
 class Rake::TestCase < MiniTest::Unit::TestCase
Index: test/rake/test_rake_task_argument_parsing.rb
===================================================================
--- test/rake/test_rake_task_argument_parsing.rb	(revision 47432)
+++ test/rake/test_rake_task_argument_parsing.rb	(revision 47433)
@@ -49,6 +49,16 @@ class TestRakeTaskArgumentParsing < Rake https://github.com/ruby/ruby/blob/trunk/test/rake/test_rake_task_argument_parsing.rb#L49
     assert_equal ["one", "two", "three_a, three_b", "four"], args
   end
 
+  def test_treat_blank_arg_as_empty_string
+    name, args = @app.parse_task_string("name[one,]")
+    assert_equal "name", name
+    assert_equal ["one", ""], args
+
+    name, args = @app.parse_task_string("name[one,,two]")
+    assert_equal "name", name
+    assert_equal ["one", "", "two"], args
+  end
+
   def test_terminal_width_using_env
     app = Rake::Application.new
     app.terminal_columns = 1234
Index: test/rake/test_rake_file_task.rb
===================================================================
--- test/rake/test_rake_file_task.rb	(revision 47432)
+++ test/rake/test_rake_file_task.rb	(revision 47433)
@@ -1,5 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/test/rake/test_rake_file_task.rb#L1
 require File.expand_path('../helper', __FILE__)
 require 'fileutils'
+require 'pathname'
 
 class TestRakeFileTask < Rake::TestCase
   include Rake
@@ -162,6 +163,20 @@ class TestRakeFileTask < Rake::TestCase https://github.com/ruby/ruby/blob/trunk/test/rake/test_rake_file_task.rb#L163
     assert_equal ["preqA", "preqB"], t.sources
   end
 
+  def test_task_can_be_pathname
+      name = "dummy"
+      file Pathname.new name
+
+      ftask = Task[name]
+
+      assert_equal name.to_s, ftask.name
+  end
+
+  def test_prerequisite_can_be_pathname
+    t = file :f => Pathname.new("preq")
+    assert_equal "preq", t.source
+  end
+
   # I have currently disabled this test.  I'm not convinced that
   # deleting the file target on failure is always the proper thing to
   # do.  I'm willing to hear input on this topic.

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

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