lib/superscript/runner.rb in superscript-0.2.0 vs lib/superscript/runner.rb in superscript-0.2.1

- old
+ new

@@ -12,11 +12,13 @@ contents = File.read(@path) unless contents ctx = Superscript::Ctx.new unless ctx @armed = false trace = TracePoint.new do |tp| - #p [@armed, tp.path, tp.lineno, tp.method_id, tp.event, tp.defined_class] + if ENV["SUPERSCRIPT_DEBUG"] + p [@armed, tp.path, tp.lineno, tp.method_id, tp.event, tp.defined_class] + end if tp.defined_class.name == "BasicObject" && tp.method_id == :instance_eval if tp.event == :script_compiled @armed = true elsif tp.event == :c_return @@ -32,15 +34,20 @@ case tp.event when :line puts "< " + contents.split("\n")[tp.lineno - 1] when :c_call - @armed = false - trace.disable - - puts "Error: Command not found '#{tp.method_id}'" - - exit 1 + next if ["String","Float", "Integer"].include? tp.defined_class.name + case tp.method_id + when :singleton_method_added + puts "Error: Deffining methods is not allowed" + trace.disable + exit 1 + else + puts "Error: Command not found '#{tp.method_id}'" + trace.disable + exit 1 + end when :call if tp.defined_class.name == "Superscript::Ctx" @armed = false end end