Creation of a Ruby Gem
Rothko: The Pinnacle of Art
For a technical explanation of the gem, click here, or for more information on how to make your own gems, click here.
A wise man once told me that all programming is just breaking problems down to other previously solved problems. And thanks to gems, you don’t even have to be the person that solved the problem. In my ruby programming career I’ve used my fair share of gems — I lean heavily on pry to explain why my code isn’t as flawless as I led myself to believe, rspec to run tests, and so many more that I watch fly past in my terminal as bundler installs them.
But one thing that always bugged me is where are all of these coming from? Who made these? What did they even do to create them? I assumed it was some ancient wizard programmers who, after thousands of years of study finally attained the arcane powers of gem creation. For a while I was happy to leave it at that.
Until I made something cool. I REALLY wanted to add graphics to my command line app and ASCII wasn’t going to cut it. I know, the idea has a bit of a “spitting-in-the-face-of-God” vibe, but I was consumed by the thought. There were some gems out there offering functionality close to what I needed, but they were either broken or diverged too much from my vision.
So I made it myself. I now had this code that could take in a PNG file and spit out beautiful color pixel art at any resolution, as long as your imagination stops at about 100 pixels wide. But that’s high-def for terminal. The program has its flaws — the limit of ANSI colors hold it back, leaving a lot of images looking muddy.
I’ve found some workarounds, fiddling with color settings after putting the image out to the terminal, but that defeats the purpose of the program to a degree.
The key, I’ve discovered, is to create art intended for the terminal– using its limited palette can be frustrating, but you can get some really cool results if you put in the time. The image below is a screenshot of my terminal.
So now what? I alone can make that image appear on my computer. What about the next programmer that comes along that wants to make pictures in terminal in spite of it being the worst possible program to do that in?
I realized, it was time for me to make a gem. Did I have what it took to ascend to high-wizardhood, or could this be a much simpler process than I’ve made it seem?
It turns out it’s super easy.
Rubygems.org has a guide → Make Your Own Gem
But even easier is if you have bundler guide you along the way and set up all of your files. All you need to do is add your code and edit the .gemspec file with personal information.
Bundler guide → Developing a Ruby Gem
The first challenge was coming up with a name. I wanted to convey that I was making art, but “Terminal Art” sounded a bit dry. So I turned to my art history knowledge and decided that I was making work similar to Mark Rothko – painting squares.
My only big hiccup was not realizing I needed a “spec.files” row in my .gemspec file. I created a completely empty gem more times than I’d care to admit which led to a lot of frustration.
Once I had my gem built I created an account on rubygems.org and pushed my gem up. I downloaded my gem maybe once or twice while testing things out. Imagine my surprise when I refreshed my profile page and saw this:
I felt like a celebrity. How did all these people even find my gem? They might just be robots that automatically download every gem, but there’s probably another fellow meat popsicle in that number that’s now using my code to make a picture.
My code was riddled with errors, and as of writing this I’ve already pushed up my third patch. However, a quick look at pry’s page shows that they’re also on their third patch, so maybe I’m just keeping pace with the greats.
If you’re curious about the rothko gem you can find more here:
Or, just add the gem to your next project!