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.4.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_conflict_email_recipients ⇒ Array
When a merge conflict occurs in Cases, send emails to these addresses.
-
#core_machine_account_password ⇒ String
Read from the
[Core]
section, keymachine_account_password
. -
#core_machine_account_username ⇒ String
Machine account for Cases.
-
#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.
320 321 322 323 324 325 326 327 |
# File 'lib/ncs_navigator/configuration.rb', line 320 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
.
439 440 441 442 443 444 445 446 447 448 449 450 451 |
# File 'lib/ncs_navigator/configuration.rb', line 439 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
308 |
# File 'lib/ncs_navigator/configuration.rb', line 308 section_accessor 'Core', :core |
#core_conflict_email_recipients ⇒ Array
When a merge conflict occurs in Cases, send emails to these addresses.
Read from the [Core]
section, key conflict_email_recipients
.
254 255 |
# File 'lib/ncs_navigator/configuration.rb', line 254 configuration_attribute :core_conflict_email_recipients, 'Core', 'conflict_email_recipients', Array, :default => [] |
#core_machine_account_password ⇒ String
Read from the [Core]
section, key machine_account_password
.
244 245 |
# File 'lib/ncs_navigator/configuration.rb', line 244 configuration_attribute :core_machine_account_password, 'Core', 'machine_account_password', String |
#core_machine_account_username ⇒ String
Machine account for Cases.
Read from the [Core]
section, key machine_account_username
.
241 242 |
# File 'lib/ncs_navigator/configuration.rb', line 241 configuration_attribute :core_machine_account_username, 'Core', 'machine_account_username', String |
#core_mail_from ⇒ String
The address from which mail sent by Core will appear to come.
Read from the [Core]
section, key mail_from
.
249 250 |
# File 'lib/ncs_navigator/configuration.rb', line 249 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
.
237 |
# File 'lib/ncs_navigator/configuration.rb', line 237 configuration_attribute :core_uri, 'Core', 'uri', URI |
#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
.
188 189 |
# File 'lib/ncs_navigator/configuration.rb', line 188 configuration_attribute :exception_email_recipients, 'Study Center', 'exception_email_recipients', Array, :default => [] |
#footer_center_html ⇒ String
Converts #footer_text into equivalent HTML.
424 425 426 427 428 429 430 431 432 |
# File 'lib/ncs_navigator/configuration.rb', line 424 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
.
210 |
# File 'lib/ncs_navigator/configuration.rb', line 210 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
.
216 |
# File 'lib/ncs_navigator/configuration.rb', line 216 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
.
222 |
# File 'lib/ncs_navigator/configuration.rb', line 222 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.
408 409 410 |
# File 'lib/ncs_navigator/configuration.rb', line 408 def primary_sampling_units @primary_sampling_units ||= read_primary_sampling_units end |
#PSC ⇒ Object
309 |
# File 'lib/ncs_navigator/configuration.rb', line 309 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
.
260 |
# File 'lib/ncs_navigator/configuration.rb', line 260 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
.
177 |
# File 'lib/ncs_navigator/configuration.rb', line 177 configuration_attribute :recruitment_type_id, 'Study Center', 'recruitment_type_id', String |
#sampling_unit_areas ⇒ Array<SamplingUnitArea> Also known as: areas
Returns the areas defined in #sampling_units_file.
369 370 371 |
# File 'lib/ncs_navigator/configuration.rb', line 369 def sampling_unit_areas @sampling_unit_areas ||= primary_sampling_units.collect(&:sampling_unit_areas).flatten 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
.
204 |
# File 'lib/ncs_navigator/configuration.rb', line 204 configuration_attribute :sampling_units_file, 'Study Center', 'sampling_units_file', Pathname |
#secondary_sampling_units ⇒ Array<SecondarySamplingUnit> Also known as: ssus
Returns the SSUs defined in #sampling_units_file.
415 416 417 |
# File 'lib/ncs_navigator/configuration.rb', line 415 def secondary_sampling_units @secondary_sampling_units ||= primary_sampling_units.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
.
277 |
# File 'lib/ncs_navigator/configuration.rb', line 277 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
.
273 |
# File 'lib/ncs_navigator/configuration.rb', line 273 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
.
265 |
# File 'lib/ncs_navigator/configuration.rb', line 265 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
.
287 |
# File 'lib/ncs_navigator/configuration.rb', line 287 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
.
269 |
# File 'lib/ncs_navigator/configuration.rb', line 269 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
.
292 |
# File 'lib/ncs_navigator/configuration.rb', line 292 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
.
282 |
# File 'lib/ncs_navigator/configuration.rb', line 282 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.
307 |
# File 'lib/ncs_navigator/configuration.rb', line 307 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
.
231 232 |
# File 'lib/ncs_navigator/configuration.rb', line 231 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
.
227 |
# File 'lib/ncs_navigator/configuration.rb', line 227 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 |
# File 'lib/ncs_navigator/configuration.rb', line 169 configuration_attribute :study_center_id, 'Study Center', 'sc_id', String |
#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
.
182 183 |
# File 'lib/ncs_navigator/configuration.rb', line 182 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
.
195 196 |
# File 'lib/ncs_navigator/configuration.rb', line 195 configuration_attribute :study_center_username, 'Study Center', 'username', String, :default => 'Username' |