Sha256: 63b72d0a9ef4230fceca4428803447d05b7499f6346eb31eeedc073ca8ee5a06

Contents?: true

Size: 609 Bytes

Versions: 3

Compression:

Stored size: 609 Bytes

Contents

module Schemacop
  class Collector
    attr_reader :current_path

    def initialize
      @exceptions = []
      @current_path = []
    end

    def valid?
      @exceptions.empty?
    end

    def path(segment)
      @current_path << segment
      yield
    ensure
      @current_path.pop
    end

    def exception_message
      return "Schemacop validation failed:\n" + @exceptions.map do |e|
        "- #{e[:path].join('')}: #{e[:message]}"
      end.join("\n")
    end

    def error(error_msg)
      @exceptions << {
        path: current_path.dup,
        message: error_msg
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
schemacop-2.2.0 lib/schemacop/collector.rb
schemacop-2.1.0 lib/schemacop/collector.rb
schemacop-2.0.0 lib/schemacop/collector.rb