Building My First Gem: Learning What I Don’t Know

Sam Troutman
3 min readJan 11, 2021

Going into our first module project in Flatiron, I was feeling pretty confident. There were numerous brutal labs that I completed successfully, and I felt like I really got the gist of how to create a command line interface. As a craft beer enthusiast and Michigander, I had the idea to scrape the beer menu from one of my favorite local breweries, and began my project. I followed along with Avi’s video on how to create a gem, learning how to use bundler to create the needed files and start with my class files. My bin file was running normally, and things were making sense. I felt so good thinking that I had really learned things and I could now translate that into building something useful.

Until I received this error message:

No such file or directory @ rb_sysopen

I had never seen this before, I had no clue what it meant, and I had followed Avi’s video and prior lessons to create my scraper. I had Nokogiri and open-uri in place, things were spelled correctly, and still I was getting an error. I searched the issue, finding answers like “make sure you have ‘https://’ included in your url” and, “why would you try to do that, anyway?” — nothing particularly useful. I also saw an answer where it might just be the website, so I scrapped my project and began using the Top Rated Michigan Beers on Beer Advocate. Same story — I was chugging along doing my project, and when it came time to scrape…. no such file or directory.

I spent an evening and a half working and searching before I realized I was never going to figure this out on my own. This was something that I was doing wrong, and I didn’t even know what I was doing wrong. I signed up for a one-on-one meeting with our cohort lead, Phil, to see if he could point out whatever silly mistake I was making. After an hour and a half on Zoom trying to figure it out (thank you, Phil!!!), he figured out that I needed to add a gem ‘net-http’, and then helped me out with figuring out everything I was doing wrong with my scraping once that worked.

To be completely honest, I’m still not 100% sure what I did wrong or what the usefulness of ‘net-http’ is (documentation says it is “Support for HTTP”). I’m still reading up on ‘net-http’, and I do know that this project illuminated what I didn’t know and how much I still have to learn. I felt more comfortable after Phil helped me set this up, though my scraping was still a mess and I had what felt like a million error messages to still work through. He also helped point out some better functionality with my scrape class, isolating the table in the CSS and calling on children within it, and I carried on with my code.

It took a lot of searching, a lot of going through old lessons, and even the Ruby for Kids (for Dummies) book I picked up, but my code is now working and I’m mostly comfortable with how it ended up. A couple of things I would like to add to clean up or for functionality in the future:

  1. Not using any hashes —after trying to figure everything else out, I wasn’t able to cut down on my usage of hashes as much as I wanted to. They were the best way I could figure out to make my program more DRY, but I would like to further refactor to do without them.
  2. When scraping, I couldn’t completely separate the beer style and ABV listings, so I combined the two attributes when returning.
  3. I’d be interested in figuring out how to make multiple lists — currently, I am scraping the top 25 beers, but I would be interested to know how to also separately display 26–50, and maybe even 51–75 and 76–100 calling on separate methods.

For now, I’m pretty okay with how it ended up, and I’ll continue to try to learn all the things I don’t know.

--

--