From bb2811600cde74bd8411422e2f1a56f9460ff7fe Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:19:00 +0100 Subject: [PATCH 1/2] fix: Update in preparation for Ruby 3 (#44) --- spec/data_structure/data_structure_spec.rb | 4 +++- spec/data_typing/data_typing_spec.rb | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/data_structure/data_structure_spec.rb b/spec/data_structure/data_structure_spec.rb index f0308c37..f971bc7a 100644 --- a/spec/data_structure/data_structure_spec.rb +++ b/spec/data_structure/data_structure_spec.rb @@ -18,7 +18,9 @@ } ] - objs.each do |model:, data:| + objs.each do |obj| + model = obj[:model] + data = obj[:data] describe model do let(:inst) { model.deserialize(data) } diff --git a/spec/data_typing/data_typing_spec.rb b/spec/data_typing/data_typing_spec.rb index cf06992d..3dddbba4 100644 --- a/spec/data_typing/data_typing_spec.rb +++ b/spec/data_typing/data_typing_spec.rb @@ -15,7 +15,10 @@ } ] - objs.each do |model:, data:| + objs.each do |obj| + model = obj[:model] + data = obj[:data] + describe model do describe "#type" do it "reserializes to original value" do From ab6bc64709bba13c234e0dfebe78cd37323c038f Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:37:25 +0100 Subject: [PATCH 2/2] fix: Upgrade for compatibility with Ruby 3 (#45) --- .github/workflows/tests.yaml | 2 +- lib/openactive/concerns/json_ld_serializable.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5a4b60ef..6b4cf5ea 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['2.6', '2.7'] + ruby-version: ['2.7', '3.0', '3.1'] steps: - uses: actions/checkout@v2 diff --git a/lib/openactive/concerns/json_ld_serializable.rb b/lib/openactive/concerns/json_ld_serializable.rb index eb34bc2a..d17ab852 100644 --- a/lib/openactive/concerns/json_ld_serializable.rb +++ b/lib/openactive/concerns/json_ld_serializable.rb @@ -25,16 +25,18 @@ def property(field, as:) def values data = {} - self.class.properties.each do |key, field:| - data[key] = send(field) + self.class.properties.each do |key, field| + field_value = field[:field] + data[key] = send(field_value) end data end def to_h data = {} - self.class.properties.each do |_key, field:| - data[field] = send(field) + self.class.properties.each do |_key, field| + field_value = field[:field] + data[field_value] = send(field_value) end data end