Sign in

CLI Data Gem Portfolio Project

I have finished by CLI Project 2 weeks before the due date, but I am still refactoring my code and learn a new thing every day. This is the process of building my project.

I started by watching all the bonus videos and review recommend projects. I created my first gem and named it to cli and push it to Github. I have included relative files and gems in the ruby file and declare the Class name in it. I got my cli and scraper files worked. However, I couldn’t use pry to test my code because the gemspec file wasn’t set up correctly. I have to use the puts method to test my code instead. Therefore, I generate the new gem and named it to best_laptop, so I can get the correct environment and gemspec files. Now, I can use pry and run Bundle correctly. I also change the Class name to the Class namespace.

There are two methods that we can use when writing the code which is inside out or outside in. The outside-in method is creating the laptop file for collection of objects, scraper file to retrieve data from the web page, and the cli file to display data to the user. The inside out method which is we hard code inside the cli file. The scraper file will scrape the data from the web page to replace the hard code. Then, we assigned the data to collection objects in the laptop file. My approach was inside out. The reason I chose this method because it took more time to scrape the data from the web site when I worked on the scaper file. The cli file provided the user interface to the user. It called the scraper and laptop methods to retrieve data from the web page and assign them to laptop objects. Then the data will be shown to the user depending on the user’s input. The laptop file will receive an array of hash and use mass assignment to create a new object for each hash. We could add additional data to the existing object when the user wanted to know more information about the selected laptop such as Pros, Cons, Bottom Line.

In conclusion, I’ve learned the benefits of OOP which are Self, Mass Assignment, and Scraping. Besides, I also have a chance to review Array, Hash, and Git & Github. I have spent a lot of time to scrap the data by using the Nokogiri CSS selectors. This helped me to understand how to retrieve specific data from the HTML document. The Bundle tool helped to create and maintain the dependencies of the project correctly. The environment file organized all the gems and ruby files. This is very helpful when class namespace and methods are called.

Project link:

Full Stack SE. I love to build beautiful web apps and learn new technologies.