Class: EnhanceSwarm::DependencyValidator
- Inherits:
-
Object
- Object
- EnhanceSwarm::DependencyValidator
- Defined in:
- lib/enhance_swarm/dependency_validator.rb
Constant Summary collapse
- REQUIRED_TOOLS =
{ 'git' => { min_version: '2.20.0', check_command: 'git --version', version_regex: /git version (\d+\.\d+\.\d+)/, critical: true } }.freeze
- OPTIONAL_TOOLS =
{ 'claude' => { min_version: '1.0.0', check_command: 'claude --version', version_regex: /(\d+\.\d+\.\d+)/, description: 'Claude CLI for enhanced agent spawning' }, 'gemini' => { min_version: '0.1.0', check_command: 'gemini --version', version_regex: /(\d+\.\d+\.\d+)/, description: 'Gemini CLI for large context analysis' } }.freeze
Class Method Summary collapse
- .generate_optional_summary(results) ⇒ Object
- .generate_summary(results) ⇒ Object
- .validate_all ⇒ Object
-
.validate_functionality ⇒ Object
Functional validation beyond version checking.
- .validate_ruby_version ⇒ Object
- .validate_tool(tool, config) ⇒ Object
- .version_meets_requirement?(current, required) ⇒ Boolean
Class Method Details
.generate_optional_summary(results) ⇒ Object
144 145 146 147 148 149 150 151 152 |
# File 'lib/enhance_swarm/dependency_validator.rb', line 144 def self.generate_optional_summary(results) optional_results = results.select { |_, result| result[:optional] } return "No optional tools checked" if optional_results.empty? total = optional_results.size passed = optional_results.count { |_, result| result[:passed] } "Optional tools: #{passed}/#{total} available" end |
.generate_summary(results) ⇒ Object
134 135 136 137 138 139 140 141 142 |
# File 'lib/enhance_swarm/dependency_validator.rb', line 134 def self.generate_summary(results) # Only count required tools for main summary required_results = results.reject { |_, result| result[:optional] } total = required_results.size passed = required_results.count { |_, result| result[:passed] } failed = total - passed "Dependency validation: #{passed}/#{total} required dependencies passed" end |
.validate_all ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/enhance_swarm/dependency_validator.rb', line 31 def self.validate_all results = {} all_critical_passed = true # Check required tools REQUIRED_TOOLS.each do |tool, config| result = validate_tool(tool, config) results[tool] = result if config[:critical] && !result[:passed] all_critical_passed = false end end # Check optional tools OPTIONAL_TOOLS.each do |tool, config| result = validate_tool(tool, config) result[:optional] = true results[tool] = result end # Check Ruby version ruby_result = validate_ruby_version results['ruby'] = ruby_result all_critical_passed = false unless ruby_result[:passed] { passed: all_critical_passed, results: results, summary: generate_summary(results), optional_summary: generate_optional_summary(results) } end |
.validate_functionality ⇒ Object
Functional validation beyond version checking
155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/enhance_swarm/dependency_validator.rb', line 155 def self.validate_functionality validations = {} # Test git functionality validations[:git_functional] = test_git_functionality # Test enhance-swarm built-in functionality validations[:session_manager_functional] = test_session_manager_functionality validations end |
.validate_ruby_version ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/enhance_swarm/dependency_validator.rb', line 114 def self.validate_ruby_version current = RUBY_VERSION required = '3.0.0' meets_requirement = version_meets_requirement?(current, required) { passed: meets_requirement, available: true, version: current, required: required, error: meets_requirement ? nil : "Ruby #{current} is below required #{required}" } end |
.validate_tool(tool, config) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/enhance_swarm/dependency_validator.rb', line 65 def self.validate_tool(tool, config) begin output = CommandExecutor.execute(config[:check_command].split.first, *config[:check_command].split[1..], timeout: 10) if config[:version_regex] version_match = output.match(config[:version_regex]) if version_match version = version_match[1] meets_requirement = version_meets_requirement?(version, config[:min_version]) { passed: meets_requirement, available: true, version: version, required: config[:min_version], error: meets_requirement ? nil : "Version #{version} is below required #{config[:min_version]}" } else { passed: false, available: true, version: 'unknown', required: config[:min_version], error: "Could not parse version from: #{output}" } end else # Tool exists but version check not configured { passed: true, available: true, version: 'unknown', required: config[:min_version], error: nil } end rescue CommandExecutor::CommandError => e { passed: false, available: false, version: nil, required: config[:min_version], error: "Tool not available: #{e.message}" } end end |
.version_meets_requirement?(current, required) ⇒ Boolean
128 129 130 131 132 |
# File 'lib/enhance_swarm/dependency_validator.rb', line 128 def self.version_meets_requirement?(current, required) Gem::Version.new(current) >= Gem::Version.new(required) rescue ArgumentError false end |