-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial OpenWeather ruby client implementation.
- Loading branch information
0 parents
commit 604b275
Showing
46 changed files
with
1,196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.env | ||
pkg | ||
Gemfile.lock | ||
.DS_Store | ||
.bundle | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--format documentation | ||
--color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Style/ModuleFunction: | ||
Enabled: false | ||
|
||
Style/Documentation: | ||
Enabled: false | ||
|
||
Metrics: | ||
Enabled: false | ||
|
||
inherit_from: .rubocop_todo.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config` | ||
# on 2020-04-28 00:01:49 -0400 using RuboCop version 0.81.0. | ||
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. | ||
|
||
# Offense count: 1 | ||
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms. | ||
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS | ||
Naming/FileName: | ||
Exclude: | ||
- 'lib/open-weather-ruby-client.rb' | ||
|
||
# Offense count: 14 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. | ||
# URISchemes: http, https | ||
Layout/LineLength: | ||
Max: 112 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
language: ruby | ||
|
||
cache: bundler | ||
|
||
rvm: | ||
- 2.6.6 | ||
|
||
before_script: | ||
- bundle exec danger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### 0.1.0 (Next) | ||
|
||
* Initial public release - [@dblock](https://github.com/dblock). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# Contributing to OpenWeather-Ruby-Client | ||
|
||
This project is work of [many contributors](https://github.com/dblock/open-weather-ruby-client/graphs/contributors). | ||
|
||
You're encouraged to submit [pull requests](https://github.com/dblock/open-weather-ruby-client/pulls), [propose features and discuss issues](https://github.com/dblock/open-weather-ruby-client/issues). | ||
|
||
In the examples below, substitute your Github username for `contributor` in URLs. | ||
|
||
### Fork the Project | ||
|
||
Fork the [project on Github](https://github.com/dblock/open-weather-ruby-client) and check out your copy. | ||
|
||
``` | ||
git clone https://github.com/contributor/open-weather-ruby-client.git | ||
cd open-weather-ruby-client | ||
git remote add upstream https://github.com/dblock/open-weather-ruby-client.git | ||
``` | ||
|
||
### Bundle Install and Test | ||
|
||
Ensure that you can build the project and run tests. | ||
|
||
``` | ||
bundle install | ||
bundle exec rake | ||
``` | ||
|
||
## Contribute Code | ||
|
||
### Create a Topic Branch | ||
|
||
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix. | ||
|
||
``` | ||
git checkout master | ||
git pull upstream master | ||
git checkout -b my-feature-branch | ||
``` | ||
|
||
### Write Tests | ||
|
||
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add tests to [spec](spec). | ||
|
||
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix. | ||
|
||
### Write Code | ||
|
||
Implement your feature or bug fix. | ||
|
||
Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop). Run `bundle exec rubocop` and fix any style issues highlighted, auto-correct issues when possible with `bundle exec rubocop -a`. To silence generally ingored issues, including line lengths or code complexity metrics, run `bundle exec rubocop --auto-gen-config`. | ||
|
||
Make sure that `bundle exec rake` completes without errors. | ||
|
||
### Write Documentation | ||
|
||
Document any external behavior in the [README](README.md). | ||
|
||
### Update Changelog | ||
|
||
Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Don't remove *Your contribution here*. | ||
|
||
Make it look like every other line, including a link to the issue being fixed, your name and link to your Github account. | ||
|
||
### Commit Changes | ||
|
||
Make sure git knows your name and email address: | ||
|
||
``` | ||
git config --global user.name "Your Name" | ||
git config --global user.email "[email protected]" | ||
``` | ||
|
||
Writing good commit logs is important. A commit log should describe what changed and why. | ||
|
||
``` | ||
git add ... | ||
git commit | ||
``` | ||
|
||
### Push | ||
|
||
``` | ||
git push origin my-feature-branch | ||
``` | ||
|
||
### Make a Pull Request | ||
|
||
Go to https://github.com/contributor/open-weather-ruby-client and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days. | ||
|
||
### Update CHANGELOG Again | ||
|
||
Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows. | ||
|
||
``` | ||
* [#123](https://github.com/dblock/open-weather-ruby-client/pull/123): Reticulated splines - [@contributor](https://github.com/contributor). | ||
``` | ||
|
||
Amend your previous commit and force push the changes. | ||
|
||
``` | ||
git commit --amend | ||
git push origin my-feature-branch -f | ||
``` | ||
|
||
### Rebase | ||
|
||
If you've been working on a change for a while, rebase with upstream/master. | ||
|
||
``` | ||
git fetch upstream | ||
git rebase upstream/master | ||
git push origin my-feature-branch -f | ||
``` | ||
|
||
### Check on Your Pull Request | ||
|
||
Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above. | ||
|
||
### Be Patient | ||
|
||
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there! | ||
|
||
## Thank You | ||
|
||
Please do know that we really appreciate and value your time and work. We love you, really. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
toc.check | ||
changelog.check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
source 'http://rubygems.org' | ||
|
||
gemspec | ||
|
||
group :development, :test do | ||
gem 'danger-changelog', '~> 0.4.2' | ||
gem 'danger-toc', '~> 0.1.3' | ||
gem 'dotenv' | ||
gem 'pry' | ||
gem 'rake' | ||
gem 'rspec' | ||
gem 'rubocop', '~> 0.81.0' | ||
gem 'vcr' | ||
gem 'webmock' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Daniel Doubrovkine | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
OpenWeather Ruby Client | ||
======================= | ||
|
||
[![Gem Version](https://badge.fury.io/rb/open-weather-ruby-client.svg)](https://badge.fury.io/rb/open-weather-ruby-client) | ||
[![Build Status](https://travis-ci.org/dblock/open-weather-ruby-client.svg?branch=master)](https://travis-ci.org/dblock/open-weather-ruby-client) | ||
|
||
A complete Ruby client for the [OpenWeather API v3](https://openweathermap.org/api). | ||
|
||
Unlike other clients, including [open-weather](https://github.com/coderhs/ruby_open_weather_map), provides a rich first class interface to OpenWeather models, implements more consistent error handling, and is built with thorough test coverage using actual OpenWeather data. | ||
|
||
## Table of Contents | ||
|
||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Current Weather](#current-weather) | ||
- [Configuration](#configuration) | ||
- [Errors](#errors) | ||
- [Users](#users) | ||
- [Resources](#resources) | ||
- [Contributing](#contributing) | ||
- [Copyright and License](#copyright-and-license) | ||
|
||
## Installation | ||
|
||
Add to Gemfile. | ||
|
||
``` | ||
gem 'open-weather-ruby-client' | ||
``` | ||
|
||
Run `bundle install`. | ||
|
||
## Usage | ||
|
||
Use an access token obtained from [API Keys](https://home.openweathermap.org/api_keys) on the OpenWeather website after registration. | ||
|
||
```ruby | ||
client = OpenWeather::Client.new( | ||
api_key: "1a2b3c4d5a6b7c8d9a8b7c6d5a4b3c2d1" | ||
) | ||
``` | ||
|
||
### Current Weather | ||
|
||
Returns the current weather. | ||
|
||
```ruby | ||
data = client.weather(city: 'London') # => OpenWeather::Models::Data | ||
|
||
data.name # => 'London' | ||
data.main.feels_like # => 277.73 | ||
data.main.humidity # => 81 | ||
data.main.pressure # => 1005 | ||
data.main.temp # => 282.57 | ||
data.main.temp_max # => 283.15 | ||
data.main.temp_min # => 281.48 | ||
``` | ||
|
||
You can retrieve data by city, state and country code. | ||
|
||
```ruby | ||
client.weather(city: 'New York', state: 'NY', country: 'USA') | ||
``` | ||
|
||
See [OpenWeather::Models::Data](lib/open_weather/models/data.rb) for all available properties. | ||
|
||
## Configuration | ||
|
||
You can configure client options, globally. | ||
|
||
```ruby | ||
OpenWeather::Client.configure do |config| | ||
config.api_key = '1a2b3c4d5a6b7c8d9a8b7c6d5a4b3c2d1' | ||
config.user_agent = 'OpenWeather Ruby Client/1.0' | ||
end | ||
``` | ||
|
||
The following settings are supported. | ||
|
||
setting | description | ||
--------------------|------------ | ||
api_key | Required API key. | ||
endpoint | Defaults to `https://api.openweathermap.org/data/2.5/`. | ||
user_agent | User-agent, defaults to _OpenWeather Ruby Client/version_. | ||
proxy | Optional HTTP proxy. | ||
ca_path | Optional SSL certificates path. | ||
ca_file | Optional SSL certificates file. | ||
logger | Optional `Logger` instance that logs HTTP requests. | ||
timeout | Optional open/read timeout in seconds. | ||
open_timeout | Optional connection open timeout in seconds. | ||
|
||
## Errors | ||
|
||
All errors that return HTTP codes 400-600 result in either `Faraday::Error::ResourceNotFound`, `Faraday::Error::ConnectionFailed` or [OpenWeather::Errors::Fault](lib/open_weather/errors/fault.rb) exceptions. | ||
|
||
## Resources | ||
|
||
* [OpenWeather API Documentation](https://openweathermap.org/api) | ||
|
||
## Contributing | ||
|
||
See [CONTRIBUTING](CONTRIBUTING.md). | ||
|
||
## Copyright and License | ||
|
||
Copyright (c) 2020, [Daniel Doubrovkine](https://twitter.com/dblockdotorg) | ||
|
||
This project is licensed under the [MIT License](LICENSE.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Releasing OpenWeather-Ruby-Client | ||
|
||
There're no hard rules about when to release open-weather-ruby-client. Release bug fixes frequently, features not so frequently and breaking API changes rarely. | ||
|
||
### Release | ||
|
||
Run tests, check that all tests succeed locally. | ||
|
||
``` | ||
bundle install | ||
rake | ||
``` | ||
|
||
Check that the last build succeeded in [Travis CI](https://travis-ci.org/dblock/open-weather-ruby-client) for all supported platforms. | ||
|
||
Change "Next" in [CHANGELOG.md](CHANGELOG.md) to the current date. | ||
|
||
``` | ||
### 0.2.2 (7/10/2015) | ||
``` | ||
|
||
Remove the line with "Your contribution here.", since there will be no more contributions to this release. | ||
|
||
Commit your changes. | ||
|
||
``` | ||
git add CHANGELOG.md | ||
git commit -m "Preparing for release, 0.2.2." | ||
git push origin master | ||
``` | ||
|
||
Release. | ||
|
||
``` | ||
$ rake release | ||
open-weather-ruby-client 0.2.2 built to pkg/open-weather-ruby-client-0.2.2.gem. | ||
Tagged v0.2.2. | ||
Pushed git commits and tags. | ||
Pushed open-weather-ruby-client 0.2.2 to rubygems.org. | ||
``` | ||
|
||
### Prepare for the Next Version | ||
|
||
Add the next release to [CHANGELOG.md](CHANGELOG.md). | ||
|
||
``` | ||
### 0.2.3 (Next) | ||
* Your contribution here. | ||
``` | ||
|
||
Increment the third version number in [lib/open_weather/version.rb](lib/open_weather/version.rb). | ||
|
||
Commit your changes. | ||
|
||
``` | ||
git add CHANGELOG.md lib/open_weather/version.rb | ||
git commit -m "Preparing for next development iteration, 0.2.3." | ||
git push origin master | ||
``` |
Oops, something went wrong.