2015-01-01 22:08:06 +08:00
|
|
|
class Hbc::Caveats
|
2014-01-15 06:41:11 +08:00
|
|
|
def initialize(block)
|
|
|
|
@block = block
|
|
|
|
end
|
|
|
|
|
|
|
|
def eval_and_print(cask)
|
2015-01-01 22:08:06 +08:00
|
|
|
Hbc::CaveatsDSL.new(cask, @block)
|
2014-01-15 06:41:11 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-01-01 22:08:06 +08:00
|
|
|
class Hbc::CaveatsDSL
|
2014-01-15 06:41:11 +08:00
|
|
|
# constructor; implicitly renders caveat text by evaluating
|
|
|
|
# block in the context of the DSL
|
|
|
|
def initialize(cask, block)
|
|
|
|
@cask = cask
|
|
|
|
retval = instance_eval &block
|
2014-02-12 22:27:49 +08:00
|
|
|
unless retval.nil?
|
|
|
|
puts retval.to_s.sub(/[\r\n \t]*\Z/, "\n\n")
|
|
|
|
end
|
2014-01-15 06:41:11 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# helpers
|
2014-11-29 03:36:16 +08:00
|
|
|
def token
|
|
|
|
@cask.token
|
|
|
|
end
|
|
|
|
|
2014-06-17 00:56:31 +08:00
|
|
|
def version
|
|
|
|
@cask.version
|
|
|
|
end
|
|
|
|
|
2014-01-15 06:41:11 +08:00
|
|
|
def caskroom_path
|
2015-02-10 05:28:59 +08:00
|
|
|
@cask.caskroom_path
|
2014-01-15 06:41:11 +08:00
|
|
|
end
|
|
|
|
|
2014-10-19 00:23:36 +08:00
|
|
|
def staged_path
|
2015-02-10 05:28:59 +08:00
|
|
|
@cask.staged_path
|
2014-01-15 06:41:11 +08:00
|
|
|
end
|
|
|
|
|
2014-02-12 22:27:49 +08:00
|
|
|
# DSL. Each method should handle output, following the convention of
|
|
|
|
# at least one trailing blank line so that the user can distinguish
|
|
|
|
# separate caveats.
|
|
|
|
#
|
|
|
|
# ( The return value of the last method in the block is also sent
|
|
|
|
# to the output by the caller, but that feature is only for the
|
|
|
|
# convenience of Cask authors. )
|
2014-10-14 23:34:44 +08:00
|
|
|
|
2014-01-15 06:41:11 +08:00
|
|
|
def path_environment_variable(path)
|
|
|
|
puts <<-EOS.undent
|
|
|
|
To use #{@cask}, you may need to add the #{path} directory
|
|
|
|
to your PATH environment variable, eg (for bash shell):
|
|
|
|
|
|
|
|
export PATH=#{path}:"$PATH"
|
|
|
|
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2014-03-27 21:21:43 +08:00
|
|
|
def zsh_path_helper(path)
|
|
|
|
puts <<-EOS.undent
|
|
|
|
To use #{@cask}, zsh users may need to add the following line to their
|
|
|
|
~/.zprofile. (Among other effects, #{path} will be added to the
|
|
|
|
PATH environment variable):
|
|
|
|
|
|
|
|
eval `/usr/libexec/path_helper -s`
|
|
|
|
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2014-01-15 06:41:11 +08:00
|
|
|
def files_in_usr_local
|
|
|
|
localpath = '/usr/local'
|
2015-01-07 22:09:53 +08:00
|
|
|
if Hbc.homebrew_prefix.to_s.downcase.index(localpath) == 0
|
2014-01-15 06:41:11 +08:00
|
|
|
puts <<-EOS.undent
|
|
|
|
Cask #{@cask} installs files under "#{localpath}". The presence of such
|
|
|
|
files can cause warnings when running "brew doctor", which is considered
|
|
|
|
to be a bug in homebrew-cask.
|
2014-02-12 22:27:49 +08:00
|
|
|
|
2014-01-15 06:41:11 +08:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-01-08 23:05:47 +08:00
|
|
|
def depends_on_java(java_version = 'any')
|
|
|
|
if java_version == 'any'
|
2016-01-05 23:11:56 +08:00
|
|
|
puts <<-EOS.undent
|
|
|
|
#{@cask} requires Java. You can install the latest version with
|
|
|
|
|
|
|
|
brew cask install java
|
|
|
|
|
2016-01-08 23:05:47 +08:00
|
|
|
EOS
|
|
|
|
elsif java_version =~ /8/ || java_version =~ /\+/
|
|
|
|
puts <<-EOS.undent
|
|
|
|
#{@cask} requires Java #{java_version}. You can install the latest version with
|
|
|
|
|
|
|
|
brew cask install java
|
|
|
|
|
2016-01-05 23:11:56 +08:00
|
|
|
EOS
|
|
|
|
else
|
|
|
|
puts <<-EOS.undent
|
|
|
|
#{@cask} requires Java #{java_version}. You can install it with
|
|
|
|
|
|
|
|
brew cask install caskroom/versions/java#{java_version}
|
|
|
|
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-15 06:41:11 +08:00
|
|
|
def logout
|
2014-01-21 04:14:43 +08:00
|
|
|
puts <<-EOS.undent
|
2014-01-15 06:41:11 +08:00
|
|
|
You must log out and log back in for the installation of #{@cask}
|
|
|
|
to take effect.
|
2014-02-12 22:27:49 +08:00
|
|
|
|
2014-01-15 06:41:11 +08:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def reboot
|
2014-01-21 04:14:43 +08:00
|
|
|
puts <<-EOS.undent
|
2014-01-15 06:41:11 +08:00
|
|
|
You must reboot for the installation of #{@cask} to take effect.
|
2014-02-12 22:27:49 +08:00
|
|
|
|
2014-01-15 06:41:11 +08:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2015-01-27 00:55:24 +08:00
|
|
|
def discontinued
|
|
|
|
puts <<-EOS.undent
|
|
|
|
#{@cask} has been officially discontinued upstream.
|
|
|
|
It may stop working correctly (or at all) in recent versions of OS X.
|
|
|
|
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2015-01-27 01:12:06 +08:00
|
|
|
def free_license(web_page)
|
|
|
|
puts <<-EOS.undent
|
|
|
|
The vendor offers a free license for #{@cask} at
|
|
|
|
#{web_page}
|
|
|
|
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2014-01-15 06:41:11 +08:00
|
|
|
def method_missing(method, *args)
|
2015-01-01 22:08:06 +08:00
|
|
|
Hbc::Utils.method_missing_message(method, @cask.to_s, 'caveats')
|
2014-01-15 06:41:11 +08:00
|
|
|
return nil
|
|
|
|
end
|
|
|
|
end
|