Skip to content

Commit 3cdfecb

Browse files
upgrade to ruby 3.1.4
1 parent 3d56932 commit 3cdfecb

11 files changed

+102
-47
lines changed

.github/workflows/deploy.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
ELASTIC_PASSWORD: ${{ secrets.RE3DATA_ES_PASSWORD }}
1818
steps:
1919
- uses: actions/checkout@v2
20-
- name: Set up Ruby 2.7
20+
- name: Set up Ruby 3.1.4
2121
uses: actions/setup-ruby@v1
2222
with:
23-
ruby-version: '2.7.6'
23+
ruby-version: '3.1.4'
2424
- uses: actions/cache@v2
2525
with:
2626
path: vendor/bundle

.github/workflows/pull_request.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
- 11211/tcp
1414
steps:
1515
- uses: actions/checkout@v2
16-
- name: Set up Ruby 2.7
16+
- name: Set up Ruby 3.1.4
1717
uses: actions/setup-ruby@v1
1818
with:
19-
ruby-version: '2.7.6'
19+
ruby-version: '3.1.4'
2020
- uses: actions/cache@v2
2121
with:
2222
path: vendor/bundle

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
ELASTIC_PASSWORD: ${{ secrets.RE3DATA_ES_PASSWORD }}
1818
steps:
1919
- uses: actions/checkout@v2
20-
- name: Set up Ruby 2.7
20+
- name: Set up Ruby 3.1.4
2121
uses: actions/setup-ruby@v1
2222
with:
23-
ruby-version: '2.7.6'
23+
ruby-version: '3.1.4'
2424
- uses: actions/cache@v2
2525
with:
2626
path: vendor/bundle

.rubocop.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ inherit_from: .rubocop_todo.yml
33
# from https://github.com/rails/rails/blob/master/.rubocop.yml
44

55
AllCops:
6-
TargetRubyVersion: 2.5
6+
TargetRubyVersion: 3.1
77
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
88
# to ignore them, so only the ones explicitly set in this file are enabled.
99
DisabledByDefault: true

Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM phusion/passenger-full:2.3.0
1+
FROM phusion/passenger-full:2.5.1
22
LABEL maintainer="tech@datacite.org"
33

44
# Set correct environment variables.
@@ -10,8 +10,8 @@ RUN usermod -a -G docker_env app
1010
# Use baseimage-docker's init process.
1111
CMD ["/sbin/my_init"]
1212

13-
# Install Ruby 2.7.6
14-
RUN bash -lc 'rvm --default use ruby-2.7.6'
13+
# Install Ruby 3.1.4
14+
RUN bash -lc 'rvm --default use ruby-3.1.4'
1515

1616
# Update installed APT packages
1717
RUN apt-get update -y -o Dpkg::Options::="--force-confold" && \
@@ -41,7 +41,7 @@ RUN mkdir -p /home/app/webapp/tmp/pids && \
4141
# Install Ruby gems
4242
WORKDIR /home/app/webapp
4343
RUN gem update --system && \
44-
gem install bundler:2.3.20 && \
44+
gem install bundler:2.5.6 && \
4545
/sbin/setuser app bundle config set --local path 'vendor/bundle' && \
4646
/sbin/setuser app bundle install
4747

Gemfile

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ gem "dalli", "~> 2.7.6"
77
gem 'lograge', '~> 0.5'
88
gem 'sentry-raven', '~> 2.9'
99
gem 'active_model_serializers', '~> 0.10.0'
10-
gem 'fast_jsonapi', '~> 1.3'
10+
gem 'jsonapi-serializer', '~> 2.2'
1111
gem 'kaminari', '~> 1.2'
1212
gem 'elasticsearch', '~> 1.1', '>= 1.1.3'
1313
gem 'elasticsearch-model', '~> 0.1.9', require: 'elasticsearch/model'
@@ -35,19 +35,19 @@ group :development, :test do
3535
end
3636

3737
group :development do
38-
gem 'listen', '>= 3.0.5', '< 3.2'
39-
gem 'spring'
40-
gem 'spring-watcher-listen', '~> 2.0.0'
38+
gem 'listen', '~> 3.9'
39+
gem 'spring', '~> 4.1', '>= 4.1.3'
4140
gem 'spring-commands-rspec'
41+
gem 'spring-watcher-listen', '~> 2.1'
4242
# gem 'httplog', '~> 1.0'
4343
end
4444

4545
group :test do
4646
gem 'capybara'
4747
gem 'webmock', '~> 3.1'
48-
gem 'vcr', '~> 3.0.3'
48+
gem 'vcr', '~> 6.1'
4949
gem 'codeclimate-test-reporter', '~> 1.0.0'
5050
gem 'simplecov'
5151
gem 'shoulda-matchers', '~> 3.1'
5252
gem 'elasticsearch-extensions'
53-
end
53+
end

Gemfile.lock

+17-19
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,7 @@ GEM
152152
faraday
153153
faraday_middleware (0.14.0)
154154
faraday (>= 0.7.4, < 1.0)
155-
fast_jsonapi (1.5)
156-
activesupport (>= 4.2)
157-
ffi (1.15.5)
155+
ffi (1.16.3)
158156
git (1.12.0)
159157
addressable (~> 2.8)
160158
rchardet (~> 1.8)
@@ -174,6 +172,8 @@ GEM
174172
ice_nine (0.11.2)
175173
json (2.6.2)
176174
jsonapi-renderer (0.2.2)
175+
jsonapi-serializer (2.2.0)
176+
activesupport (>= 4.2)
177177
kaminari (1.2.2)
178178
activesupport (>= 4.1.0)
179179
kaminari-actionview (= 1.2.2)
@@ -186,10 +186,9 @@ GEM
186186
activerecord
187187
kaminari-core (= 1.2.2)
188188
kaminari-core (1.2.2)
189-
listen (3.1.5)
190-
rb-fsevent (~> 0.9, >= 0.9.4)
191-
rb-inotify (~> 0.9, >= 0.9.7)
192-
ruby_dep (~> 1.2)
189+
listen (3.9.0)
190+
rb-fsevent (~> 0.10, >= 0.10.3)
191+
rb-inotify (~> 0.9, >= 0.9.10)
193192
lograge (0.12.0)
194193
actionpack (>= 4)
195194
activesupport (>= 4)
@@ -265,7 +264,7 @@ GEM
265264
thor (~> 1.0)
266265
rainbow (3.1.1)
267266
rake (13.0.6)
268-
rb-fsevent (0.11.1)
267+
rb-fsevent (0.11.2)
269268
rb-inotify (0.10.1)
270269
ffi (~> 1.0)
271270
rchardet (1.8.0)
@@ -305,7 +304,6 @@ GEM
305304
rubocop-performance (1.3.0)
306305
rubocop (>= 0.68.0)
307306
ruby-progressbar (1.11.0)
308-
ruby_dep (1.5.0)
309307
sentry-raven (2.13.0)
310308
faraday (>= 0.7.6, < 1.0)
311309
shoulda-matchers (3.1.3)
@@ -315,12 +313,12 @@ GEM
315313
json (>= 1.8, < 3)
316314
simplecov-html (~> 0.10.0)
317315
simplecov-html (0.10.2)
318-
spring (2.1.1)
316+
spring (4.2.1)
319317
spring-commands-rspec (1.0.4)
320318
spring (>= 0.9.1)
321-
spring-watcher-listen (2.0.1)
319+
spring-watcher-listen (2.1.0)
322320
listen (>= 2.7, < 4.0)
323-
spring (>= 1.2, < 3.0)
321+
spring (>= 4)
324322
sprockets (4.1.1)
325323
concurrent-ruby (~> 1.0)
326324
rack (> 1, < 3)
@@ -333,7 +331,7 @@ GEM
333331
tzinfo (2.0.5)
334332
concurrent-ruby (~> 1.0)
335333
unicode-display_width (2.2.0)
336-
vcr (3.0.3)
334+
vcr (6.2.0)
337335
virtus (2.0.0)
338336
axiom-types (~> 0.1)
339337
coercible (~> 1.0)
@@ -369,15 +367,15 @@ DEPENDENCIES
369367
elasticsearch-model (~> 0.1.9)
370368
elasticsearch-persistence (~> 0.1.9)
371369
elasticsearch-rails (~> 0.1.9)
372-
fast_jsonapi (~> 1.3)
373370
git (~> 1.5)
374371
google-protobuf (~> 3.0)
375372
graphql (~> 1.9, >= 1.9.4)
376373
graphql-batch (~> 0.4.0)
377374
graphql-cache (~> 0.6.0)!
378375
graphql-errors (~> 0.3.0)
376+
jsonapi-serializer (~> 2.2)
379377
kaminari (~> 1.2)
380-
listen (>= 3.0.5, < 3.2)
378+
listen (~> 3.9)
381379
lograge (~> 0.5)
382380
maremma (>= 4.1)
383381
rack-cors (~> 1.0)
@@ -388,11 +386,11 @@ DEPENDENCIES
388386
sentry-raven (~> 2.9)
389387
shoulda-matchers (~> 3.1)
390388
simplecov
391-
spring
389+
spring (~> 4.1, >= 4.1.3)
392390
spring-commands-rspec
393-
spring-watcher-listen (~> 2.0.0)
394-
vcr (~> 3.0.3)
391+
spring-watcher-listen (~> 2.1)
392+
vcr (~> 6.1)
395393
webmock (~> 3.1)
396394

397395
BUNDLED WITH
398-
2.3.20
396+
2.5.6

app/controllers/re3data_controller.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def index
1212
end
1313

1414
page = params[:page] || {}
15-
if page[:size].present?
15+
if page[:size].present?
1616
page[:size] = [page[:size].to_i, 1000].min
1717
max_number = page[:size] > 0 ? 10000/page[:size] : 1
1818
else
@@ -26,11 +26,11 @@ def index
2626
elsif params[:ids].present?
2727
response = Repository.find_by_id(params[:ids], page: page, sort: sort)
2828
else
29-
response = Repository.query(params[:query],
30-
page: page,
31-
sort: sort,
29+
response = Repository.query(params[:query],
30+
page: page,
31+
sort: sort,
3232
subject: params[:subject],
33-
open: params[:open],
33+
open: params[:open],
3434
certified: params[:certified],
3535
pid: params[:pid],
3636
software: params[:software],
@@ -59,7 +59,7 @@ def index
5959
}.compact
6060
options[:is_collection] = true
6161

62-
render json: Re3dataSerializer.new(@repositories, options).serialized_json, status: :ok
62+
render json: Re3dataSerializer.new(@repositories, options).serializable_hash.to_json, status: :ok
6363
rescue Elasticsearch::Transport::Transport::Errors::LengthRequired
6464
render json: []
6565
end
@@ -68,7 +68,7 @@ def show
6868
options = {}
6969
options[:is_collection] = false
7070

71-
render json: Re3dataSerializer.new(@repository, options).serialized_json, status: :ok
71+
render json: Re3dataSerializer.new(@repository, options).serializable_hash.to_json, status: :ok
7272
end
7373

7474
def suggest

app/serializers/re3data_serializer.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
class Re3dataSerializer
2-
include FastJsonapi::ObjectSerializer
2+
include JSONAPI::Serializer
33
set_key_transform :camel_lower
44
set_type :re3data
55

6-
attributes :re3data_id, :repositoryName, :repositoryUrl, :repositoryContacts, :description, :repositoryLanguages, :certificates, :types,
7-
:additionalNames, :subjects, :contentTypes, :providerTypes,
6+
attributes :re3data_id, :repositoryName, :repositoryUrl, :repositoryContacts, :description, :repositoryLanguages, :certificates, :types,
7+
:additionalNames, :subjects, :contentTypes, :providerTypes,
88
:keywords, :institutions, :dataAccesses, :dataUploads, :dataUploadLicenses, :pidSystems,
99
:apis, :pidSystems, :software, :startDate, :endDate, :created, :updated
1010

@@ -23,4 +23,4 @@ class Re3dataSerializer
2323
attribute :updated do |object|
2424
object.updated.strftime("%FT%TZ")
2525
end
26-
end
26+
end
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# frozen_string_literal: true
2+
3+
# Monkey patch for jsonapi-serializer gem
4+
5+
module FastJsonapi
6+
module SerializationCore
7+
class_methods do
8+
def get_included_records(record, includes_list, known_included_objects, fieldsets, params = {})
9+
return unless includes_list.present?
10+
return [] unless relationships_to_serialize
11+
12+
includes_list = parse_includes_list(includes_list)
13+
14+
includes_list.each_with_object([]) do |include_item, included_records|
15+
relationship_item = relationships_to_serialize[include_item.first]
16+
17+
next unless relationship_item&.include_relationship?(record, params)
18+
19+
associated_objects = relationship_item.fetch_associated_object(record, params)
20+
21+
if associated_objects.is_a?(Elasticsearch::Model::HashWrapper)
22+
associated_objects = OpenStruct.new(associated_objects)
23+
end
24+
25+
included_objects = Array(associated_objects)
26+
27+
next if included_objects.empty?
28+
29+
static_serializer = relationship_item.static_serializer
30+
static_record_type = relationship_item.static_record_type
31+
32+
included_objects.each do |inc_obj|
33+
serializer = static_serializer || relationship_item.serializer_for(inc_obj, params)
34+
record_type = static_record_type || serializer.record_type
35+
36+
if include_item.last.any?
37+
serializer_records = serializer.get_included_records(inc_obj, include_item.last, known_included_objects, fieldsets, params)
38+
included_records.concat(serializer_records) unless serializer_records.empty?
39+
end
40+
41+
code = "#{record_type}_#{serializer.id_from_record(inc_obj, params)}"
42+
next if known_included_objects.include?(code)
43+
44+
known_included_objects << code
45+
46+
included_records << serializer.record_hash(inc_obj, fieldsets[record_type], includes_list, params)
47+
end
48+
end
49+
end
50+
end
51+
end
52+
end

docker-compose.local.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: "2.1"
2+
3+
services:
4+
web:
5+
build: .

0 commit comments

Comments
 (0)