From a3de405ec4d8ec9cd194ddf5173d4408bfcf4e0d Mon Sep 17 00:00:00 2001 From: kibigo! <kibigo@ucsb.edu> Date: Mon, 14 Feb 2022 10:24:14 -0800 Subject: [PATCH] comet: configure to use surfliner_schema gem Adds a new `EnvSchemaReader` service to provide the underlying functionality of `EnvSchemaLoader`. --- ci/comet.yml | 1 + comet/Gemfile | 1 + comet/Gemfile.lock | 7 +++++++ comet/app/services/env_schema_loader.rb | 17 +++++------------ comet/app/services/env_schema_reader.rb | 11 +++++++++++ 5 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 comet/app/services/env_schema_reader.rb diff --git a/ci/comet.yml b/ci/comet.yml index 0c37176435..50ee3d8c60 100644 --- a/ci/comet.yml +++ b/ci/comet.yml @@ -17,6 +17,7 @@ include: - ci/comet.yml - comet/**/* - comet/Dockerfile + - gems/surfliner_schema/**/* .rabbitmq_helpers: &rabbitmq_helpers | exists_rabbitmq_operator() { diff --git a/comet/Gemfile b/comet/Gemfile index 38cffdc814..df25166620 100644 --- a/comet/Gemfile +++ b/comet/Gemfile @@ -26,6 +26,7 @@ gem "redis", "4.6.0" gem "rsolr", "2.4.0" gem "sass-rails", "5.1.0" gem "sidekiq", "6.2.1" +gem "surfliner_schema", path: "../gems/surfliner_schema" gem "tinymce-rails", "5.10.2" gem "turbolinks", "5.2.1" gem "uglifier", "4.2.0" diff --git a/comet/Gemfile.lock b/comet/Gemfile.lock index 03b3163c39..5bdac9c848 100644 --- a/comet/Gemfile.lock +++ b/comet/Gemfile.lock @@ -58,6 +58,12 @@ GIT tinymce-rails valkyrie (~> 2, >= 2.1.1) +PATH + remote: ../gems/surfliner_schema + specs: + surfliner_schema (0.1.0.pre) + valkyrie (~> 2.2) + GEM remote: https://rubygems.org/ specs: @@ -1014,6 +1020,7 @@ DEPENDENCIES selenium-webdriver (= 3.142.7) sidekiq (= 6.2.1) standard (= 1.7.1) + surfliner_schema! tinymce-rails (= 5.10.2) turbolinks (= 5.2.1) uglifier (= 4.2.0) diff --git a/comet/app/services/env_schema_loader.rb b/comet/app/services/env_schema_loader.rb index 905f790acc..42c3a16177 100644 --- a/comet/app/services/env_schema_loader.rb +++ b/comet/app/services/env_schema_loader.rb @@ -2,19 +2,12 @@ # this class overrides the standard schema loader to read schema names from the # environment, instead of taking an argument -class EnvSchemaLoader < Hyrax::SimpleSchemaLoader - def metadata_models - @metadata_models ||= ENV["METADATA_MODELS"] - .to_s - .split(",") - .map(&:to_sym) +class EnvSchemaLoader < SurflinerSchema::HyraxLoader + def initialize + super self.class.reader_class.instance end - def definitions(_schema_name) - metadata_models.map do |model| - schema_config(model)["attributes"].map do |name, config| - AttributeDefinition.new(name, config) - end - end.flatten + def self.reader_class + EnvSchemaReader end end diff --git a/comet/app/services/env_schema_reader.rb b/comet/app/services/env_schema_reader.rb new file mode 100644 index 0000000000..568e89d739 --- /dev/null +++ b/comet/app/services/env_schema_reader.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require "singleton" + +class EnvSchemaReader < SurflinerSchema::Reader + include Singleton + + def initialize + super(*ENV["METADATA_MODELS"].to_s.split(",").map(&:to_sym)) + end +end -- GitLab