Class: Cask::CaskLoader::FromContentLoader Private

Inherits:
AbstractContentLoader show all
Defined in:
cask/cask_loader.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.

Loads a cask from a string.

Instance Attribute Summary

Attributes inherited from AbstractContentLoader

#content, #tap

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::Output::Mixin

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_once, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_removed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning

Constructor Details

#initialize(content, tap: nil) ⇒ 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.

Parameters:

  • content (String)
  • tap (Tap, nil) (defaults to: nil)


73
74
75
76
77
78
# File 'cask/cask_loader.rb', line 73

def initialize(content, tap: nil)
  super()

  @content = T.let(content.dup.force_encoding("UTF-8"), String)
  @tap = tap
end

Class Method Details

.try_new(_ref, warn: false) ⇒ nil

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.

Parameters:

  • _ref (String)
  • warn (Boolean) (defaults to: false)

Returns:

  • (nil)


67
68
69
70
# File 'cask/cask_loader.rb', line 67

def self.try_new(_ref, warn: false)
  CaskLoader.odeprecated "Cask::CaskLoader::FromContentLoader.try_new", "Cask::CaskLoader.from_content"
  nil
end

Instance Method Details

#load(config:) ⇒ Cask

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.

Parameters:

Returns:

Raises:



81
82
83
84
85
86
87
88
89
90
# File 'cask/cask_loader.rb', line 81

def load(config:)
  @config = config

  cask = ENV.clear_sensitive_environment_for_eval! do
    instance_eval(content, "(cask content)")
  end
  raise CaskUnavailableError.new("(content)", "Source does not contain a cask.") unless cask.is_a?(Cask)

  cask
end