Skip to content

Commit

Permalink
update of gem to work with ruby 3
Browse files Browse the repository at this point in the history
  • Loading branch information
foton committed Oct 20, 2022
1 parent 29abfd5 commit 4c464ac
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 57 deletions.
73 changes: 37 additions & 36 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,78 @@ PATH
remote: .
specs:
czech_post_b2b_client (1.3.0)
ox (~> 2.11)
ox

GEM
remote: https://rubygems.org/
specs:
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
ansi (1.5.0)
ast (2.4.2)
builder (3.2.4)
byebug (11.1.3)
coderay (1.1.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
coderay (1.1.3)
crack (0.4.5)
rexml
hashdiff (1.0.1)
json (2.6.2)
method_source (1.0.0)
minitest (5.14.0)
minitest-reporters (1.4.2)
minitest (5.16.3)
minitest-reporters (1.5.0)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
ox (2.13.4)
parallel (1.22.0)
parser (3.1.1.0)
ox (2.14.11)
parallel (1.22.1)
parser (3.1.2.1)
ast (~> 2.4.1)
pry (0.13.1)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.9.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (~> 0.13.0)
public_suffix (4.0.6)
pry (>= 0.13, < 0.15)
public_suffix (5.0.0)
rainbow (3.1.1)
rake (13.0.1)
regexp_parser (2.2.1)
rake (13.0.6)
regexp_parser (2.6.0)
rexml (3.2.5)
rubocop (1.26.1)
rubocop (1.37.0)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.0.0)
parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.16.0, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.22.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.16.0)
rubocop-ast (1.22.0)
parser (>= 3.1.1.0)
rubocop-minitest (0.9.0)
rubocop (>= 0.74)
rubocop-minitest (0.22.2)
rubocop (>= 0.90, < 2.0)
ruby-progressbar (1.11.0)
safe_yaml (1.0.5)
unicode-display_width (2.1.0)
webmock (3.8.3)
addressable (>= 2.3.6)
unicode-display_width (2.3.0)
webmock (3.18.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)

PLATFORMS
ruby

DEPENDENCIES
bundler (~> 2.1)
bundler
czech_post_b2b_client!
minitest (~> 5.0)
minitest-reporters (~> 1.0)
pry-byebug (~> 3.0)
rake (~> 13.0)
rubocop (~> 1.26.1)
rubocop-minitest (~> 0.6)
webmock (~> 3.0)
minitest
minitest-reporters
pry-byebug
rake
rubocop
rubocop-minitest
webmock

BUNDLED WITH
2.2.28
20 changes: 10 additions & 10 deletions czech_post_b2b_client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_dependency 'ox', '~> 2.11'

spec.add_development_dependency 'bundler', '~> 2.1'
spec.add_development_dependency 'minitest', '~> 5.0'
spec.add_development_dependency 'minitest-reporters', '~> 1.0'
spec.add_development_dependency 'pry-byebug', '~> 3.0'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rubocop', '~> 1.26.1'
spec.add_development_dependency 'rubocop-minitest', '~> 0.6'
spec.add_development_dependency 'webmock', '~> 3.0'
spec.add_dependency 'ox'

spec.add_development_dependency 'bundler'
spec.add_development_dependency 'minitest'
spec.add_development_dependency 'minitest-reporters'
spec.add_development_dependency 'pry-byebug'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rubocop-minitest'
spec.add_development_dependency 'webmock'
end
2 changes: 1 addition & 1 deletion lib/czech_post_b2b_client/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def initialize
}

@language = :cs
@logger = defined?(Rails) ? ::Rails.logger : ::Logger.new($stdout)
@logger = defined?(Rails::Logger) ? ::Rails.logger : ::Logger.new($stdout)
@b2b_api_base_uri = 'https://b2b.postaonline.cz/services/POLService/v1'
@sending_post_office_location_number = 1

Expand Down
3 changes: 2 additions & 1 deletion lib/czech_post_b2b_client/services/orchestrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class Orchestrator < SteppedService::Base
def result_of_subservice(service_hash)
service_name = service_hash.keys.first
service_class = send("#{service_name}_class")
service = service_class.call(service_hash.values.first)

service = service_class.call(**service_hash.values.first)

if service.failed?
errors.add_from_hash({ service_name => service.errors.full_messages })
Expand Down
2 changes: 1 addition & 1 deletion lib/czech_post_b2b_client/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module CzechPostB2bClient
VERSION = '1.3.0'
VERSION = '1.4.0'
end
8 changes: 7 additions & 1 deletion lib/stepped_service/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ class Base
attr_reader :result

def self.call(*args, **keyword_args)
new(*args, **keyword_args).call
if args.blank?
new(**keyword_args).call
elsif keyword_args.blank?
new(*args).call
else
new(*args, **keyword_args).call
end
end

# You can override it, to not use steps
Expand Down
2 changes: 1 addition & 1 deletion test/services/address_sheets_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_it_fails_with_errors_in_response_data # rubocop:disable Metrics/AbcSize
builder_service_class.stub(:call, builder) do
api_caller_service_class.stub(:call, api_caller) do
parser_service_class.stub(:call, parser) do
@service = tested_service_class.call(tested_service_args)
@service = tested_service_class.call(**tested_service_args)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/services/parcels_send_process_updater_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_it_fails_with_errors_in_response_data # rubocop:disable Metrics/AbcSiz
builder_service_class.stub(:call, builder) do
api_caller_service_class.stub(:call, api_caller) do
parser_service_class.stub(:call, parser) do
@service = tested_service_class.call(tested_service_args)
@service = tested_service_class.call(**tested_service_args)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/services/parcels_sync_sender_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_it_fails_with_errors_in_response_data # rubocop:disable Metrics/AbcSize
builder_service_class.stub(:call, builder) do
api_caller_service_class.stub(:call, api_caller) do
parser_service_class.stub(:call, parser) do
@service = tested_service_class.call(tested_service_args)
@service = tested_service_class.call(**tested_service_args)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions test/support/communicator_service_testing_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_it_calls_api_when_data_are_ok # rubocop:disable Metrics/AbcSize
builder_service_class.stub(:call, builder) do
api_caller_service_class.stub(:call, api_caller) do
parser_service_class.stub(:call, parser) do
@service = tested_service_class.call(tested_service_args)
@service = tested_service_class.call(**tested_service_args)
end
end
end
Expand All @@ -61,7 +61,7 @@ def test_it_handle_builder_errors

builder_service_class.stub(:call, builder) do
api_caller_service_class.stub(:call, not_to_be_called_mock('ApiCaller')) do
@service = tested_service_class.call(tested_service_args)
@service = tested_service_class.call(**tested_service_args)
end
end

Expand All @@ -78,7 +78,7 @@ def test_it_handle_api_caller_errors # rubocop:disable Metrics/AbcSize
builder_service_class.stub(:call, builder) do
api_caller_service_class.stub(:call, api_caller) do
parser_service_class.stub(:call, not_to_be_called_mock('ResponseParser')) do
@service = tested_service_class.call(tested_service_args)
@service = tested_service_class.call(**tested_service_args)
end
end
end
Expand All @@ -99,7 +99,7 @@ def test_it_handle_parser_errors # rubocop:disable Metrics/AbcSize
builder_service_class.stub(:call, builder) do
api_caller_service_class.stub(:call, api_caller) do
parser_service_class.stub(:call, parser) do
@service = tested_service_class.call(tested_service_args)
@service = tested_service_class.call(**tested_service_args)
end
end
end
Expand Down

0 comments on commit 4c464ac

Please sign in to comment.