lib/procemon/mpatch/proc.rb in procemon-0.1.3 vs lib/procemon/mpatch/proc.rb in procemon-0.1.4

- old
+ new

@@ -18,11 +18,10 @@ # defaults begin return_string= String.new block= 0 end - if @@source_cache.keys.include? self.object_id return @@source_cache[self.object_id] else File.open(Dir.pwd.dup.concat(File::Separator).concat(self.source_location[0]) ).each_line_from self.source_location[1] do |line| @@ -37,12 +36,19 @@ 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 + @@source_cache[self.object_id]= return_string + return return_string end end + alias :source_string :source end