Method: Querly::Script.load

Defined in:
lib/querly/script.rb

.load(path:, source:) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/querly/script.rb', line 6

def self.load(path:, source:)
  parser = Parser::Ruby25.new(Builder.new).tap do |parser|
    parser.diagnostics.all_errors_are_fatal = true
    parser.diagnostics.ignore_warnings = true
  end
  buffer = Parser::Source::Buffer.new(path.to_s, 1)
  buffer.source = source
  self.new(path: path, node: parser.parse(buffer))
end