From 8cdb43d0b816ddbd131e6b77831753728cfbe905 Mon Sep 17 00:00:00 2001 From: Ryan Baumann Date: Fri, 17 Mar 2023 13:56:05 -0400 Subject: [PATCH] Acronymize APIS --- app/assets/javascripts/apis-mapping.js | 6 +++--- app/controllers/apis_identifiers_controller.rb | 2 +- app/helpers/apis_identifier_helper.rb | 4 ++-- app/models/apis_identifier.rb | 6 +++--- config/initializers/inflections.rb | 1 + config/initializers/zeitwerk.rb | 2 ++ test/integration/apis_workflow_test.rb | 4 ++-- 7 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/apis-mapping.js b/app/assets/javascripts/apis-mapping.js index 73272427f..6c15254ef 100644 --- a/app/assets/javascripts/apis-mapping.js +++ b/app/assets/javascripts/apis-mapping.js @@ -14,7 +14,7 @@ var apis_map = { tpl: "$apis_identifier_inventoryNo"}, {name: "apisId", xpath: "/t:TEI/t:teiHeader/t:fileDesc/t:publicationStmt/t:idno[@type='apisid']", - children: [["text()","getApisCollection"],["text()","getApisId"]], + children: [["text()","getAPISCollection"],["text()","getAPISId"]], tpl: "$apis_identifier_apisCollection.apis.$apis_identifier_apisId", required: true}, {xpath: "/t:TEI/t:teiHeader/t:fileDesc/t:publicationStmt/t:idno[@type='TM']", @@ -104,10 +104,10 @@ var apis_map = { } }, functions: { - getApisCollection: function(apisId) { + getAPISCollection: function(apisId) { return apisId.substring(0,apisId.indexOf(".")); }, - getApisId: function(apisId) { + getAPISId: function(apisId) { return apisId.substring(apisId.lastIndexOf(".") + 1); }, getDate: function(date) { diff --git a/app/controllers/apis_identifiers_controller.rb b/app/controllers/apis_identifiers_controller.rb index 0dab41177..859c69456 100644 --- a/app/controllers/apis_identifiers_controller.rb +++ b/app/controllers/apis_identifiers_controller.rb @@ -1,4 +1,4 @@ -class ApisIdentifiersController < IdentifiersController +class APISIdentifiersController < IdentifiersController before_action :authorize before_action :ownership_guard, only: %i[update updatexml] require 'pp' diff --git a/app/helpers/apis_identifier_helper.rb b/app/helpers/apis_identifier_helper.rb index 5fb800a3f..970ea9149 100644 --- a/app/helpers/apis_identifier_helper.rb +++ b/app/helpers/apis_identifier_helper.rb @@ -1,5 +1,5 @@ -module ApisIdentifierHelper - module ApisDate +module APISIdentifierHelper + module APISDate def self.getYear; end end end diff --git a/app/models/apis_identifier.rb b/app/models/apis_identifier.rb index e88ee40ce..4a7d8915f 100644 --- a/app/models/apis_identifier.rb +++ b/app/models/apis_identifier.rb @@ -23,10 +23,10 @@ def preview(parameters = {}, xsl = nil) end after_initialize :post_initialization_configuration - # Loads +ApisConfiguration+ object (APIS xpath for EpiDoc and options for the editor) and presets valid EpiDoc attributes + # Loads +APISConfiguration+ object (APIS xpath for EpiDoc and options for the editor) and presets valid EpiDoc attributes # Side effect on +@configuration+ and + @valid_epidoc_attributes+ def post_initialization_configuration - @configuration = ApisConfiguration.new # YAML::load_file(File.join(Rails.root, %w{config apis.yml}))[:apis][:metadata] + @configuration = APISConfiguration.new # YAML::load_file(File.join(Rails.root, %w{config apis.yml}))[:apis][:metadata] @valid_epidoc_attributes = @configuration.keys end @@ -117,7 +117,7 @@ def xml_title_text 'Description of document' end - class ApisConfiguration + class APISConfiguration attr_reader :scheme, :keys def initialize diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 55c5fb2bf..9102bd811 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -14,4 +14,5 @@ inflect.acronym 'DDB' inflect.acronym 'HGV' inflect.acronym 'DCLP' + inflect.acronym 'APIS' end diff --git a/config/initializers/zeitwerk.rb b/config/initializers/zeitwerk.rb index dcc571bd1..505045197 100644 --- a/config/initializers/zeitwerk.rb +++ b/config/initializers/zeitwerk.rb @@ -6,6 +6,7 @@ "ddb" => "DDB", "hgv" => "HGV", "dclp" => "DCLP", + "apis" => "APIS", "ddb_identifier" => "DDBIdentifier", "hgv_meta_identifier" => "HGVMetaIdentifier", "hgv_meta_identifier_helper" => "HGVMetaIdentifierHelper", @@ -13,5 +14,6 @@ "dclp_meta_identifier_helper" => "DCLPMetaIdentifierHelper", "dclp_text_identifier" => "DCLPTextIdentifier", "dclp_text_identifier_helper" => "DCLPTextIdentifierHelper" + "apis_identifier" => "APISIdentifier" ) end diff --git a/test/integration/apis_workflow_test.rb b/test/integration/apis_workflow_test.rb index ee6aae709..588785519 100644 --- a/test/integration/apis_workflow_test.rb +++ b/test/integration/apis_workflow_test.rb @@ -1,7 +1,7 @@ require 'test_helper' require 'ddiff' -class ApisWorkflowTest < ActionDispatch::IntegrationTest +class APISWorkflowTest < ActionDispatch::IntegrationTest def generate_board_vote_for_decree(_board, decree, identifier, user) FactoryBot.create(:vote, publication_id: identifier.publication.id, @@ -77,7 +77,7 @@ def log_diffs(a, b) end end -class ApisWorkflowTest < ActionDispatch::IntegrationTest +class APISWorkflowTest < ActionDispatch::IntegrationTest context 'for idp3' do context 'apis testing' do setup do