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

ruby-changes:8071

From: nobu <ko1@a...>
Date: Sat, 27 Sep 2008 06:22:36 +0900 (JST)
Subject: [ruby-changes:8071] Ruby:r19597 (trunk): * lib/rake.rb (Module#rake_extension, String#ext, String#pathmap): use

nobu	2008-09-27 06:22:21 +0900 (Sat, 27 Sep 2008)

  New Revision: 19597

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

  Log:
    * lib/rake.rb (Module#rake_extension, String#ext, String#pathmap): use
      built-in methods.
    
    * lib/rake.rb (String#pathmap): fixed typo in rdoc.

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 19596)
+++ ChangeLog	(revision 19597)
@@ -1,3 +1,10 @@
+Sat Sep 27 06:22:18 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/rake.rb (Module#rake_extension, String#ext, String#pathmap): use
+	  built-in methods.
+
+	* lib/rake.rb (String#pathmap): fixed typo in rdoc.
+
 Sat Sep 27 04:28:41 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* file.c (rmext): preceding dots are not a part of extension.
Index: lib/rake.rb
===================================================================
--- lib/rake.rb	(revision 19596)
+++ lib/rake.rb	(revision 19597)
@@ -60,7 +60,7 @@
   #   end
   #
   def rake_extension(method)
-    if instance_methods.include?(method.to_s) || instance_methods.include?(method.to_sym)
+    if method_defined?(method)
       $stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists"
     else
       yield
@@ -84,7 +84,7 @@
       if newext != ''
         newext = (newext =~ /^\./) ? newext : ("." + newext)
       end
-      dup.sub!(%r(([^/\\])\.[^./\\]*$)) { $1 + newext } || self + newext
+      self.chomp(File.extname(self)) << newext
     end
   end
 
@@ -161,7 +161,7 @@
     #   '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
+    # Also the %d, %p, %f, %n, %x, and %X operators can take a
     # 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
@@ -203,17 +203,13 @@
         when '%f'
           result << File.basename(self)
         when '%n'
-          result << File.basename(self).ext
+          result << File.basename(self, '.*')
         when '%d'
           result << File.dirname(self)
         when '%x'
-          result << $1 if self =~ /[^\/](\.[^.]+)$/
+          result << File.extname(self)
         when '%X'
-          if self =~ /^(.*[^\/])(\.[^.]+)$/
-            result << $1
-          else
-            result << self
-          end
+          result << self.ext
         when '%p'
           result << self
         when '%s'

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

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