mirror of
https://github.com/wavetermdev/homebrew-cask.git
synced 2026-08-05 13:43:24 -07:00
Merge pull request #2637 from rolandwalker/version_caveats
add os_version_only to caveats DSL
This commit is contained in:
@@ -320,6 +320,7 @@ The following methods may be called to generate standard warning messages:
|
||||
| `reboot` | The user should reboot to complete installation
|
||||
| `files_in_usr_local` | The Cask installs files to `/usr/local`, which may confuse Homebrew
|
||||
| `arch_only(list)` | The Cask only supports certain architectures. Currently valid elements of `list` are `intel-32` and `intel-64`
|
||||
| `os_version_only(list)` | The Cask only supports certain OS X Versions. Currently valid elements of `list` are `10.5`, `10.6`, `10.7`, `10.8`, and `10.9`
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@@ -104,6 +104,32 @@ class Cask::CaveatsDSL
|
||||
end
|
||||
end
|
||||
|
||||
# minor bug: because output from os_version_only is conditional, the
|
||||
# existence of this directive causes the "===> Caveats" header to
|
||||
# appear even if no warning is output. One workaround would
|
||||
# be to spin out os-version-detection from caveats into a separate
|
||||
# Cask stanza, and that is probably a sensible design.
|
||||
def os_versions_only(*supported_versions)
|
||||
known_versions = %w{10.0 10.1 10.2 10.3 10.3 10.5 10.6 10.7 10.8 10.9}
|
||||
supported_versions.each do |version|
|
||||
unless known_versions.include?(version)
|
||||
# There ought to be some standard exceptions for Cask validation errors
|
||||
raise "The only valid arguments to caveats os_version_only in #{@cask} are: #{known_versions.join(', ')}"
|
||||
end
|
||||
end
|
||||
unless supported_versions.include?(MACOS_VERSION)
|
||||
puts <<-EOS.undent
|
||||
Cask #{@cask} provides binaries for these OS versions: #{supported_versions.join(', ')}.
|
||||
But you appear to be running on an unsupported version
|
||||
|
||||
#{MACOS_VERSION}
|
||||
|
||||
Therefore #{@cask} is not expected to work on your system.
|
||||
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
def method_missing(method, *args)
|
||||
poo = <<-EOPOO.undent
|
||||
Unexpected method #{method} called on caveats in Cask #{@cask}.
|
||||
|
||||
@@ -16,6 +16,9 @@ class WithCaveats < TestCask
|
||||
caveats do
|
||||
puts 'Custom text via puts followed by DSL-generated text:'
|
||||
manual_installer('Installer.app')
|
||||
# since all known OS versions are specified, no output should be
|
||||
# generated here during the test
|
||||
os_versions_only('10.0', '10.1', '10.2', '10.3', '10.3', '10.5', '10.6', '10.7', '10.8', '10.9')
|
||||
end
|
||||
caveats do
|
||||
# since both valid arches are specified, no output should be
|
||||
|
||||
Reference in New Issue
Block a user