class CC::CLI::ValidateConfig
Constants
- NO_CONFIG_MESSAGE
- SHORT_HELP
- TOO_MANY_CONFIG_MESSAGE
- VALID_CONFIG_MESSAGE
Attributes
config[R]
registry_path[R]
registry_prefix[R]
validator[R]
Public Instance Methods
run()
click to toggle source
# File lib/cc/cli/validate_config.rb, line 9 def run require_json_or_yaml process_args if any_issues? display_issues else puts format(VALID_CONFIG_MESSAGE, validator.path) end exit 1 unless validator.valid? end
Private Instance Methods
any_issues?()
click to toggle source
# File lib/cc/cli/validate_config.rb, line 40 def any_issues? validator.errors.any? || validator.warnings.any? end
display_issues()
click to toggle source
# File lib/cc/cli/validate_config.rb, line 45 def display_issues validator.errors.each do |error| puts "#{colorize("ERROR", :red)}: #{error}" end validator.warnings.each do |warning| puts "#{colorize("WARNING", :yellow)}: #{warning}" end end
engine_registry()
click to toggle source
# File lib/cc/cli/validate_config.rb, line 79 def engine_registry EngineRegistry.new(registry_path, registry_prefix) end
process_args()
click to toggle source
# File lib/cc/cli/validate_config.rb, line 26 def process_args @registry_path = EngineRegistry::DEFAULT_MANIFEST_PATH @registry_prefix = "" # Undocumented; we only need these from Builder so we can validate # engines/channels against our own registry and prefix. while (arg = @args.shift) case arg when "--registry" then @registry_path = @args.shift when "--registry-prefix" then @registry_prefix = @args.shift end end end
require_json_or_yaml()
click to toggle source
# File lib/cc/cli/validate_config.rb, line 55 def require_json_or_yaml if !filesystem.exist?(Config::YAMLAdapter::DEFAULT_PATH) && !filesystem.exist?(Config::JSONAdapter::DEFAULT_PATH) puts NO_CONFIG_MESSAGE exit 0 elsif filesystem.exist?(Config::YAMLAdapter::DEFAULT_PATH) && filesystem.exist?(Config::JSONAdapter::DEFAULT_PATH) puts "#{colorize("WARNING", :yellow)}: #{TOO_MANY_CONFIG_MESSAGE}" end end