aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/dsl/base.rb
blob: 4bf62014e692cb6944f1d38994088d5ffd8a86c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Hbc::DSL::Base
  extend Forwardable

  def initialize(cask, command = Hbc::SystemCommand)
    @cask = cask
    @command = command
  end

  def_delegators :@cask, :token, :version, :caskroom_path, :staged_path, :appdir

  def system_command(executable, options = {})
    @command.run!(executable, options)
  end

  def method_missing(method, *)
    underscored_class = self.class.name.gsub(%r{([[:lower:]])([[:upper:]][[:lower:]])}, '\1_\2').downcase
    section = underscored_class.downcase.split("::").last
    Hbc::Utils.method_missing_message(method, @cask.to_s, section)
    nil
  end
end