A simple command line application which uses Hacker News API to get details for up to a 100 of the top posts.
- Clone repository
cdto the project's root directory
This is the preferred way to use the application as you don't have to worry about setup of your local environment and minimize software installations.
Head to the Docker website and download the installation for your platform.
- Run
docker build -t hackernews .to build the image (note that this might take a few minutes if you don't haven't previously downloaded the base images) - Run
docker run hackernews --posts 5to build the container and run the application to see the top 5 posts from Hacker News
- Install ruby on your machine. For Windows, you can find some information here. If you are on Mac, I suggest you install Homewbrew(a package management system) and run
brew install ruby. - Run
gem install bundler - Run
bundle installto install all of the required gems - Run
ruby hackernews.rb --posts 5to see the top 5 posts from Hacker News
- Faraday - HTTP library used for connecting to the API.
- RSpec - Testing framework used for TDD of the application.
- Webmock - Library used for stubbing HTTP requests to avoid hitting the API during development and testing.
- Use this API and
OpenURIto get posts with the details loaded in an array. It will be faster as you wound't need to make an API call for each story based on the ID. Need to consider who is maintaining the API as it's not the official one. - An alternative solution is to parse Hacker News using the Nokogiri library.