My Love Affair with Pry

Posted by jessenovotny on July 20, 2016

I can’t begin to explain what an epiphany I had when Pry first made sense. It was a tricky concept to grasp at first and thankfully I caught on quickly but it was obvious that this must be quite a challenge for many.

The only thing I can say is “the sooner you understand Pry the better”

Using Pry has made a world of difference in debugging my code. And since programming is all about fixing broken code, this is an essential tool to have in your kit.

For all the programmers out there, I have an interesting thought experiment for you. Try to imagine what the world would be like without Pry. I guess that’s like asking what the world would be like without music or sunshine. Okay, I admit that might be be a bit dramatic but there is something to be said about a function that is so simple and yet it’s very concept can be such a struggle to understand.

I thought I was using Pry correctly until I had a screen-share session with a Learn expert who showed me how he places lots of Prys all over his code when debugging. There must have been at least a half dozen in play when we ran the code and jumped from one Pry to the next figuring out where the issue was located. Up until that point, I had only ever placed one or two Prys in my code at a time. Needless to say my mind was blown.

How does this relate to my first CLI gem?

That’s a good question and here’s the answer. If I had to use Nokigiri to scrape the web for information WITHOUT the help of Pry I probably would have pulled my hair out, jumped in front of a bus, and then run around naked in a McDonald’s. It would be crazy beyond belief. Fortunately, none of this happened and I was able to run Pry as I inspect my code and the return from different Nokigiri commands to extract the right information.

When I started the CLI gem lab, the most daunting part was getting started. That was seconds before I read the instructions and found Avi’s video walkthrough, which confirmed my suspicion; there’s nothing more gut wrenching than looking at a blank file and knowing you have to fill it in with stuff… lots and lots of stuff, such that it will do something marvelous!

Well Avi, I want to personally thank you for pointing me in the direction of “New Gem with Bundler” from railscasts.com. That and showing me how to setup the environment. I had this down half way through the video and this felt comfortable powering through my code from there. But then I was confronted with my next biggest road block…

What the heck is my gem going to do anyways?

After going through the 2 examples given in the instructions and the Daily Deals gem Avi makes in the video, I was sure that every good idea was already taken. It can’t be too simple that it’s not even impressive and it can’t be too complicated that it takes me weeks to finish. The obvious first step was to grab a sticky note and start jotting down my personal interests…

Since Pokemon Go took the world by storm and yes, I am a fan (I was a rabid consumer of Pokemon cards and their first Game Boy game when I was in 5th grade), it’s no surprise that “Pokemon” was the second item on this list, just below “rock climbing”, but only because I would feel silly if it were the first thing that came to mind (when it really was).

Anyways, I had also listed “camping”, “biking”, “dogs”, and few other notable favorites. I put a lot of thought into what my first gem would do. I resisted the urge to make it Pokemon inspired because of how ridiculously trendy it all is. I tossed around a few ideas about my other passions but eventually caved in and realized the concept for a gem that would truly revolutionize the world of Pokemon, or rather it might actually prove helpful.

Once I had the idea set, the structure laid out, and was able to scrape the web for what I needed, coding the rest of my gem wasn’t too much a struggle. If anything, I’m feeling pretty impressed with myself for looking at a couple files filled with original code which were completely blank less than 24 hours prior. Now, if you really want to know what my Pokemon gem does, you’ll need to checkout my README in the link below ;) https://github.com/jessenovotny/pokemon-cli-gem

Before exploring my gem, please beware, if you don’t know what Pokemon is or you’re just not a fan, there’s a chance you could be incredibly confused, disappointed or even experience some slight vertigo. I also can’t promise you won’t be curious enough to download Pokemon Go only to find yourself sucked into another version of reality where landmarks have turned into spectacular virtual gyms with giant colorful spires, local points of interest have become places of congregation for people glued to their phones, whimsical creatures keep popping up out of nowhere and you simply cannot resist the urge to catch them all.

Now a Charmeleon just popped up on my phone so I’ll have to end this blog post here to go trap him in one of my little magical Pokeballs. #sorrynotsorry