diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-26 21:22:21 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-26 21:22:21 +0000 |
commit | 95f9f98ac54c3ada20c049d71f8e2c0b79541ba8 (patch) | |
tree | 4bc5ad20d8a3e0abd88d4ea5e1c99cf89de4f9a8 /lib/rake.rb | |
parent | 605a46dd0535bc7706f3f412ee974c559e084a57 (diff) |
* lib/rake.rb (Module#rake_extension, String#ext, String#pathmap): use
built-in methods.
* lib/rake.rb (String#pathmap): fixed typo in rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rake.rb')
-rwxr-xr-x | lib/rake.rb | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/rake.rb b/lib/rake.rb index 313e169feb..f78cd3cd3d 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -60,7 +60,7 @@ class Module # 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 @@ class String 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 @@ class String # '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 @@ class String 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' |