Skip to content

Commit

Permalink
Merge pull request #3 from mtomady/upgrade-ruby-and-gems
Browse files Browse the repository at this point in the history
Upgrade ruby and gems
  • Loading branch information
jpawlyn authored Feb 28, 2024
2 parents 9148347 + 5c162e9 commit a5c6843
Show file tree
Hide file tree
Showing 23 changed files with 317 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
timeout-minutes: 20
strategy:
matrix:
ruby: [ '2.6', '2.7', '3.0', 'jruby-9.3.4.0' ]
ruby: [ '3.1', '3.2', '3.3' ]
steps:
- name: Checkout icd-api
uses: actions/checkout@v2
Expand Down
19 changes: 18 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
inherit_from: .rubocop_todo.yml

# see https://docs.rubocop.org/rubocop/configuration.html#merging-arrays-using-inherit_mode
inherit_mode:
merge:
- Exclude

require:
- rubocop-rspec

AllCops:
TargetRubyVersion: 2.6
NewCops: enable
SuggestExtensions: false

Gemspec/DevelopmentDependencies:
Enabled: false

Gemspec/RequiredRubyVersion:
Enabled: false

Metrics/BlockLength:
Exclude:
Expand Down
46 changes: 46 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 10000`
# on 2024-01-25 08:03:40 UTC using RuboCop version 1.60.2.
# 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: 2
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/icd/api/client_spec.rb'

# Offense count: 1
# Configuration parameters: Max, CountAsOne.
RSpec/ExampleLength:
Exclude:
- 'spec/icd/api/authorizer_spec.rb'

# Offense count: 1
RSpec/MessageChain:
Exclude:
- 'spec/icd/api/access_token_spec.rb'

# Offense count: 1
# Configuration parameters: Max.
RSpec/MultipleExpectations:
Exclude:
- 'spec/icd/api/client_spec.rb'

# Offense count: 8
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Exclude:
- 'spec/icd/api/access_token_spec.rb'
- 'spec/icd/api/authorizer_spec.rb'
- 'spec/icd/api/options_spec.rb'

# Offense count: 1
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
- 'spec/icd/api/authorizer_spec.rb'
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.0
1 change: 0 additions & 1 deletion .ruby_version

This file was deleted.

2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ gemspec

gem 'rake', '~> 13.0'

gem 'rubocop', '~> 0.80'

group :test do
gem 'rspec', '~> 3.0'
gem 'vcr'
Expand Down
119 changes: 62 additions & 57 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,90 +7,95 @@ PATH
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.4)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.6)
bigdecimal (3.1.6-java)
crack (0.4.5)
rexml
diff-lcs (1.5.0)
faraday (1.10.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.3)
multipart-post (>= 1.2, < 3)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
hashdiff (1.0.1)
multipart-post (2.1.1)
parallel (1.21.0)
parser (3.1.1.0)
faraday (2.9.0)
faraday-net_http (>= 2.0, < 3.2)
faraday-net_http (3.1.0)
net-http
hashdiff (1.1.0)
json (2.7.1)
json (2.7.1-java)
language_server-protocol (3.17.0.3)
net-http (0.4.1)
uri
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
public_suffix (5.0.3)
racc
public_suffix (5.0.4)
racc (1.7.3)
racc (1.7.3-java)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.2.1)
rexml (3.2.5)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
rake (13.1.0)
regexp_parser (2.9.0)
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.6)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
rubocop (0.93.1)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
rubocop (1.60.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 2.7.1.5)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8)
rexml
rubocop-ast (>= 0.6.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (1.16.0)
parser (>= 3.1.1.0)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
unicode-display_width (1.8.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.20.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
rubocop-rspec (2.26.1)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
unicode-display_width (2.5.0)
uri (0.13.0)
vcr (6.2.0)
webmock (3.18.1)
webmock (3.19.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)

PLATFORMS
arm64-darwin-22
universal-java-11
x86_64-darwin-20
x86_64-linux

DEPENDENCIES
base64
bigdecimal
icd-api!
rake (~> 13.0)
rspec (~> 3.0)
rubocop (~> 0.80)
rubocop
rubocop-rspec
vcr
webmock

BUNDLED WITH
2.2.22
2.5.4
8 changes: 6 additions & 2 deletions icd-api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
spec.description = 'Desc'
spec.homepage = 'https://www.github.com'
spec.license = 'MIT'
spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
spec.required_ruby_version = Gem::Requirement.new('>= 3.1.0')

spec.metadata['allowed_push_host'] = 'http://mygemserver.com'

Expand All @@ -32,6 +32,10 @@ Gem::Specification.new do |spec|
spec.add_dependency('faraday', '>= 1.7')

# gem.add_development_dependency "bundler"
spec.add_development_dependency 'base64'
spec.add_development_dependency 'bigdecimal'
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop', '>=1.30.0'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rubocop-rspec'
spec.metadata['rubygems_mfa_required'] = 'true'
end
4 changes: 2 additions & 2 deletions lib/icd/api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
module Icd
module Api
class Client
def initialize(client_id:, client_secret:, **_options)
def initialize(client_id:, client_secret:, **options)
@client_id = client_id
@client_secret = client_secret
@options = Options.new
@options = Options.new(options)
end

def search(term)
Expand Down
4 changes: 2 additions & 2 deletions lib/icd/api/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(endpoint, params)
private

def connection
@connection ||= Faraday.new(url: options.root_url, headers: headers) do |faraday|
@connection ||= Faraday.new(url: options.root_url, headers:) do |faraday|
faraday.adapter Faraday.default_adapter
faraday.response :json
faraday.request :json
Expand All @@ -32,7 +32,7 @@ def api_path
end

def headers
{ accept: 'application/json', 'API-Version' => 'v2', 'Accept-Language' => 'en',
{ accept: 'application/json', 'API-Version' => 'v2', 'Accept-Language' => options.language.to_s,
'Authorization' => "Bearer #{access_token.token}" }
end

Expand Down
23 changes: 15 additions & 8 deletions lib/icd/api/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,26 @@
module Icd
module Api
class Options
DEFAULT_RELEASE_ID = '2022-02'
DEFAULT_REVISION = '11'
DEFAULT_LINEARIZATION_NAME = 'mms'
# see https://id.who.int/swagger/index.html
# and https://icd.who.int/docs/icd-api/SupportedClassifications/
DEFAULT_API_ROOT_URL = 'https://id.who.int'
DEFAULT_LANGUAGE = 'en'
DEFAULT_LINEARIZATION_NAME = 'mms'
DEFAULT_RELEASE_ID = '2023-01'
DEFAULT_REVISION = '11'

def initialize(**options)
def initialize(options = {})
@options = options
end

def language
@options[:language] ||= DEFAULT_LANGUAGE
end

def linearization_name
@options[:linearization_name] ||= DEFAULT_LINEARIZATION_NAME
end

def release_id
@options[:release_id] ||= DEFAULT_RELEASE_ID
end
Expand All @@ -20,10 +31,6 @@ def revision
DEFAULT_REVISION
end

def linearization_name
@options[:linearization_name] ||= DEFAULT_LINEARIZATION_NAME
end

def root_url
@options[:root_url] ||= DEFAULT_API_ROOT_URL
end
Expand Down
45 changes: 22 additions & 23 deletions spec/icd/api/access_token_spec.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
# frozen_string_literal: true

RSpec.describe Icd::Api::AccessToken do
let(:token) do
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9' \
'.eyJuYmYiOjE2NDU1NDEzNDAsImV4cCI6MTY' \
'0NTU0NDk0MCwiaXNzIjoiaHR0cHM6Ly9pY2R' \
'hY2Nlc3NtYW5hZ2VtZW50Lndoby5pbnQiLCJ' \
'hdWQiOlsiaHR0cHM6Ly9pY2RhY2Nlc3NtYW5' \
'hZ2VtZW50Lndoby5pbnQvcmVzb3VyY2VzIiw' \
'iaWNkYXBpIl0sImNsaWVudF9pZCI6IjY3MDY' \
'wNjg1LTE0ZDAtNDQxMS1iNjA3LTI2YmM4NmR' \
'kOWY0N185ODNiMDU0YS1kOTg0LTQ2NmEtOGE' \
'4OC1iOTE1MWUyZDVmZjAiLCJzY29wZSI6WyJ' \
'pY2RhcGlfYWNjZXNzIl19.MXGNVUIcgd6CD5' \
'5Qh6naBD38DuqFmB1ib4RBts0nL4nH7fGEq-' \
'JqM5DYdx-IcfQ9SMjVCSviL3YKy-1s9kklHE' \
'75xof5-YdVdfyR6X9E-oUZEXsSM8dSTrwxcj' \
'kXOg7HnNeiqEZxMHdlA1-f0i0OLJ_Q7W8VE2' \
'9rdHm3Qoh9-kCVJbePzLkaXIsnVOXqNSPsAM' \
'Q2vDLV2viKzgGNHiKljIFR8BoOOftAAbs97a' \
'pNW99Ke4bawiu4zAw6VxBH02_ElvxRvVzOxn' \
'VnH0xHuEmf6S2BcR_WVCGcKwLl80YpV3utN7' \
'ukL6YRm_5Gcl_bx208zbfbAzCk0NDZtEpZlRgToQ'
end

subject do
described_class.new({ 'expires_in' => 4000, 'access_token' => token })
end

let(:token) do
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9' \
'.eyJuYmYiOjE2NDU1NDEzNDAsImV4cCI6MTY' \
'0NTU0NDk0MCwiaXNzIjoiaHR0cHM6Ly9pY2R' \
'hY2Nlc3NtYW5hZ2VtZW50Lndoby5pbnQiLCJ' \
'hdWQiOlsiaHR0cHM6Ly9pY2RhY2Nlc3NtYW5' \
'hZ2VtZW50Lndoby5pbnQvcmVzb3VyY2VzIiw' \
'iaWNkYXBpIl0sImNsaWVudF9pZCI6IjY3MDY' \
'wNjg1LTE0ZDAtNDQxMS1iNjA3LTI2YmM4NmR' \
'kOWY0N185ODNiMDU0YS1kOTg0LTQ2NmEtOGE' \
'4OC1iOTE1MWUyZDVmZjAiLCJzY29wZSI6WyJ' \
'pY2RhcGlfYWNjZXNzIl19.MXGNVUIcgd6CD5' \
'5Qh6naBD38DuqFmB1ib4RBts0nL4nH7fGEq-' \
'JqM5DYdx-IcfQ9SMjVCSviL3YKy-1s9kklHE' \
'75xof5-YdVdfyR6X9E-oUZEXsSM8dSTrwxcj' \
'kXOg7HnNeiqEZxMHdlA1-f0i0OLJ_Q7W8VE2' \
'9rdHm3Qoh9-kCVJbePzLkaXIsnVOXqNSPsAM' \
'Q2vDLV2viKzgGNHiKljIFR8BoOOftAAbs97a' \
'pNW99Ke4bawiu4zAw6VxBH02_ElvxRvVzOxn' \
'VnH0xHuEmf6S2BcR_WVCGcKwLl80YpV3utN7' \
'ukL6YRm_5Gcl_bx208zbfbAzCk0NDZtEpZlRgToQ'
end
let(:time_now) { Time.now.utc }

before do
Expand Down
Loading

0 comments on commit a5c6843

Please sign in to comment.