lib/procemon/function/proc_source/method.rb in procemon-0.2.0 vs lib/procemon/function/proc_source/method.rb in procemon-0.3.1

- old
+ new

@@ -1,6 +1,6 @@ -class Method +module MethodToProcSource # creatue a raw eval-able process source, so you can set # the right bindings using the .to_proc call from String methods def source @@ -20,10 +20,15 @@ break if block == 0 end begin + if return_string.split("\n")[0].include? '(' + return_string.sub!('(',' ') + return_string.sub!(')',' ') + end + args_to_replace = return_string.split("\n")[0].match(/\s*def\s*\S*\s*(.*)/).captures[0] if args_to_replace != String.new return_string.sub!(args_to_replace,"|#{args_to_replace}|") end @@ -32,11 +37,10 @@ end return_string.sub!(/\s*\bdef\s*[\w\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 @@ -46,6 +50,14 @@ end alias :source_string :source alias :proc_source :source +end + +class Method + include MethodToProcSource +end + +class UnboundMethod + include MethodToProcSource end \ No newline at end of file