aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2014-12-10 00:53:57 -0500
committerJack Nagel2014-12-10 00:55:26 -0500
commitbc0c203934f67624a4a3cd2bd15f1b4eb93b0236 (patch)
treec9cfb748ac5f5168b8a27bdd532b97a4715fa055 /Library
parent576258a00a6bf0ca29a3c32f79e4d52ed7a57cd0 (diff)
downloadhomebrew-bc0c203934f67624a4a3cd2bd15f1b4eb93b0236.tar.bz2
Provide version reader method
Diffstat (limited to 'Library')
-rw-r--r--Library/Formula/rpm.rb10
-rw-r--r--Library/Homebrew/download_strategy.rb7
-rw-r--r--Library/Homebrew/test/test_download_strategies.rb2
3 files changed, 8 insertions, 11 deletions
diff --git a/Library/Formula/rpm.rb b/Library/Formula/rpm.rb
index 0d685c9c4..ac2fac36b 100644
--- a/Library/Formula/rpm.rb
+++ b/Library/Formula/rpm.rb
@@ -1,14 +1,10 @@
require 'formula'
class RpmDownloadStrategy < CurlDownloadStrategy
- def initialize name, resource
- super
- @tarball_name = "#{name}-#{resource.version}.tar.gz"
- end
-
def stage
- safe_system "rpm2cpio.pl <#{cached_location} | cpio -vi #{@tarball_name}"
- safe_system "/usr/bin/tar -xzf #{@tarball_name} && rm #{@tarball_name}"
+ tarball_name = "#{name}-#{version}.tar.gz"
+ safe_system "rpm2cpio.pl <#{cached_location} | cpio -vi #{tarball_name}"
+ safe_system "/usr/bin/tar -xzf #{tarball_name} && rm #{tarball_name}"
chdir
end
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 84cbf3778..bc31babd9 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -3,12 +3,13 @@ require 'utils/json'
class AbstractDownloadStrategy
include FileUtils
- attr_reader :meta, :name, :resource
+ attr_reader :meta, :name, :version, :resource
def initialize name, resource
@name = name
@resource = resource
@url = resource.url
+ @version = resource.version
@meta = resource.specs
end
@@ -120,7 +121,7 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
end
def head?
- resource.version.head?
+ version.head?
end
private
@@ -155,7 +156,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
def initialize(name, resource)
super
@mirrors = resource.mirrors.dup
- @tarball_path = HOMEBREW_CACHE.join("#{name}-#{resource.version}#{ext}")
+ @tarball_path = HOMEBREW_CACHE.join("#{name}-#{version}#{ext}")
@temporary_path = Pathname.new("#{cached_location}.incomplete")
end
diff --git a/Library/Homebrew/test/test_download_strategies.rb b/Library/Homebrew/test/test_download_strategies.rb
index 3dabc7af7..2f4a324ef 100644
--- a/Library/Homebrew/test/test_download_strategies.rb
+++ b/Library/Homebrew/test/test_download_strategies.rb
@@ -2,7 +2,7 @@ require 'testing_env'
require 'download_strategy'
class ResourceDouble
- attr_reader :url, :specs
+ attr_reader :url, :specs, :version
def initialize(url="http://example.com/foo.tar.gz", specs={})
@url = url