Sha256: afe10c8da2a5ae98c7c73a15c873b69702f03e2efc5837bd2a2fa4ea5abfde7a

Contents?: true

Size: 594 Bytes

Versions: 5

Compression:

Stored size: 594 Bytes

Contents

# typed: strict
# frozen_string_literal: true

require "spoom/visitor"

module Spoom
  class ParseError < Error; end

  class << self
    extend T::Sig

    sig { params(ruby: String, file: String).returns(Prism::Node) }
    def parse_ruby(ruby, file:)
      result = Prism.parse(ruby)
      unless result.success?
        message = +"Error while parsing #{file}:\n"

        result.errors.each do |e|
          message << "- #{e.message} (at #{e.location.start_line}:#{e.location.start_column})\n"
        end

        raise ParseError, message
      end

      result.value
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spoom-1.5.0 lib/spoom/parse.rb
spoom-1.4.2 lib/spoom/parse.rb
spoom-1.4.1 lib/spoom/parse.rb
spoom-1.4.0 lib/spoom/parse.rb
spoom-1.3.3 lib/spoom/parse.rb