Sha256: c279da8991ed9d3deddf80283cb950234c0b94bf2b477e076133001bf7540245
Contents?: true
Size: 642 Bytes
Versions: 10
Compression:
Stored size: 642 Bytes
Contents
module RailsExecution module Services class SyntaxChecker OK_MESSAGE = 'Syntax OK' def initialize(code) @code = code end def call return false if code.blank? init_tempfile return is_ok? end private attr_reader :code def init_tempfile @file = ::Tempfile.new('syntax_checker') @file.binmode @file.write(code) @file.flush @file end def is_ok? result = `cat #{@file.path} | ruby -c` result.strip == OK_MESSAGE rescue SyntaxError return false end end end end
Version data entries
10 entries across 10 versions & 1 rubygems