Class: Ukiryu::Definition::Loader
- Inherits:
-
Object
- Object
- Ukiryu::Definition::Loader
- Defined in:
- lib/ukiryu/definition/loader.rb
Overview
Loader for tool definitions from various sources
The loader orchestrates loading tool definitions from different sources (files, strings, bundled locations, register) and provides a unified interface for definition loading.
Class Method Summary collapse
-
.clear_cache(source = nil) ⇒ Object
Clear the profile cache.
-
.load_from_file(path, options = {}) ⇒ Models::ToolDefinition
Load a tool definition from a file path.
-
.load_from_source(source, options = {}) ⇒ Models::ToolDefinition
Load a tool definition from a source.
-
.load_from_string(yaml_string, options = {}) ⇒ Models::ToolDefinition
Load a tool definition from a YAML string.
-
.profile_cache ⇒ Cache
Get the profile cache (bounded LRU cache).
Class Method Details
.clear_cache(source = nil) ⇒ Object
Clear the profile cache
73 74 75 76 77 78 79 |
# File 'lib/ukiryu/definition/loader.rb', line 73 def clear_cache(source = nil) if source profile_cache.delete(source.cache_key) else profile_cache.clear end end |
.load_from_file(path, options = {}) ⇒ Models::ToolDefinition
Load a tool definition from a file path
48 49 50 51 |
# File 'lib/ukiryu/definition/loader.rb', line 48 def load_from_file(path, = {}) source = Sources::FileSource.new(path) load_from_source(source, ) end |
.load_from_source(source, options = {}) ⇒ Models::ToolDefinition
Load a tool definition from a source
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ukiryu/definition/loader.rb', line 19 def load_from_source(source, = {}) # Check cache first cache_key = source.cache_key return profile_cache[cache_key] if profile_cache.key?(cache_key) # Load YAML content from source yaml_content = source.load # Parse using lutaml-model profile = parse_yaml(yaml_content, source) # Validate if requested validation_mode = [:validation] || :strict validate_profile(profile, validation_mode) if validation_mode != :none # Resolve profile inheritance (merges parent commands into child profiles) profile.resolve_inheritance! # Cache the profile profile_cache[cache_key] = profile profile end |
.load_from_string(yaml_string, options = {}) ⇒ Models::ToolDefinition
Load a tool definition from a YAML string
58 59 60 61 |
# File 'lib/ukiryu/definition/loader.rb', line 58 def load_from_string(yaml_string, = {}) source = Sources::StringSource.new(yaml_string) load_from_source(source, ) end |