Class: Cask::CaskLoader::FromContentLoader Private
- Inherits:
-
AbstractContentLoader
- Object
- AbstractContentLoader
- Cask::CaskLoader::FromContentLoader
- 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
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(content, tap: T.unsafe(nil)) ⇒ void constructor private
- #load(config:) ⇒ Cask private
Methods included from Utils::Output::Mixin
#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_deprecated, #pretty_disabled, #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.
94 95 96 97 98 99 |
# File 'cask/cask_loader.rb', line 94 def initialize(content, tap: T.unsafe(nil)) super() @content = T.let(content.dup.force_encoding("UTF-8"), String) @tap = T.let(tap, T.nilable(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.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'cask/cask_loader.rb', line 72 def self.try_new(ref, warn: false) return if ref.is_a?(Cask) content = ref.to_str # Cache compiled regex @regex ||= T.let( 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, T.nilable(Regexp), ) return unless content.match?(@regex) new(content) 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.
102 103 104 105 106 |
# File 'cask/cask_loader.rb', line 102 def load(config:) @config = config instance_eval(content, __FILE__, __LINE__) end |