loading...
Cover image for Practice Makes Perfect

Practice Makes Perfect

dclements9 profile image DylanC Updated on ・2 min read

Six weeks go by quickly, especially when you’re learning a skill that plunges you ever deeper into an endless world of excitement. Looking back, I can hardly believe I’ve learned as much as I have.

I started my CLI project about two weeks ago, thinking I knew what I needed to complete it. But I wanted to solidify that knowledge. Practice makes perfect. But creative practice fills in the gaps you didn’t know were there.

The project needed to scrape a website, provide the user with information, and have a command-line interface to interact with the program. I chose to scrape an event schedule to create an agenda for the user (GDG DevFest 2018). While properly learning to iterate through, filter, and attach my scraped results to an object, my best friend was Pry.

I could go on and on about my love for Pry. But I’ll try to share a few of my favorite commands of Pry instead. While the most fundamental benefit of Pry is to essentially ‘pry’ open code, there is so much more to it.

If you’re familiar with the terminal on a Unix system, you’ve probably used the ‘ls’ command to list files and folders. Pry has something similar. The ‘ls’ command will show you a list of possible methods and variables for the location you pried open. While this may seem like a trivial command by itself, when combined with other commands, it becomes mighty.

Which brings me to my next command, ‘play’. More specifically, ‘play -l’ will play the line specified next. This command also provides a relatively easy way to step into or around blocks and iterations. When it’s combined with ‘ls’, you can follow changes to variables and methods as they happen.

My last command is more of a tip of how to use a command than an actual command. While outside of a ‘do’ block, ‘exit’ will exit from the program. But while inside, it can provide valuable information about each iteration the block goes through, giving much needed debugging support.

Overall, this was a very tiny piece of what I’ve learned about this project. But I’ll save that for another post. The journey continues!

Attribution

Cover Photo by Jordan Sanchez on Unsplash

Posted on Jan 23 by:

dclements9 profile

DylanC

@dclements9

Flatiron School Graduate. Enjoying the never ending adventure of code.

Discussion

markdown guide
 

Great post, fellow Flatiron student! I learned things about Pry from you! I had never dug into the documentation on pry to learn the extent of other commands one can use. Kudos on your blog post!

 
 

Nice! Didn't know about play. One of my favorite commands is !, which clears the input. It's useful if you're writing like a do...end block, and have a typo but hit enter already.

 

Love ! too. Saves so much time instead of: kill pry, retrigger pry, try again. What are some of your other favorites?

I haven't messed around with all of the commands as much as I've wanted to yet.

 

Maybe for the next post you could tell us more about what PRY is? Is it a terminal command? What language does it operate on? Show us an example of the input and output?

 

Awesome suggestions. Thanks. I'll definitely give it a go.