Class: NcsNavigator::Configuration
- Inherits:
-
Object
- Object
- NcsNavigator::Configuration
- Defined in:
- lib/ncs_navigator/configuration.rb,
lib/ncs_navigator/configuration/version.rb,
lib/ncs_navigator/configuration/sampling_units.rb
Overview
The typed access point for the common configuration in the NCS Navigator suite.
Defined Under Namespace
Classes: Error, PrimarySamplingUnit, SamplingUnitArea, SecondarySamplingUnit, TertiarySamplingUnit
Constant Summary collapse
- APPLICATION_SECTIONS =
['Staff Portal', 'Core', 'PSC']
- VERSION =
'0.3.0'
Instance Attribute Summary collapse
-
#ini_filename ⇒ Pathname
readonly
The file from which this configuration was initialized, if any.
Class Method Summary collapse
-
.configuration_attribute(name, section, key, type, options = {})
Defines a mapping from the configuration file to an attribute on this class.
-
.section_accessor(section_name, accessor_name)
Defines an attribute that exposes the raw contents of a section.
Instance Method Summary collapse
-
#action_mailer_smtp_settings ⇒ Hash<Symbol, Object>
Provides a configuration hash suitable for passing to
ActionMailer::Base.smtp_settings
. - #Core ⇒ Object
-
#core_mail_from ⇒ String
The address from which mail sent by Core will appear to come.
-
#core_uri ⇒ URI
The root URI for the NCS Navigator Core deployment in this instance of the suite.
-
#exception_email_recipients ⇒ Array
The e-mail addresses which will receive uncaught exceptions from any application in the suite.
-
#footer_center_html ⇒ String
Converts #footer_text into equivalent HTML.
-
#footer_logo_left ⇒ Pathname
The image that should appear on the left side of the footer in Staff Portal and Core.
-
#footer_logo_right ⇒ Pathname
The image that should appear on the right side of the footer in Staff Portal and Core.
-
#footer_text ⇒ String
The text that should appear in the center of the footer in Staff Portal and Core.
-
#initialize(source) ⇒ Configuration
constructor
Creates a new Configuration.
-
#primary_sampling_units ⇒ Array<PrimarySamplingUnit>
(also: #psus)
The PSUs defined in #sampling_units_file.
- #PSC ⇒ Object
-
#psc_uri ⇒ URI
The root URI for the PSC deployment in this instance of the suite.
-
#recruitment_type_id ⇒ String
The recruitment strategy for this study center.
-
#sampling_unit_areas ⇒ Array<SamplingUnitArea>
(also: #areas)
The areas defined in #sampling_units_file.
-
#sampling_units_file ⇒ Pathname
The CSV describing the PSU, "sampling areas", SSUs, and (if applicable) TSUs for this center.
-
#secondary_sampling_units ⇒ Array<SecondarySamplingUnit>
(also: #ssus)
The SSUs defined in #sampling_units_file.
-
#smtp_authentication_method ⇒ Symbol
The type of authentication needed for the SMTP server, if any.
-
#smtp_helo_domain ⇒ String
The the HELO domain for the SMTP server, if any.
-
#smtp_host ⇒ String
The hostname of the SMTP server the suite should use to send mail.
-
#smtp_password ⇒ String
The password to use when authenticating to the SMTP server, if authentication is required.
-
#smtp_port ⇒ Fixnum
The port for the SMTP server the suite should use.
-
#smtp_starttls ⇒ Boolean
Whether to try to use STARTTLS if the SMTP server supports it.
-
#smtp_username ⇒ String
The username to use when authenticating to the SMTP server, if authentication is required.
-
#Staff Portal($2) ⇒ Hash<String, String>
Exposes all the values from the [$1] section.
-
#staff_portal_mail_from ⇒ String
The address from which mail sent by Staff Portal will appear to come.
-
#staff_portal_uri ⇒ URI
The root URI for the Staff Portal deployment in this instance of the suite.
-
#study_center_id ⇒ String
(also: #sc_id)
Read from the
[Study Center]
section, keysc_id
. -
#study_center_short_name ⇒ String
A short, human-readable name or abbreviation for the Study Center.
-
#study_center_username ⇒ String
The name for the institutional identity used in this deployment of NCS Navigator.
Constructor Details
#initialize(source) ⇒ Configuration
Creates a new Configuration.
310 311 312 313 314 315 316 317 |
# File 'lib/ncs_navigator/configuration.rb', line 310 def initialize(source) case source when String init_from_ini(source) else init_from_hash(source) end end |
Instance Attribute Details
#ini_filename ⇒ Pathname (readonly)
The file from which this configuration was initialized, if any.
157 158 159 |
# File 'lib/ncs_navigator/configuration.rb', line 157 def ini_filename @ini_filename end |
Class Method Details
.configuration_attribute(name, section, key, type, options = {})
This method returns an undefined value.
Defines a mapping from the configuration file to an attribute on this class.
72 73 74 75 |
# File 'lib/ncs_navigator/configuration.rb', line 72 def configuration_attribute(name, section, key, type, ={}) configuration_attributes << ConfigurationAttribute.new(name, section, key, type, ) attr_accessor name end |
.section_accessor(section_name, accessor_name)
This method returns an undefined value.
Defines an attribute that exposes the raw contents of a section.
86 87 88 89 90 |
# File 'lib/ncs_navigator/configuration.rb', line 86 def section_accessor(section_name, accessor_name) define_method accessor_name.to_sym do @application_sections[section_name.to_s] ||= {} end end |
Instance Method Details
#action_mailer_smtp_settings ⇒ Hash<Symbol, Object>
Provides a configuration hash suitable for passing to
ActionMailer::Base.smtp_settings
.
424 425 426 427 428 429 430 431 432 433 434 435 436 |
# File 'lib/ncs_navigator/configuration.rb', line 424 def action_mailer_smtp_settings Hash[ { :address => smtp_host, :port => smtp_port, :domain => smtp_helo_domain, :user_name => smtp_username, :password => smtp_password, :authentication => smtp_authentication_method, :enable_starttls_auto => smtp_starttls }.select { |k, v| v } ] end |
#Core ⇒ Object
298 |
# File 'lib/ncs_navigator/configuration.rb', line 298 section_accessor 'Core', :core |
#core_mail_from ⇒ String
The address from which mail sent by Core will appear to come.
Read from the [Core]
section, key mail_from
.
244 245 |
# File 'lib/ncs_navigator/configuration.rb', line 244 configuration_attribute :core_mail_from, 'Core', 'mail_from', String, :default => '[email protected]' |
#core_uri ⇒ URI
The root URI for the NCS Navigator Core deployment in this instance of
the suite.
Read from the [Core]
section, key uri
.
240 |
# File 'lib/ncs_navigator/configuration.rb', line 240 configuration_attribute :core_uri, 'Core', 'uri', URI, :required => true |
#exception_email_recipients ⇒ Array
The e-mail addresses which will receive uncaught exceptions from
any application in the suite.
Read from the [Study Center]
section, key exception_email_recipients
.
190 191 |
# File 'lib/ncs_navigator/configuration.rb', line 190 configuration_attribute :exception_email_recipients, 'Study Center', 'exception_email_recipients', Array, :default => [] |
#footer_center_html ⇒ String
Converts #footer_text into equivalent HTML.
409 410 411 412 413 414 415 416 417 |
# File 'lib/ncs_navigator/configuration.rb', line 409 def return nil unless html = .split("\n").join("<br>\n") if html.respond_to?(:html_safe) html.html_safe else html end end |
#footer_logo_left ⇒ Pathname
The image that should appear on the left side of the footer in
Staff Portal and Core. This should be a path to a file on the
deployed server.
Read from the [Study Center]
section, key footer_logo_left
.
213 |
# File 'lib/ncs_navigator/configuration.rb', line 213 configuration_attribute :footer_logo_left, 'Study Center', 'footer_logo_left', Pathname |
#footer_logo_right ⇒ Pathname
The image that should appear on the right side of the footer in
Staff Portal and Core. This should be a path to a file on the
deployed server.
Read from the [Study Center]
section, key footer_logo_right
.
219 |
# File 'lib/ncs_navigator/configuration.rb', line 219 configuration_attribute :footer_logo_right, 'Study Center', 'footer_logo_right', Pathname |
#footer_text ⇒ String
The text that should appear in the center of the footer in Staff
Portal and Core. This is usually the center's contact
information.
Read from the [Study Center]
section, key footer_text
.
225 |
# File 'lib/ncs_navigator/configuration.rb', line 225 configuration_attribute :footer_text, 'Study Center', 'footer_text', String |
#primary_sampling_units ⇒ Array<PrimarySamplingUnit> Also known as: psus
Returns the PSUs defined in #sampling_units_file.
393 394 395 |
# File 'lib/ncs_navigator/configuration.rb', line 393 def primary_sampling_units @primary_sampling_units ||= sampling_unit_areas.collect(&:primary_sampling_unit).uniq end |
#PSC ⇒ Object
299 |
# File 'lib/ncs_navigator/configuration.rb', line 299 section_accessor 'PSC', :psc |
#psc_uri ⇒ URI
The root URI for the PSC deployment in this instance of
the suite.
Read from the [PSC]
section, key uri
.
250 |
# File 'lib/ncs_navigator/configuration.rb', line 250 configuration_attribute :psc_uri, 'PSC', 'uri', URI, :required => true |
#recruitment_type_id ⇒ String
The recruitment strategy for this study center. The acceptable
values are those from the code list recruit_type_cl1
in the
MDES.
Read from the [Study Center]
section, key recruitment_type_id
.
178 179 |
# File 'lib/ncs_navigator/configuration.rb', line 178 configuration_attribute :recruitment_type_id, 'Study Center', 'recruitment_type_id', String, :required => true |
#sampling_unit_areas ⇒ Array<SamplingUnitArea> Also known as: areas
Returns the areas defined in #sampling_units_file.
359 360 361 |
# File 'lib/ncs_navigator/configuration.rb', line 359 def sampling_unit_areas @sampling_unit_areas ||= read_sampling_unit_areas end |
#sampling_units_file ⇒ Pathname
The CSV describing the PSU, "sampling areas", SSUs, and (if applicable) TSUs for this center.
The format is described in the comments in the
sample INI.
Read from the [Study Center]
section, key sampling_units_file
.
206 207 |
# File 'lib/ncs_navigator/configuration.rb', line 206 configuration_attribute :sampling_units_file, 'Study Center', 'sampling_units_file', Pathname, :required => true |
#secondary_sampling_units ⇒ Array<SecondarySamplingUnit> Also known as: ssus
Returns the SSUs defined in #sampling_units_file.
400 401 402 |
# File 'lib/ncs_navigator/configuration.rb', line 400 def secondary_sampling_units @secondary_sampling_units ||= sampling_unit_areas.collect(&:secondary_sampling_units).flatten end |
#smtp_authentication_method ⇒ Symbol
The type of authentication needed for the SMTP server, if any.
Read from the [SMTP]
section, key authentication
.
267 |
# File 'lib/ncs_navigator/configuration.rb', line 267 configuration_attribute :smtp_authentication_method, 'SMTP', 'authentication', Symbol |
#smtp_helo_domain ⇒ String
The the HELO domain for the SMTP server, if any.
Read from the [SMTP]
section, key domain
.
263 |
# File 'lib/ncs_navigator/configuration.rb', line 263 configuration_attribute :smtp_helo_domain, 'SMTP', 'domain', String |
#smtp_host ⇒ String
The hostname of the SMTP server the suite should use to send
mail.
Read from the [SMTP]
section, key host
.
255 |
# File 'lib/ncs_navigator/configuration.rb', line 255 configuration_attribute :smtp_host, 'SMTP', 'host', String, :default => 'localhost' |
#smtp_password ⇒ String
The password to use when authenticating to the SMTP server, if
authentication is required.
Read from the [SMTP]
section, key password
.
277 |
# File 'lib/ncs_navigator/configuration.rb', line 277 configuration_attribute :smtp_password, 'SMTP', 'password', String |
#smtp_port ⇒ Fixnum
The port for the SMTP server the suite should use.
Read from the [SMTP]
section, key port
.
259 |
# File 'lib/ncs_navigator/configuration.rb', line 259 configuration_attribute :smtp_port, 'SMTP', 'port', Fixnum, :default => 25 |
#smtp_starttls ⇒ Boolean
Whether to try to use STARTTLS if the SMTP server supports
it. Defaults to false.
Read from the [SMTP]
section, key starttls
.
282 |
# File 'lib/ncs_navigator/configuration.rb', line 282 configuration_attribute :smtp_starttls, 'SMTP', 'starttls', 'Boolean', :default => false |
#smtp_username ⇒ String
The username to use when authenticating to the SMTP server, if
authentication is required.
Read from the [SMTP]
section, key username
.
272 |
# File 'lib/ncs_navigator/configuration.rb', line 272 configuration_attribute :smtp_username, 'SMTP', 'username', String |
#Staff Portal($2) ⇒ Hash<String, String>
Exposes all the values from the [$1] section. This allows for flexibility in adding new options. The downside is that they are not automatically coerced or documented.
297 |
# File 'lib/ncs_navigator/configuration.rb', line 297 section_accessor 'Staff Portal', :staff_portal |
#staff_portal_mail_from ⇒ String
The address from which mail sent by Staff Portal will appear to come.
Read from the [Staff Portal]
section, key mail_from
.
234 235 |
# File 'lib/ncs_navigator/configuration.rb', line 234 configuration_attribute :staff_portal_mail_from, 'Staff Portal', 'mail_from', String, :default => '[email protected]' |
#staff_portal_uri ⇒ URI
The root URI for the Staff Portal deployment in this instance of
the suite.
Read from the [Staff Portal]
section, key uri
.
230 |
# File 'lib/ncs_navigator/configuration.rb', line 230 configuration_attribute :staff_portal_uri, 'Staff Portal', 'uri', URI, :required => true |
#study_center_id ⇒ String Also known as: sc_id
Read from the [Study Center]
section, key sc_id
.
169 170 |
# File 'lib/ncs_navigator/configuration.rb', line 169 configuration_attribute :study_center_id, 'Study Center', 'sc_id', String, :required => true |
#study_center_short_name ⇒ String
A short, human-readable name or abbreviation for the Study
Center.
Read from the [Study Center]
section, key short_name
.
184 185 |
# File 'lib/ncs_navigator/configuration.rb', line 184 configuration_attribute :study_center_short_name, 'Study Center', 'short_name', String, :default => 'SC' |
#study_center_username ⇒ String
The name for the institutional identity used in this deployment
of NCS Navigator. For instance, for the Greater Chicago Study
Center, it is "Northwestern NetID". The default is "Username".
Read from the [Study Center]
section, key username
.
197 198 |
# File 'lib/ncs_navigator/configuration.rb', line 197 configuration_attribute :study_center_username, 'Study Center', 'username', String, :default => 'Username' |