зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
605a46dd05
Коммит
95f9f98ac5
|
@ -1,3 +1,10 @@
|
||||||
|
Sat Sep 27 06:22:18 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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@ruby-lang.org>
|
Sat Sep 27 04:28:41 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* file.c (rmext): preceding dots are not a part of extension.
|
* file.c (rmext): preceding dots are not a part of extension.
|
||||||
|
|
16
lib/rake.rb
16
lib/rake.rb
|
@ -60,7 +60,7 @@ class Module
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
def rake_extension(method)
|
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"
|
$stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists"
|
||||||
else
|
else
|
||||||
yield
|
yield
|
||||||
|
@ -84,7 +84,7 @@ class String
|
||||||
if newext != ''
|
if newext != ''
|
||||||
newext = (newext =~ /^\./) ? newext : ("." + newext)
|
newext = (newext =~ /^\./) ? newext : ("." + newext)
|
||||||
end
|
end
|
||||||
dup.sub!(%r(([^/\\])\.[^./\\]*$)) { $1 + newext } || self + newext
|
self.chomp(File.extname(self)) << newext
|
||||||
end
|
end
|
||||||
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") => 'a/b'
|
||||||
# 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d'
|
# '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
|
# pattern/replacement argument to perform simple string substititions on a
|
||||||
# particular part of the path. The pattern and replacement are speparated
|
# particular part of the path. The pattern and replacement are speparated
|
||||||
# by a comma and are enclosed by curly braces. The replacement spec comes
|
# by a comma and are enclosed by curly braces. The replacement spec comes
|
||||||
|
@ -203,17 +203,13 @@ class String
|
||||||
when '%f'
|
when '%f'
|
||||||
result << File.basename(self)
|
result << File.basename(self)
|
||||||
when '%n'
|
when '%n'
|
||||||
result << File.basename(self).ext
|
result << File.basename(self, '.*')
|
||||||
when '%d'
|
when '%d'
|
||||||
result << File.dirname(self)
|
result << File.dirname(self)
|
||||||
when '%x'
|
when '%x'
|
||||||
result << $1 if self =~ /[^\/](\.[^.]+)$/
|
result << File.extname(self)
|
||||||
when '%X'
|
when '%X'
|
||||||
if self =~ /^(.*[^\/])(\.[^.]+)$/
|
result << self.ext
|
||||||
result << $1
|
|
||||||
else
|
|
||||||
result << self
|
|
||||||
end
|
|
||||||
when '%p'
|
when '%p'
|
||||||
result << self
|
result << self
|
||||||
when '%s'
|
when '%s'
|
||||||
|
|
Загрузка…
Ссылка в новой задаче