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
-
.can_load?(ref) ⇒ Boolean
private
Instance Method Summary collapse
-
#initialize(content, tap: nil) ⇒ FromContentLoader
constructor
private
A new instance of FromContentLoader.
-
#load(config:) ⇒ Object
private
Constructor Details
#initialize(content, tap: nil) ⇒ FromContentLoader
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.
Returns a new instance of FromContentLoader.
67 68 69 70 71 72 |
# File 'cask/cask_loader.rb', line 67 def initialize(content, tap: nil) super() @content = content.force_encoding("UTF-8") @tap = tap end |
Class Method Details
.can_load?(ref) ⇒ 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.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'cask/cask_loader.rb', line 51 def self.can_load?(ref) return false unless ref.respond_to?(:to_str) 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 content.match?(@regex) 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.
74 75 76 77 78 |
# File 'cask/cask_loader.rb', line 74 def load(config:) @config = config instance_eval(content, __FILE__, __LINE__) end |