--------------060202010105010009040807
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Robin Stocker wrote:

> Here's my solution...

And mine's attached to this mail.

I wrote this a while ago and it works by extracting a proc's origin file 
name and line number from its .inspect string and using the source code 
(which usually does not have to be read from disc) -- it works with 
procs generated in IRB, eval() calls and regular files. It does not work 
from ruby -e and stuff like "foo".instance_eval "lambda {}".source 
probably doesn't work either.

Usage:

   code  ambda { puts "Hello World" }
   puts code.source
   Marshal.load(Marshal.dump(code)).call
   YAML.load(code.to_yaml).call

--------------060202010105010009040807
Content-Type: application/x-ruby;
 nameroc_source.rb"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filenameroc_source.rb"

cmVxdWlyZSAnc3RyaW5naW8nDQpyZXF1aXJlICdpcmIvcnVieS1sZXgnDQoNCiMgVGVsbCB0
aGUgcnVieSBpbnRlcnByZXRlciB0byBsb2FkIGNvZGUgbGluZXMgb2YgcmVxdWlyZWQgZmls
ZXMNCiMgaW50byB0aGlzIGZpbGVuYW1lIC0+IGxpbmVzIEhhc2guIFRoaXMgYmVoYXZpb3Vy
IHNlZW1zIHRvIGJlDQojIHZlcnkgdW5kb2N1bWVudGVkIGFuZCB0aGVyZWZvcmUgc2hvdWxk
bid0IHJlYWxseSBiZSByZWxpZWQgb24uDQpTQ1JJUFRfTElORVNfXyA9IHt9IHVubGVzcyBk
ZWZpbmVkPyBTQ1JJUFRfTElORVNfXw0KDQptb2R1bGUgUHJvY1NvdXJjZQ0KICBkZWYgZ2V0
X2xpbmVzKGZpbGVuYW1lLCBzdGFydF9saW5lID0gMCkNCiAgICBjYXNlIGZpbGVuYW1lDQog
ICAgICAjIHNwZWNpYWwgIihpcmIpIiBkZXNjcmlwdG9yPw0KICAgICAgd2hlbiAiKGlyYiki
DQogICAgICAgIElSQi5jb25mWzpNQUlOX0NPTlRFWFRdLmlvLmxpbmUoc3RhcnRfbGluZSAu
LiAtMSkNCiAgICAgICMgc3BlY2lhbCAiKGV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gICAgICAgICAgICAgICMgb2theSwgY29kZSB3aWxs
IGZvbGxvdyBzb29uLg0KICAgICAgICAgICAgICAgIHN0YXRlID0gOmJlZm9yZV9jb2RlDQog
ICAgICAgICAgICAgIGVsc2UNCiAgICAgICAgICAgICAgICAjIG11bHRpcGxlIHByb2NzIG9u
IG9uZSBsaW5lDQogICAgICAgICAgICAgICAgcmV0dXJuDQogICAgICAgICAgICAgIGVuZA0K
ICAgICAgICAgICAgZW5kDQogICAgICAgICAgZW5kDQogICAgICAgICMgdG9rZW4gaXMgbGFt
YmRhIG9yIHByb2MgY2FsbD8NCiAgICAgICAgZWxzaWYgdG9rZW4uaXNfYT8oUnVieVRva2Vu
OjpUa0lERU5USUZJRVIpIGFuZA0KICAgICAgICAgICAgICAld3twcm9jIGxhbWJkYX0uaW5j
bHVkZT8odG9rZW4uaW5zdGFuY2VfdmFyaWFibGVfZ2V0KDpAbmFtZSkpDQogICAgICAgICAg
dW5sZXNzIHN0YXRlID09IDpjaGVja19tb3JlDQogICAgICAgICAgICAjIG9rYXksIGNvZGUg
d2lsbCBmb2xsb3cgc29vbi4NCiAgICAgICAgICAgIHN0YXRlID0gOmJlZm9yZV9jb2RlDQog
ICAgICAgICAgZWxzZQ0KICAgICAgICAgICAgIyBtdWx0aXBsZSBwcm9jcyBvbiBvbmUgbGlu
ZQ0KICAgICAgICAgICAgcmV0dXJuDQogICAgICAgICAgZW5kDQogICAgICAgIGVuZA0KDQog
ICAgICAjIHdlJ3JlIHdhaXRpbmcgZm9yIHRoZSBjb2RlIHN0YXJ0IHRvIGFwcGVhci4NCiAg
ICAgIGVsc2lmIHN0YXRlID09IDpiZWZvcmVfY29kZQ0KICAgICAgICBpZiB0b2tlbi5pc19h
PyhSdWJ5VG9rZW46OlRrZkxCUkFDRSkgb3IgdG9rZW4uaXNfYT8oUnVieVRva2VuOjpUa0RP
KQ0KICAgICAgICAgICMgZm91bmQgdGhlIGNvZGUgc3RhcnQsIHVwZGF0ZSBzdGF0ZSB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