From: "aemadrid@..." Date: 2007-11-09T04:45:08+09:00 Subject: Re: Dynamic syntax check This looks really good. Thanks! AEM On Nov 8, 1:41 am, Calamitas wrote: > On 08/11/2007, aemad...@gmail.com wrote: > > > Is there any way to check the Ruby syntax on a file or string of Ruby > > code besides doing something like `ruby -v xyz.rb`? Is there a gem > > that would help me here? > > From the file sample/test.rb in the Ruby source code distribution: > > def valid_syntax?(code, fname) > eval("BEGIN {return true}\n#{code}", nil, fname, 0) > rescue Exception > puts $!.message > false > end > > Peter