Class: Ukiryu::Config
- Inherits:
-
Object
- Object
- Ukiryu::Config
- Defined in:
- lib/ukiryu/config.rb,
lib/ukiryu/config/env_schema.rb,
lib/ukiryu/config/env_provider.rb,
lib/ukiryu/config/type_converter.rb,
lib/ukiryu/config/override_resolver.rb
Overview
Global configuration for Ukiryu Provides unified configuration across CLI, Ruby API, and programmatic interfaces
Configuration priority (highest to lowest):
-
CLI options (passed at runtime)
-
Environment variables (UKIRYU_*)
-
Programmatic configuration (Config.configure)
-
Default values
Defined Under Namespace
Classes: EnvProvider, EnvSchema, OverrideResolver, TypeConverter
Instance Attribute Summary collapse
-
#resolver ⇒ Object
readonly
Returns the value of attribute resolver.
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Config
Configure Ukiryu with a block.
- .instance ⇒ Object
-
.method_missing(method) ⇒ Object
Delegate to instance.
-
.reset! ⇒ Object
Reset configuration to defaults.
- .respond_to_missing?(method, include_private = false) ⇒ Boolean
Instance Method Summary collapse
-
#colors_disabled? ⇒ Boolean
Check if colors are disabled Returns true if use_color is explicitly false or if NO_COLOR is set.
-
#debug ⇒ Boolean
Debug mode flag.
-
#debug=(value) ⇒ Object
Set debug mode.
-
#dry_run ⇒ Boolean
Dry run flag.
-
#dry_run=(value) ⇒ Object
Set dry run mode.
-
#format ⇒ Symbol
Output format.
-
#format=(value) ⇒ Object
Set output format.
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#metrics ⇒ Boolean
Metrics collection flag.
-
#metrics=(value) ⇒ Object
Set metrics collection.
-
#output ⇒ String?
Output file path.
-
#output=(value) ⇒ Object
Set output file path.
-
#register ⇒ String?
Register path.
-
#register=(value) ⇒ Object
Set register path.
-
#reset! ⇒ Object
Reset configuration to defaults.
-
#set_cli_option(key, value) ⇒ Object
Set CLI option (highest priority).
-
#shell ⇒ Symbol?
Shell to use for command execution.
-
#shell=(value) ⇒ Object
Set shell.
-
#timeout ⇒ Integer?
Execution timeout in seconds.
-
#timeout=(value) ⇒ Object
Set execution timeout.
-
#to_h ⇒ Hash
Get configuration as hash.
-
#use_color ⇒ Boolean
Use color in output.
-
#use_color=(value) ⇒ Object
Set color usage.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
77 78 79 |
# File 'lib/ukiryu/config.rb', line 77 def initialize @resolver = build_resolver end |
Instance Attribute Details
#resolver ⇒ Object (readonly)
Returns the value of attribute resolver.
75 76 77 |
# File 'lib/ukiryu/config.rb', line 75 def resolver @resolver end |
Class Method Details
.configure {|config| ... } ⇒ Config
Configure Ukiryu with a block
44 45 46 47 |
# File 'lib/ukiryu/config.rb', line 44 def configure yield instance if block_given? instance end |
.instance ⇒ Object
35 36 37 38 39 |
# File 'lib/ukiryu/config.rb', line 35 def instance mutex.synchronize do @instance ||= new end end |
.method_missing(method) ⇒ Object
Delegate to instance
57 58 59 |
# File 'lib/ukiryu/config.rb', line 57 def method_missing(method, ...) instance.send(method, ...) end |
.reset! ⇒ Object
Reset configuration to defaults
50 51 52 53 54 |
# File 'lib/ukiryu/config.rb', line 50 def reset! mutex.synchronize do @instance = new end end |
.respond_to_missing?(method, include_private = false) ⇒ Boolean
61 62 63 |
# File 'lib/ukiryu/config.rb', line 61 def respond_to_missing?(method, include_private = false) instance.respond_to?(method) || super end |
Instance Method Details
#colors_disabled? ⇒ Boolean
Check if colors are disabled Returns true if use_color is explicitly false or if NO_COLOR is set
173 174 175 |
# File 'lib/ukiryu/config.rb', line 173 def colors_disabled? use_color == false end |
#debug ⇒ Boolean
Debug mode flag
100 101 102 |
# File 'lib/ukiryu/config.rb', line 100 def debug @resolver.resolve(:debug) end |
#debug=(value) ⇒ Object
Set debug mode
106 107 108 |
# File 'lib/ukiryu/config.rb', line 106 def debug=(value) @resolver.set_programmatic(:debug, value) end |
#dry_run ⇒ Boolean
Dry run flag
112 113 114 |
# File 'lib/ukiryu/config.rb', line 112 def dry_run @resolver.resolve(:dry_run) end |
#dry_run=(value) ⇒ Object
Set dry run mode
118 119 120 |
# File 'lib/ukiryu/config.rb', line 118 def dry_run=(value) @resolver.set_programmatic(:dry_run, value) end |
#format ⇒ Symbol
Output format
124 125 126 |
# File 'lib/ukiryu/config.rb', line 124 def format @resolver.resolve(:format) end |
#format=(value) ⇒ Object
Set output format
130 131 132 |
# File 'lib/ukiryu/config.rb', line 130 def format=(value) @resolver.set_programmatic(:format, value) end |
#metrics ⇒ Boolean
Metrics collection flag
179 180 181 |
# File 'lib/ukiryu/config.rb', line 179 def metrics @resolver.resolve(:metrics) end |
#metrics=(value) ⇒ Object
Set metrics collection
185 186 187 |
# File 'lib/ukiryu/config.rb', line 185 def metrics=(value) @resolver.set_programmatic(:metrics, value) end |
#output ⇒ String?
Output file path
136 137 138 |
# File 'lib/ukiryu/config.rb', line 136 def output @resolver.resolve(:output) end |
#output=(value) ⇒ Object
Set output file path
142 143 144 |
# File 'lib/ukiryu/config.rb', line 142 def output=(value) @resolver.set_programmatic(:output, value) end |
#register ⇒ String?
Register path
148 149 150 |
# File 'lib/ukiryu/config.rb', line 148 def register @resolver.resolve(:register) end |
#register=(value) ⇒ Object
Set register path
154 155 156 |
# File 'lib/ukiryu/config.rb', line 154 def register=(value) @resolver.set_programmatic(:register, value) end |
#reset! ⇒ Object
Reset configuration to defaults
82 83 84 |
# File 'lib/ukiryu/config.rb', line 82 def reset! @resolver = build_resolver end |
#set_cli_option(key, value) ⇒ Object
Set CLI option (highest priority)
204 205 206 |
# File 'lib/ukiryu/config.rb', line 204 def set_cli_option(key, value) @resolver.set_cli(key, value) end |
#shell ⇒ Symbol?
Shell to use for command execution
191 192 193 |
# File 'lib/ukiryu/config.rb', line 191 def shell @resolver.resolve(:shell) end |
#shell=(value) ⇒ Object
Set shell
197 198 199 |
# File 'lib/ukiryu/config.rb', line 197 def shell=(value) @resolver.set_programmatic(:shell, value&.to_sym) end |
#timeout ⇒ Integer?
Execution timeout in seconds
88 89 90 |
# File 'lib/ukiryu/config.rb', line 88 def timeout @resolver.resolve(:timeout) end |
#timeout=(value) ⇒ Object
Set execution timeout
94 95 96 |
# File 'lib/ukiryu/config.rb', line 94 def timeout=(value) @resolver.set_programmatic(:timeout, value) end |
#to_h ⇒ Hash
Get configuration as hash
210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/ukiryu/config.rb', line 210 def to_h { timeout: timeout, debug: debug, dry_run: dry_run, metrics: metrics, shell: shell, format: format, output: output, register: register, use_color: use_color } end |
#use_color ⇒ Boolean
Use color in output
160 161 162 |
# File 'lib/ukiryu/config.rb', line 160 def use_color @resolver.resolve(:use_color) end |
#use_color=(value) ⇒ Object
Set color usage
166 167 168 |
# File 'lib/ukiryu/config.rb', line 166 def use_color=(value) @resolver.set_programmatic(:use_color, value) end |