Skip to content

Commit

Permalink
Merge branch 'development' into feature/parse-diff-files
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Sep 16, 2024
2 parents 6ed7256 + be47dfd commit 99b9343
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 30 deletions.
58 changes: 30 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,22 @@ GEM
bcrypt (3.1.20)
bigdecimal (3.1.8)
builder (3.3.0)
childprocess (5.1.0)
logger (~> 1.5)
coderay (1.1.3)
concurrent-ruby (1.3.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crack (1.0.0)
bigdecimal
rexml
cube-ruby (0.0.3)
daemons (1.4.1)
date (3.3.4)
docile (1.4.0)
docile (1.4.1)
domain_name (0.6.20240107)
email_spec (2.2.2)
email_spec (2.3.0)
htmlentities (~> 4.3.3)
launchy (~> 2.1)
launchy (>= 2.1, < 4.0)
mail (~> 2.7)
eventmachine (1.2.7)
faraday (1.10.3)
Expand All @@ -76,32 +78,33 @@ GEM
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http (1.0.2)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
ffi (1.16.3)
hashdiff (1.1.0)
hashdiff (1.1.1)
hashie (5.0.0)
htmlentities (4.3.4)
http-accept (1.7.0)
http-cookie (1.0.6)
http-cookie (1.0.7)
domain_name (~> 0.5)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
json (2.7.2)
json-ld (3.0.2)
multi_json (~> 1.12)
rdf (>= 2.2.8, < 4.0)
jwt (2.8.2)
jwt (2.9.0)
base64
language_server-protocol (3.17.0.3)
launchy (2.5.2)
launchy (3.0.1)
addressable (~> 2.8)
childprocess (~> 5.0)
libxml-ruby (2.9.0)
link_header (0.0.8)
logger (1.6.0)
logger (1.6.1)
macaddr (1.7.2)
systemu (~> 2.6.5)
mail (2.8.1)
Expand All @@ -112,7 +115,7 @@ GEM
method_source (1.1.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0604)
mime-types-data (3.2024.0903)
mini_mime (1.1.5)
minitest (4.7.5)
minitest-reporters (0.14.24)
Expand All @@ -122,9 +125,9 @@ GEM
powerbar
multi_json (1.15.0)
multipart-post (2.4.1)
net-http-persistent (4.0.2)
net-http-persistent (4.0.4)
connection_pool (~> 2.2)
net-imap (0.4.14)
net-imap (0.4.16)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -134,12 +137,14 @@ GEM
net-smtp (0.5.0)
net-protocol
netrc (0.11.0)
oj (3.16.4)
oj (3.16.6)
bigdecimal (>= 3.0)
ostruct (>= 0.2)
omni_logger (0.1.4)
logger
parallel (1.25.1)
parser (3.3.3.0)
ostruct (0.6.0)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
pony (1.13.1)
Expand All @@ -150,7 +155,7 @@ GEM
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.1.1)
racc (1.8.0)
racc (1.8.1)
rack (1.6.13)
rack-test (0.8.3)
rack (>= 1.0, < 3)
Expand All @@ -171,7 +176,7 @@ GEM
rdf-xsd (3.2.1)
rdf (~> 3.2)
rexml (~> 3.2)
redis (5.2.0)
redis (5.3.0)
redis-client (>= 0.22.0)
redis-client (0.22.2)
connection_pool
Expand All @@ -183,22 +188,20 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.3.1)
strscan
rexml (3.3.7)
rsolr (1.1.2)
builder (>= 2.1.2)
rubocop (1.64.1)
rubocop (1.66.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
Expand All @@ -210,9 +213,8 @@ GEM
simplecov-cobertura (2.1.0)
rexml
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
strscan (3.1.0)
systemu (2.6.5)
test-unit-minitest (0.9.1)
minitest (~> 4.7)
Expand All @@ -223,7 +225,7 @@ GEM
thread_safe (0.3.6)
timeout (0.4.1)
tzinfo (0.3.62)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)
uuid (2.3.9)
macaddr (~> 1.0)
webmock (3.23.1)
Expand Down
32 changes: 32 additions & 0 deletions config/config.rb.sample
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,38 @@ begin
link: 'https://www.googleapis.com/oauth2/v3/userinfo'
}
}

config.ui_name = 'Bioportal'
config.title = 'NCBO BioPortal'
config.description = "The world's most comprehensive repository of biomedical ontologies"
config.color = '#234979'
config.logo = ''
config.fundedBy = [
{
img_src: 'https://identity.stanford.edu/wp-content/uploads/sites/3/2020/07/block-s-right.png',
url: 'https://www.stanford.edu',

},
{
img_src: 'https://ontoportal.org/images/logo.png',
url: 'https://ontoportal.org/',
}
]
config.federated_portals = {
'agroportal' => {
api: 'http://data.agroportal.lirmm.fr',
ui: 'http://agroportal.lirmm.fr',
apikey: '1cfae05f-9e67-486f-820b-b393dec5764b',
color: '#1e2251'
},
'bioportal' => {
api: 'http://data.bioontology.org',
ui: 'http://bioportal.bioontology.org',
apikey: '4a5011ea-75fa-4be6-8e89-f45c8c84844e',
color: '#234979'
},

}
end
rescue NameError => e
binding.pry
Expand Down
11 changes: 9 additions & 2 deletions lib/ontologies_linked_data/config/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ def config(&block)
# ###

@settings.ui_name ||= 'Bioportal'
@settings.title ||= ''
@settings.description ||= ''
@settings.color ||= ''
@settings.logo ||= ''
@settings.fundedBy ||= {}
@settings.federated_portals ||= {}

@settings.ui_host ||= 'bioportal.bioontology.org'
@settings.replace_url_prefix ||= false
@settings.id_url_prefix ||= DEFAULT_PREFIX
@settings.replace_url_prefix ||= false
@settings.id_url_prefix ||= DEFAULT_PREFIX
@settings.queries_debug ||= false
@settings.enable_monitoring ||= false
@settings.cube_host ||= 'localhost'
Expand Down
57 changes: 57 additions & 0 deletions lib/ontologies_linked_data/models/portal_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module LinkedData
module Models
class PortalConfig < LinkedData::Models::Base
model :SemanticArtefactCatalogue, namespace: :mod, name_with: :acronym
attribute :acronym, enforce: [:unique, :existence]
attribute :title, namespace: :dcterms, enforce: [:existence]
attribute :color, enforce: [:existence, :valid_hash_code]
attribute :description, namespace: :dcterms
attribute :logo, namespace: :foaf, enforce: [:url]
attribute :numberOfArtefacts, namespace: :mod, handler: :ontologies_count
attribute :federated_portals, handler: :federated_portals_settings
attribute :fundedBy, namespace: :foaf, enforce: [:list]

serialize_default :acronym, :title, :color, :description, :logo, :numberOfArtefacts, :federated_portals, :fundedBy

def initialize(*args)
super
init_federated_portals_settings
end

def self.current_portal_config
p = LinkedData::Models::PortalConfig.new

p.acronym = LinkedData.settings.ui_name.downcase
p.title = LinkedData.settings.title
p.description = LinkedData.settings.description
p.color = LinkedData.settings.color
p.logo = LinkedData.settings.logo
p.fundedBy = LinkedData.settings.fundedBy
p
end

def init_federated_portals_settings(federated_portals = nil)
@federated_portals = federated_portals || LinkedData.settings.federated_portals.symbolize_keys
end

def federated_portals_settings
@federated_portals
end

def ontologies_count
LinkedData::Models::Ontology.where(viewingRestriction: 'public').count
end

def self.valid_hash_code(inst, attr)
inst.bring(attr) if inst.bring?(attr)
str = inst.send(attr)

return if (/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/ === str)
[:valid_hash_code,
"Invalid hex color code: '#{str}'. Please provide a valid hex code in the format '#FFF' or '#FFFFFF'."]
end
end
end
end


27 changes: 27 additions & 0 deletions test/models/test_portal_configuration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require_relative '../test_case'

class TestPortalConfiguration < LinkedData::TestCase

def test_read_portal_config
config = LinkedData::Models::PortalConfig.current_portal_config

expected = { acronym: 'bioportal',
title: 'NCBO BioPortal',
color: '#234979',
description: "The world's most comprehensive repository of biomedical ontologies",
logo: '',
fundedBy: [{ img_src: 'https://identity.stanford.edu/wp-content/uploads/sites/3/2020/07/block-s-right.png', url: 'https://www.stanford.edu' },
{ img_src: 'https://ontoportal.org/images/logo.png', url: 'https://ontoportal.org/' }],
id: RDF::URI.new('http://data.bioontology.org/SemanticArtefactCatalogues/bioportal') }

assert config.valid?

assert_equal expected, config.to_hash

expected_federated_portals = { 'agroportal' => { api: 'http://data.agroportal.lirmm.fr', ui: 'http://agroportal.lirmm.fr', apikey: '1cfae05f-9e67-486f-820b-b393dec5764b', color: '#1e2251' },
'bioportal' => { api: 'http://data.bioontology.org', ui: 'http://bioportal.bioontology.org', apikey: '4a5011ea-75fa-4be6-8e89-f45c8c84844e', color: '#234979' } }.symbolize_keys
assert_equal expected_federated_portals, config.federated_portals
refute_nil config.numberOfArtefacts
end
end

0 comments on commit 99b9343

Please sign in to comment.