diff --git a/lib/hbc/cask.rb b/lib/hbc/cask.rb index 2fb8ccbb2e..651dff2d7e 100644 --- a/lib/hbc/cask.rb +++ b/lib/hbc/cask.rb @@ -14,16 +14,6 @@ class Hbc::Cask @token = self.class.token end - def caskroom_path - Hbc.caskroom.join(token) - end - - # todo: move to staged.rb ? - def staged_path - cask_version = version ? version : :unknown - caskroom_path.join(cask_version.to_s) - end - METADATA_SUBDIR = '.metadata' def metadata_master_container_path diff --git a/lib/hbc/dsl.rb b/lib/hbc/dsl.rb index eef04b6eee..1942ecb0cf 100644 --- a/lib/hbc/dsl.rb +++ b/lib/hbc/dsl.rb @@ -222,11 +222,13 @@ module Hbc::DSL end def caskroom_path - @caskroom_path ||= self.caskroom + @caskroom_path ||= Hbc.caskroom.join(self.token) end def staged_path - @staged_path ||= self.caskroom.join(self.name, self.version) + return @staged_path if @staged_path + cask_version = self.version || :unknown + @staged_path = self.caskroom_path.join(cask_version.to_s) end def caveats(*string, &block) diff --git a/lib/hbc/without_source.rb b/lib/hbc/without_source.rb index f87407d310..489c06504c 100644 --- a/lib/hbc/without_source.rb +++ b/lib/hbc/without_source.rb @@ -1,13 +1,21 @@ class Hbc::WithoutSource < Hbc::Cask - def staged_path - caskroom_path.children.first - end - def initialize(sourcefile_path=nil) @sourcefile_path = sourcefile_path @token = sourcefile_path end + # Override from `Hbc::DSL` because `@token` is set to the constructor argument + # instead of `self.class.token` as in `Hbc::Cask`. + def caskroom_path + Hbc.caskroom.join(token) + end + + # Override from `Hbc::DSL` because we don't have a cask source file to work + # with, so we don't know the cask's `version`. + def staged_path + caskroom_path.children.first + end + def to_s "#{token} (!)" end