22require 'ostruct'
33
44module LinkedData
5- extend self
5+ module_function
6+
67 attr_reader :settings
78
89 @settings = OpenStruct . new
910 @settings_run = false
1011
12+ DEFAULT_PREFIX = 'http://data.bioontology.org/' . freeze
13+
1114 def config ( &block )
1215 return if @settings_run
16+
1317 @settings_run = true
1418
1519 overide_connect_goo = false
1620
1721 # Set defaults
18- @settings . goo_backend_name ||= " 4store"
22+ @settings . goo_backend_name ||= ' 4store'
1923 @settings . goo_port ||= 9000
20- @settings . goo_host ||= " localhost"
21- @settings . goo_path_query ||= " /sparql/"
22- @settings . goo_path_data ||= " /data/"
23- @settings . goo_path_update ||= " /update/"
24- @settings . search_server_url ||= " http://localhost:8983/solr/term_search_core1"
25- @settings . property_search_server_url ||= " http://localhost:8983/solr/prop_search_core1"
26- @settings . repository_folder ||= " ./test/data/ontology_files/repo"
27- @settings . rest_url_prefix ||= "http://data.bioontology.org/"
24+ @settings . goo_host ||= ' localhost'
25+ @settings . goo_path_query ||= ' /sparql/'
26+ @settings . goo_path_data ||= ' /data/'
27+ @settings . goo_path_update ||= ' /update/'
28+ @settings . search_server_url ||= ' http://localhost:8983/solr/term_search_core1'
29+ @settings . property_search_server_url ||= ' http://localhost:8983/solr/prop_search_core1'
30+ @settings . repository_folder ||= ' ./test/data/ontology_files/repo'
31+ @settings . rest_url_prefix ||= DEFAULT_PREFIX
2832 @settings . enable_security ||= false
2933 @settings . enable_slices ||= false
3034
@@ -35,47 +39,47 @@ def config(&block)
3539 # @settings.redis_port ||= 6379
3640 # ###
3741
38- @settings . ui_host ||= " bioportal.bioontology.org"
39- @settings . replace_url_prefix ||= false
40- @settings . id_url_prefix ||= "http://data.bioontology.org/"
42+ @settings . ui_host ||= ' bioportal.bioontology.org'
43+ @settings . replace_url_prefix ||= false
44+ @settings . id_url_prefix ||= DEFAULT_PREFIX
4145 @settings . queries_debug ||= false
4246 @settings . enable_monitoring ||= false
43- @settings . cube_host ||= " localhost"
47+ @settings . cube_host ||= ' localhost'
4448 @settings . cube_port ||= 1180
4549
4650 # Caching http
4751 @settings . enable_http_cache ||= false
48- @settings . http_redis_host ||= " localhost"
52+ @settings . http_redis_host ||= ' localhost'
4953 @settings . http_redis_port ||= 6379
5054
5155 #Caching goo
52- @settings . goo_redis_host ||= " localhost"
56+ @settings . goo_redis_host ||= ' localhost'
5357 @settings . goo_redis_port ||= 6379
5458
5559 #Ontology Analytics Redis
56- @settings . ontology_analytics_redis_host ||= " localhost"
60+ @settings . ontology_analytics_redis_host ||= ' localhost'
5761 @settings . ontology_analytics_redis_port ||= 6379
5862
5963 # PURL server config parameters
6064 @settings . enable_purl ||= false
61- @settings . purl_host ||= " purl.bioontology.org"
65+ @settings . purl_host ||= ' purl.bioontology.org'
6266 @settings . purl_port ||= 80
63- @settings . purl_username ||= ""
64- @settings . purl_password ||= ""
65- @settings . purl_maintainers ||= ""
66- @settings . purl_target_url_prefix ||= " http://bioportal.bioontology.org"
67+ @settings . purl_username ||= ''
68+ @settings . purl_password ||= ''
69+ @settings . purl_maintainers ||= ''
70+ @settings . purl_target_url_prefix ||= ' http://bioportal.bioontology.org'
6771
6872 # Email settings
69- @settings . enable_notifications ||= false
70- @settings . email_sender ||= " admin@example.org" # Default sender for emails
71- @settings . email_override ||= " test.email@example.org" # By default, all email gets sent here. Disable with email_override_disable.
73+ @settings . enable_notifications ||= false
74+ @settings . email_sender ||= ' admin@example.org' # Default sender for emails
75+ @settings . email_override ||= ' test.email@example.org' # By default, all email gets sent here. Disable with email_override_disable.
7276 @settings . email_disable_override ||= false
73- @settings . smtp_host ||= " localhost"
77+ @settings . smtp_host ||= ' localhost'
7478 @settings . smtp_port ||= 25
75- @settings . smtp_user ||= " user"
76- @settings . smtp_password ||= " password"
79+ @settings . smtp_user ||= ' user'
80+ @settings . smtp_password ||= ' password'
7781 @settings . smtp_auth_type ||= :none # :none, :plain, :login, :cram_md5
78- @settings . smtp_domain ||= " localhost.localhost"
82+ @settings . smtp_domain ||= ' localhost.localhost'
7983 @settings . enable_starttls_auto ||= false # set to true for use with gmail
8084
8185 # number of times to retry a query when empty records are returned
@@ -89,20 +93,18 @@ def config(&block)
8993
9094 unless @settings . redis_host . nil?
9195 puts "Error: 'redis_host' is not a valid conf parameter."
92- puts " Redis databases were split into multiple hosts (09/22/13)."
93- raise Exception , " redis_host is not a valid conf parameter."
96+ puts ' Redis databases were split into multiple hosts (09/22/13).'
97+ raise StandardError , ' redis_host is not a valid conf parameter.'
9498 end
9599
96100 # Check to make sure url prefix has trailing slash
97- @settings . rest_url_prefix = @settings . rest_url_prefix + " /" unless @settings . rest_url_prefix [ -1 ] . eql? ( "/" )
101+ @settings . rest_url_prefix = " #{ @settings . rest_url_prefix } /" unless @settings . rest_url_prefix [ -1 ] . eql? ( '/' )
98102
99103 puts "(LD) >> Using rdf store #{ @settings . goo_host } :#{ @settings . goo_port } "
100104 puts "(LD) >> Using term search server at #{ @settings . search_server_url } "
101105 puts "(LD) >> Using property search server at #{ @settings . property_search_server_url } "
102- puts "(LD) >> Using HTTP Redis instance at " +
103- "#{ @settings . http_redis_host } :#{ @settings . http_redis_port } "
104- puts "(LD) >> Using Goo Redis instance at " +
105- "#{ @settings . goo_redis_host } :#{ @settings . goo_redis_port } "
106+ puts "(LD) >> Using HTTP Redis instance at #{ @settings . http_redis_host } :#{ @settings . http_redis_port } "
107+ puts "(LD) >> Using Goo Redis instance at #{ @settings . goo_redis_host } :#{ @settings . goo_redis_port } "
106108
107109 connect_goo unless overide_connect_goo
108110 end
@@ -132,15 +134,14 @@ def connect_goo
132134 port : @settings . goo_redis_port )
133135
134136 if @settings . enable_monitoring
135- puts "(LD) >> Enable SPARQL monitoring with cube #{ @settings . cube_host } :" +
136- "#{ @settings . cube_port } "
137+ puts "(LD) >> Enable SPARQL monitoring with cube #{ @settings . cube_host } :#{ @settings . cube_port } "
137138 conf . enable_cube do |opts |
138139 opts [ :host ] = @settings . cube_host
139140 opts [ :port ] = @settings . cube_port
140141 end
141142 end
142143 end
143- rescue Exception => e
144+ rescue StandardError => e
144145 abort ( "EXITING: Cannot connect to triplestore and/or search server:\n #{ e } \n #{ e . backtrace . join ( "\n " ) } " )
145146 end
146147 end
@@ -150,26 +151,27 @@ def connect_goo
150151 # We do this at initial runtime because goo needs namespaces for its DSL
151152 def goo_namespaces
152153 Goo . configure do |conf |
153- conf . add_namespace ( :omv , RDF ::Vocabulary . new ( " http://omv.ontoware.org/2005/05/ontology#" ) )
154- conf . add_namespace ( :skos , RDF ::Vocabulary . new ( " http://www.w3.org/2004/02/skos/core#" ) )
155- conf . add_namespace ( :owl , RDF ::Vocabulary . new ( " http://www.w3.org/2002/07/owl#" ) )
154+ conf . add_namespace ( :omv , RDF ::Vocabulary . new ( ' http://omv.ontoware.org/2005/05/ontology#' ) )
155+ conf . add_namespace ( :skos , RDF ::Vocabulary . new ( ' http://www.w3.org/2004/02/skos/core#' ) )
156+ conf . add_namespace ( :owl , RDF ::Vocabulary . new ( ' http://www.w3.org/2002/07/owl#' ) )
156157 conf . add_namespace ( :rdfs , RDF ::Vocabulary . new ( "http://www.w3.org/2000/01/rdf-schema#" ) )
158+ conf . add_namespace ( :rdfs , RDF ::Vocabulary . new ( 'http://www.w3.org/2000/01/rdf-schema#' ) )
157159 conf . add_namespace ( :metadata ,
158- RDF ::Vocabulary . new ( " http://data.bioontology.org/metadata/" ) ,
160+ RDF ::Vocabulary . new ( ' http://data.bioontology.org/metadata/' ) ,
159161 default = true )
160162 conf . add_namespace ( :metadata_def ,
161- RDF ::Vocabulary . new ( " http://data.bioontology.org/metadata/def/" ) )
162- conf . add_namespace ( :dc , RDF ::Vocabulary . new ( " http://purl.org/dc/elements/1.1/" ) )
163- conf . add_namespace ( :xsd , RDF ::Vocabulary . new ( " http://www.w3.org/2001/XMLSchema#" ) )
163+ RDF ::Vocabulary . new ( ' http://data.bioontology.org/metadata/def/' ) )
164+ conf . add_namespace ( :dc , RDF ::Vocabulary . new ( ' http://purl.org/dc/elements/1.1/' ) )
165+ conf . add_namespace ( :xsd , RDF ::Vocabulary . new ( ' http://www.w3.org/2001/XMLSchema#' ) )
164166 conf . add_namespace ( :oboinowl_gen ,
165- RDF ::Vocabulary . new ( " http://www.geneontology.org/formats/oboInOwl#" ) )
166- conf . add_namespace ( :obo_purl , RDF ::Vocabulary . new ( " http://purl.obolibrary.org/obo/" ) )
167+ RDF ::Vocabulary . new ( ' http://www.geneontology.org/formats/oboInOwl#' ) )
168+ conf . add_namespace ( :obo_purl , RDF ::Vocabulary . new ( ' http://purl.obolibrary.org/obo/' ) )
167169 conf . add_namespace ( :umls ,
168- RDF ::Vocabulary . new ( " http://bioportal.bioontology.org/ontologies/umls/" ) )
169- conf . id_prefix = "http://data.bioontology.org/"
170+ RDF ::Vocabulary . new ( ' http://bioportal.bioontology.org/ontologies/umls/' ) )
171+ conf . id_prefix = DEFAULT_PREFIX
170172 conf . pluralize_models ( true )
171173 end
172174 end
173- self . goo_namespaces
175+ goo_namespaces
174176
175177end
0 commit comments