Skip to content

Commit

Permalink
Add zeitwerk inflector for BPIDResolver
Browse files Browse the repository at this point in the history
Fixes #250
  • Loading branch information
jvendetti committed Jan 28, 2023
1 parent 918e2bf commit 5491043
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def redirect_new_api(class_view = false)
@error = "Please provide an ontology id or concept id with an ontology id."
return
end
acronym = BpidResolver.id_to_acronym(params[:ontology])
acronym = BPIDResolver.id_to_acronym(params[:ontology])
not_found unless acronym
if class_view
@ontology = LinkedData::Client::Models::Ontology.find_by_acronym(acronym).first
Expand All @@ -262,7 +262,7 @@ def redirect_new_api(class_view = false)
def params_cleanup_new_api
params = @_params
if params[:ontology] && params[:ontology].to_i > 0
params[:ontology] = BpidResolver.id_to_acronym(params[:ontology])
params[:ontology] = BPIDResolver.id_to_acronym(params[:ontology])
end

params
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def check_params_ontologies(params)
params[:ontologies] = [params[:ontologies]]
end
if params[:ontologies].first.to_i > 0
params[:ontologies].map! {|o| BpidResolver.id_to_acronym(o)}
params[:ontologies].map! {|o| BPIDResolver.id_to_acronym(o)}
end
params[:ontologies] = params[:ontologies].join(",")
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/bpid_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'json'
require 'open-uri'

class BpidResolver
class BPIDResolver
require Rails.root + 'lib/resolver/acronym_from_virtual'
require Rails.root + 'lib/resolver/virtual_from_acronym'
require Rails.root + 'lib/resolver/virtual_from_version'
Expand Down
5 changes: 4 additions & 1 deletion config/initializers/zeitwerk.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# frozen_string_literal: true

Rails.autoloaders.each do |autoloader|
autoloader.inflector = Zeitwerk::Inflector.new
autoloader.inflector.inflect(
"kgcl" => "KGCL",
'bpid_resolver' => 'BPIDResolver',
'kgcl' => 'KGCL'
)
end
2 changes: 1 addition & 1 deletion lib/resolver/acronym_from_virtual.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BpidResolver::ACRONYM_FROM_VIRTUAL = {
BPIDResolver::ACRONYM_FROM_VIRTUAL = {
"old:acronym_from_virtual:3013" => "DIAGONT",
"old:acronym_from_virtual:3245" => "SuicidO",
"old:acronym_from_virtual:1247" => "GEOSPECIES",
Expand Down
2 changes: 1 addition & 1 deletion lib/resolver/virtual_from_acronym.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BpidResolver::VIRTUAL_FROM_ACRONYM = {
BPIDResolver::VIRTUAL_FROM_ACRONYM = {
"JERM" => 1488,
"OGSF" => 3214,
"NATPRO" => 3004,
Expand Down
2 changes: 1 addition & 1 deletion lib/resolver/virtual_from_version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BpidResolver::VIRTUAL_FROM_VERSION = {
BPIDResolver::VIRTUAL_FROM_VERSION = {
"old:virtual_from_version:40876" => 1048,
"old:virtual_from_version:44059" => 1125,
"old:virtual_from_version:46266" => 1172,
Expand Down

0 comments on commit 5491043

Please sign in to comment.