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

#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled

Constructor Details

#initialize(content, tap: T.unsafe(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) (defaults to: T.unsafe(nil))
 84 85 86 87 88 89
# File 'cask/cask_loader.rb', line 84 def initialize(content, tap: T.unsafe(nil)) super() @content = content.dup.force_encoding("UTF-8") @tap = tap end

Class Method Details

.try_new(ref, warn: false) ⇒ T.attached_class?

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:

  • (T.attached_class, nil)
 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
# File 'cask/cask_loader.rb', line 65 def self.try_new(ref, warn: false) return if ref.is_a?(Cask) content = ref.to_str # Cache compiled regex  @regex ||= begin token = /(?:"[^"]*"|'[^']*')/ curly = /\(\s*#{token.source}\s*\)\s*\{.*\}/ do_end = /\s+#{token.source}\s+do(?:\s*;\s*|\s+).*end/ /\A\s*cask(?:#{curly.source}|#{do_end.source})\s*\Z/m end return unless content.match?(@regex) new(content) end

Instance Method Details

#load(config:) ⇒ 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.

 91 92 93 94 95
# File 'cask/cask_loader.rb', line 91 def load(config:) @config = config instance_eval(content, __FILE__, __LINE__) end