One Essential, And Three Other Cool Ruby Gems For You To Check Out
Hello there, my name is Alex, and I’ve just started my dive into Ruby. One thing I’ve quickly noticed is how almost everything in Ruby requires a ‘gem’, so I decided I’d do some research into gems that might be helpful or useful in the future. These are a few of the gems I found that I thought might be of use, as well as pry, a SUPER ESSENTIAL gem that you CANNOT work without!
Are you running into errors and issues with your code that you just can’t seem to find the source of? Have you tried require ‘pry’/binding.pry?
The ‘pry’ gem is extremely useful in both tracking down the source fo errors and testing your code to make sure that the values you should be outputting are correct.
To install ‘pry’ and make testing your code dynamic type or copy/paste the following into your console:
gem install pry
Then when you would like to use pry, simply put this at the top of the file you would like to pry:
And then put this where you would like the program to pause so you can test:
Now go ahead and type in a few of your object methods and see what happens! Its also possible to use multiple ‘binding.pry’s to stop your application multiple times and check step by step how your values are being operated on. Its an extremely vital and useful tool once you get used to using it.
While trying to find gems to display art in my application I ran into a problem: I would be able to display pictures already stored in the app, but not upload and append images to new instances that should have them. CarrierWave fixed this by adding an image upload function thru its gem, as well as being an image processor once the images are uploaded. It also has a function for multiple file uploads.
It goes without saying that using this gem would save a lot of effort on both the developer and the client side. By reducing the amount of work a user has to do to upload an image as well as the now added functionality of being able to add and update pictures without fundamentally changing and possibly breaking your app, we have made the app both easier to use and more engaging from either perspective.
Catpix isn’t able to upload images, but it IS a lightweight and extremely simple way to display images in your terminal when running your program. The quality of the images can be defined in your app, which is very helpful when running on older or slower systems. This is good for offline apps, where a user will have less of a focus on uploading media and more on text with some occasional images.
This gem actually requires the user to install the MagickCore bundle before using it, but it vastly improves on that library by making the code a lot more concise, which in turn gives us less opportunities to break our code
Rmagick (required for install:
gem install catpix
Renders images in the terminal. It will handle most image formats (png, jpg, gif, bpm and many more). As long as…
If you’ve never seen or even heard of ‘datamoshing’, here is your crash course: by removing key frames in a video, we (us ually!)get a nice artifacted, oozing, flowing effect. That isn’t *always* the case, but the effects are almost always visually striking and unsettling. Neat! The best part of this gem is that it allows you to glitch an .avi at whichever level you feel comfortable, and the docs walk you through the process while giving you examples along the way, so that you know in advance what you’re about to do to your file.
This gem isn’t really useful for most apps you’ll make, but its really fun to experiment with on your own videos, and is very low impact as far as the amount of coding you’ll be doing compared to the end result. Its a very impressive tool that only breaks things, which is really cool as long as you’ve backed up your originals.
gem install aviglitch
WARNING: THIS WILL USUALLY DESTROY YOUR AVI FILE SO DO THIS AT YOUR OWN RISK!!!!!
There are so many gems in ruby that do so many different things and build on the core functionality of the library. Its just as easy to find cool stuff that works for you as it is to get completely lost in gems that do useless cool stuff. As I get deeper into my coding journey, I’m realizing how much of an impact the open source community has on pretty much everything we’re doing, and its incredible to see how much of these projects are willingly shared, then expanded on. Hopefully, at some point, we’ll all be able to make our own gems that help other people with their projects, or even just mess up some data in a cool way.