ruby -run
Ruby is well known as a language that is easy to use from the surface but is very deep and complex underneath. That's what we know and love about it. Its standard library has a similar design and contains many hidden gems. One of the gems I've learned about recently is un. It's designed to be a command line utility executed directly from ruby. This is its usage description: This means that if you type ruby -run -e help httpd you'll see a help message that will describe how that command works. Most of the commands have pretty limited utility. They seem to be portable UNIX utilities for use when Ruby is present but a UNIX environment is not. In fact, the package is described as "Utilities to replace common UNIX commands in Makefiles etc." Perhaps they're useful in embedded systems (I understand that Ruby is commonly used for embedded systems in Japan). The two that stand out to me are httpd and colorize. httpd is very useful. It's become my go-to utility when I need to quickly serve files over HTTP. Just type ruby -run -e httpd . press "Enter" and boom you're done! You should see something like this on your screen: Now you can open localhost:8080 in your browser and see the files you've served. colorize prints out the Ruby code of any file you give it with syntax highlighting. I've not used it in a practical setting yet. But it might be useful when looking through Ruby files in a terminal as an alternative to cat.
Ruby is well known as a language that is easy to use from the surface but is very deep and complex underneath. That's what we know and love about it. Its standard library has a similar design and contains many hidden gems. One of the gems I've learned about recently is un. It's designed to be a command line utility executed directly from ruby
. This is its usage description:
This means that if you type
ruby -run -e help httpd
you'll see a help message that will describe how that command works.
Most of the commands have pretty limited utility. They seem to be portable UNIX utilities for use when Ruby is present but a UNIX environment is not. In fact, the package is described as "Utilities to replace common UNIX commands in Makefiles etc." Perhaps they're useful in embedded systems (I understand that Ruby is commonly
used for embedded systems in Japan).
The two that stand out to me are httpd
and colorize
. httpd
is very useful. It's become my go-to utility when I need to quickly serve files over HTTP.
Just type
ruby -run -e httpd .
press "Enter" and boom you're done! You should see something like this on your screen:
Now you can open localhost:8080
in your browser and see the files you've served.
colorize
prints out the Ruby code of any file you give it with syntax highlighting. I've not used it in a practical setting yet. But it might be useful when looking through Ruby files in a terminal as an alternative to cat
.