Skip to content

Commit

Permalink
Merge pull request #72 from psu-libraries/ruby3
Browse files Browse the repository at this point in the history
ruby3
  • Loading branch information
whereismyjetpack authored Jul 20, 2022
2 parents 3da5d0b + e89cbef commit 067e316
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
./bin/generate_app
test:
docker:
- image: cimg/ruby:2.7.5-browsers
- image: cimg/ruby:3.1.2-browsers
- image: mysql:8
environment:
MYSQL_ROOT_PASSWORD: etda
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ inherit_gem:
niftany: niftany_rubocop.yml

AllCops:
TargetRubyVersion: 2.7.5
TargetRubyVersion: 3.1.2
Exclude:
- 'db/**/*'
- 'script/**/*'
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.5
3.1.2
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM harbor.k8s.libraries.psu.edu/library/ruby-2.7.5-node-16:20220712 as base
FROM harbor.k8s.libraries.psu.edu/library/ruby-3.1.2-node-16:20220712 as base
ENV GA_TRACKING_ID=GA-123456789
WORKDIR /app

Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.5'
ruby '3.1.2'

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem 'rails', '~> 7.0.3'
Expand Down Expand Up @@ -81,7 +81,7 @@ end

group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'niftany'
gem 'niftany', '>= 0.10'
gem 'pry-byebug'
gem 'solr_wrapper', '>= 0.3'
end
Expand Down
53 changes: 27 additions & 26 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ GEM
http-cookie (1.0.5)
domain_name (~> 0.5)
http-form_data (2.3.0)
i18n (1.10.0)
i18n (1.11.0)
concurrent-ruby (~> 1.0)
importmap-rails (1.1.0)
actionpack (>= 6.0.0)
Expand All @@ -182,6 +182,7 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.6.2)
kaminari (1.2.2)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2)
Expand All @@ -207,7 +208,7 @@ GEM
method_source (1.0.0)
mini_mime (1.1.2)
minitar (0.9)
minitest (5.15.0)
minitest (5.16.2)
msgpack (1.5.2)
mysql2 (0.5.4)
net-imap (0.2.3)
Expand All @@ -224,18 +225,18 @@ GEM
digest
net-protocol
timeout
niftany (0.9.0)
niftany (0.10.0)
colorize (~> 0.8.1)
erb_lint (~> 0.0.22)
rubocop (~> 0.79)
rubocop (~> 1.3)
rubocop-performance (~> 1.1)
rubocop-rails (~> 2.3)
rubocop-rspec (~> 1.3)
rubocop-rspec (~> 2)
scss_lint (~> 0.55)
nio4r (2.5.8)
nokogiri (1.13.6-x86_64-darwin)
nokogiri (1.13.7-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.13.6-x86_64-linux)
nokogiri (1.13.7-x86_64-linux)
racc (~> 1.4)
oai (1.2.1)
builder (>= 3.1.0)
Expand All @@ -257,7 +258,7 @@ GEM
puma (5.6.4)
nio4r (~> 2.0)
racc (1.6.0)
rack (2.2.3.1)
rack (2.2.4)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (7.0.3)
Expand All @@ -277,7 +278,7 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
railties (7.0.3)
actionpack (= 7.0.3)
Expand Down Expand Up @@ -318,27 +319,27 @@ GEM
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.10.2)
rubocop (0.93.1)
rubocop (1.31.2)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 2.7.1.5)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8)
rexml
rubocop-ast (>= 0.6.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.18.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (1.18.0)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.19.1)
parser (>= 3.1.1.0)
rubocop-performance (1.10.2)
rubocop (>= 0.90.0, < 2.0)
rubocop-performance (1.14.3)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.9.1)
rubocop-rails (2.15.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 0.90.0, < 2.0)
rubocop-rspec (1.44.1)
rubocop (~> 0.87)
rubocop-ast (>= 0.7.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-rspec (2.12.1)
rubocop (~> 1.31)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
Expand Down Expand Up @@ -400,7 +401,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (1.8.0)
unicode-display_width (2.2.0)
view_component (2.56.2)
activesupport (>= 5.0.0, < 8.0)
method_source (~> 1.0)
Expand Down Expand Up @@ -445,7 +446,7 @@ DEPENDENCIES
jbuilder
jquery-rails
mysql2
niftany
niftany (>= 0.10)
pry-byebug
puma (~> 5.0)
rails (~> 7.0.3)
Expand All @@ -465,7 +466,7 @@ DEPENDENCIES
webdrivers

RUBY VERSION
ruby 2.7.5p203
ruby 3.1.2p20

BUNDLED WITH
2.3.5
2 changes: 1 addition & 1 deletion app/components/custom_document_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def access_level_display
end
contents << top_content
contents << tag.div(bottom_content, class: 'row justify-content-center')
content_tag(:div, contents.join(''), nil, false)
content_tag(:div, contents.join, nil, false)
end

private
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base
include Blacklight::Controller
layout :determine_layout if respond_to? :layout

rescue_from CanCan::AccessDenied, with: :render_401
rescue_from CanCan::AccessDenied, with: :render401

def login
session[:redirect_url] = home_or_original_path
Expand All @@ -20,8 +20,8 @@ def about; end

private

def render_401
render template: '/error/401', formats: [:html, :json], status: 401
def render401
render template: '/error/401', formats: [:html, :json], status: :unauthorized
end

def home_or_original_path
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def solr_download_final_submission

full_file_path = @doc.file_by_id(params[:id].to_i, @doc.access_level.current_access_level)
if full_file_path.nil?
render plain: 'An Error has occurred', status: 500
render plain: 'An Error has occurred', status: :internal_server_error
else
authorize! :read, @doc
send_file full_file_path, disposition: :inline
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/legacy_redirect_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ def redirect_original_urls
doc = bl_response.documents.first || nil
new_id = doc.present? ? doc.id : nil
if new_id.present?
redirect_to "/catalog/#{new_id}", status: 301
redirect_to "/catalog/#{new_id}", status: :moved_permanently
else
render template: '/error/404', formats: [:html, :json], status: 404
render template: '/error/404', formats: [:html, :json], status: :not_found
end
end
end
6 changes: 3 additions & 3 deletions app/helpers/blacklight_display_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ def download_links(document)
document.final_submissions.each do |final_submission_id, name|
links.append(
content_tag(:span,
link_to(tag.i('', { class: 'fa fa-download download-link-fa' }) + "Download #{name}",
link_to(tag.i(class: 'fa fa-download download-link-fa') + "Download #{name}",
Rails.application.routes.url_helpers.final_submission_file_path(final_submission_id),
{ class: 'file-link form-control' }))
class: 'file-link form-control'))
)
end

links.join('')
links.join
end

def facet_link(value, field)
Expand Down
72 changes: 36 additions & 36 deletions app/models/fake_solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,61 +19,61 @@ def initialize(options = {})
DateTime.parse(Faker::Date.between(from: 5.years.ago, to: Date.today).to_s).getutc
defended_at = Faker::Date.between(from: 5.years.ago, to: Date.today).strftime('%FT%TZ') # eg.'2016-11-17T15:00:00Z'
@doc = {
"year_isi": Faker::Date.between(from: 5.years.ago, to: Date.today).year,
"final_submission_files_uploaded_at_dtsi":
DateTime.parse(Faker::Date.between(from: 5.years.ago, to: Date.today).to_s).getutc,
"id": options[:id] || Faker::Number.number(digits: 4),
"access_level_ss": access_level,
"db_id": Faker::Number.unique.within(range: 1..1000),
"db_legacy_old_id": options[:db_legacy_old_id] || Faker::Number.unique.within(range: 1..1000),
"released_metadata_at_dtsi": released_metadata_at_dtsi,
"title_tesi": title,
"title_ssi": title,
"db_legacy_id": Faker::Number.unique.within(range: 1..1000),
"abstract_tesi": abstract,
"semester_ssi": 'Spring',
"download_access_group_ssim": [
year_isi: Faker::Date.between(from: 5.years.ago, to: Date.today).year,
final_submission_files_uploaded_at_dtsi: DateTime.parse(Faker::Date.between(from: 5.years.ago,
to: Date.today).to_s).getutc,
id: options[:id] || Faker::Number.number(digits: 4),
access_level_ss: access_level,
db_id: Faker::Number.unique.within(range: 1..1000),
db_legacy_old_id: options[:db_legacy_old_id] || Faker::Number.unique.within(range: 1..1000),
released_metadata_at_dtsi:,
title_tesi: title,
title_ssi: title,
db_legacy_id: Faker::Number.unique.within(range: 1..1000),
abstract_tesi: abstract,
semester_ssi: 'Spring',
download_access_group_ssim: [
'public',
'open_access'
],
"read_access_group_ssim": [
read_access_group_ssim: [
'public'
],
"final_submission_file_isim": file_ids,
"file_name_ssim": file_names,
"author_name_tesi": name.name,
"last_name_ssi": last_name,
"last_name_tesi": last_name,
"middle_name_ssi": middle_name,
"first_name_ssi": first_name,
"degree_name_ssi": 'MS',
"degree_description_ssi": 'Master of Science',
"degree_type_slug_ssi": 'Master Thesis',
"degree_type_ssi": 'Master Thesis',
"program_name_tesi": 'Statistics',
"program_name_ssi": 'Statistics',
"committee_member_name_ssim": [
final_submission_file_isim: file_ids,
file_name_ssim: file_names,
author_name_tesi: name.name,
last_name_ssi: last_name,
last_name_tesi: last_name,
middle_name_ssi: middle_name,
first_name_ssi: first_name,
degree_name_ssi: 'MS',
degree_description_ssi: 'Master of Science',
degree_type_slug_ssi: 'Master Thesis',
degree_type_ssi: 'Master Thesis',
program_name_tesi: 'Statistics',
program_name_ssi: 'Statistics',
committee_member_name_ssim: [
committee_member_name
],
"committee_member_name_tesim": [
committee_member_name_tesim: [
committee_member_name
],
"committee_member_email_ssim": [
committee_member_email_ssim: [
Faker::Internet.email
],
"committee_member_and_role_tesim": [
committee_member_and_role_tesim: [
"#{committee_member_name} Advisor/Co-Advisor",
"#{name.name} Thesis Advisor/Co-Advisor",
"#{name.name} Advisor/Co-Advisor",
"#{name.name} Thesis Advisor/Co-Advisor"
],
"committee_member_role_ssim": [
committee_member_role_ssim: [
'Advisor/Co-Advisor',
'Thesis Advisor/Co-Advisor'
],
"keyword_ssim": keywords,
"keyword_tesim": keywords,
"defended_at_dtsi": defended_at
keyword_ssim: keywords,
keyword_tesim: keywords,
defended_at_dtsi: defended_at
}
end
end
6 changes: 3 additions & 3 deletions lib/etda_explore/solr_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ def create_collection
action: 'CREATE',
name: config.collection_name,
numShards: config.num_shards,
"collection.configName": config.configset_name)
'collection.configName': config.configset_name)
check_resp(resp)
end

def modify_collection
resp = connection.get(SolrConfig::COLLECTION_PATH,
action: 'MODIFYCOLLECTION',
collection: config.collection_name,
"collection.configName": config.configset_name)
'collection.configName': config.configset_name)
check_resp(resp)
end

def upload_config
resp = connection.post(SolrConfig::CONFIG_PATH) do |req|
req.params = { "action": 'UPLOAD', "name": config.configset_name }
req.params = { action: 'UPLOAD', name: config.configset_name }
req.headers['Content-Type'] = 'octect/stream'
req.body = raw_data
end
Expand Down
4 changes: 2 additions & 2 deletions lib/etda_explore/solr_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def tempfile
def solr_md5
digest = []
Dir.glob("#{dir}/**/*").each do |f|
digest.push(Digest::MD5.hexdigest(File.open(f).read)) if File.file?(f)
digest.push(Digest::MD5.hexdigest(File.read(f))) if File.file?(f)
end
Digest::MD5.hexdigest(digest.join(''))
Digest::MD5.hexdigest(digest.join)
end
end
end
Loading

0 comments on commit 067e316

Please sign in to comment.