Class: Cask::Artifact::Symlinked Private
- Inherits:
-
Relocated
- Object
- AbstractArtifact
- Relocated
- Cask::Artifact::Symlinked
- Includes:
- OS::Mac::Cask::Artifact::Symlinked
- Defined in:
- cask/artifact/symlinked.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 are installed by symlinking them to the target location.
Direct Known Subclasses
Constant Summary
Constants inherited from AbstractArtifact
AbstractArtifact::DirectivesType
Instance Attribute Summary
Attributes inherited from AbstractArtifact
Class Method Summary collapse
- .english_description ⇒ String private
- .link_type_english_name ⇒ String private
Instance Method Summary collapse
- #install_phase(force: false, adopt: false, overwrite: false, dry_run: false, command: SystemCommand, **options) ⇒ void private
-
#link_action(force: false, adopt: false, overwrite: false) ⇒ Symbol
private
What linking would do to the current target without changing anything:
:link,:overwrite,:already_linked,:skip_formulaor:conflict. - #summarize_installed ⇒ String private
-
#target_links_to_source? ⇒ Boolean
private
Whether the target is this cask's symlink, even if the source has since gone.
- #uninstall_phase(dry_run: false, command: SystemCommand, **_options) ⇒ void private
Methods inherited from Relocated
#add_altname_metadata, from_args, #initialize, #resolve_target, #source, #summarize, #target, #to_a
Methods included from OS::Linux::Cask::Artifact::Relocated
Methods inherited from AbstractArtifact
#cask_sandbox, #config, dirmethod, dsl_key, english_article, english_name, #initialize, read_script_arguments, #run_cask_sandbox, #sort_order, #staged_path_join_executable, #summarize, #to_args
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Constructor Details
This class inherits a constructor from Cask::Artifact::Relocated
Class Method Details
.english_description ⇒ 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.
16 17 18 |
# File 'cask/artifact/symlinked.rb', line 16 def self.english_description "#{english_name} #{link_type_english_name}s" end |
.link_type_english_name ⇒ 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.
11 12 13 |
# File 'cask/artifact/symlinked.rb', line 11 def self.link_type_english_name "Symlink" end |
Instance Method Details
#install_phase(force: false, adopt: false, overwrite: false, dry_run: false, command: SystemCommand, **options) ⇒ 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.
This method returns an undefined value.
30 31 32 33 |
# File 'cask/artifact/symlinked.rb', line 30 def install_phase(force: false, adopt: false, overwrite: false, dry_run: false, command: SystemCommand, **) link(force:, adopt:, overwrite:, dry_run:, command:, **) end |
#link_action(force: false, adopt: false, overwrite: false) ⇒ Symbol
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.
What linking would do to the current target without changing anything:
:link, :overwrite, :already_linked, :skip_formula or :conflict.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'cask/artifact/symlinked.rb', line 73 def link_action(force: false, adopt: false, overwrite: false) return :link unless target.exist? if overwrite || ((force || adopt) && target.symlink? && (target_links_to_source? || target.realpath.to_s.start_with?("#{cask.caskroom_path}/"))) :overwrite elsif target_links_to_source? :already_linked elsif conflicting_formula :skip_formula else :conflict end end |
#summarize_installed ⇒ 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.
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'cask/artifact/symlinked.rb', line 47 def summarize_installed if target.symlink? && target.exist? && target.readlink.exist? "#{printable_target} -> #{target.readlink} (#{target.readlink.abv})" else string = if target.symlink? "#{printable_target} -> #{target.readlink}" else printable_target end Formatter.error(string, label: "Broken Link") end end |
#target_links_to_source? ⇒ Boolean
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.
Whether the target is this cask's symlink, even if the source has since gone.
63 64 65 66 67 68 |
# File 'cask/artifact/symlinked.rb', line 63 def target_links_to_source? target.symlink? && (target.readlink == source || target.realpath == source.realpath) rescue => e odebug "Error checking whether #{target} links to #{source}: #{e}" false end |
#uninstall_phase(dry_run: false, command: SystemCommand, **_options) ⇒ 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.
This method returns an undefined value.
42 43 44 |
# File 'cask/artifact/symlinked.rb', line 42 def uninstall_phase(dry_run: false, command: SystemCommand, **) unlink(dry_run:, command:) end |