class CanCamel::Linter

Constants

LintingError

Public Instance Methods

lint() click to toggle source
# File lib/can_camel/linter.rb, line 5
def lint
  Cache.reload! rescue return
  %i(lint_nodes lint_filters).reduce(true) { |base, x| base && send(x) }
end
lint!() click to toggle source
# File lib/can_camel/linter.rb, line 10
def lint!
  raise LintingError unless lint
end
lint_filters() click to toggle source
# File lib/can_camel/linter.rb, line 20
def lint_filters
  CanCamel::Filter.filters.values.flatten.uniq.each { |filter| !filter.respond_to?(:lint!) || filter.lint! }
  true
rescue CanCamel::Linter::LintingError
  false
end
lint_node(node) click to toggle source
# File lib/can_camel/linter.rb, line 14
def lint_node(node)
  node = node.dup
  node.inherit!
  %i(validate_node).reduce(true) { |base, x| base && send(x, node) }
end

Private Instance Methods

lint_nodes() click to toggle source
# File lib/can_camel/linter.rb, line 38
def lint_nodes
  CanCamel::Node.all.reduce(true) { |base, x| base && lint_node(x) }
end
validate_node(node) click to toggle source
# File lib/can_camel/linter.rb, line 29
def validate_node(node)
  node.condition.each do |method, args|
    Validators.validate!(filter: method, args: args.symbolize_keys, path: node.path)
  end
  true
rescue Validators::ValidationError, LintingError
  false
end