Kaizoku - My First Ruby Gem


I had so much fun building Groupie that I decided to build another CLI! This time I wanted to incorporate web scraping and turn my CLI into a Ruby Gem. The result is Kaizoku.

Kaizoku means “pirate” in Japanese. Kaizoku scours the internet for the best Ruby gems.

Here is the Github link to the source code.

Video Walkthrough

Installing Kaizoku**

If you visit rubygems.org and search for Kaizoku, you will see my gem! Here is a direct link. You can also use the terminal to search for and install the gem by typing gem search kaizoku and gem install kaizoku.

Making a Gem

There are a ton of helpful guides on rubygems.org. Their guides walk you through making your first gem and publishing it to the site.

The trickiest part for me was pushing the gem to RubyGems.org. I kept on getting an error that had something to do with a “changelog.” After some quick googling, I realized that a changelog is simply a .md file you add to the gem. The changelog.md file is where you record notable changes to the project. My changelog’s is based on Keep a ChangeLog template.

Web Scraping with Nokogiri

Nokogiri is Ruby gem that fetches and parses HTML documents (a web scraper). Kaizoku uses Nokogiri to scrape ruby-toolbox.com. Here an example of the code used to return a list of categorized gems:

 def get_category
   doc = Nokogiri::HTML(open("https://www.ruby-toolbox.com"))
   doc.css(".category-group").each do |category|
     puts category.css("h3").text
   end
   get_subcategory_screen
 end