Coder Social home page Coder Social logo

weather-forecast's Introduction

Weather Forecast Exercise

A simple weather forecast app. See ASSIGNMENT.md for the original assignment.

Submitted by Tim Morton ([email protected]).

Setup and Running

The setup is similar to any other Rails app. There are no API keys or database setup needed.

  • Ensure you have a valid Ruby install. 3.1.4 is the tested version; most version managers (ie rbenv) will detect it from the .ruby-version file.
  • Install gems: bundle install
  • Run specs: rspec
  • Run server: ./bin/rails server
  • Visit http://127.0.0.1:3000/

Design Notes

API usage

This app uses two APIs - one for geocoding, and one for weather reports. I've set them up in two different ways.

Geocoding

For geocoding, I'm using the Geocoder gem, which is calling the nominatim service under the hood.

These requests are not cached, but the gem has caching options that could be configured.

Weather Forecasts

For weather forecasts, I wrote my own client for weather.gov. While there are gems for this, I figured a hand-rolled client would be a better demonstration.

See forecast_lookup.rb for the network code.

Caching

The weather forecasts are cached for 30 minutes, by postal code, as requested in the assignment.

The cache is the standard Rails.cache, which is configured to use memory_store in development. It will not persist between restarts of the server process.

I considered using ActiveRecord and storing the forecasts in a database, as the "cache". That may be useful for future features of this application, but it was overkill for the assignment given.

Testing

My tests of the network code rely on the VCR gem. It provides fast, consistent mocked network traffic, based on actual requests.

End Notes

Thanks for looking this over. Hopefully this exercise demonstrates some skill - looking forward to talking further!

weather-forecast's People

Contributors

tmorton 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.