aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Reiter2016-08-24 12:32:17 +0200
committerGitHub2016-08-24 12:32:17 +0200
commitfa19447a2d9d311909452ee35b309d08558c9a3a (patch)
tree5b0ca185d5fd05dddc9cc5bdde563a44947487fd
parentff7d3f226ae3b2bd216539d10b1724b18be1a127 (diff)
parent85635a1e1927281edbf55ac0214357fd184c70bc (diff)
downloadbrew-fa19447a2d9d311909452ee35b309d08558c9a3a.tar.bz2
Merge pull request #793 from reitermarkus/refactoring-pathname
Merge Cask’s `Pathname` extension with Homebrew’s.
-rw-r--r--Library/Homebrew/cask/lib/hbc/container/gzip.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/extend.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/extend/pathname.rb19
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb1
-rw-r--r--Library/Homebrew/cask/spec/spec_helper.rb1
-rw-r--r--Library/Homebrew/cask/test/cask/installer_test.rb2
-rw-r--r--Library/Homebrew/cask/test/support/Casks/container-gzip.rb2
-rw-r--r--Library/Homebrew/cask/test/test_helper.rb1
-rw-r--r--Library/Homebrew/extend/pathname.rb10
9 files changed, 9 insertions, 31 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/container/gzip.rb b/Library/Homebrew/cask/lib/hbc/container/gzip.rb
index 1d2cc1f37..161578162 100644
--- a/Library/Homebrew/cask/lib/hbc/container/gzip.rb
+++ b/Library/Homebrew/cask/lib/hbc/container/gzip.rb
@@ -10,7 +10,7 @@ class Hbc::Container::Gzip < Hbc::Container::Base
def extract
Dir.mktmpdir do |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)
end
diff --git a/Library/Homebrew/cask/lib/hbc/extend.rb b/Library/Homebrew/cask/lib/hbc/extend.rb
index 629c53468..e836b6bc8 100644
--- a/Library/Homebrew/cask/lib/hbc/extend.rb
+++ b/Library/Homebrew/cask/lib/hbc/extend.rb
@@ -2,5 +2,5 @@
require "hbc/extend/hash"
require "hbc/extend/io"
require "hbc/extend/optparse"
-require "hbc/extend/pathname"
+require "extend/pathname"
require "hbc/extend/string"
diff --git a/Library/Homebrew/cask/lib/hbc/extend/pathname.rb b/Library/Homebrew/cask/lib/hbc/extend/pathname.rb
deleted file mode 100644
index 598a99cd2..000000000
--- a/Library/Homebrew/cask/lib/hbc/extend/pathname.rb
+++ /dev/null
@@ -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
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index 8e55b8a99..8f43884a3 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -1,6 +1,5 @@
require "rubygems"
-require "extend/pathname"
require "hbc/cask_dependencies"
require "hbc/staged"
require "hbc/verify"
diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb
index a826cfcf0..d197db983 100644
--- a/Library/Homebrew/cask/spec/spec_helper.rb
+++ b/Library/Homebrew/cask/spec/spec_helper.rb
@@ -13,7 +13,6 @@ project_root = Pathname.new(File.expand_path("../..", __FILE__))
$LOAD_PATH.unshift(File.expand_path("#{ENV['HOMEBREW_REPOSITORY']}/Library/Homebrew"))
require "global"
-require "extend/pathname"
# add Homebrew-Cask to load path
$LOAD_PATH.push(project_root.join("lib").to_s)
diff --git a/Library/Homebrew/cask/test/cask/installer_test.rb b/Library/Homebrew/cask/test/cask/installer_test.rb
index 34ea2e321..2275c3080 100644
--- a/Library/Homebrew/cask/test/cask/installer_test.rb
+++ b/Library/Homebrew/cask/test/cask/installer_test.rb
@@ -154,7 +154,7 @@ describe Hbc::Installer do
dest_path = Hbc.caskroom.join("container-gzip", asset.version)
dest_path.must_be :directory?
- file = Hbc.appdir.join("container-gzip--#{asset.version}")
+ file = Hbc.appdir.join("container")
file.must_be :file?
end
diff --git a/Library/Homebrew/cask/test/support/Casks/container-gzip.rb b/Library/Homebrew/cask/test/support/Casks/container-gzip.rb
index 0a5c64ba9..eac74a04c 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-gzip.rb
+++ b/Library/Homebrew/cask/test/support/Casks/container-gzip.rb
@@ -5,5 +5,5 @@ test_cask 'container-gzip' do
url TestHelper.local_binary_url('container.gz')
homepage 'https://example.com/container-gzip'
- app 'container-gzip--1.2.3'
+ app 'container'
end
diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb
index fdbd8af0e..24c979535 100644
--- a/Library/Homebrew/cask/test/test_helper.rb
+++ b/Library/Homebrew/cask/test/test_helper.rb
@@ -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"))
require "global"
-require "extend/pathname"
# add Homebrew-Cask to load path
$LOAD_PATH.push(project_root.join("lib").to_s)
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index c9cc9d3f3..324f72d1e 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -216,10 +216,10 @@ class Pathname
# extended to support common double extensions
def extname(path = to_s)
- BOTTLE_EXTNAME_RX.match(path)
- return $1 if $1
- /(\.(tar|cpio|pax)\.(gz|bz2|lz|xz|Z))$/.match(path)
- return $1 if $1
+ bottle_ext = path[BOTTLE_EXTNAME_RX, 1]
+ return bottle_ext if bottle_ext
+ archive_ext = path[/(\.(tar|cpio|pax)\.(gz|bz2|lz|xz|Z))$/, 1]
+ return archive_ext if archive_ext
File.extname(path)
end
@@ -445,8 +445,8 @@ class Pathname
end
end
+ # https://bugs.ruby-lang.org/issues/9915
if RUBY_VERSION == "2.0.0"
- # https://bugs.ruby-lang.org/issues/9915
prepend Module.new {
def inspect
super.force_encoding(@path.encoding)