Class: Cask::Artifact::Relocated Private
- Inherits:
-
AbstractArtifact
- Object
- AbstractArtifact
- Cask::Artifact::Relocated
- Defined in:
- cask/artifact/relocated.rb
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Superclass for all artifacts which have a source and a target location.
Instance Attribute Summary
Attributes inherited from AbstractArtifact
Class Method Summary collapse
-
.from_args(cask, *args) ⇒ Object
private
Instance Method Summary collapse
-
#initialize(cask, source, **target_hash) ⇒ void
constructor
private
-
#resolve_target(target, base_dir: config.public_send(self.class.dirmethod)) ⇒ Object
private
-
#source ⇒ Object
private
-
#summarize ⇒ String
private
-
#target ⇒ Object
private
-
#to_a ⇒ Object
private
Methods inherited from AbstractArtifact
#<=>, #config, dirmethod, dsl_key, english_article, english_name, read_script_arguments, #staged_path_join_executable, #to_args, #to_s
Methods included from Predicable
Constructor Details
#initialize(cask, source, **target_hash) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
41 42 43 44 45 46 47 |
# File 'cask/artifact/relocated.rb', line 41 def initialize(cask, source, **target_hash) super(cask, source, **target_hash) target = target_hash[:target] @source_string = source.to_s @target_string = target.to_s end |
Class Method Details
.from_args(cask, *args) ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'cask/artifact/relocated.rb', line 12 def self.from_args(cask, *args) source_string, target_hash = args if target_hash raise CaskInvalidError unless target_hash.respond_to?(:keys) target_hash.assert_valid_keys(:target) end target_hash ||= {} new(cask, source_string, **target_hash) end |
Instance Method Details
#resolve_target(target, base_dir: config.public_send(self.class.dirmethod)) ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
26 27 28 29 30 31 32 33 34 35 |
# File 'cask/artifact/relocated.rb', line 26 def resolve_target(target, base_dir: config.public_send(self.class.dirmethod)) target = Pathname(target) if target.relative? return target. if target.descend.first.to_s == "~" return base_dir/target if base_dir end target end |
#source ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
49 50 51 52 53 54 55 |
# File 'cask/artifact/relocated.rb', line 49 def source @source ||= begin base_path = cask.staged_path base_path = base_path.join(cask.url.only_path) if cask.url&.only_path.present? base_path.join(@source_string) end end |
#summarize ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
68 69 70 71 |
# File 'cask/artifact/relocated.rb', line 68 def summarize target_string = @target_string.empty? ? "" : " -> #{@target_string}" "#{@source_string}#{target_string}" end |
#target ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
57 58 59 |
# File 'cask/artifact/relocated.rb', line 57 def target @target ||= resolve_target(@target_string.presence || source.basename) end |
#to_a ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
61 62 63 64 65 |
# File 'cask/artifact/relocated.rb', line 61 def to_a [@source_string].tap do |ary| ary << { target: @target_string } unless @target_string.empty? end end |