Skip to content

Commit

Permalink
Merge branch 'master' into alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
troya2 authored Dec 31, 2023
2 parents c596d08 + aeac490 commit b084339
Show file tree
Hide file tree
Showing 18 changed files with 142 additions and 45 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/danger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: PR Linter
on: [pull_request]
jobs:
danger:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 3.1
- run: |
# the personal token is public, this is ok, base64 encode to avoid tripping Github
TOKEN=$(echo -n Z2hwX0xNQ3VmanBFeTBvYkZVTWh6NVNqVFFBOEUxU25abzBqRUVuaAo= | base64 --decode)
DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
15 changes: 15 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: RuboCop
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true
- name: Run RuboCop
run: bundle exec rubocop

26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
entry:
- { ruby: "2.7" }
- { ruby: "3.0" }
- { ruby: "3.1" }
- { ruby: "3.2" }
- { ruby: ruby-head, ignore: true }
- { ruby: jruby-head, ignore: true }
name: Test (ruby=${{ matrix.entry.ruby }})
steps:
- uses: actions/checkout@v3
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ${{ matrix.entry.ruby }}
- name: Run Tests
continue-on-error: ${{ matrix.entry.ignore || false }}
run: bundle exec rspec

33 changes: 28 additions & 5 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-05-15 23:25:38 -0400 using RuboCop version 0.81.0.
# on 2023-03-20 09:58:58 UTC using RuboCop version 1.48.1.
# 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.
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'open-weather-ruby-client.gemspec'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedMethods.
# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?
Lint/RedundantSafeNavigation:
Exclude:
- 'lib/open_weather/endpoints/stations.rb'

# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
# 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: 76
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'lib/open_weather/logger.rb'
- 'spec/open_weather/client_spec.rb'

# Offense count: 7
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 181
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
### 0.2.1 (Next)
### 0.4.1 (Next)

* Your contribution here.

### 0.4.0 (2023/08/13)

* [#33](https://github.com/dblock/open-weather-ruby-client/pull/33): Upgrade Faraday to 2.x - [@dgarwood](https://github.com/dgarwood).

### 0.3.0 (2023/03/25)

* [#30](https://github.com/dblock/open-weather-ruby-client/pull/30): Added support for Ruby 3.2 - [@petergoldstein](https://github.com/petergoldstein).
* [#27](https://github.com/dblock/open-weather-ruby-client/pull/27): Removed default values for Faraday’s SSL settings ca_file and ca_path - [@sunny](https://github.com/sunny).
* [#21](https://github.com/dblock/open-weather-ruby-client/pull/21), [#20](https://github.com/dblock/open-weather-ruby-client/pull/20), [#19](https://github.com/dblock/open-weather-ruby-client/pull/19), [#18](https://github.com/dblock/open-weather-ruby-client/pull/18): Added support for Stations API - [@wasabigeek](https://github.com/wasabigeek).
* [#22](https://github.com/dblock/open-weather-ruby-client/pull/23): Removed API version from `Config#endpoint` - [@dblock](https://github.com/dblock).
* [#25](https://github.com/dblock/open-weather-ruby-client/pull/25): Exposed the national weather alerts response in the One Call API [@troya2](https://github.com/troya2).
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ 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.
Go back to your pull request after a few minutes and see whether it passed muster with GitHub Actions. Everything should look green, otherwise fix issues and amend your commit as described above.

### Be Patient

Expand Down
12 changes: 0 additions & 12 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,3 @@
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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)
[![Tests Status](https://github.com/dblock/open-weather-ruby-client/actions/workflows/test.yml/badge.svg)](https://github.com/dblock/open-weather-ruby-client/actions)

A Ruby client for the [OpenWeather API v2.5 and v3.0](https://openweathermap.org/api).

Expand Down
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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.
Check that the last build succeeded in GitHub Actions for all supported platforms.

Change "Next" in [CHANGELOG.md](CHANGELOG.md) to the current date.

Expand Down
15 changes: 15 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Upgrading OpenWeather Ruby Client
=================================

### Upgrading to >= 0.3.0

[#27](https://github.com/dblock/open-weather-ruby-client/pull/27) Removes default values for Faraday's SSL settings `ca_file` and `ca_path`.

If you previously relied on `OpenSSL::X509::DEFAULT_CERT_FILE` or `OpenSSL::X509::DEFAULT_CERT_DIR` to set these values you must now do so explicitly. E.g.:

```ruby
OpenWeather::Client.configure do |config|
config.ca_path = OpenSSL::X509::DEFAULT_CERT_DIR
config.ca_file = OpenSSL::X509::DEFAULT_CERT_FILE
end
```
3 changes: 2 additions & 1 deletion lib/open-weather-ruby-client.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

require 'faraday'
require 'faraday_middleware'
require 'faraday/multipart'

require 'json'
require 'logger'
require 'hashie'
Expand Down
4 changes: 2 additions & 2 deletions lib/open_weather/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def reset
self.endpoint = 'https://api.openweathermap.org/data'
self.api_key = nil
self.user_agent = "OpenWeather Ruby Client/#{OpenWeather::VERSION}"
self.ca_path = defined?(OpenSSL) ? OpenSSL::X509::DEFAULT_CERT_DIR : nil
self.ca_file = defined?(OpenSSL) ? OpenSSL::X509::DEFAULT_CERT_FILE : nil
self.ca_path = nil
self.ca_file = nil
self.proxy = nil
self.logger = nil
self.timeout = nil
Expand Down
13 changes: 6 additions & 7 deletions lib/open_weather/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ def connection
request_options[:open_timeout] = open_timeout if open_timeout
options[:request] = request_options if request_options.any?

::Faraday::Connection.new(endpoint, options) do |connection|
connection.use ::Faraday::Request::Multipart
connection.use ::Faraday::Request::UrlEncoded
connection.use ::OpenWeather::Response::RaiseError
connection.use ::FaradayMiddleware::ParseJson, content_type: /\bjson$/
connection.response :logger, logger if logger
connection.adapter ::Faraday.default_adapter
Faraday.new(endpoint, options) do |f|
f.request :multipart
f.request :url_encoded
f.use ::OpenWeather::Response::RaiseError
f.response :json, content_type: /\bjson$/
f.response :logger, logger if logger
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/open_weather/raise_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module OpenWeather
module Response
class RaiseError < ::Faraday::Response::Middleware
class RaiseError < ::Faraday::Response::RaiseError
def on_complete(env)
case env[:status]
when 404
Expand Down
2 changes: 1 addition & 1 deletion lib/open_weather/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module OpenWeather
VERSION = '0.2.1'
VERSION = '0.4.1'
end
14 changes: 12 additions & 2 deletions open-weather-ruby-client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ Gem::Specification.new do |s|
s.licenses = ['MIT']
s.summary = 'OpenWeather API Ruby client.'
s.add_dependency 'activesupport'
s.add_dependency 'faraday', '>= 1.0.0'
s.add_dependency 'faraday_middleware'
s.add_dependency 'faraday', '>= 2.0.1'
s.add_dependency 'faraday-multipart'
s.add_dependency 'hashie'

s.add_development_dependency 'danger-changelog', '~> 0.4.2'
s.add_development_dependency 'danger-toc', '~> 0.1.3'
s.add_development_dependency 'dotenv'
s.add_development_dependency 'pry'
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec'
s.add_development_dependency 'rubocop', '~> 1.48.1'
s.add_development_dependency 'vcr'
s.add_development_dependency 'webmock'
end
2 changes: 1 addition & 1 deletion spec/open_weather/endpoints/stations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
}

expect(client).to receive(:post)
.with('3.0/measurements', body: [create_params])
.with('3.0/measurements', { body: [create_params] })
.and_call_original

data = client.create_measurements([create_params])
Expand Down

0 comments on commit b084339

Please sign in to comment.