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:) ⇒ Object private
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.
77 78 79 80 81 82 |
# File 'cask/cask_loader.rb', line 77 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.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'cask/cask_loader.rb', line 58 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.
84 85 86 87 88 |
# File 'cask/cask_loader.rb', line 84 def load(config:) @config = config instance_eval(content, __FILE__, __LINE__) end |