Module: Ukiryu::Tools
- Defined in:
- lib/ukiryu/tools.rb,
lib/ukiryu/tools/base.rb,
lib/ukiryu/tools/generator.rb,
lib/ukiryu/tools/class_generator.rb,
lib/ukiryu/tools/executable_finder.rb
Overview
Tools namespace for tool-specific classes
This namespace contains dynamically generated classes for each tool, providing a fully OOP interface for working with command-line tools.
Defined Under Namespace
Modules: ClassGenerator, ExecutableFinder, Generator Classes: Base
Class Method Summary collapse
-
.const_missing(name) ⇒ Class
Autoload tool classes via const_missing.
Class Method Details
.const_missing(name) ⇒ Class
Autoload tool classes via const_missing
When you reference Ukiryu::Tools::Imagemagick, this method automatically generates the class if it doesn’t exist.
Platform aliases are resolved first - e.g., Ping resolves to PingBsd on macOS or PingGnu on Linux based on the current platform.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ukiryu/tools.rb', line 41 def const_missing(name) # Convert CamelCase constant name to snake_case tool name # e.g., PingBsd -> ping_bsd, PingGnu -> ping_gnu, Ping -> ping tool_name_str = name.to_s .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') # Add underscore before caps that follow lowercase .gsub(/([a-z\d])([A-Z])/, '\1_\2') # Add underscore between lowercase and uppercase .downcase tool_name = tool_name_str.to_sym # First, check if it's a platform alias # Look for tools that implement this alias for the current platform platform_impl = find_platform_implementation(tool_name) return Generator.generate_and_const_set(platform_impl) if platform_impl # If not an alias, try to generate the tool directly generated = Generator.generate_and_const_set(tool_name) return generated if generated # If nothing found, let the error propagate nil end |