CLI Data Gem Walkthrough
Last updated
Last updated
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
46 lines (41 sloc) 2.06 KB
This video walks through the process of planning and building a CLI gem. There will be more videos on the process of building a more complex gem as well as on refactoring and improving a CLI gem.
Planning your application
Generating and setting up a basic gem
Basic CLI User interface
Setting up your Objects
Setting up your Scraper
Bring it all together!
Planning the gem.
Beginning the building process.
Setting up or generating the basic structure of the gem.
Creating and stubbing out the executable file.
requiring files with require
and require_relative
.
Coding the CLI
class — our controller.
Stubbing out the CLI
class with hard-coded return data.
Creating the menu.
Setting up our Deal
class.
#today
method to return today's deals.
Stubbing out our first Deal
instances with hard-coded data.
Setting up the Deal
class attributes.
Testing our data in the console.
Wire up our menu with conditional logic to work with our array of deals.
Iterate over and display deals.
Fix spelling on #availability
.
Setting up our scraper class — should we use a Deal class method or a standalone class?
Set up Deals#scrape_deals
method.
Adding gem dependencies to the app.
Add dependencies to gemspec.
Development dependencies or runtime dependencies?
Code individual scrape methods for each site.
Use CSS selectors to scrape desired information.
Create new Deal
objects and set the attributes based on the scraped info.
Update logic for #availability
.
Final thoughts and tips on the building process.
<iframe width="100%" height="720" src="" frameborder="0" allowfullscreen></iframe>
View on Learn.co and start learning to code for free.