diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..dc6667d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +# Indent with 2 spaces +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 diff --git a/.github/workflows/gempush.yml b/.github/workflows/gempush.yml index afddb51..c1acf69 100644 --- a/.github/workflows/gempush.yml +++ b/.github/workflows/gempush.yml @@ -12,10 +12,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Ruby 2.7 + - name: Set up Ruby 3.0 uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.0 - name: Publish to RubyGems run: | diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index e70141b..f0df388 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: ['2.7', '3.0'] + ruby: ['3.0', '3.1', '3.2', '3.3'] name: Ruby ${{ matrix.ruby }} Test steps: - uses: actions/checkout@master diff --git a/.rubocop.yml b/.rubocop.yml index 70c56bb..56fdf98 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.0 Metrics/ClassLength: Enabled: false @@ -103,3 +103,6 @@ Security/YAMLLoad: Style/RegexpLiteral: Enabled: false + +Naming/VariableNumber: + Enabled: false diff --git a/.ruby-version b/.ruby-version index 1f7da99..eca690e 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.7 +3.0.5 diff --git a/CHANGELOG.md b/CHANGELOG.md index 653dfb2..b78062d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ -## Unreleased (2023-12-01) +## 0.7.0 (2024-02-06) +- Drop support for Ruby 2 +- Updating minimum Ruby version to Ruby 3.0.5 +- Add test support for Ruby 3.1, 3.2, 3.3 +- Updated Rubocop to enforce 3.0.x conventions +- Linting fixes - Update `BatchReportResource#batch_report_body` to allow `sub merchant id` to be received from `Bambora::Client` or `elements` ## 0.6.0 (2023-05-02) diff --git a/bambora-client.gemspec b/bambora-client.gemspec index ce7bee5..a502103 100644 --- a/bambora-client.gemspec +++ b/bambora-client.gemspec @@ -37,7 +37,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.7.7' + spec.required_ruby_version = '>= 3.0.5' spec.add_dependency 'faraday', '~> 2.0.1' spec.add_dependency 'faraday-excon' @@ -46,11 +46,11 @@ Gem::Specification.new do |spec| spec.add_dependency 'multiparty', '~> 0' spec.add_development_dependency 'bundler', '~> 2' - spec.add_development_dependency 'pry', '~> 0.12.0' - spec.add_development_dependency 'pry-byebug', '~> 3.7' + spec.add_development_dependency 'pry' + spec.add_development_dependency 'pry-byebug' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec', '~> 3.0' spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4.1' - spec.add_development_dependency 'rubocop', '~> 0.74.0' + spec.add_development_dependency 'rubocop', '~> 1.12.0' spec.add_development_dependency 'webmock', '~> 3.7' end diff --git a/lib/bambora/adapters/query_string_response.rb b/lib/bambora/adapters/query_string_response.rb index 975566d..93c6c3d 100644 --- a/lib/bambora/adapters/query_string_response.rb +++ b/lib/bambora/adapters/query_string_response.rb @@ -8,7 +8,7 @@ def to_h parsed_response = super return error_response if parsed_response.values.flatten.empty? # We didn't get a query string back. - parsed_response.each_with_object({}) { |(key, val), obj| obj[key] = val.length == 1 ? val.first : val } + parsed_response.transform_values { |val| val.length == 1 ? val.first : val } end private diff --git a/lib/bambora/bank/adapters/payment_profile_response.rb b/lib/bambora/bank/adapters/payment_profile_response.rb index bebe78e..49bc999 100644 --- a/lib/bambora/bank/adapters/payment_profile_response.rb +++ b/lib/bambora/bank/adapters/payment_profile_response.rb @@ -13,8 +13,8 @@ def initialize(response) end def to_h - parsed_query_string.each_with_object({}) do |(key, val), obj| - obj[transform(key)] = val + parsed_query_string.transform_keys do |key| + transform(key) end end diff --git a/lib/bambora/bank/batch_report_resource.rb b/lib/bambora/bank/batch_report_resource.rb index bd19b37..d52bea2 100644 --- a/lib/bambora/bank/batch_report_resource.rb +++ b/lib/bambora/bank/batch_report_resource.rb @@ -56,16 +56,14 @@ def show(report_data) response = client.post(path: sub_path, body: batch_report_body(report_data)) response = ensure_record_key_exists(response) - response = add_messages_to_response(response) - - response + add_messages_to_response(response) end private def ensure_record_key_exists(response) # bambora can return null or empty record results, fill it in for consistency - response.dig(:response)[:record] = [] if response.dig(:response, :record).nil? + response[:response][:record] = [] if response.dig(:response, :record).nil? response end diff --git a/lib/bambora/bank/builders/payment_profile_params.rb b/lib/bambora/bank/builders/payment_profile_params.rb index 1b5fd5b..8835abf 100644 --- a/lib/bambora/bank/builders/payment_profile_params.rb +++ b/lib/bambora/bank/builders/payment_profile_params.rb @@ -16,8 +16,8 @@ class << self # # @params params [Hash] def build(params) - params.each_with_object({}) do |(key, value), obj| - obj[transform_key(key)] = value + params.transform_keys do |key| + transform_key(key) end end diff --git a/lib/bambora/client/version.rb b/lib/bambora/client/version.rb index f6f11fd..3bb4dc3 100644 --- a/lib/bambora/client/version.rb +++ b/lib/bambora/client/version.rb @@ -2,6 +2,6 @@ module Bambora class Client - VERSION = '0.6.0' + VERSION = '0.7.0' end end diff --git a/lib/bambora/rest/json_client.rb b/lib/bambora/rest/json_client.rb index e11241d..67dfe6b 100644 --- a/lib/bambora/rest/json_client.rb +++ b/lib/bambora/rest/json_client.rb @@ -30,7 +30,7 @@ class JSONClient < Bambora::Rest::Client # @param api_key [String] Indicating the API Key to be used with the request. # # @return [Hash] Indicating success or failure of the operation. - def get(path:, params: nil, api_key:) + def get(path:, api_key:, params: nil) parse_response_body( super(path: path, params: params, headers: build_headers(api_key: api_key)), ).to_h