GitXplorerGitXplorer
a

whither

public
0 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
02b704bbf96806f3512843b3e8810425c13e05c5

Add Temperature model to do conversions between units

aaschrab committed 2 years ago
Unverified
b22b3d22577da5d1a6cca7c9b58b8e0fa100ff3d

Add weather controller and route to it

aaschrab committed 2 years ago
Unverified
8194e32324a08287a54c0608356f34df88e11a80

Initial weather model

aaschrab committed 2 years ago
Unverified
1dc357e364856d6544708461f45a2fa3f9286cc3

Extract some methods from Location model to ApiClient concern

aaschrab committed 2 years ago
Unverified
c08f4eb7ff4acaa58a86283107fb5a5835cc7f86

Basic implementation of Location model

aaschrab committed 2 years ago
Unverified
6ec41bda25d27e2d9328cffc0dc99a89c40f6891

Install climate_control gem

aaschrab committed 2 years ago

README

The README file for this repository.

README

This is a basic Ruby on Rails app to display weather for a specified address in the US.

Configuration

This application requires two environment variables to be set with API keys.

The first is GOOGLE_MAP_API_KEY, which is used to get information about the entered address such as the zipcode and geographic coordinates. Instructions for getting a key can be found at https://cloud.google.com/docs/authentication/api-keys.

The second required variable is OPENWEATHER_API_KEY. This is used to retrieve weather information for the coordinates obtained from the previous API. Instructions for creating these API keys can be found at https://openweathermap.org/api.

Running

This application was developed using Ruby version 3.2.2, and it is recommended that Ruby 3.2.x is used to run it. It may work with other versions, but that hasn't been tested.

bundle # Install dependencies specified in `Gemfile`
rails dev:cache # Toggle caching in dev mode to on (assuming it wasn't already on)
rails server # Start development-mode server

The last command there will display a URL, which you can open in your web browser to use the application.

Class descriptions

Models

Temperature

A simple class to represent a temperature. It supports any of the following temperature scales:

  • Kelvin
  • Degrees Celsius
  • Degrees Fahrenheit

Read and write acccessors are available for all of those scales. When initializing, the desired scale can be passed as a Symbol in the second argument with :kelvin being the default.

ApiClient concern

Some common functionality for working with the geolocation and weather APIs.

Location

Use a geolocation API to get zipcode and coordinates for an address passed as a String.

Weather

Use an API to get weather information for a Location. The passed location must respond to the following methods:

  • #zipcode
  • #latitude
  • #longitude

Controllers

Weather

Present a form for the user to enter an address, and display weather at that address.