From 24dc2215564ff2d2a317f2234417b691b3a4f385 Mon Sep 17 00:00:00 2001 From: Andy Davis Date: Wed, 19 Jan 2022 15:19:54 -0600 Subject: [PATCH 1/5] Update to be compatible with ruby 3.x --- .github/workflows/tests.yml | 2 +- lib/propono/services/publisher.rb | 4 ++-- propono.gemspec | 1 + test/services/publisher_test.rb | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index afc13a0..fa72d6f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: matrix: os: - ubuntu-latest - ruby-version: [2.6, 2.7] + ruby-version: [2.6, 2.7, 3.0.0-preview1] steps: - uses: actions/checkout@v2 diff --git a/lib/propono/services/publisher.rb b/lib/propono/services/publisher.rb index f501c4e..5c49d60 100644 --- a/lib/propono/services/publisher.rb +++ b/lib/propono/services/publisher.rb @@ -5,8 +5,8 @@ class PublisherError < ProponoError end class Publisher - def self.publish(*args) - new(*args).publish + def self.publish(aws_client, propono_config, topic_name, message, options={}) + new(aws_client, propono_config, topic_name, message, **options).publish end attr_reader :aws_client, :propono_config, :topic_name, :message, :id, :async diff --git a/propono.gemspec b/propono.gemspec index 657b539..4e1e560 100644 --- a/propono.gemspec +++ b/propono.gemspec @@ -20,6 +20,7 @@ Gem::Specification.new do |spec| spec.add_dependency "aws-sdk-sns" spec.add_dependency "aws-sdk-sqs" + spec.add_dependency "nokogiri" spec.add_development_dependency "bundler", "~> 2.1" spec.add_development_dependency "rake" diff --git a/test/services/publisher_test.rb b/test/services/publisher_test.rb index 86b7f61..a472a38 100644 --- a/test/services/publisher_test.rb +++ b/test/services/publisher_test.rb @@ -11,8 +11,8 @@ def test_initialization def test_self_publish_calls_new topic = "topic123" message = "message123" - Publisher.expects(:new).with(aws_client, topic, message).returns(mock(publish: nil)) - Publisher.publish(aws_client, topic, message) + Publisher.expects(:new).with(aws_client, propono_config, topic, message).returns(mock(publish: nil)) + Publisher.publish(aws_client, propono_config, topic, message) end def test_initializer_generates_an_id From cfc80046607612ce74d3981b330fa84217ca99b5 Mon Sep 17 00:00:00 2001 From: Andy Davis Date: Wed, 19 Jan 2022 16:52:09 -0600 Subject: [PATCH 2/5] Manage ruby versions --- lib/propono/services/publisher.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/propono/services/publisher.rb b/lib/propono/services/publisher.rb index 5c49d60..1a3f5b9 100644 --- a/lib/propono/services/publisher.rb +++ b/lib/propono/services/publisher.rb @@ -5,8 +5,14 @@ class PublisherError < ProponoError end class Publisher - def self.publish(aws_client, propono_config, topic_name, message, options={}) - new(aws_client, propono_config, topic_name, message, **options).publish + if RUBY_VERSION < '3' + def self.publish(*args) + new(*args).publish + end + else + def self.publish(aws_client, propono_config, topic_name, message, options = {}) + new(aws_client, propono_config, topic_name, message, **options).publish + end end attr_reader :aws_client, :propono_config, :topic_name, :message, :id, :async From 00811b4c8aa2488f2524efdd3a02288c9f4f62ea Mon Sep 17 00:00:00 2001 From: Andy Davis Date: Thu, 20 Jan 2022 09:41:54 -0600 Subject: [PATCH 3/5] Make nokogiri a development dependency, so users can work with whatever XML parser they have in their project --- propono.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/propono.gemspec b/propono.gemspec index 4e1e560..a3c9af3 100644 --- a/propono.gemspec +++ b/propono.gemspec @@ -20,11 +20,11 @@ Gem::Specification.new do |spec| spec.add_dependency "aws-sdk-sns" spec.add_dependency "aws-sdk-sqs" - spec.add_dependency "nokogiri" spec.add_development_dependency "bundler", "~> 2.1" spec.add_development_dependency "rake" spec.add_development_dependency "mocha" + spec.add_development_dependency "nokogiri" spec.add_development_dependency "yard" spec.add_development_dependency "minitest", "~> 5.0.8" end From 80f79d2627ce7105b2df38b1ba4c27121459cb35 Mon Sep 17 00:00:00 2001 From: Andy Davis Date: Thu, 20 Jan 2022 09:44:35 -0600 Subject: [PATCH 4/5] Expand list of tested rubies --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fa72d6f..c0ac6fe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,13 +15,13 @@ jobs: matrix: os: - ubuntu-latest - ruby-version: [2.6, 2.7, 3.0.0-preview1] + ruby-version: [2.6, 2.7, '3.0', 3.1] steps: - uses: actions/checkout@v2 - name: Set up Ruby - uses: ruby/setup-ruby@a699edbce608a2c128dedad88e3b6a0e28687b3c + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true From 31e9fcef931f94fd43554fa0ec6bca106cce3aa1 Mon Sep 17 00:00:00 2001 From: Andy Davis Date: Fri, 21 Jan 2022 08:34:26 -0600 Subject: [PATCH 5/5] Pin the ruby-setup action to the latest sha (ensures that the setup we use is not changed without our knowledge) --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c0ac6fe..4660d66 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v2 - name: Set up Ruby - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@180e1d1f1c5eadbfbab3dab6fb79ab0c07e3cecc with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true