Class: Cask::DSL::Caveats

Inherits:
Base
  • Object
show all
Defined in:
brew/Library/Homebrew/cask/dsl/caveats.rb

Instance Method Summary collapse

Methods inherited from Base

#method_missing, #respond_to_missing?, #system_command

Constructor Details

#initialize(*args) ⇒ Caveats

Returns a new instance of Caveats



13
14
15
16
17
# File 'brew/Library/Homebrew/cask/dsl/caveats.rb', line 13

def initialize(*args)
  super(*args)
  @built_in_caveats = {}
  @custom_caveats = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Cask::DSL::Base

Instance Method Details

#eval_caveats(&block) ⇒ Object



40
41
42
43
44
45
46
# File 'brew/Library/Homebrew/cask/dsl/caveats.rb', line 40

def eval_caveats(&block)
  result = instance_eval(&block)
  return unless result
  return if result == :built_in_caveat

  @custom_caveats << result.to_s.sub(/\s*\Z/, "\n")
end

#puts(*args) ⇒ Object

Override puts to collect caveats.



35
36
37
38
# File 'brew/Library/Homebrew/cask/dsl/caveats.rb', line 35

def puts(*args)
  @custom_caveats += args
  :built_in_caveat
end

#to_sObject



30
31
32
# File 'brew/Library/Homebrew/cask/dsl/caveats.rb', line 30

def to_s
  (@custom_caveats + @built_in_caveats.values).join("\n")
end