Browse Source

support for caveats

i.e. custom messages printed after installing a cask

refs #218
phinze 12 years ago
parent
commit
7a1a6a9308
  1. 8
      Casks/adobe-air.rb
  2. 2
      lib/cask/dsl.rb
  3. 4
      lib/cask/installer.rb
  4. 20
      test/cask/dsl_test.rb
  5. 8
      test/cask/installer_test.rb
  6. 11
      test/support/Casks/with-caveats.rb
  7. 6
      test/test_helper.rb

8
Casks/adobe-air.rb

@ -2,10 +2,12 @@ class AdobeAir < Cask
url 'http://airdownload.adobe.com/air/mac/download/3.5/AdobeAIR.dmg'
homepage 'https://get.adobe.com/air/'
version '3.5'
#caveat 'You need to run {{install_path}}/AdobeAIRInstaller.app to actually install Adobe AIR'
sha1 '8fbd2dffc20442903d8b51e7362a3191f39752b4'
link :app, :none
def caveats; <<-EOS.undent
You need to run #{destination_path/'AdobeAIRInstaller.app'} to actually install Adobe AIR
EOS
end
end

2
lib/cask/dsl.rb

@ -16,6 +16,8 @@ module Cask::DSL
def linkables; self.class.linkables || {}; end
def caveats; ''; end
module ClassMethods
def homepage(homepage=nil)
@homepage ||= homepage

4
lib/cask/installer.rb

@ -17,6 +17,10 @@ class Cask::Installer
end
ohai "Success! #{cask} installed to #{cask.destination_path}"
unless cask.caveats.empty?
ohai 'Caveats', cask.caveats
end
end
def uninstall(cask)

20
test/cask/dsl_test.rb

@ -69,4 +69,24 @@ describe Cask::DSL do
instance = CaskWithNoLinkables.new
Array(instance.linkable_apps).must_equal %w[]
end
it "allows caveats to be specified via a method define" do
PlainCask = Class.new(Cask)
instance = PlainCask.new
instance.caveats.must_be :empty?
CaskWithCaveats = Class.new(Cask)
CaskWithCaveats.class_eval do
def caveats; <<-EOS.undent
When you install this cask, you probably want to know this.
EOS
end
end
instance = CaskWithCaveats.new
instance.caveats.must_equal "When you install this cask, you probably want to know this.\n"
end
end

8
test/cask/installer_test.rb

@ -53,6 +53,14 @@ describe Cask::Installer do
end
no_checksum.must_be :installed?
end
it "prints caveats if they're present" do
with_caveats = Cask.load('with-caveats')
TestHelper.must_output(self, lambda {
Cask::Installer.install(with_caveats)
}, /Here are some things you might want to know/)
with_caveats.must_be :installed?
end
end
describe "uninstall" do

11
test/support/Casks/with-caveats.rb

@ -0,0 +1,11 @@
class WithCaveats < TestCask
url TestHelper.local_binary('caffeine.zip')
homepage 'http://example.com/local-caffeine'
version '1.2.3'
sha1 'd2fbdad1619934313026fc831e6c6e3dd97ac030'
def caveats; <<-EOS.undent
Here are some things you might want to know.
EOS
end
end

6
test/test_helper.rb

@ -58,7 +58,11 @@ class TestHelper
lambda.call
end
(out+err).chomp.must_equal expected.gsub(/^ */, '')
if expected.is_a? Regexp
(out+err).chomp.must_match expected
else
(out+err).chomp.must_equal expected.gsub(/^ */, '')
end
end
def self.valid_alias?(candidate)

Loading…
Cancel
Save