Skip to content

luizcarvalho/open_weather_map

Repository files navigation

OpenWeatherMap

A Ruby interface to the Open Weather Map API.

Maintainability Test Coverage

Installation

Add this line to your application's Gemfile:

gem 'open_weather_map', gituhub: 'luizcarvalho/open_weather_map'

And then execute:

> bundle install

Or install it yourself as:

> gem install open_weather_map

Quick start

Configuration

You need set appidvariable (you can found it here). You can simple set environment variable OPEN_WEATHER_MAP_APP_ID or use configuration module. With it, you change others configurations too.

OpenWeatherMap.configure do |config|
    config.lang = 'en' # or variable OPEN_WEATHER_MAP_LANG
    config.base_url = 'https://api.openweathermap.org' # or variable OPEN_WEATHER_MAP_LANG
    config.api_version = '2.5' # or variable OPEN_WEATHER_MAP_API_VERSION
    config.appid = # OPEN_WEATHER_MAP_APP_ID
    config.units = 'metric' # or variable OPEN_WEATHER_MAP_UNITS
end

Usage

You can use this client to get current weather data and daily forecast up to 16 days.

To get current weather data

# https://openweathermap.org/current
api_client.call_api('data/weather', query_params: { lat: '-10.1837852', lon: '-48.3336423' })

To get forecast weather data from 5 days, for example

# https://openweathermap.org/forecast5
api_client.call_api('data/forecast', query_params: { lat: '-10.1837852', lon: '-48.3336423' })

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/luizcarvalho/open_weather_map.

License

The gem is available as open source under the terms of the MIT License.

About

Ruby client to fetch weather information from https://openweathermap.org

Resources

License

Stars

Watchers

Forks

Packages

No packages published