Git Product home page Git Product logo

ts-weather's Introduction

README

My solution for a weather report programming challenge. Try it out here

Screenshot

The programming challenge prompt

  • Accept an address as input
  • Retrieve forecast data for the given address. This should include, at minimum, the current temperature (Bonus points - Retrieve high/low and/or extended forecast)
  • Display the requested forecast details to the user
  • Cache the forecast details for 30 minutes for all subsequent requests by zip codes.
  • Display indicator if result is pulled from cache.

Usage

As the prompt requires, once the service is running you can enter:

  • an address
  • city & state
  • city & country

... and the app will return:

  • current temperature
  • high/low
  • extended forcast

It will also cache responses for 30 mins per zip code.

Additional gems added beyond standard Rails gems

Weather forecast gem

Address validation

  • geocoder - I'll ensure the address passed in is valid before I make the call to OpenWeatherMap. I'll be using the lat/long in the response in my OpenWeatherMap call.

Testing

  • rspec-rails - RSpec has become a standard in the Rails community and is my favoritee unit testing library
  • webmock - Webmock ensures that no network requests are allowed during test runs.
  • timecop - "A gem providing "time travel" and "time freezing" capabilities, making it dead simple to test time-dependent code." ~Timecop repository.

Debugging

  • pry-byebug - Helpful for setting breakpoints while building the solution

Orchstration

  • foreman - Useful to manage both my Puma web server and my webpacker server. ** I have Procfile for Heroku and Procfile.dev for my local environment.
  • dotenv-rails - Useful to load environment variables from my .env file.

Caching

  • redis - Using Redis to store my cached weather calls. Redis' TTL method allows me to easily get the expiration time of the cached data.

Get started

  1. Install Ruby 3.x
  • I'm using the latest version of Ruby, but any version of Ruby 3 should work.
  1. Install Redis
  • Required for caching
  1. Install Bundler
gem install bundler
  1. Run bundle install
  • This will install all required gems for the app.
  1. Copy the .env-sample and save it as .env. You'll need to get an API key for OpenWeatherMap for this solution to work. The Raygun API key is a nice to have for error reporting that isn't a necessity.

  2. Run foreman start -f Procfile.dev

Running the test suite

After running installing Ruby & Bundler as outlined in the Get started section above, run bundle exec rspec to run the suite of tests I wrote for this project.

If you'd like you can also run bundle exec rubocop to see how I've stayed in Ruby best practices. Adjustments I've made to Rubocop can be found here

ts-weather's People

Contributors

abelmartin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.