diff options
| author | Markus Reiter | 2017-12-03 21:21:31 +0100 |
|---|---|---|
| committer | Markus Reiter | 2018-01-27 21:47:18 +0100 |
| commit | b4df0246256519cf3879263eb7447cfcd5498491 (patch) | |
| tree | d79c6d8aa1a650a3f71312433fabed94fcfdebf6 | |
| parent | 6760d26319c6fcbf8ba74bd737530adc7831da22 (diff) | |
| download | brew-b4df0246256519cf3879263eb7447cfcd5498491.tar.bz2 | |
Allow passing down configuration into Cask.
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/artifact/abstract_artifact.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/artifact/artifact.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/artifact/relocated.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cask.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/dsl.rb | 2 |
5 files changed, 10 insertions, 8 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/abstract_artifact.rb b/Library/Homebrew/cask/lib/hbc/artifact/abstract_artifact.rb index f9f736662..077105468 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/abstract_artifact.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/abstract_artifact.rb @@ -95,10 +95,11 @@ module Hbc [executable, arguments] end - attr_reader :cask + attr_reader :cask, :config def initialize(cask) @cask = cask + @config = cask.config end def to_s diff --git a/Library/Homebrew/cask/lib/hbc/artifact/artifact.rb b/Library/Homebrew/cask/lib/hbc/artifact/artifact.rb index 0f37afade..b7df4b0bd 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/artifact.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/artifact.rb @@ -25,7 +25,7 @@ module Hbc new(cask, source_string, **target_hash) end - def self.resolve_target(target) + def resolve_target(target) Pathname(target) end diff --git a/Library/Homebrew/cask/lib/hbc/artifact/relocated.rb b/Library/Homebrew/cask/lib/hbc/artifact/relocated.rb index 155d52c06..9195d889a 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/relocated.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/relocated.rb @@ -18,8 +18,8 @@ module Hbc new(cask, source_string, **target_hash) end - def self.resolve_target(target) - Config.global.public_send(dirmethod).join(target) + def resolve_target(target) + config.public_send(self.class.dirmethod).join(target) end attr_reader :source, :target @@ -32,7 +32,7 @@ module Hbc source = cask.staged_path.join(source) @source = source target ||= source.basename - @target = self.class.resolve_target(target) + @target = resolve_target(target) end def to_a diff --git a/Library/Homebrew/cask/lib/hbc/cask.rb b/Library/Homebrew/cask/lib/hbc/cask.rb index df885371a..681130c1b 100644 --- a/Library/Homebrew/cask/lib/hbc/cask.rb +++ b/Library/Homebrew/cask/lib/hbc/cask.rb @@ -6,17 +6,18 @@ module Hbc extend Forwardable include Metadata - attr_reader :token, :sourcefile_path + attr_reader :token, :sourcefile_path, :config def tap return super if block_given? # Object#tap @tap end - def initialize(token, sourcefile_path: nil, tap: nil, &block) + def initialize(token, sourcefile_path: nil, tap: nil, config: Config.global, &block) @token = token @sourcefile_path = sourcefile_path @tap = tap + @config = config @dsl = DSL.new(self) return unless block_given? @dsl.instance_eval(&block) diff --git a/Library/Homebrew/cask/lib/hbc/dsl.rb b/Library/Homebrew/cask/lib/hbc/dsl.rb index 969fc8680..9a88f1b62 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl.rb @@ -292,7 +292,7 @@ module Hbc end def appdir - Config.global.appdir + cask.config.appdir end end end |
