From a47fffa4cb16e2263beba5edf19b4cdf4608f810 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 1 Feb 2021 12:04:25 -0500 Subject: [PATCH 01/11] Bump okcomputer from 1.18.1 to 1.18.2 (#685) Bumps [okcomputer](https://github.com/sportngin/okcomputer) from 1.18.1 to 1.18.2. - [Release notes](https://github.com/sportngin/okcomputer/releases) - [Changelog](https://github.com/sportngin/okcomputer/blob/master/CHANGELOG.markdown) - [Commits](https://github.com/sportngin/okcomputer/compare/1.18.1...v1.18.2) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 94b02a3f2..482f403cf 100644 --- a/Gemfile +++ b/Gemfile @@ -79,7 +79,7 @@ gem 'iso-639', '0.3.5' gem 'jquery-rails', '4.4.0' # system monitoring -gem 'okcomputer', '1.18.1' +gem 'okcomputer', '1.18.2' # we're using postgres as our database within rails gem 'pg', '1.2.3' diff --git a/Gemfile.lock b/Gemfile.lock index 20f4903be..e015c6434 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -630,7 +630,7 @@ GEM multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - okcomputer (1.18.1) + okcomputer (1.18.2) openseadragon (0.5.0) rails (> 3.2.0) orm_adapter (0.5.0) @@ -1007,7 +1007,7 @@ DEPENDENCIES linkeddata (~> 3.0) listen (>= 3.0.5, < 3.3) mini_magick (= 4.10.1) - okcomputer (= 1.18.1) + okcomputer (= 1.18.2) pg (= 1.2.3) puma (= 3.12.6) rails (~> 5.2) From 002684e5e9882d1b7a599f7d29e371cd40418408 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Mon, 1 Feb 2021 12:50:43 -0500 Subject: [PATCH 02/11] lock nokogiri at 1.10.10 until migration (#688) --- Gemfile | 9 +++++---- Gemfile.lock | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 482f403cf..247065e70 100644 --- a/Gemfile +++ b/Gemfile @@ -125,12 +125,13 @@ gem 'mini_magick', '4.10.1' # manually add this gem to enable questioning_authority to parse linked-data results gem 'linkeddata', '~> 3.0' -# hydra-role-management requires bootstrap_form without declaring a version, -# bootstrap_form >=4.5.0 requires a ruby version >= 2.5 (we're stuck on 2.4.3 -# until we migrate to aws). # -# @todo remove this restriction after aws migration +# these are gems that we need to lock until we can upgrade ruby to >= 2.5 +# (on-prem is locked at 2.4.3). +# +# @todo remove these restriction after aws migration gem 'bootstrap_form', '~> 4.4.0' +gem 'nokogiri', '~> 1.10.10' # development dependencies (not as necessary to # lock down versions here) diff --git a/Gemfile.lock b/Gemfile.lock index e015c6434..2b8740ddb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1007,6 +1007,7 @@ DEPENDENCIES linkeddata (~> 3.0) listen (>= 3.0.5, < 3.3) mini_magick (= 4.10.1) + nokogiri (~> 1.10.10) okcomputer (= 1.18.2) pg (= 1.2.3) puma (= 3.12.6) From b8c8ac4b3e9cbd0c2dadc47d3e556876e118575a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 1 Feb 2021 13:01:07 -0500 Subject: [PATCH 03/11] Bump capistrano from 3.14.1 to 3.15.0 (#687) Bumps [capistrano](https://github.com/capistrano/capistrano) from 3.14.1 to 3.15.0. - [Release notes](https://github.com/capistrano/capistrano/releases) - [Commits](https://github.com/capistrano/capistrano/compare/v3.14.1...v3.15.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 247065e70..95e910043 100644 --- a/Gemfile +++ b/Gemfile @@ -144,7 +144,7 @@ group :development do gem 'spring-watcher-listen', '~> 2.0.0' # Use Capistrano for deployment - gem 'capistrano', '~> 3.14', require: false + gem 'capistrano', '~> 3.15', require: false gem 'capistrano-bundler', '~> 1.3' gem 'capistrano-ext', '~> 1.2.1' gem 'capistrano-passenger', '~> 0.2.0' diff --git a/Gemfile.lock b/Gemfile.lock index 2b8740ddb..7af865295 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -165,7 +165,7 @@ GEM builder (3.2.4) byebug (11.1.1) cancancan (1.17.0) - capistrano (3.14.1) + capistrano (3.15.0) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) @@ -206,7 +206,7 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.7) + concurrent-ruby (1.1.8) connection_pool (2.2.3) crack (0.4.3) safe_yaml (~> 1.0.0) @@ -479,7 +479,7 @@ GEM tinymce-rails (~> 4.1) hyrax-spec (0.3.2) rspec (~> 3.6) - i18n (1.8.5) + i18n (1.8.7) concurrent-ruby (~> 1.0) ice_nine (0.11.2) iiif_manifest (0.5.0) @@ -911,7 +911,7 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sshkit (1.21.1) + sshkit (1.21.2) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) stub_env (1.0.4) @@ -975,7 +975,7 @@ DEPENDENCIES bootsnap (= 1.4.7) bootstrap_form (~> 4.4.0) byebug - capistrano (~> 3.14) + capistrano (~> 3.15) capistrano-bundler (~> 1.3) capistrano-ext (~> 1.2.1) capistrano-passenger (~> 0.2.0) From ecc1aa85df0cd65a70d5df90ab5291d98f7cfafb Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 1 Feb 2021 13:24:22 -0500 Subject: [PATCH 04/11] Bump rspec-rails from 3.9.0 to 4.0.1 (#684) Bumps [rspec-rails](https://github.com/rspec/rspec-rails) from 3.9.0 to 4.0.1. - [Release notes](https://github.com/rspec/rspec-rails/releases) - [Changelog](https://github.com/rspec/rspec-rails/blob/main/Changelog.md) - [Commits](https://github.com/rspec/rspec-rails/compare/v3.9.0...v4.0.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index 95e910043..f238dd401 100644 --- a/Gemfile +++ b/Gemfile @@ -167,7 +167,7 @@ group :development, :test do gem 'rails-controller-testing', '~> 1.0.5' gem 'rspec', '~> 3.8' gem 'rspec-its', '~> 1.1' - gem 'rspec-rails', '~> 3.6' + gem 'rspec-rails', '~> 4.0' gem 'rspec_junit_formatter', '~> 0.4.1' gem 'rubocop', '~> 0.63' gem 'rubocop-rspec', '~> 1.3' diff --git a/Gemfile.lock b/Gemfile.lock index 7af865295..0106a5598 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -229,7 +229,7 @@ GEM devise_cas_authenticatable (1.10.4) devise (>= 1.2.0) rubycas-client (>= 2.2.1) - diff-lcs (1.3) + diff-lcs (1.4.4) docile (1.3.2) docopt (0.5.0) dotenv (2.7.5) @@ -579,7 +579,7 @@ GEM listen (3.2.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.8.0) + loofah (2.9.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -598,7 +598,7 @@ GEM mini_magick (4.10.1) mini_mime (1.0.2) mini_portile2 (2.4.0) - minitest (5.14.2) + minitest (5.14.3) msgpack (1.3.3) multi_json (1.15.0) multi_xml (0.6.0) @@ -774,26 +774,26 @@ GEM rspec-core (~> 3.9.0) rspec-expectations (~> 3.9.0) rspec-mocks (~> 3.9.0) - rspec-core (3.9.0) - rspec-support (~> 3.9.0) - rspec-expectations (3.9.0) + rspec-core (3.9.3) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.4) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) rspec-its (1.3.0) rspec-core (>= 3.0.0) rspec-expectations (>= 3.0.0) - rspec-mocks (3.9.0) + rspec-mocks (3.9.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) - rspec-rails (3.9.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) - rspec-support (~> 3.9.0) - rspec-support (3.9.0) + rspec-rails (4.0.1) + actionpack (>= 4.2) + activesupport (>= 4.2) + railties (>= 4.2) + rspec-core (~> 3.9) + rspec-expectations (~> 3.9) + rspec-mocks (~> 3.9) + rspec-support (~> 3.9) + rspec-support (3.9.4) rspec_junit_formatter (0.4.1) rspec-core (>= 2, < 4, != 2.12.0) rubocop (0.63.1) @@ -1017,7 +1017,7 @@ DEPENDENCIES rsolr (= 2.3.0) rspec (~> 3.8) rspec-its (~> 1.1) - rspec-rails (~> 3.6) + rspec-rails (~> 4.0) rspec_junit_formatter (~> 0.4.1) rubocop (~> 0.63) rubocop-rspec (~> 1.3) From 965e9c7e3f43f0e64fa52b88091b7dc15472c33e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 2 Feb 2021 11:26:51 -0500 Subject: [PATCH 05/11] Bump rails from 5.2.4.3 to 5.2.4.4 (#686) Bumps [rails](https://github.com/rails/rails) from 5.2.4.3 to 5.2.4.4. - [Release notes](https://github.com/rails/rails/releases) - [Commits](https://github.com/rails/rails/compare/v5.2.4.3...v5.2.4.4) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- Gemfile.lock | 72 ++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0106a5598..082e404a9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,25 +1,25 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.2.4.3) - actionpack (= 5.2.4.3) + actioncable (5.2.4.4) + actionpack (= 5.2.4.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.4.3) - actionpack (= 5.2.4.3) - actionview (= 5.2.4.3) - activejob (= 5.2.4.3) + actionmailer (5.2.4.4) + actionpack (= 5.2.4.4) + actionview (= 5.2.4.4) + activejob (= 5.2.4.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.4.3) - actionview (= 5.2.4.3) - activesupport (= 5.2.4.3) + actionpack (5.2.4.4) + actionview (= 5.2.4.4) + activesupport (= 5.2.4.4) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.4.3) - activesupport (= 5.2.4.3) + actionview (5.2.4.4) + activesupport (= 5.2.4.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -43,26 +43,26 @@ GEM active_encode (0.7.0) rails sprockets (< 4) - activejob (5.2.4.3) - activesupport (= 5.2.4.3) + activejob (5.2.4.4) + activesupport (= 5.2.4.4) globalid (>= 0.3.6) - activemodel (5.2.4.3) - activesupport (= 5.2.4.3) + activemodel (5.2.4.4) + activesupport (= 5.2.4.4) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (5.2.4.3) - activemodel (= 5.2.4.3) - activesupport (= 5.2.4.3) + activerecord (5.2.4.4) + activemodel (= 5.2.4.4) + activesupport (= 5.2.4.4) arel (>= 9.0) activerecord-import (1.0.5) activerecord (>= 3.2) - activestorage (5.2.4.3) - actionpack (= 5.2.4.3) - activerecord (= 5.2.4.3) + activestorage (5.2.4.4) + actionpack (= 5.2.4.4) + activerecord (= 5.2.4.4) marcel (~> 0.3.1) - activesupport (5.2.4.3) + activesupport (5.2.4.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -659,18 +659,18 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.4.3) - actioncable (= 5.2.4.3) - actionmailer (= 5.2.4.3) - actionpack (= 5.2.4.3) - actionview (= 5.2.4.3) - activejob (= 5.2.4.3) - activemodel (= 5.2.4.3) - activerecord (= 5.2.4.3) - activestorage (= 5.2.4.3) - activesupport (= 5.2.4.3) + rails (5.2.4.4) + actioncable (= 5.2.4.4) + actionmailer (= 5.2.4.4) + actionpack (= 5.2.4.4) + actionview (= 5.2.4.4) + activejob (= 5.2.4.4) + activemodel (= 5.2.4.4) + activerecord (= 5.2.4.4) + activestorage (= 5.2.4.4) + activesupport (= 5.2.4.4) bundler (>= 1.3.0) - railties (= 5.2.4.3) + railties (= 5.2.4.4) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -683,9 +683,9 @@ GEM loofah (~> 2.3) rails_autolink (1.1.6) rails (> 3.1) - railties (5.2.4.3) - actionpack (= 5.2.4.3) - activesupport (= 5.2.4.3) + railties (5.2.4.4) + actionpack (= 5.2.4.4) + activesupport (= 5.2.4.4) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) From 5fc09c8a0dbcadadfaf4e202deff492d0fd4f4b3 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Wed, 3 Feb 2021 15:35:02 -0500 Subject: [PATCH 06/11] add label overrides hash to Spot::ISO6391 service (#692) * add Spot::ISO6391::OVERRIDES constant map for language label overrides * add comments --- app/services/spot/iso6391.rb | 70 ++++++++++++++++------------- spec/services/spot/iso_6391_spec.rb | 8 ++++ 2 files changed, 46 insertions(+), 32 deletions(-) diff --git a/app/services/spot/iso6391.rb b/app/services/spot/iso6391.rb index a99cab9bd..3fb382ba5 100644 --- a/app/services/spot/iso6391.rb +++ b/app/services/spot/iso6391.rb @@ -1,39 +1,45 @@ # frozen_string_literal: true - -# An utility class for the +iso-639+ gem. We're storing the dictionary -# in a class variable so we don't need to load it every time. module Spot - class ISO6391 - class << self - # All of the ISO-639-1 entries in a key/val hash - # - # @example - # Spot::LanguageAuthority.all.first.to_h - # # => {'aa' => 'Afar'} - # - # @return [Array String>>] - def all - @all ||= mapped_639_1_entries - end - - # Find the label for a language by its 2-char entry. - # - # @param [String] id - # @return [String, NilClass] - def label_for(id) - all[id.downcase] - end + # Helper module for ISO-639 language code -> english-name conversion. Essentially a wrapper + # around the +iso-639+ gem, with the ability to provide overrides for some language labels. + # + # @example Getting the English label for a language from the iso-639 gem + # Spot::ISO6391.label_for('en') + # # => "English" + # + # @example Getting the English label for a language that uses a local override + # Spot::ISO6391::OVERRIDES + # # => { 'es' => 'Spanish' } + # ISO_639.find('es').english_name + # # => "Spanish; Castilian" + # Spot::ISO6391.label_for('es') + # # => "Spanish" + module ISO6391 + # Local overrides for labels. Allows us to add preferred labels for values + # instead of relying on the +iso-639+ gem labels. + OVERRIDES = { + 'es' => 'Spanish' + }.freeze - private + # All of the ISO-639-1 entries in a key/val hash + # + # @example + # Spot::LanguageAuthority.all.first.to_h + # # => {'aa' => 'Afar'} + # + # @return [Array String>>] + def self.all + @all ||= ISO_639::ISO_639_1.select { |e| e.alpha2.present? }.map { |e| [e.alpha2, e.english_name] }.to_h + end - # iso639-1 entries mapped to a key/val hash - # - # @return [Hash String>] - def mapped_639_1_entries - ISO_639::ISO_639_1.select { |e| e.alpha2.present? } - .map { |e| [e.alpha2, e.english_name] } - .to_h - end + # Find the label for a language by its 2-char entry. Tries our local overrides hash first + # falling back to the +iso-639+ gem label. + # + # @param [String] id + # @return [String, NilClass] + def self.label_for(id) + id = id.to_s.downcase + OVERRIDES[id] || all[id] end end end diff --git a/spec/services/spot/iso_6391_spec.rb b/spec/services/spot/iso_6391_spec.rb index f461bfb8a..eacb4615f 100644 --- a/spec/services/spot/iso_6391_spec.rb +++ b/spec/services/spot/iso_6391_spec.rb @@ -16,6 +16,14 @@ it { is_expected.to eq 'Esperanto' } end + context 'when a local override for an entry exists' do + let(:id) { 'es' } + let(:original_value) { ISO_639.find(id).english_name } + + it { is_expected.not_to eq original_value } + it { is_expected.to eq described_class::OVERRIDES[id] } + end + context 'when an entry does not exist' do let(:id) { ':(' } From dde5dcf991df429cb61f0956b2165c6e4739830d Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Thu, 4 Feb 2021 11:03:34 -0500 Subject: [PATCH 07/11] iso-639-update-final-draft_FINAL-b.docx (#693) * use i18n for overrides * update language indexer * lint fixed * nil if id == label in qa language authority --- app/authorities/qa/authorities/language.rb | 4 +-- .../concerns/indexes_language_and_label.rb | 2 +- app/services/spot/iso6391.rb | 34 ++++++------------- config/locales/iso_639.en.yml | 3 ++ spec/services/spot/iso_6391_spec.rb | 18 +++++++--- .../indexing/indexes_language_and_label.rb | 2 +- 6 files changed, 30 insertions(+), 33 deletions(-) create mode 100644 config/locales/iso_639.en.yml diff --git a/app/authorities/qa/authorities/language.rb b/app/authorities/qa/authorities/language.rb index 2c8946a8c..3de562bee 100644 --- a/app/authorities/qa/authorities/language.rb +++ b/app/authorities/qa/authorities/language.rb @@ -11,7 +11,7 @@ class Language < Qa::Authorities::Base # # @return [Array String>>] def all - Spot::ISO6391.all.map { |key, val| wrap(id: key, label: val) } + Spot::ISO6391.all.map { |key, val| wrap(id: key, label: val) }.compact end # @param [String] id @@ -38,7 +38,7 @@ def search(query) # @param [String] label # @return [Hash String>] def wrap(id:, label:) - return if id.nil? || label.nil? + return if id == label { id: id, label: label, value: id } end diff --git a/app/indexers/concerns/indexes_language_and_label.rb b/app/indexers/concerns/indexes_language_and_label.rb index 4e2f97110..9cd7f4b73 100644 --- a/app/indexers/concerns/indexes_language_and_label.rb +++ b/app/indexers/concerns/indexes_language_and_label.rb @@ -14,7 +14,7 @@ def generate_solr_document object.language.each do |lang| doc[value_field] << lang - doc[label_field] << (Spot::ISO6391.label_for(lang) || lang) + doc[label_field] << Spot::ISO6391.label_for(lang) end end end diff --git a/app/services/spot/iso6391.rb b/app/services/spot/iso6391.rb index 3fb382ba5..76543f1c6 100644 --- a/app/services/spot/iso6391.rb +++ b/app/services/spot/iso6391.rb @@ -1,26 +1,8 @@ # frozen_string_literal: true module Spot - # Helper module for ISO-639 language code -> english-name conversion. Essentially a wrapper - # around the +iso-639+ gem, with the ability to provide overrides for some language labels. - # - # @example Getting the English label for a language from the iso-639 gem - # Spot::ISO6391.label_for('en') - # # => "English" - # - # @example Getting the English label for a language that uses a local override - # Spot::ISO6391::OVERRIDES - # # => { 'es' => 'Spanish' } - # ISO_639.find('es').english_name - # # => "Spanish; Castilian" - # Spot::ISO6391.label_for('es') - # # => "Spanish" + # Helper module for obtaining labels for ISO-639-1 values. Uses +I18n+ gem to allow + # custom labels for languages to be provided as a locale file (see +config/locales/iso_639.en.yml+) module ISO6391 - # Local overrides for labels. Allows us to add preferred labels for values - # instead of relying on the +iso-639+ gem labels. - OVERRIDES = { - 'es' => 'Spanish' - }.freeze - # All of the ISO-639-1 entries in a key/val hash # # @example @@ -29,17 +11,21 @@ module ISO6391 # # @return [Array String>>] def self.all - @all ||= ISO_639::ISO_639_1.select { |e| e.alpha2.present? }.map { |e| [e.alpha2, e.english_name] }.to_h + @all ||= ISO_639::ISO_639_1.select { |e| e.alpha2.present? }.map { |e| [e.alpha2, label_for(e.alpha2)] }.to_h end - # Find the label for a language by its 2-char entry. Tries our local overrides hash first - # falling back to the +iso-639+ gem label. + # Find the label for a language by its 2-char entry. + # Possible values, in priority order, are: + # + # - locale value => I18n.t('iso_639_1.es') + # - iso-639 gem english name => ISO_639.find('es').english_name + # - the id value as provided => 'es' # # @param [String] id # @return [String, NilClass] def self.label_for(id) id = id.to_s.downcase - OVERRIDES[id] || all[id] + I18n.t(id, scope: ['iso_639_1'], default: [ISO_639.find(id)&.english_name, id]) end end end diff --git a/config/locales/iso_639.en.yml b/config/locales/iso_639.en.yml new file mode 100644 index 000000000..cfb836513 --- /dev/null +++ b/config/locales/iso_639.en.yml @@ -0,0 +1,3 @@ +en: + iso_639_1: + es: Spanish diff --git a/spec/services/spot/iso_6391_spec.rb b/spec/services/spot/iso_6391_spec.rb index eacb4615f..c0f588c56 100644 --- a/spec/services/spot/iso_6391_spec.rb +++ b/spec/services/spot/iso_6391_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true RSpec.describe Spot::ISO6391 do - describe '#all' do + describe '.all' do subject { described_class.all } it { is_expected.to be_a Hash } it { is_expected.not_to be_empty } end - describe '#label_for' do + describe '.label_for' do subject { described_class.label_for(id) } context 'when a 2-char entry exists' do @@ -17,17 +17,25 @@ end context 'when a local override for an entry exists' do - let(:id) { 'es' } + let(:id) { 'en' } let(:original_value) { ISO_639.find(id).english_name } + let(:expected_value) { 'ANGLISH' } + + before do + allow(I18n) + .to receive(:t) + .with(id, default: [original_value, id], scope: ['iso_639_1']) + .and_return(expected_value) + end it { is_expected.not_to eq original_value } - it { is_expected.to eq described_class::OVERRIDES[id] } + it { is_expected.to eq expected_value } end context 'when an entry does not exist' do let(:id) { ':(' } - it { is_expected.to be_nil } + it { is_expected.to eq id } end end end diff --git a/spec/support/shared_examples/indexing/indexes_language_and_label.rb b/spec/support/shared_examples/indexing/indexes_language_and_label.rb index 838ae7b6d..259af0dcf 100644 --- a/spec/support/shared_examples/indexing/indexes_language_and_label.rb +++ b/spec/support/shared_examples/indexing/indexes_language_and_label.rb @@ -13,7 +13,7 @@ # rubocop:enable RSpec/InstanceVariable let(:languages) { ['en', 'ja', 'nope'] } - let(:labels) { ['English', 'Japanese', 'nope'] } + let(:labels) { languages.map { |lang| Spot::ISO6391.label_for(lang) } } it 'stores the raw values as _ssim' do expect(solr_doc['language_ssim']).to contain_exactly(*languages) From 4473148233f9489a1459e8973f99931048339e2b Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Thu, 4 Feb 2021 12:21:33 -0500 Subject: [PATCH 08/11] create Spot::WorksControllerBehavior mixin (#694) * create works_controller_behavior mixin * use absolute paths for hyrax includes * make WorksControllerBehavior a concern --- .../configurable_iiif_manifest_presenter.rb | 29 ------------------ .../spot/works_controller_behavior.rb | 30 +++++++++++++++++++ app/controllers/hyrax/images_controller.rb | 10 +------ .../hyrax/publications_controller.rb | 10 +------ 4 files changed, 32 insertions(+), 47 deletions(-) delete mode 100644 app/controllers/concerns/spot/configurable_iiif_manifest_presenter.rb create mode 100644 app/controllers/concerns/spot/works_controller_behavior.rb diff --git a/app/controllers/concerns/spot/configurable_iiif_manifest_presenter.rb b/app/controllers/concerns/spot/configurable_iiif_manifest_presenter.rb deleted file mode 100644 index 1f27c1f2f..000000000 --- a/app/controllers/concerns/spot/configurable_iiif_manifest_presenter.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true -module Spot - # abstracts out a +:iiif_manifest_presenter_klass+ attribute to override the Hyrax one. - # in our case, we want to change how the metadata is rendered. - # - # @see https://github.com/samvera/hyrax/blob/v2.9.0/app/controllers/concerns/hyrax/works_controller_behavior.rb#L146-L151 - module ConfigurableIiifManifestPresenter - extend ActiveSupport::Concern - - included do - class_attribute :iiif_manifest_presenter_klass - self.iiif_manifest_presenter_klass = ::Spot::IiifManifestPresenter - end - - private - - # same behavior as Hyrax::WorksControllerBehavior#iiif_manifest_presenter, - # but uses the configurable +:iiif_manifest_presenter_klass+ attribute - # to allow for other subclassed presenters. - # - # @return [Hyrax::IiifManifestPresenter] - def iiif_manifest_presenter - iiif_manifest_presenter_klass.new(curation_concern_from_search_results).tap do |p| - p.hostname = request.hostname - p.ability = current_ability - end - end - end -end diff --git a/app/controllers/concerns/spot/works_controller_behavior.rb b/app/controllers/concerns/spot/works_controller_behavior.rb new file mode 100644 index 000000000..bb9e5ef44 --- /dev/null +++ b/app/controllers/concerns/spot/works_controller_behavior.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true +module Spot + # Base controller for Works that we can inherit from. Inherits Hyrax work behaviors + # as well as handling for CSVs and using our own IIIF presenter. + # + # @example usage + # class DigitizedResourcesController < ApplicationController + # include Spot::WorksControllerBehavior + # end + # + module WorksControllerBehavior + extend ActiveSupport::Concern + include ::Hyrax::WorksControllerBehavior + include ::Hyrax::BreadcrumbsForWorks + include AdditionalFormatsForController + + private + + # Overrides Hyrax behavior by using our own IIIF presenter that relies on Blacklight locales + # to generate field labels. + # + # @return [Spot::IiifManifestPresenter] + def iiif_manifest_presenter + ::Spot::IiifManifestPresenter.new(curation_concern_from_search_results).tap do |p| + p.hostname = request.hostname + p.ability = current_ability + end + end + end +end diff --git a/app/controllers/hyrax/images_controller.rb b/app/controllers/hyrax/images_controller.rb index 028ff3431..aae3386fd 100644 --- a/app/controllers/hyrax/images_controller.rb +++ b/app/controllers/hyrax/images_controller.rb @@ -1,17 +1,9 @@ # frozen_string_literal: true module Hyrax - # Generated controller for Image class ImagesController < ApplicationController - # Adds Hyrax behaviors to the controller. - include Hyrax::WorksControllerBehavior - include Hyrax::BreadcrumbsForWorks - - # use our local IiifManifestPresenter for rendering manifest metadata - include Spot::ConfigurableIiifManifestPresenter + include ::Spot::WorksControllerBehavior self.curation_concern_type = ::Image - - # Use this line if you want to use a custom presenter self.show_presenter = Hyrax::ImagePresenter end end diff --git a/app/controllers/hyrax/publications_controller.rb b/app/controllers/hyrax/publications_controller.rb index 5f5091081..0eed8a5b8 100644 --- a/app/controllers/hyrax/publications_controller.rb +++ b/app/controllers/hyrax/publications_controller.rb @@ -1,17 +1,9 @@ # frozen_string_literal: true module Hyrax class PublicationsController < ApplicationController - # Adds Hyrax behaviors to the controller. - include Hyrax::WorksControllerBehavior - include Hyrax::BreadcrumbsForWorks - include Spot::AdditionalFormatsForController - - # use our local IiifManifestPresenter for rendering manifest metadata - include Spot::ConfigurableIiifManifestPresenter + include Spot::WorksControllerBehavior self.curation_concern_type = ::Publication - - # Use this line if you want to use a custom presenter self.show_presenter = Hyrax::PublicationPresenter end end From 9732a61f4fa224645eb676416f9d07e82a90bb6e Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Thu, 4 Feb 2021 13:24:02 -0500 Subject: [PATCH 09/11] add shared_example for Spot::WorksControllerBehavior --- .../hyrax/images_controller_spec.rb | 9 +--- .../hyrax/publications_controller_spec.rb | 46 +--------------- .../shared_examples/spot_works_controller.rb | 52 +++++++++++++++++++ 3 files changed, 54 insertions(+), 53 deletions(-) create mode 100644 spec/support/shared_examples/spot_works_controller.rb diff --git a/spec/controllers/hyrax/images_controller_spec.rb b/spec/controllers/hyrax/images_controller_spec.rb index 2d5419c57..d0f53787d 100644 --- a/spec/controllers/hyrax/images_controller_spec.rb +++ b/spec/controllers/hyrax/images_controller_spec.rb @@ -1,11 +1,4 @@ # frozen_string_literal: true - -# Generated via -# `rails generate hyrax:work Image` -require 'rails_helper' - RSpec.describe Hyrax::ImagesController do - it "has tests" do - skip "Add your tests here" - end + it_behaves_like 'it includes Spot::WorksControllerBehavior' end diff --git a/spec/controllers/hyrax/publications_controller_spec.rb b/spec/controllers/hyrax/publications_controller_spec.rb index eaf1b3a68..08db6ed86 100644 --- a/spec/controllers/hyrax/publications_controller_spec.rb +++ b/spec/controllers/hyrax/publications_controller_spec.rb @@ -1,48 +1,4 @@ # frozen_string_literal: true RSpec.describe Hyrax::PublicationsController do - let(:doc) { create(:publication, :public) } - - context 'when visiting a known publication' do - before do - get :show, params: { id: doc.id } - end - - it { expect(response).to be_successful } - end - - context 'when visiting a non-existant publication' do - # TODO: this shouldn't be raising an exception, but rather be rendering a 404 - - it 'raises a Blacklight::RecordNotFound error' do - expect { get :show, params: { id: 'not-here' } } - .to raise_error(Blacklight::Exceptions::RecordNotFound) - end - end - - context 'when visiting a Private Publication as a guest' do - let(:doc) { create(:publication, :private) } - - before do - get :show, params: { id: doc.id } - end - - it 'redirects to the login page' do - expect(response.status).to eq 302 - expect(response.headers['Location']).to include '/users/sign_in' - end - end - - context 'when requesting the metadata as csv' do - let(:disposition) { response.header.fetch('Content-Disposition') } - let(:content_type) { response.header.fetch('Content-Type') } - - it 'downloads the file' do - get :show, params: { id: doc.id, format: 'csv' } - - expect(response).to be_successful - expect(disposition).to include 'attachment' - expect(content_type).to eq 'text/csv' - expect(response.body).to start_with('id,title') - end - end + it_behaves_like 'it includes Spot::WorksControllerBehavior' end diff --git a/spec/support/shared_examples/spot_works_controller.rb b/spec/support/shared_examples/spot_works_controller.rb new file mode 100644 index 000000000..e880f6f24 --- /dev/null +++ b/spec/support/shared_examples/spot_works_controller.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true +RSpec.shared_examples 'it includes Spot::WorksControllerBehavior' do + let(:work_type) { described_class.name.split('::').last.sub('Controller', '').singularize.downcase.to_sym } + let(:work) { create(work_type, :public) } + + describe 'Hyrax::WorksControllerBehavior' do + # @todo is this class_attribute going anywhere? keep an eye on it, i guess. + context "when visiting a known #{described_class.curation_concern_type}" do + before do + get :show, params: { id: work.id } + end + + it { expect(response).to be_successful } + end + + context 'when visiting a non-existant publication' do + it 'raises a Blacklight::RecordNotFound error' do + expect { get :show, params: { id: 'not-here' } } + .to raise_error(Blacklight::Exceptions::RecordNotFound) + end + end + + context 'when visiting a Private Publication as a guest' do + let(:doc) { create(:publication, :private) } + + before do + get :show, params: { id: doc.id } + end + + it 'redirects to the login page' do + expect(response.status).to eq 302 + expect(response.headers['Location']).to include '/users/sign_in' + end + end + end + + describe 'additional formats' do + context 'when requesting the metadata as csv' do + let(:disposition) { response.header.fetch('Content-Disposition') } + let(:content_type) { response.header.fetch('Content-Type') } + + it 'downloads the file' do + get :show, params: { id: work.id, format: 'csv' } + + expect(response).to be_successful + expect(disposition).to include 'attachment' + expect(content_type).to eq 'text/csv' + expect(response.body).to start_with('id,title') + end + end + end +end From 7dae8d2f61ca3465a4dd2c335ae4a2c181603f2c Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Fri, 5 Feb 2021 10:19:23 -0500 Subject: [PATCH 10/11] add citls department option (#695) --- config/authorities/lafayette_departments.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/authorities/lafayette_departments.yml b/config/authorities/lafayette_departments.yml index c5e3dff42..62d69370f 100644 --- a/config/authorities/lafayette_departments.yml +++ b/config/authorities/lafayette_departments.yml @@ -5,6 +5,7 @@ terms: - Art - Asian Studies - Biology + - Center for the Integration of Teaching, Learning, and Scholarship - Chemical & Biomolecular Engineering - Chemistry - Civil & Environmental Engineering From 4f164466ce63fa913f7e5da45819bd13ec0495c9 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Fri, 5 Feb 2021 11:50:49 -0500 Subject: [PATCH 11/11] changelog for 2021.3 --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e67a21111..1cda750fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # changelog +## [2021.3] - 2021-02-05 + +### enhancements ๐Ÿ”ง +- adds a locale for custom language labels (`"iso_639_1.<2 letter code>"`) (#693) +- creates a `Spot::WorksControllerBehavior` mixin for common mixins/behavior (#694) + - adds .csv handling to `Hyrax::ImagesController`, which was causing a bunch of honeybadger reports +- add "Center for the Integration of Teaching, Learning, and Scholarship" academic department option (#695) + +### dependencies ๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ง +- capistrano to 3.15.0 (#687) +- nokogiri locked at `~> "1.10.10"` until we can upgrade ruby (#688) +- okcomputer to 1.18.2 (#685) +- rails to 5.2.4.4 (#686) +- rspec-rails to 4.0.1 (#684) + + ## [2021.2] - 2021-01-21 ### bug fixes ๐Ÿž @@ -560,6 +576,7 @@ fixes: Initial pre-release (live on ldr.stage.lafayette.edu) +[2021.3]: https://github.com/LafayetteCollegeLibraries/spot/releases/tag/2021.3 [2021.2]: https://github.com/LafayetteCollegeLibraries/spot/releases/tag/2021.2 [2021.1]: https://github.com/LafayetteCollegeLibraries/spot/releases/tag/2021.1 [2020.13]: https://github.com/LafayetteCollegeLibraries/spot/releases/tag/2020.13