aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2014-12-25 20:43:40 +0000
committerMike McQuaid2014-12-28 12:14:49 +0000
commit88208af8e488fe202fd5cb6b96a9f508ca635d5e (patch)
tree620bb6f90701da3beb7527840d0d4b2165da796f /Library
parent7b0cc143cbde69a7b99322a4e4000459acf0eb12 (diff)
downloadbrew-88208af8e488fe202fd5cb6b96a9f508ca635d5e.tar.bz2
requirement: add cask and download attributes.
Print out the message pointing to the Cask and/or download location too.a
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/requirement.rb30
1 files changed, 28 insertions, 2 deletions
diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb
index d06d65d6b..760e0f287 100644
--- a/Library/Homebrew/requirement.rb
+++ b/Library/Homebrew/requirement.rb
@@ -9,17 +9,42 @@ require 'build_environment'
class Requirement
include Dependable
- attr_reader :tags, :name
+ attr_reader :tags, :name, :cask, :download
alias_method :option_name, :name
def initialize(tags=[])
+ @cask ||= self.class.cask
+ @download ||= self.class.download
+ tags.each do |tag|
+ next unless tag.is_a? Hash
+ @cask ||= tag[:cask]
+ @download ||= tag[:download]
+ end
@tags = tags
@tags << :build if self.class.build
@name ||= infer_name
end
# The message to show when the requirement is not met.
- def message; "" end
+ def message
+ s = ""
+ if cask
+ s += <<-EOS.undent
+
+ You can install with Homebrew Cask:
+ brew install Caskroom/cask/#{cask}
+ EOS
+ end
+
+ if download
+ s += <<-EOS.undent
+
+ You can download from:
+ #{download}
+ EOS
+ end
+ s
+ end
# Overriding #satisfied? is deprecated.
# Pass a block or boolean to the satisfy DSL method instead.
@@ -110,6 +135,7 @@ class Requirement
attr_reader :env_proc
attr_rw :fatal, :default_formula
+ attr_rw :cask, :download
# build is deprecated, use `depends_on <requirement> => :build` instead
attr_rw :build