News Reader: My First Ruby Gem and How to Use it

Jean Gérard Bousiquot
JGB Solutions
Published in
2 min readOct 30, 2018

Hi! My name is Jean Gérard Bousiquot, a software Engineer at NouKòd.

Today I’m going to walk you through the instructions on how to use my first Ruby gem. It’s available on Github and RubyGems.org.

Let’s begin!

The gem is called News Reader. It is a CLI app that allows you to list and read a list of articles scraped from a website on the internet.

This project is for education purpose only. Do not use it in production. I built it as a homework of the Full Stack Web Developer curriculum I’m following at Flatiron School.

Open a terminal window. I’m using iTerm2 on a Mac. Try it on Windows or Linux. Make sure you have Ruby and Ruby gems installed on your machine. It should come with Ruby by default.

  • Go to your projects folder
  • Create a folder to try the gem mkdir -p /your/project/folder/news-reader & cd into it
  • In your terminal type echo “source ‘https://rubygems.org’\ngem ‘news_reader’” > Gemfile
  • Then type bundle install — path vendor to install the dependencies locally in a vendor folder

Wait for the the dependencies to be installed.

  • Create ruby test file with touch test.rb
  • Add this code in your ruby file:

require “bundler/setup”
require ‘news_reader’

NewsReader::CLI.start

We use the CLI.start to start the app. It’s namespaced with NewsReader.

  • Now run the program with ruby test.rb

The app scrapes articles from this blog: http://www.loremipsum.biz/blog
and allows you to browse/list them in the terminal.

Here’s a video if you are more a visual person.

Now have fun!!!

--

--

Jean Gérard Bousiquot
JGB Solutions

Software Engineer @NouKod by day. Entrepreneur @jgb_solutions (https://jgb.solutions) by night. Web & Mobile. #JavaScript/#Ruby/#PHP enthusiast.