I use following now to check syntax error:
system "ruby -wc path/to/file.rb"
but it very waste time if there are too many file(for instance, i refactory code), so my question is: is there way to ruby syntax check in ruby code?
ruby
I use following now to check syntax error:
system "ruby -wc path/to/file.rb"
but it very waste time if there are too many file(for instance, i refactory code), so my question is: is there way to ruby syntax check in ruby code?
Best Answer
Under MRI, you can use
RubyVM::InstructionSequence#compile
(relevant documentation) to compile Ruby code (which will throw exceptions if there are errors):