Class: Hbc::Artifact::Artifact

Inherits:
Moved show all
Defined in:
Library/Homebrew/cask/lib/hbc/artifact/artifact.rb

Instance Attribute Summary

Attributes inherited from Relocated

#source, #target

Attributes inherited from AbstractArtifact

#cask, #config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Moved

english_description, #install_phase, #summarize_installed, #uninstall_phase

Methods inherited from Relocated

#summarize, #to_a

Methods inherited from AbstractArtifact

#<=>, dirmethod, dsl_key, english_article, read_script_arguments, #to_s

Methods included from Predicable

#attr_predicate

Constructor Details

#initialize(cask, source, target: nil) ⇒ Artifact

Returns a new instance of Artifact



32
33
34
# File 'Library/Homebrew/cask/lib/hbc/artifact/artifact.rb', line 32

def initialize(cask, source, target: nil)
  super(cask, source, target: target)
end

Class Method Details

.english_nameObject



8
9
10
# File 'Library/Homebrew/cask/lib/hbc/artifact/artifact.rb', line 8

def self.english_name
  "Generic Artifact"
end

.from_args(cask, *args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'Library/Homebrew/cask/lib/hbc/artifact/artifact.rb', line 12

def self.from_args(cask, *args)
  source_string, target_hash = args

  if source_string.nil?
    raise CaskInvalidError.new(cask.token, "no source given for #{english_name}")
  end

  unless target_hash.is_a?(Hash)
    raise CaskInvalidError.new(cask.token, "target required for #{english_name} '#{source_string}'")
  end

  target_hash.extend(HashValidator).assert_valid_keys(:target)

  new(cask, source_string, **target_hash)
end

Instance Method Details

#resolve_target(target) ⇒ Object



28
29
30
# File 'Library/Homebrew/cask/lib/hbc/artifact/artifact.rb', line 28

def resolve_target(target)
  Pathname(target)
end