Logo

dev-resources.site

for different kinds of informations.

ruby -run

Published at
1/15/2025
Categories
ruby
tooling
beginners
tutorial
Author
delonnewman
Categories
4 categories in total
ruby
open
tooling
open
beginners
open
tutorial
open
Author
11 person written this
delonnewman
open
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:

ruby -run -e cp -- [OPTION] SOURCE DEST<br>
ruby -run -e ln -- [OPTION] TARGET LINK_NAME<br>
ruby -run -e mv -- [OPTION] SOURCE DEST<br>
ruby -run -e rm -- [OPTION] FILE<br>
ruby -run -e mkdir -- [OPTION] DIRS<br>
ruby -run -e rmdir -- [OPTION] DIRS<br>
ruby -run -e install -- [OPTION] SOURCE DEST<br>
ruby -run -e chmod -- [OPTION] OCTAL-MODE FILE<br>
ruby -run -e touch -- [OPTION] FILE<br>
ruby -run -e wait_writable -- [OPTION] FILE<br>
ruby -run -e mkmf -- [OPTION] EXTNAME [OPTION]<br>
ruby -run -e httpd -- [OPTION] [DocumentRoot]<br>
ruby -run -e colorize -- [FILE]<br>
ruby -run -e help [COMMAND]

This means that if you type

ruby -run -e help httpd
Enter fullscreen mode Exit fullscreen mode

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 .
Enter fullscreen mode Exit fullscreen mode

press "Enter" and boom you're done! You should see something like this on your screen:

[2025-01-12 13:43:26] INFO  WEBrick 1.6.1<br>
[2025-01-12 13:43:26] INFO  ruby 2.7.5 (2021-11-24) [arm64-darwin24]<br>
[2025-01-12 13:43:26] INFO  WEBrick::HTTPServer#start: pid=27808 port=8080

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.

beginners Article's
30 articles in total
Beginner-friendly resources provide step-by-step guidance and foundational knowledge for those new to coding or technology.
Favicon
7 Developer Tools That Will Boost Your Workflow in 2025
Favicon
Creating a live HTML, CSS and JS displayer
Favicon
Build Your First AI Application Using LlamaIndex!
Favicon
Creating Arrays with Reference Variables
Favicon
How To Build Beautiful Terminal UIs (TUIs) in JavaScript 2: forms!
Favicon
The Great Failure of 2024
Favicon
CΓ³mo Iniciar y Crecer como Desarrollador Frontend en 2025
Favicon
Chronicles of Supermarket website
Favicon
Building a Serverless REST API with AWS Lambda and API Gateway
Favicon
ruby -run
Favicon
Day 04: Docker Compose: Managing multi-container applications
Favicon
From Bootcamp to Senior Engineer: Growing, Learning, and Feeling Green
Favicon
From "Never Engineering" to "Why Not?"
Favicon
Easy Discount Calculation: Tax, Fees & Discount Percentage Explained
Favicon
How to Resolve the 'Permission Denied' Error in PHP File Handling
Favicon
Introduction to Terraform: Revolutionizing Infrastructure as Code
Favicon
2025: The Year of Decentralization – How Nostr Will Make You a Standout Developer
Favicon
Amazon S3 vs. Glacier: Data Archival Explained
Favicon
What is Next Js: A Beginner's guide to Next Js
Favicon
Debugging Adventure Day 1: What to Do When Your Code Doesn’t Work
Favicon
Top 5 SaaS Trends for 2025
Favicon
Easy 301 Redirects For SEO
Favicon
How to Choose the Right Shopify Theme for Your Business Needs
Favicon
ruby -run, again
Favicon
Build a Secure Password Generator with Javascript
Favicon
got Tired of analysis paralyysis so i built an extensioon to get into flow faster
Favicon
Survival Manual: How to Create and Manage a Project in Git
Favicon
badly I want to know how to code😭😭
Favicon
AI Integration with vscodium
Favicon
Test Scenarios vs. Test Cases: Understanding the Differences

Featured ones: