Sha256: ca4379331c996a787b1e8ca5e0478e9b6a1601be3f5f0b0e8e80c605387ff255

Contents?: true

Size: 714 Bytes

Versions: 1

Compression:

Stored size: 714 Bytes

Contents

Dir.glob(File.expand_path('spec/*.rb', __dir__)).sort.each(&method(:require))

module MARC
  module Spec
    class << self
      def find(query_string, marc_record)
        root = parse_query(query_string)
        executor = Queries::QueryExecutor.new(marc_record, root)
        executor.execute
      end

      def parse_query(query_string)
        parse_tree = parser.parse(query_string, reporter: reporter)
        xform.apply(parse_tree)
      end

      private

      def parser
        @parser ||= Parsing::Parser.new
      end

      def xform
        @xform ||= Queries::Transform.new
      end

      def reporter
        @reporter ||= Parslet::ErrorReporter::Contextual.new
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-marc-spec-0.1.0 lib/marc/spec.rb