Merge pull request #793 from reitermarkus/refactoring-pathname
Merge Cask’s `Pathname` extension with Homebrew’s.
This commit is contained in:
commit
fa19447a2d
@ -10,7 +10,7 @@ class Hbc::Container::Gzip < Hbc::Container::Base
|
|||||||
def extract
|
def extract
|
||||||
Dir.mktmpdir do |unpack_dir|
|
Dir.mktmpdir do |unpack_dir|
|
||||||
@command.run!("/usr/bin/ditto", args: ["--", @path, unpack_dir])
|
@command.run!("/usr/bin/ditto", args: ["--", @path, unpack_dir])
|
||||||
@command.run!("/usr/bin/gunzip", args: ["--quiet", "--", Pathname.new(unpack_dir).join(@path.basename)])
|
@command.run!("/usr/bin/gunzip", args: ["--quiet", "--name", "--", Pathname.new(unpack_dir).join(@path.basename)])
|
||||||
|
|
||||||
extract_nested_inside(unpack_dir)
|
extract_nested_inside(unpack_dir)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -2,5 +2,5 @@
|
|||||||
require "hbc/extend/hash"
|
require "hbc/extend/hash"
|
||||||
require "hbc/extend/io"
|
require "hbc/extend/io"
|
||||||
require "hbc/extend/optparse"
|
require "hbc/extend/optparse"
|
||||||
require "hbc/extend/pathname"
|
require "extend/pathname"
|
||||||
require "hbc/extend/string"
|
require "hbc/extend/string"
|
||||||
|
|||||||
@ -1,19 +0,0 @@
|
|||||||
require "pathname"
|
|
||||||
|
|
||||||
class Pathname
|
|
||||||
# extended to support common double extensions
|
|
||||||
def extname(path = to_s)
|
|
||||||
%r{(\.(dmg|tar|cpio|pax)\.(gz|bz2|lz|xz|Z|zip))$} =~ path
|
|
||||||
return Regexp.last_match(1) if Regexp.last_match(1)
|
|
||||||
File.extname(path)
|
|
||||||
end
|
|
||||||
|
|
||||||
# https://bugs.ruby-lang.org/issues/9915
|
|
||||||
if RUBY_VERSION == "2.0.0"
|
|
||||||
prepend Module.new {
|
|
||||||
def inspect
|
|
||||||
super.force_encoding(@path.encoding)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1,6 +1,5 @@
|
|||||||
require "rubygems"
|
require "rubygems"
|
||||||
|
|
||||||
require "extend/pathname"
|
|
||||||
require "hbc/cask_dependencies"
|
require "hbc/cask_dependencies"
|
||||||
require "hbc/staged"
|
require "hbc/staged"
|
||||||
require "hbc/verify"
|
require "hbc/verify"
|
||||||
|
|||||||
@ -13,7 +13,6 @@ project_root = Pathname.new(File.expand_path("../..", __FILE__))
|
|||||||
$LOAD_PATH.unshift(File.expand_path("#{ENV['HOMEBREW_REPOSITORY']}/Library/Homebrew"))
|
$LOAD_PATH.unshift(File.expand_path("#{ENV['HOMEBREW_REPOSITORY']}/Library/Homebrew"))
|
||||||
|
|
||||||
require "global"
|
require "global"
|
||||||
require "extend/pathname"
|
|
||||||
|
|
||||||
# add Homebrew-Cask to load path
|
# add Homebrew-Cask to load path
|
||||||
$LOAD_PATH.push(project_root.join("lib").to_s)
|
$LOAD_PATH.push(project_root.join("lib").to_s)
|
||||||
|
|||||||
@ -154,7 +154,7 @@ describe Hbc::Installer do
|
|||||||
|
|
||||||
dest_path = Hbc.caskroom.join("container-gzip", asset.version)
|
dest_path = Hbc.caskroom.join("container-gzip", asset.version)
|
||||||
dest_path.must_be :directory?
|
dest_path.must_be :directory?
|
||||||
file = Hbc.appdir.join("container-gzip--#{asset.version}")
|
file = Hbc.appdir.join("container")
|
||||||
file.must_be :file?
|
file.must_be :file?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -5,5 +5,5 @@ test_cask 'container-gzip' do
|
|||||||
url TestHelper.local_binary_url('container.gz')
|
url TestHelper.local_binary_url('container.gz')
|
||||||
homepage 'https://example.com/container-gzip'
|
homepage 'https://example.com/container-gzip'
|
||||||
|
|
||||||
app 'container-gzip--1.2.3'
|
app 'container'
|
||||||
end
|
end
|
||||||
|
|||||||
@ -14,7 +14,6 @@ tap_root = Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homeb
|
|||||||
$LOAD_PATH.unshift(File.expand_path("#{ENV['HOMEBREW_REPOSITORY']}/Library/Homebrew"))
|
$LOAD_PATH.unshift(File.expand_path("#{ENV['HOMEBREW_REPOSITORY']}/Library/Homebrew"))
|
||||||
|
|
||||||
require "global"
|
require "global"
|
||||||
require "extend/pathname"
|
|
||||||
|
|
||||||
# add Homebrew-Cask to load path
|
# add Homebrew-Cask to load path
|
||||||
$LOAD_PATH.push(project_root.join("lib").to_s)
|
$LOAD_PATH.push(project_root.join("lib").to_s)
|
||||||
|
|||||||
@ -216,10 +216,10 @@ class Pathname
|
|||||||
|
|
||||||
# extended to support common double extensions
|
# extended to support common double extensions
|
||||||
def extname(path = to_s)
|
def extname(path = to_s)
|
||||||
BOTTLE_EXTNAME_RX.match(path)
|
bottle_ext = path[BOTTLE_EXTNAME_RX, 1]
|
||||||
return $1 if $1
|
return bottle_ext if bottle_ext
|
||||||
/(\.(tar|cpio|pax)\.(gz|bz2|lz|xz|Z))$/.match(path)
|
archive_ext = path[/(\.(tar|cpio|pax)\.(gz|bz2|lz|xz|Z))$/, 1]
|
||||||
return $1 if $1
|
return archive_ext if archive_ext
|
||||||
File.extname(path)
|
File.extname(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -445,8 +445,8 @@ class Pathname
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if RUBY_VERSION == "2.0.0"
|
|
||||||
# https://bugs.ruby-lang.org/issues/9915
|
# https://bugs.ruby-lang.org/issues/9915
|
||||||
|
if RUBY_VERSION == "2.0.0"
|
||||||
prepend Module.new {
|
prepend Module.new {
|
||||||
def inspect
|
def inspect
|
||||||
super.force_encoding(@path.encoding)
|
super.force_encoding(@path.encoding)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user