@@ -236,13 +236,9 @@ def initialize(path)
236236 if /\0 / =~ @path
237237 raise ArgumentError , "pathname contains \\ 0: #{ @path . inspect } "
238238 end
239-
240- self . taint if @path . tainted?
241239 end
242240
243241 def freeze ( ) super ; @path . freeze ; self end
244- def taint ( ) super ; @path . taint ; self end
245- def untaint ( ) super ; @path . untaint ; self end
246242
247243 #
248244 # Compare this pathname with +other+. The comparison is string-based.
@@ -827,8 +823,8 @@ class Pathname # * IO *
827823 #
828824 # This method has existed since 1.8.1.
829825 #
830- def each_line ( * args , & block ) # :yield: line
831- IO . foreach ( @path , * args , & block )
826+ def each_line ( ... ) # :yield: line
827+ IO . foreach ( @path , ... )
832828 end
833829
834830 # See <tt>IO.read</tt>. Returns all data from the file, or the first +N+ bytes
@@ -840,7 +836,7 @@ def read(*args) IO.read(@path, *args) end
840836 def binread ( *args ) IO . binread ( @path , *args ) end
841837
842838 # See <tt>IO.readlines</tt>. Returns all the lines from the file.
843- def readlines ( * args ) IO . readlines ( @path , * args ) end
839+ def readlines ( ... ) IO . readlines ( @path , ... ) end
844840
845841 # See <tt>IO.sysopen</tt>.
846842 def sysopen ( *args ) IO . sysopen ( @path , *args ) end
@@ -885,8 +881,8 @@ def ftype() File.ftype(@path) end
885881 def make_link ( old ) File . link ( old , @path ) end
886882
887883 # See <tt>File.open</tt>. Opens the file for reading or writing.
888- def open ( * args , & block ) # :yield: file
889- File . open ( @path , * args , & block )
884+ def open ( ... ) # :yield: file
885+ File . open ( @path , ... )
890886 end
891887
892888 # See <tt>File.readlink</tt>. Read symbolic link.
@@ -924,7 +920,11 @@ def expand_path(*args) self.class.new(File.expand_path(@path, *args)) end
924920
925921 # See <tt>File.split</tt>. Returns the #dirname and the #basename in an
926922 # Array.
927- def split ( ) File . split ( @path ) . map { |f | self . class . new ( f ) } end
923+ def split ( )
924+ array = File . split ( @path )
925+ raise TypeError , 'wrong argument type nil (expected Array)' unless Array === array
926+ array . map { |f | self . class . new ( f ) }
927+ end
928928end
929929
930930
@@ -1006,11 +1006,11 @@ def zero?() FileTest.zero?(@path) end
10061006
10071007class Pathname # * Dir *
10081008 # See <tt>Dir.glob</tt>. Returns or yields Pathname objects.
1009- def Pathname . glob ( *args ) # :yield: pathname
1009+ def Pathname . glob ( *args , ** kwargs ) # :yield: pathname
10101010 if block_given?
1011- Dir . glob ( *args ) { |f | yield self . new ( f ) }
1011+ Dir . glob ( *args , ** kwargs ) { |f | yield self . new ( f ) }
10121012 else
1013- Dir . glob ( *args ) . map { |f | self . new ( f ) }
1013+ Dir . glob ( *args , ** kwargs ) . map { |f | self . new ( f ) }
10141014 end
10151015 end
10161016
@@ -1027,6 +1027,7 @@ def entries() Dir.entries(@path).map {|f| self.class.new(f) } end
10271027 #
10281028 # This method has existed since 1.8.1.
10291029 def each_entry ( &block ) # :yield: pathname
1030+ return to_enum ( __method__ ) unless block_given?
10301031 Dir . foreach ( @path ) { |f | yield self . class . new ( f ) }
10311032 end
10321033
@@ -1124,14 +1125,15 @@ def unlink()
11241125end
11251126
11261127class Pathname
1127- undef =~
1128+ undef =~ if Kernel . method_defined? ( :=~ )
11281129end
11291130
11301131module Kernel
11311132 # create a pathname object.
11321133 #
11331134 # This method is available since 1.8.5.
11341135 def Pathname ( path ) # :doc:
1136+ return path if Pathname === path
11351137 Pathname . new ( path )
11361138 end
11371139 private :Pathname
0 commit comments