Sha256: b781da2578f6eae65605d0bd19707bf9e80d6e071e72ea5dfd7674c3c5ceb0d5
Contents?: true
Size: 1.09 KB
Versions: 8
Compression:
Stored size: 1.09 KB
Contents
class Proc # create a raw eval-able process source, so you can set # the right bindings using the .to_proc call from String methods class << self attr_accessor :source_cache end Proc.source_cache= Hash.new def source(test=nil) # defaults begin return_string= ProcSource.new block= 0 end unless test.nil? puts Proc.source_cache.inspect puts self.object_id end unless Proc.source_cache[self.object_id].nil? return Proc.source_cache[self.object_id] else File.open(File.expand_path(self.source_location[0]) ).each_line_from self.source_location[1] do |line| block += line.source_formater_for_line_sub return_string.concat(line) break if block == 0 end return_string.sub!(/^[\w\W]*Proc.new\s*{/,'Proc.new{') return_string.sub!(/}[^}]*$/,"}") if !return_string.include?('Proc.new') return_string.sub!(/^[^{]*(?!={)/,'Proc.new') end Proc.source_cache[self.object_id]= return_string return return_string end end alias :source_string :source end
Version data entries
8 entries across 8 versions & 1 rubygems