class Getto::Roda::Config::Checker
Public Class Methods
new(schema)
click to toggle source
# File lib/getto/roda/config.rb, line 30 def initialize(schema) @schema = schema end
Public Instance Methods
validate!(config)
click to toggle source
# File lib/getto/roda/config.rb, line 34 def validate!(config) validate_config!([], @schema, config) end
Private Instance Methods
full_path(path,key)
click to toggle source
# File lib/getto/roda/config.rb, line 65 def full_path(path,key) [*path, key].join("/") end
validate_config!(path, schema, config)
click to toggle source
# File lib/getto/roda/config.rb, line 40 def validate_config!(path, schema, config) unless config raise "#{path.join("/")} is nil" end schema.each do |key,spec| case spec when ::Class unless config[key].is_a?(spec) raise "#{full_path(path,key)} is not a #{spec}" end when ::Array unless spec.include?(config[key]) raise "#{full_path(path,key)} is not in [#{spec.join(",")}]" end when ::Hash validate_config!([*path,key], spec, config[key]) else # :nocov: raise "invalid schema: #{full_path(path,key)} : #{spec}" # :nocov: end end end