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
commit67d0e541cefe9994c09bcdc67f27b1dc8fb47336 (patch)
tree18d0e0466123de1099637c97fe5068a5ea93d3d9 /Library
parentfde8e61155d6944b92db9d91c84374d02d8ba43f (diff)
downloadhomebrew-67d0e541cefe9994c09bcdc67f27b1dc8fb47336.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