My Profile Photo

Rachel on Ruby


A blog about my adventures in web development using Ruby.


My First Gem

As part of the Learn.Co Web Development program, I was tasked with building a Ruby command-line gem. The gem I built is called “Tutorial Central” and can be found on RubyGems.org and on my GitHub site. Basically, I took the awesome site www.hackr.io, which curates a bunch of tutorials for all different programming languages, and created a program that allows you to browse the site’s categories and tutorials from your command line. It’s very simple, and I doubt it will be very useful to many people (at least in it’s current state) but you should absolutely check out that website!

As for the whole gem creation process, the best advice I can give to those who might also be thinking about building a gem is to JUST GET STARTED. Like a lot of people out there, I am a perfectionist and want to make sure that I’m doing things ‘the right way’ and am fully prepared before I start any project. This means that basically anytime I am about to try something new – whether it’s a new vacation spot, buying a new product, or here, building a gem – I spend an ungodly amount of time researching the shit out of anything and everything involved. This can end up being a no-man’s-land for me - there will always be one more tutorial or blog post to read. If it’s the same information I’ve read, then I’m just procrastinating, and if the author has a completely new/different opinion, it most likely will only confuse me, not help me.

Programming is one of those fields where you absolutely have to learn by doing - and you will most likely never feel “ready” to take on a completely new concept or project. But the good thing is that (most likely) whatever you do will not cause the world to fall apart or the internet to crash (in fact if you’re like me you won’t even be able to get the damn thing to run at all) so there’s no harm in JUST. STARTING.

Once your have your idea, I would say don’t even think about the ‘gem’ part of your program yet. Build the basic classes and methods of your program first, because you know how to get at least that far. Then, once you already have a basic program, look into how to turn that into a gem. I recommend using bundler, as you’re likely already familiar with it and it makes things very simple. Then all you have to do is transfer your code into the right structure and get it all to talk to one another (although admittedly that’s where I had the most trouble - ‘requires’ and ‘require_relative’s’ just do not click for me sometimes). If you go about creating your gem this way, when you get stuck it will be on a specific problem that you can get help with rather than the overwhelming ‘how to build a ruby gem’ google search. Don’t be afraid to just try something - error codes are not that scary, and they at least mean that something is happening, versus staring at a blank file! Good luck!

comments powered by Disqus