Skip to content

Commit

Permalink
Merge pull request #88 from ualbertalib/bump_ruby_3.1
Browse files Browse the repository at this point in the history
Bump ruby 3.1
  • Loading branch information
pgwillia authored May 18, 2023
2 parents a0c7421 + d06b510 commit 7b1b2f9
Show file tree
Hide file tree
Showing 28 changed files with 172 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Ruby 2.6
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.6
ruby-version: 3.1.4

- name: Cache Ruby gems
uses: actions/cache@v2
Expand Down
8 changes: 6 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ AllCops:
- 'tmp/**/*'
- 'vendor/**/*'
ExtraDetails: true
TargetRubyVersion: 2.5
TargetRubyVersion: 3.1
NewCops: enable

# readability is Actually Good
Layout/EmptyLinesAroundClassBody:
Expand Down Expand Up @@ -45,7 +46,7 @@ Metrics/CyclomaticComplexity:
Layout/LineLength:
Enabled: true
Max: 120 # default is 80
IgnoredPatterns: ['\A\s*#'] # tweak to ignore long comments, which often are examples or URLs that are not easily broken up
AllowedPatterns: ['\A\s*#'] # tweak to ignore long comments, which often are examples or URLs that are not easily broken up

# Avoid methods longer than 10 lines of code.
Metrics/MethodLength:
Expand Down Expand Up @@ -133,3 +134,6 @@ Style/WordArray:

Performance/TimesMap:
Enabled: false

Lint/SymbolConversion:
EnforcedStyle: consistent
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 3.1.4
13 changes: 13 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,16 @@ gemspec
# RDF stuff
gem 'acts_as_rdfable', github: 'ualbertalib/acts_as_rdfable', tag: 'v0.2.4'
gem 'builder_deferred_tagging', github: 'ualbertalib/builder_deferred_tagging', tag: 'v0.01'

gem 'builder', '~> 3.0'
gem 'nanoid'
gem 'pg'
gem 'rails', '>= 5.2.3', '< 7'
gem 'redis', '~> 4.1'

group :development, :test do
gem 'pry'
gem 'rubocop', '~> 1.7'
gem 'rubocop-performance'
gem 'rubocop-rails', '~> 2.19', '>= 2.19.1'
end
52 changes: 30 additions & 22 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ PATH
remote: .
specs:
oaisys (0.1.0)
builder (~> 3.0)
nanoid
pg
rails (>= 5.2.3, < 7)
redis (~> 4.1)
rubocop
rubocop-performance
rubocop-rails

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -90,7 +82,7 @@ GEM
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
ast (2.4.0)
ast (2.4.2)
builder (3.2.4)
coderay (1.1.2)
concurrent-ruby (1.1.10)
Expand All @@ -100,7 +92,7 @@ GEM
activesupport (>= 5.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.4)
json (2.6.3)
loofah (2.19.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand All @@ -116,9 +108,9 @@ GEM
nokogiri (1.13.10)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
parallel (1.19.1)
parser (2.7.0.2)
ast (~> 2.4.0)
parallel (1.23.0)
parser (3.2.2.1)
ast (~> 2.4.1)
pg (1.2.2)
pry (0.12.2)
coderay (~> 1.1.0)
Expand Down Expand Up @@ -153,24 +145,32 @@ GEM
method_source
rake (>= 12.2)
thor (~> 1.0)
rainbow (3.0.0)
rainbow (3.1.1)
rake (13.0.6)
redis (4.1.3)
regexp_parser (2.8.0)
request_store (1.4.1)
rack (>= 1.4)
rubocop (0.79.0)
jaro_winkler (~> 1.5.1)
rexml (3.2.5)
rubocop (1.50.2)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 2.7.0.1)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.28.0)
parser (>= 3.2.1.0)
rubocop-performance (1.5.2)
rubocop (>= 0.71.0)
rubocop-rails (2.4.1)
rubocop-rails (2.19.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 0.72.0)
ruby-progressbar (1.10.1)
rubocop (>= 1.33.0, < 2.0)
ruby-progressbar (1.13.0)
sprockets (4.1.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand All @@ -181,7 +181,7 @@ GEM
thor (1.2.1)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
unicode-display_width (1.6.1)
unicode-display_width (2.4.2)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand All @@ -192,9 +192,17 @@ PLATFORMS

DEPENDENCIES
acts_as_rdfable!
builder (~> 3.0)
builder_deferred_tagging!
nanoid
oaisys!
pg
pry
rails (>= 5.2.3, < 7)
redis (~> 4.1)
rubocop (~> 1.7)
rubocop-performance
rubocop-rails (~> 2.19, >= 2.19.1)

BUNDLED WITH
2.1.4
50 changes: 25 additions & 25 deletions app/controllers/oaisys/pmh_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Oaisys::PMHController < Oaisys::ApplicationController

def bad_verb
bad_verb = params.permit(:verb).to_h[:verb]
raise Oaisys::BadVerbError.new(bad_verb: bad_verb)
raise Oaisys::BadVerbError.new(bad_verb:)
end

def identify
Expand All @@ -40,17 +40,17 @@ def list_sets

sets.map! do |top_level_sets_id, id, title, description|
top_level_set = top_level_sets.find { |a| a[0] == top_level_sets_id }[1]
full_set_id = top_level_sets_id + ':' + id
full_set_name = top_level_set + ' / ' + title
full_set_id = "#{top_level_sets_id}:#{id}"
full_set_name = "#{top_level_set} / #{title}"
[full_set_id, full_set_name, description]
end
resumption_token = resumption_token_from_params(parameters: parameters)
resumption_token = resumption_token_from_params(parameters:)
parameters = parameters.slice(:verb, :resumptionToken) if resumption_token_provided

render :list_sets, formats: :xml, locals: { sets: sets, parameters: parameters.except(:page, :item_count),
cursor: cursor, complete_list_size: total_count,
resumption_token: resumption_token, last_page: sets_model.last_page?,
resumption_token_provided: resumption_token_provided }
render :list_sets, formats: :xml, locals: { sets:, parameters: parameters.except(:page, :item_count),
cursor:, complete_list_size: total_count,
resumption_token:, last_page: sets_model.last_page?,
resumption_token_provided: }
end

def list_metadata_formats
Expand All @@ -66,14 +66,14 @@ def list_metadata_formats
'oai_dc'
end

raise Oaisys::IdDoesNotExistError.new(parameters: parameters) if identifier_format.nil?
raise Oaisys::IdDoesNotExistError.new(parameters:) if identifier_format.nil?

formats = SUPPORTED_FORMATS.select { |supported_format| supported_format[:metadataPrefix] == identifier_format }
raise Oaisys::NoMetadataFormatsError.new(parameters: parameters) if formats.empty?
raise Oaisys::NoMetadataFormatsError.new(parameters:) if formats.empty?
end

render :list_metadata_formats,
formats: :xml, locals: { formats: formats, parameters: prep_identifiers(parameters) }
formats: :xml, locals: { formats:, parameters: prep_identifiers(parameters) }
end

def list_records
Expand Down Expand Up @@ -103,11 +103,11 @@ def list_records
params = params.slice(:verb, :resumptionToken) if resumption_token_provided

render :list_records,
formats: :xml, locals: { items: items, parameters: params.except(:page, :item_count),
metadata_format: metadata_format,
cursor: cursor, complete_list_size: total_count,
resumption_token: resumption_token, last_page: items.last_page?,
resumption_token_provided: resumption_token_provided }
formats: :xml, locals: { items:, parameters: params.except(:page, :item_count),
metadata_format:,
cursor:, complete_list_size: total_count,
resumption_token:, last_page: items.last_page?,
resumption_token_provided: }
end

# get_record is referring to the verb, not a getter.
Expand Down Expand Up @@ -151,10 +151,10 @@ def list_identifiers
resumption_token = resumption_token_from_params(parameters: params)
params = params.slice(:verb, :resumptionToken) if resumption_token_provided
render :list_identifiers,
formats: :xml, locals: { identifiers: identifiers, parameters: params.except(:page, :item_count),
cursor: cursor, complete_list_size: total_count,
resumption_token: resumption_token, last_page: identifiers_model.last_page?,
resumption_token_provided: resumption_token_provided }
formats: :xml, locals: { identifiers:, parameters: params.except(:page, :item_count),
cursor:, complete_list_size: total_count,
resumption_token:, last_page: identifiers_model.last_page?,
resumption_token_provided: }
end

private
Expand Down Expand Up @@ -202,8 +202,8 @@ def expect_args(required: [], optional: [], exclusive: [])
end

def model_for_verb_format(verb:, format:)
model = ActsAsRdfable.known_classes_for(format: format).first
raise Oaisys::CannotDisseminateError.new(parameters: { verb: verb, metadataPrefix: format }) if model.blank?
model = ActsAsRdfable.known_classes_for(format:).first
raise Oaisys::CannotDisseminateError.new(parameters: { verb:, metadataPrefix: format }) if model.blank?

model
end
Expand All @@ -220,7 +220,7 @@ def query_params_from_api_params(params)
end

def public_items_for_metadata_format(verb:, format:, page:, restricted_to_set: nil, from_date: nil, until_date: nil)
model = model_for_verb_format(verb: verb, format: format)
model = model_for_verb_format(verb:, format:)
model = model.public_items
model = model.public_items.belongs_to_path(restricted_to_set.tr(':', '/')) if restricted_to_set.present?

Expand All @@ -241,7 +241,7 @@ def sets_on_page(page:)
end

def expire_token(resumption_token:, verb:)
Oaisys::Engine.config.redis.expire_token(resumption_token: resumption_token, verb: verb, identifier: user_agent)
Oaisys::Engine.config.redis.expire_token(resumption_token:, verb:, identifier: user_agent)
end

def resumption_token_from_params(parameters:)
Expand All @@ -251,7 +251,7 @@ def resumption_token_from_params(parameters:)
end

def params_from_resumption_token(resumption_token:, verb:)
Oaisys::Engine.config.redis.get_parameters(resumption_token: resumption_token, verb: verb, identifier: user_agent)
Oaisys::Engine.config.redis.get_parameters(resumption_token:, verb:, identifier: user_agent)
end

def user_agent
Expand Down
20 changes: 10 additions & 10 deletions app/helpers/oaisys/error_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def error_header(error_code:)
if error_code == :badArgument
{ 'xmlns': 'http://www.openarchives.org/OAI/2.0/',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation': 'http://www.openarchives.org/OAI/2.0/ '\
'xsi:schemaLocation': 'http://www.openarchives.org/OAI/2.0/ ' \
'http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd' }
else
{ 'xmlns:dc': 'http://purl.org/dc/elements/1.1/',
Expand All @@ -17,15 +17,15 @@ def error_header(error_code:)
'xmlns:oreatom': 'http://www.openarchives.org/ore/atom/',
'xmlns:oai_dc': 'http://www.openarchives.org/OAI/2.0/oai_dc/',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation': 'http://www.openarchives.org/OAI/2.0/ '\
'http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd '\
'http://www.openarchives.org/OAI/2.0/oai-identifier '\
'http://www.openarchives.org/OAI/2.0/oai-identifier.xsd '\
'http://www.openarchives.org/OAI/2.0/oai_dc/ '\
'http://www.openarchives.org/OAI/2.0/oai_dc.xsd '\
'http://www.ndltd.org/standards/metadata/etdms/1.0/ '\
'http://www.ndltd.org/standards/metadata/etdms/1-0/etdms.xsd '\
'http://www.w3.org/2005/Atom' }
'xsi:schemaLocation': 'http://www.openarchives.org/OAI/2.0/ ' \
'http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd ' \
'http://www.openarchives.org/OAI/2.0/oai-identifier ' \
'http://www.openarchives.org/OAI/2.0/oai-identifier.xsd ' \
'http://www.openarchives.org/OAI/2.0/oai_dc/ ' \
'http://www.openarchives.org/OAI/2.0/oai_dc.xsd ' \
'http://www.ndltd.org/standards/metadata/etdms/1.0/ ' \
'http://www.ndltd.org/standards/metadata/etdms/1-0/etdms.xsd ' \
'http://www.w3.org/2005/Atom' }
end
end
end
4 changes: 2 additions & 2 deletions app/helpers/oaisys/list_identifiers_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ def resumption_token(xml_object:, complete_list_size:, cursor:, resumption_token
return unless !last_page || resumption_token_provided

if last_page
xml_object.tag!('resumptionToken', completeListSize: complete_list_size, cursor: cursor)
xml_object.tag!('resumptionToken', completeListSize: complete_list_size, cursor:)
else
expiration_date = (Time.current + Oaisys::Engine.config.resumption_token_expiry).utc.xmlschema
xml_object.tag!('resumptionToken', { expirationDate: expiration_date,
completeListSize: complete_list_size, cursor: cursor }, resumption_token)
completeListSize: complete_list_size, cursor: }, resumption_token)
end
end
end
4 changes: 2 additions & 2 deletions app/helpers/oaisys/set_description_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def set_description(xml:, description:)
xml.tag!('oai_dc:dc', 'xmlns:oai_dc': 'http://www.openarchives.org/OAI/2.0/oai_dc/',
'xmlns:dc': 'http://purl.org/dc/elements/1.1/',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation': 'http://www.openarchives.org/OAI/2.0/oai_dc/ '\
'http://www.openarchives.org/OAI/2.0/oai_dc.xsd') do
'xsi:schemaLocation': 'http://www.openarchives.org/OAI/2.0/oai_dc/ ' \
'http://www.openarchives.org/OAI/2.0/oai_dc.xsd') do
xml.tag!('dc:description', description)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/oaisys/pmh/error.xml.builder
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
xml.push_deferred_attribute(error_header(error_code: error_code))
xml.push_deferred_attribute(error_header(error_code:))

xml.tag!('request', parameters, 'https://era.library.ualberta.ca/oai')
xml.error(error_message, code: error_code)
18 changes: 9 additions & 9 deletions app/views/oaisys/pmh/get_record.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ xml.push_deferred_attribute('xmlns:dc': 'http://purl.org/dc/elements/1.1/',
'xmlns:oreatom': 'http://www.openarchives.org/ore/atom/',
'xmlns:oai_dc': 'http://www.openarchives.org/OAI/2.0/oai_dc/',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation': 'http://www.openarchives.org/OAI/2.0/ '\
'http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd '\
'http://www.openarchives.org/OAI/2.0/oai-identifier '\
'http://www.openarchives.org/OAI/2.0/oai-identifier.xsd '\
'http://www.openarchives.org/OAI/2.0/oai_dc/ '\
'http://www.openarchives.org/OAI/2.0/oai_dc.xsd '\
'http://www.ndltd.org/standards/metadata/etdms/1.0/ '\
'http://www.ndltd.org/standards/metadata/etdms/1-0/etdms.xsd '\
'http://www.w3.org/2005/Atom')
'xsi:schemaLocation': 'http://www.openarchives.org/OAI/2.0/ ' \
'http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd ' \
'http://www.openarchives.org/OAI/2.0/oai-identifier ' \
'http://www.openarchives.org/OAI/2.0/oai-identifier.xsd ' \
'http://www.openarchives.org/OAI/2.0/oai_dc/ ' \
'http://www.openarchives.org/OAI/2.0/oai_dc.xsd ' \
'http://www.ndltd.org/standards/metadata/etdms/1.0/ ' \
'http://www.ndltd.org/standards/metadata/etdms/1-0/etdms.xsd ' \
'http://www.w3.org/2005/Atom')

xml.tag!('request', parameters, 'https://era.library.ualberta.ca/oai')

Expand Down
Loading

0 comments on commit 7b1b2f9

Please sign in to comment.