diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index ca9534d..776cf32 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -13,17 +13,14 @@ jobs: strategy: matrix: ruby-version: - - '2.6' - - '2.7' - - '3.0' + - '3.1' + - '3.2' + - '3.3' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Ruby - # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, - # change this to (see https://github.com/ruby/setup-ruby#versioning): - # uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically diff --git a/.rubocop.yml b/.rubocop.yml index f32b417..22fefb2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,9 @@ -Metrics/LineLength: +AllCops: + NewCops: disable + +Layout/LineLength: Max: 100 - + Metrics/BlockLength: Exclude: - 'spec/**/*_spec.rb' \ No newline at end of file diff --git a/.ruby-version b/.ruby-version index 0cadbc1..2451c27 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.5.5 +3.0.7 diff --git a/google_distance_matrix.gemspec b/google_distance_matrix.gemspec index 4cba11f..f2ed1de 100644 --- a/google_distance_matrix.gemspec +++ b/google_distance_matrix.gemspec @@ -19,6 +19,8 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] + spec.required_ruby_version = '>= 3.0' + spec.add_dependency 'activemodel', '>= 3.2.13', '< 7.2' spec.add_dependency 'activesupport', '>= 3.2.13', '< 7.2' spec.add_dependency 'google_business_api_url_signer', '~> 0.1.3' @@ -26,7 +28,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler' spec.add_development_dependency 'rake' spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 0.59.2' + spec.add_development_dependency 'rubocop', '~> 0.93.1' spec.add_development_dependency 'shoulda-matchers', '~> 4.0.0.rc1' spec.add_development_dependency 'webmock', '~> 3.4.2' end diff --git a/lib/google_distance_matrix/client.rb b/lib/google_distance_matrix/client.rb index d9312e5..f9114b0 100644 --- a/lib/google_distance_matrix/client.rb +++ b/lib/google_distance_matrix/client.rb @@ -32,8 +32,8 @@ def get(url, instrumentation: {}, **_options) end handle response, url - rescue Timeout::Error => error - raise ServerError, error + rescue Timeout::Error => e + raise ServerError, e end private diff --git a/lib/google_distance_matrix/place.rb b/lib/google_distance_matrix/place.rb index afdad75..f529e1d 100644 --- a/lib/google_distance_matrix/place.rb +++ b/lib/google_distance_matrix/place.rb @@ -95,8 +95,6 @@ def assign_attributes(attributes) @lng = attributes[:lng] end - # rubocop:disable Metrics/AbcSize - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Style/GuardClause def validate_attributes unless address.present? || (lat.present? && lng.present?) @@ -107,8 +105,6 @@ def validate_attributes raise ArgumentError, 'Cannot provide address, lat and lng.' end end - # rubocop:enable Metrics/AbcSize - # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Style/GuardClause end end diff --git a/lib/google_distance_matrix/polyline_encoder/value_encoder.rb b/lib/google_distance_matrix/polyline_encoder/value_encoder.rb index 1f7ea8b..4105d08 100644 --- a/lib/google_distance_matrix/polyline_encoder/value_encoder.rb +++ b/lib/google_distance_matrix/polyline_encoder/value_encoder.rb @@ -14,6 +14,7 @@ class PolylineEncoder class ValueEncoder # rubocop:disable Metrics/MethodLength # rubocop:disable Metrics/AbcSize + # rubocop:disable Metrics/CyclomaticComplexity def encode(value) negative = value < 0 value = value.abs @@ -49,6 +50,7 @@ def encode(value) # step 11: Convert to ASCII chunks_of_5_bits.map(&:chr) end + # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/MethodLength # rubocop:enable Metrics/AbcSize diff --git a/lib/google_distance_matrix/url_builder.rb b/lib/google_distance_matrix/url_builder.rb index 7f88ab6..a64bd82 100644 --- a/lib/google_distance_matrix/url_builder.rb +++ b/lib/google_distance_matrix/url_builder.rb @@ -81,7 +81,6 @@ def params end # rubocop:disable Metrics/MethodLength - # rubocop:disable Metrics/AbcSize def places_to_param(places) places_to_param_config = { lat_lng_scale: configuration.lat_lng_scale } @@ -102,7 +101,6 @@ def places_to_param(places) out.join(DELIMITER) end # rubocop:enable Metrics/MethodLength - # rubocop:enable Metrics/AbcSize def protocol configuration.protocol + '://' diff --git a/spec/lib/google_distance_matrix/client_cache_spec.rb b/spec/lib/google_distance_matrix/client_cache_spec.rb index 0db3593..1e8b214 100644 --- a/spec/lib/google_distance_matrix/client_cache_spec.rb +++ b/spec/lib/google_distance_matrix/client_cache_spec.rb @@ -12,7 +12,7 @@ subject { described_class.new client, cache } - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength describe '::key' do it 'returns a digest of given URL' do key = described_class.key 'some url with secret parts', config @@ -29,7 +29,7 @@ expect(subject.get(url, options)).to eq 'cached-data' end - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength it 'asks client when cache miss' do expect(client).to receive(:get).with(url, options).and_return 'api-data' diff --git a/spec/lib/google_distance_matrix/configuration_spec.rb b/spec/lib/google_distance_matrix/configuration_spec.rb index d3ee280..31c1902 100644 --- a/spec/lib/google_distance_matrix/configuration_spec.rb +++ b/spec/lib/google_distance_matrix/configuration_spec.rb @@ -91,12 +91,12 @@ it { expect(subject.logger).to be_nil } it { expect(subject.cache).to be_nil } - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength it 'has a default expected cache_key_transform' do key = subject.cache_key_transform.call('foo') expect(key).to eq 'f7fbba6e0636f890e56fbbf3283e524c6fa3204ae298382d624741d0dc6638326e282c41be5e4254d8820772c5518a2c5a8c0c7f7eda19594a7eb539453e1ed7' end - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength end describe '#to_param' do