Class: Querly::Preprocessor

Inherits:
Object
  • Object
show all
Defined in:
lib/querly/preprocessor.rb

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ext:, command:) ⇒ Preprocessor

Returns a new instance of Preprocessor.



16
17
18
19
# File 'lib/querly/preprocessor.rb', line 16

def initialize(ext:, command:)
  @ext = ext
  @command = command
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



14
15
16
# File 'lib/querly/preprocessor.rb', line 14

def command
  @command
end

#extObject (readonly)

Returns the value of attribute ext.



13
14
15
# File 'lib/querly/preprocessor.rb', line 13

def ext
  @ext
end

Instance Method Details

#run!(source_code) ⇒ Object

Raises:



21
22
23
24
25
# File 'lib/querly/preprocessor.rb', line 21

def run!(source_code)
  output, status = Open3.capture2({ 'RUBYOPT' => nil }, command, stdin_data: source_code)
  raise Error.new(status: status, command: command) unless status.success?
  output
end