Sha256: b768d020909c41b3f73a8bee8f831ca9051f663ca108f303deef7111e644b99e
Contents?: true
Size: 1.18 KB
Versions: 5
Compression:
Stored size: 1.18 KB
Contents
# Author:: Nicolas Despres <nicolas.despres@gmail.com>. # Copyright:: Copyright (c) 2004, 2005 TTK team. All rights reserved. # License:: LGPL # $Id: assert_eval.rb 567 2005-04-13 08:00:06Z polrop $ require 'safe_eval.rb' module TTK module Strategies class Strategy class AssertEval < SafeEval def initialize super(3, true) end def run(code_str='', binding={}, filename='(AssertEval)', lineno=1) code_str.strip! return nil if code_str.empty? super(code_str, get_binding(binding), filename, lineno) end public :run def set_environment Kernel.module_eval('undef_method :`') require 'pathname' Pathname.module_eval('undef_method :open') end protected :set_environment def get_binding(local_binding) code = '' local_binding.each do |fileid, filename| code += "#{fileid} = Pathname.new('#{filename}')\n" end eval(code) return binding end protected :get_binding end # class AssertEval end # class Strategy end # module Strategies end # module TTK
Version data entries
5 entries across 5 versions & 1 rubygems