class Querly::Preprocessor

Attributes

command[R]
ext[R]

Public Class Methods

new(ext:, command:) click to toggle source
# File lib/querly/preprocessor.rb, line 16
def initialize(ext:, command:)
  @ext = ext
  @command = command
end

Public Instance Methods

run!(path) click to toggle source
# File lib/querly/preprocessor.rb, line 21
def run!(path)
  stdout_read, stdout_write = IO.pipe

  output = ""

  reader = Thread.new do
    while (line = stdout_read.gets)
      output << line
    end
  end

  succeeded = system(command, in: path.to_s, out: stdout_write)
  stdout_write.close

  reader.join

  raise Error.new(status: $?, command: command) unless succeeded

  output
end