Class: Ukiryu::Definition::Sources::StringSource
- Inherits:
-
Ukiryu::Definition::Source
- Object
- Ukiryu::Definition::Source
- Ukiryu::Definition::Sources::StringSource
- Defined in:
- lib/ukiryu/definition/sources/string.rb
Overview
Load tool definitions from a YAML string
This source handles YAML content provided directly as a string, useful for definitions obtained via command-line flags or programmatic generation.
Instance Attribute Summary collapse
-
#content ⇒ String
readonly
The YAML content.
-
#content_hash ⇒ String
readonly
The SHA256 hash of the content.
Instance Method Summary collapse
-
#cache_key ⇒ String
Get a unique cache key for this string source.
-
#initialize(content) ⇒ StringSource
constructor
Create a new string-based definition source.
-
#load ⇒ String
Load the YAML definition content.
-
#size ⇒ Integer
Get the size of the content in bytes.
-
#source_type ⇒ Symbol
Get the source type.
Methods inherited from Ukiryu::Definition::Source
Constructor Details
#initialize(content) ⇒ StringSource
Create a new string-based definition source
25 26 27 28 |
# File 'lib/ukiryu/definition/sources/string.rb', line 25 def initialize(content) @content = validate_content!(content) @content_hash = sha256(@content) end |
Instance Attribute Details
#content ⇒ String (readonly)
The YAML content
14 15 16 |
# File 'lib/ukiryu/definition/sources/string.rb', line 14 def content @content end |
#content_hash ⇒ String (readonly)
The SHA256 hash of the content
18 19 20 |
# File 'lib/ukiryu/definition/sources/string.rb', line 18 def content_hash @content_hash end |
Instance Method Details
#cache_key ⇒ String
Get a unique cache key for this string source
The cache key is based on the SHA256 hash of the content, ensuring identical strings produce identical cache keys.
50 51 52 |
# File 'lib/ukiryu/definition/sources/string.rb', line 50 def cache_key "string:#{content_hash}" end |
#load ⇒ String
Load the YAML definition content
33 34 35 |
# File 'lib/ukiryu/definition/sources/string.rb', line 33 def load @content end |
#size ⇒ Integer
Get the size of the content in bytes
57 58 59 |
# File 'lib/ukiryu/definition/sources/string.rb', line 57 def size @content.bytesize end |
#source_type ⇒ Symbol
Get the source type
40 41 42 |
# File 'lib/ukiryu/definition/sources/string.rb', line 40 def source_type :string end |