Fix issues with Pathname.install and arrays
This commit is contained in:
parent
32281b7a7f
commit
34955880d5
@ -102,11 +102,21 @@ class Pathname
|
|||||||
end
|
end
|
||||||
|
|
||||||
def install src
|
def install src
|
||||||
if File.exist? src
|
if src.is_a? Array
|
||||||
|
src.each {|src| install src }
|
||||||
|
elsif File.exist? src
|
||||||
mkpath
|
mkpath
|
||||||
|
if File.symlink? src
|
||||||
|
# we cp symlinks because FileUtils.mv is shit and won't mv a symlink
|
||||||
|
# if its final destination has an invalid target! FFS. Ruby is shit.
|
||||||
|
FileUtils.cp src, to_s
|
||||||
|
else
|
||||||
|
# we mv when possible as it is faster and you should only be using
|
||||||
|
# this function when installing from the temporary build directory
|
||||||
FileUtils.mv src, to_s
|
FileUtils.mv src, to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def cp dst
|
def cp dst
|
||||||
if file?
|
if file?
|
||||||
@ -116,13 +126,14 @@ class Pathname
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# for filetypes we support
|
||||||
def extname
|
def extname
|
||||||
/\.(zip|tar\.(gz|bz2)|tgz)$/.match to_s
|
/\.(zip|tar\.(gz|bz2)|tgz)$/.match to_s
|
||||||
return ".#{$1}" if $1
|
return ".#{$1}" if $1
|
||||||
return File.extname(to_s)
|
return File.extname(to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
# for files we support, basename without extension
|
# for filetypes we support, basename without extension
|
||||||
def stem
|
def stem
|
||||||
return File.basename(to_s, extname)
|
return File.basename(to_s, extname)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user