Giter VIP home page Giter VIP logo

apple's Introduction

Ruby on Rails CI

Weather Forecasting with Rails

This sample application presents an extended weather forecast for a given address, where an address can be either of a street address, city and state, or a street address and a zipcode.

Given an address, the application uses a public API to convert the address to a (latitude, longitude) pair. Next, the coordinates are passed to another freely-available API to find forecast information, including URLs for extended data such as a weeklong forecast. Finally, the application retrieves JSON data from the foreacast endpoint and presents it. Forecast information for a particular address is cached for 30 minutes.

Installation

Clone this repo to your development environment, change to the directory containing the source, and run the following commands. (Configuration files exist for rvm and asdf.)

bundle install
rspec
rails s

Point your browser to localhost:3000.

Configuration

Three environment variables are available to control the behavior of the application.

  • WEATHER_CACHE_OFF (default: false): If caching is enabled in the Rails environment, but WEATHER_CACHE_OFF is true, no caching occurs.

  • WEATHER_CACHE_EXPIRY_IN_SECONDS (default: 30 minutes): Set this variable to a number of seconds to control the expiry of cached information.

  • WEATHER_DEBUG_HTTP (default: false): Set this variable to true to see all network requests and responses made by the application. The value of debug in the configuration YAML files have precedence.

Configuration of each service -- the geocoder and the forecast lookup -- are controlled by YAML files found in config/services.

Of Interest

  • All code has been policed by Rubocop. See the configuration file for the cops and rules applied. (The Markdown linter has been applied to this README.)

  • The controllers are very thin, as are the models. The application "glue" is provided via a set of services implemented per the Interactor pattern.

  • Networking calls can be debugged easily. Simply set debug: true in any of the network service configurations.

  • The code uses a handful of Rails features to make the code more robust and modular:

    • Views use strict locals, which disables the sharing of instance variables between a controller and its partials.
    • A localization file provides for customization of time formats.
    • YAML files are used to configure the endpoints of various services.
    • Turbo is disabled for the application to reduce complexity.
  • A minimal but functional Github action has been installed in this repo to run tests after each push.

Colophon

For a complete list of gems used in the application, see

Room for Improvement

The application follows Rails best practices, but could be made more feature-rich. Some areas for improvement:

  • Integrate anyway_config for more flexible configuration, including "dot" files, environment variables, and Rails secrets.

  • Enable and use Turbo, Hotwire, and Stimulus to provide single-page application behaavior and real-time forecase updates.

  • Implement more integration tests and include the climate_control gem to test environment variables.

  • Add the Tailwind CSS framework or its ilk and style pages.

apple's People

Contributors

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