2009-11-15

_ : a library that allows you to write Ruby script by using only _

I published one of my darling libraries into gemcutter, named _. By using _, you can write Ruby script that consist only of _.

Getting started

$ gem install _

Source code: http://github.com/mame/_

Gem info: http://gemcutter.org/gems/_

Example

This is "Hello, world!" __script__ written in Ruby:

require "_"
____ _ _____ ____ __ ____ ____ __ ___ ____ __ __ _ ______
_____ ___ _ _ ___ _____ ______ ____ _ _ ____ _ _ ____ _
____ __ __ ___ _ ______ ___ ____ __ ______ ____ _ ____ ____
__ _ ____ _ _ ___ _____ _____ _ ______ ____ _ ______ _____

This is nothing but normal Ruby __script__. Works on Ruby 1.8 and 1.9. You can rearrenge line breaks but can not change the order of _s.

$ ruby18 -rubygems __hello__.rb
Hello, world!

$ ruby19 __hello__.rb
Hello, world!

If you mind the first `require' line, the option `-r_' can be used in Ruby 1.9.

$ ruby19 -r_ -e '____ _ _____ ____ __ ____ ____ __ ___ ____ __
__ _ ______ _____ ___ _ _ ___ _____ ______ ____ _ _ ____ _ _
____ _ ____ __ __ ___ _ ______ ___ ____ __ ______ ____ _ ____
____ __ _ ____ _ _ ___ _____ _____ _ ______ ____ _ ______ _____
'
Hello, world!

And, you can translate your own script into __script__ by __script__ method.

$ echo -n 'puts"Hello, world!"' | ruby19 -r_ -e 'puts __script__($<.read)'
require "_"
____ _ _____ ____ __ ____ ____ __ ___ ____ __ __ _ ______
_____ ___ _ _ ___ _____ ______ ____ _ _ ____ _ _ ____ _
____ __ __ ___ _ ______ ___ ____ __ ______ ____ _ ____ ____
__ _ ____ _ _ ___ _____ _____ _ ______ ____ _ ______ _____

translated from mamememo in Japanese (2009-04-02) and (2009-11-15).

No comments:

Post a Comment