ncs_navigator_configuration 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.yardopts +5 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +9 -0
- data/README.md +40 -0
- data/Rakefile +7 -0
- data/lib/ncs_navigator/configuration/sampling_units.rb +71 -0
- data/lib/ncs_navigator/configuration/version.rb +5 -0
- data/lib/ncs_navigator/configuration.rb +381 -0
- data/ncs_navigator_configuration.gemspec +30 -0
- data/sample_configuration.ini +111 -0
- data/spec/ncs_navigator/configuration/version_spec.rb +13 -0
- data/spec/ncs_navigator/configuration_spec.rb +477 -0
- data/spec/ncs_navigator/every_su.csv +4 -0
- data/spec/ncs_navigator/everything.ini +32 -0
- data/spec/ncs_navigator/no_tsus.csv +4 -0
- data/spec/spec_helper.rb +10 -0
- metadata +196 -0
data/.gitignore
ADDED
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
NCS Navigator Common Configuration
|
2
|
+
==================================
|
3
|
+
|
4
|
+
This gem provides common configuration services to the various
|
5
|
+
applications that make up NCS Navigator. It's not generally useful
|
6
|
+
outside of that suite.
|
7
|
+
|
8
|
+
Use
|
9
|
+
---
|
10
|
+
|
11
|
+
{NcsNavigator::Configuration} defines the common configuration
|
12
|
+
attributes for applications in the NCS Navigator suite. It also
|
13
|
+
provides helpers (e.g.,
|
14
|
+
{NcsNavigator::Configuration#action_mailer_smtp_settings} for applying
|
15
|
+
the configuration to some utility libraries.
|
16
|
+
|
17
|
+
{NcsNavigator.configuration} provides a global access point for an
|
18
|
+
instance of `NcsNavigator::Configuration`. It can be explicitly set,
|
19
|
+
but more commonly it is initialized from a configuration file named
|
20
|
+
`/etc/nubic/ncs/navigator.ini` (see next section) on first access. If
|
21
|
+
the INI file is changed, you'll need to set
|
22
|
+
`NcsNavigator.configuration` to `nil` to have the changes reflected in
|
23
|
+
the global instance.
|
24
|
+
|
25
|
+
Configuration
|
26
|
+
-------------
|
27
|
+
|
28
|
+
An instance of {NcsNavigator::Configuration} may be initialized from
|
29
|
+
an INI file or by passing a Hash to its constructor. The INI file
|
30
|
+
should match {file:sample_configuration.ini} available alongside this
|
31
|
+
file. The Hash should have two levels, the top level matching the INI
|
32
|
+
file's sections and the second level the keys.
|
33
|
+
|
34
|
+
In addition to the typed configuration properties available on
|
35
|
+
`NcsNavigator::Configuration`, there are also three
|
36
|
+
application-specific accessors: {#staff_portal, #core, and
|
37
|
+
#psc}. These provide untyped direct access to the configuration
|
38
|
+
properties in the respective sections of the INI file, allowing
|
39
|
+
applications to define their own additional configuration properties
|
40
|
+
without modifying this library.
|
data/Rakefile
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'ncs_navigator/configuration'
|
2
|
+
|
3
|
+
class NcsNavigator::Configuration
|
4
|
+
class PrimarySamplingUnit < Struct.new(:id)
|
5
|
+
##
|
6
|
+
# @return [Array<SamplingUnitArea>] the areas in this PSU.
|
7
|
+
def sampling_unit_areas
|
8
|
+
@sampling_unit_areas ||= []
|
9
|
+
end
|
10
|
+
|
11
|
+
##
|
12
|
+
# @return [Array<SecondarySamplingUnit>] the SSUs in this PSU.
|
13
|
+
def secondary_sampling_units
|
14
|
+
sampling_unit_areas.collect(&:secondary_sampling_units).flatten
|
15
|
+
end
|
16
|
+
|
17
|
+
alias :areas :sampling_unit_areas
|
18
|
+
alias :ssus :secondary_sampling_units
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# NCS Navigator defines the concept of an "area" encompassing one or
|
23
|
+
# more SSUs. See {file:sample_configuration.ini} for more information.
|
24
|
+
class SamplingUnitArea < Struct.new(:name, :primary_sampling_unit)
|
25
|
+
def initialize(*)
|
26
|
+
super
|
27
|
+
primary_sampling_unit.sampling_unit_areas << self
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# @return [Array<SecondarySamplingUnit>] the SSUs in this area.
|
32
|
+
def secondary_sampling_units
|
33
|
+
@secondary_sampling_units ||= []
|
34
|
+
end
|
35
|
+
|
36
|
+
alias :psu :primary_sampling_unit
|
37
|
+
alias :ssus :secondary_sampling_units
|
38
|
+
end
|
39
|
+
|
40
|
+
class SecondarySamplingUnit < Struct.new(:id, :name, :sampling_unit_area)
|
41
|
+
def initialize(*)
|
42
|
+
super
|
43
|
+
sampling_unit_area.secondary_sampling_units << self
|
44
|
+
end
|
45
|
+
|
46
|
+
##
|
47
|
+
# @return [PrimarySamplingUnit] the PSU to which this SSU belongs.
|
48
|
+
def primary_sampling_unit
|
49
|
+
area.psu
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# @return [TertiarySamplingUnit] any TSUs defined for this SSU.
|
54
|
+
def tertiary_sampling_units
|
55
|
+
@tertiary_sampling_units ||= []
|
56
|
+
end
|
57
|
+
|
58
|
+
alias :psu :primary_sampling_unit
|
59
|
+
alias :area :sampling_unit_area
|
60
|
+
alias :tsus :tertiary_sampling_units
|
61
|
+
end
|
62
|
+
|
63
|
+
class TertiarySamplingUnit < Struct.new(:id, :name, :secondary_sampling_unit)
|
64
|
+
def initialize(*)
|
65
|
+
super
|
66
|
+
secondary_sampling_unit.tertiary_sampling_units << self
|
67
|
+
end
|
68
|
+
|
69
|
+
alias :ssu :secondary_sampling_unit
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,381 @@
|
|
1
|
+
require 'inifile'
|
2
|
+
require 'pathname'
|
3
|
+
require 'fastercsv'
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
module NcsNavigator
|
7
|
+
# Additions to the root module are defined here instead of in
|
8
|
+
# lib/ncs_navigator.rb to avoid conflicts with other gems. There is
|
9
|
+
# no single gem which defines the NcsNavigator module, so no gem
|
10
|
+
# should respond when `require`ing 'ncs_navigator'.
|
11
|
+
|
12
|
+
##
|
13
|
+
# The location from which the global configuration instance is read
|
14
|
+
# if a global instance is not explicitly set.
|
15
|
+
DEFAULT_CONFIGURATION_PATH = '/etc/nubic/ncs/navigator.ini'
|
16
|
+
|
17
|
+
##
|
18
|
+
# The global configuration instance. Automatically instantiated on
|
19
|
+
# first reference from {.DEFAULT_CONFIGURATION_PATH} if it is not
|
20
|
+
# set explicitly.
|
21
|
+
#
|
22
|
+
# @return [Configuration]
|
23
|
+
def self.configuration
|
24
|
+
@configuration ||= Configuration.new(DEFAULT_CONFIGURATION_PATH)
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# Replaces the global configuration with a provided instance.
|
29
|
+
# Set to `nil` to reload from {.DEFAULT_CONFIGURATION_PATH}.
|
30
|
+
#
|
31
|
+
# @param [Configuration,nil] config the new configuration
|
32
|
+
# @return [void]
|
33
|
+
def self.configuration=(config)
|
34
|
+
@configuration = config
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
# The typed access point for the common configuration in the NCS
|
39
|
+
# Navigator suite.
|
40
|
+
class Configuration
|
41
|
+
autoload :VERSION, 'ncs_navigator/configuration/version'
|
42
|
+
|
43
|
+
autoload :PrimarySamplingUnit, 'ncs_navigator/configuration/sampling_units'
|
44
|
+
autoload :SecondarySamplingUnit, 'ncs_navigator/configuration/sampling_units'
|
45
|
+
autoload :TertiarySamplingUnit, 'ncs_navigator/configuration/sampling_units'
|
46
|
+
autoload :SamplingUnitArea, 'ncs_navigator/configuration/sampling_units'
|
47
|
+
|
48
|
+
######
|
49
|
+
|
50
|
+
APPLICATION_SECTIONS = ['Staff Portal', 'Core', 'PSC']
|
51
|
+
|
52
|
+
class << self
|
53
|
+
##
|
54
|
+
# Defines a mapping from the configuration file to an attribute
|
55
|
+
# on this class.
|
56
|
+
#
|
57
|
+
# @param [Symbol] name the name of the attribute.
|
58
|
+
# @param [String] section the section of the configuration file
|
59
|
+
# from which it is read.
|
60
|
+
# @param [String] key the configuration key within the section
|
61
|
+
# for the attribute.
|
62
|
+
# @param [Class] type the type to which the configuration value
|
63
|
+
# should be coerced.
|
64
|
+
# @param [Hash] options additional options controlling the
|
65
|
+
# behavior of the attribute.
|
66
|
+
# @option options [Boolean] :required (false) is the
|
67
|
+
# configuration property mandatory? If it is, reading the
|
68
|
+
# configuration will fail if it is not provided or is blank.
|
69
|
+
# @option options [Object] :default the default value for the
|
70
|
+
# configuration property.
|
71
|
+
#
|
72
|
+
# @return [void]
|
73
|
+
def configuration_attribute(name, section, key, type, options={})
|
74
|
+
configuration_attributes << ConfigurationAttribute.new(name, section, key, type, options)
|
75
|
+
attr_accessor name
|
76
|
+
end
|
77
|
+
|
78
|
+
##
|
79
|
+
# @private used by instances, but not intended to be public.
|
80
|
+
def configuration_attributes
|
81
|
+
@configuration_attributes ||= []
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# @private implementation detail
|
86
|
+
class ConfigurationAttribute < Struct.new(:name, :section, :key, :type, :options)
|
87
|
+
def extract_and_set(config, hash)
|
88
|
+
v = raw_value_from(hash)
|
89
|
+
v = coerce(v, config)
|
90
|
+
if v.nil? && options[:required]
|
91
|
+
fail "Please set a value for [#{section}]: #{key}"
|
92
|
+
end
|
93
|
+
config.send(:"#{name}=", v)
|
94
|
+
end
|
95
|
+
|
96
|
+
def raw_value_from(hash)
|
97
|
+
if hash[section]
|
98
|
+
hash[section][key]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def coerce(raw_value, config)
|
103
|
+
return options[:default] if raw_value.nil?
|
104
|
+
case
|
105
|
+
when type == String
|
106
|
+
raw_value.to_s
|
107
|
+
when type == Symbol
|
108
|
+
raw_value.to_sym
|
109
|
+
when type == Fixnum
|
110
|
+
raw_value.to_i
|
111
|
+
when type == Pathname
|
112
|
+
coerce_to_pathname(raw_value, config)
|
113
|
+
when type == URI
|
114
|
+
URI.parse(raw_value.to_s)
|
115
|
+
when type == 'Boolean'
|
116
|
+
raw_value.to_s.downcase.strip == 'true' ? true : false
|
117
|
+
else
|
118
|
+
fail "Do not know how to coerce to #{type} for #{name} from [#{section}]: #{key}"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def coerce_to_pathname(raw_value, config)
|
123
|
+
base = Pathname.new(raw_value.to_s)
|
124
|
+
if base.absolute? || !config.ini_filename
|
125
|
+
base
|
126
|
+
else
|
127
|
+
config.ini_filename.dirname + base
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
##
|
134
|
+
# The file from which this configuration was initialized, if any.
|
135
|
+
#
|
136
|
+
# @return [Pathname]
|
137
|
+
attr_reader :ini_filename
|
138
|
+
|
139
|
+
# TODO: it would be nice if the macro below generated method doc
|
140
|
+
# for both the reader and the writer.
|
141
|
+
|
142
|
+
##
|
143
|
+
# The SC_ID for the study center using this deployment of NCS
|
144
|
+
# Navigator. This value must match an ID in the MDES.
|
145
|
+
#
|
146
|
+
# @macro [attach] configuration_attribute
|
147
|
+
# Read from the `[$2]` section, key `$3`.
|
148
|
+
# @return [$4]
|
149
|
+
configuration_attribute :study_center_id, 'Study Center', 'sc_id', String,
|
150
|
+
:required => true
|
151
|
+
|
152
|
+
alias :sc_id :study_center_id
|
153
|
+
|
154
|
+
##
|
155
|
+
# The name for the institutional identity used in this deployment
|
156
|
+
# of NCS Navigator. For instance, for the Greater Chicago Study
|
157
|
+
# Center, it is "Northwestern NetID". The default is "Username".
|
158
|
+
configuration_attribute :study_center_username, 'Study Center', 'username', String,
|
159
|
+
:default => 'Username'
|
160
|
+
|
161
|
+
##
|
162
|
+
# The CSV describing the PSU, "sampling areas", SSUs, and (if
|
163
|
+
# applicable) TSUs for this center.
|
164
|
+
#
|
165
|
+
# The format is described in the comments in the
|
166
|
+
# {file:sample_configuration.ini sample INI}.
|
167
|
+
configuration_attribute :sampling_units_file, 'Study Center', 'sampling_units_file', Pathname,
|
168
|
+
:required => true
|
169
|
+
|
170
|
+
##
|
171
|
+
# The image that should appear on the left side of the footer in
|
172
|
+
# Staff Portal and Core. This should be a path to a file on the
|
173
|
+
# deployed server.
|
174
|
+
configuration_attribute :footer_logo_left, 'Study Center', 'footer_logo_left', Pathname
|
175
|
+
|
176
|
+
##
|
177
|
+
# The image that should appear on the right side of the footer in
|
178
|
+
# Staff Portal and Core. This should be a path to a file on the
|
179
|
+
# deployed server.
|
180
|
+
configuration_attribute :footer_logo_right, 'Study Center', 'footer_logo_right', Pathname
|
181
|
+
|
182
|
+
##
|
183
|
+
# The text that should appear in the center of the footer in Staff
|
184
|
+
# Portal and Core. This is usually the center's contact
|
185
|
+
# information.
|
186
|
+
configuration_attribute :footer_text, 'Study Center', 'footer_text', String
|
187
|
+
|
188
|
+
##
|
189
|
+
# The root URI for the Staff Portal deployment in this instance of
|
190
|
+
# the suite.
|
191
|
+
configuration_attribute :staff_portal_uri, 'Staff Portal', 'uri', URI, :required => true
|
192
|
+
|
193
|
+
##
|
194
|
+
# The root URI for the NCS Navigator Core deployment in this instance of
|
195
|
+
# the suite.
|
196
|
+
configuration_attribute :core_uri, 'Core', 'uri', URI, :required => true
|
197
|
+
|
198
|
+
##
|
199
|
+
# The root URI for the PSC deployment in this instance of
|
200
|
+
# the suite.
|
201
|
+
configuration_attribute :psc_uri, 'PSC', 'uri', URI, :required => true
|
202
|
+
|
203
|
+
##
|
204
|
+
# The hostname of the SMTP server the suite should use to send
|
205
|
+
# mail.
|
206
|
+
configuration_attribute :smtp_host, 'SMTP', 'host', String, :default => 'localhost'
|
207
|
+
|
208
|
+
##
|
209
|
+
# The port for the SMTP server the suite should use.
|
210
|
+
configuration_attribute :smtp_port, 'SMTP', 'port', Fixnum, :default => 25
|
211
|
+
|
212
|
+
##
|
213
|
+
# The the HELO domain for the SMTP server, if any.
|
214
|
+
configuration_attribute :smtp_helo_domain, 'SMTP', 'domain', String
|
215
|
+
|
216
|
+
##
|
217
|
+
# The type of authentication needed for the SMTP server, if any.
|
218
|
+
configuration_attribute :smtp_authentication_method, 'SMTP', 'authentication', Symbol
|
219
|
+
|
220
|
+
##
|
221
|
+
# The username to use when authenticating to the SMTP server, if
|
222
|
+
# authentication is required.
|
223
|
+
configuration_attribute :smtp_username, 'SMTP', 'username', String
|
224
|
+
|
225
|
+
##
|
226
|
+
# The password to use when authenticating to the SMTP server, if
|
227
|
+
# authentication is required.
|
228
|
+
configuration_attribute :smtp_password, 'SMTP', 'password', String
|
229
|
+
|
230
|
+
##
|
231
|
+
# Whether to try to use STARTTLS if the SMTP server supports
|
232
|
+
# it. Defaults to false.
|
233
|
+
configuration_attribute :smtp_starttls, 'SMTP', 'starttls', 'Boolean', :default => false
|
234
|
+
|
235
|
+
##
|
236
|
+
# Creates a new Configuration.
|
237
|
+
#
|
238
|
+
# @param [String, Hash] source the basis for this
|
239
|
+
# configuration. If it's a `String`, it's interpreted as a the
|
240
|
+
# filename for an INI file ({file:sample_configuration.ini
|
241
|
+
# sample}). If it's a `Hash`, it should have two levels. The
|
242
|
+
# first level represents the sections and the second level the
|
243
|
+
# keys and values.
|
244
|
+
def initialize(source)
|
245
|
+
case source
|
246
|
+
when String
|
247
|
+
init_from_ini(source)
|
248
|
+
else
|
249
|
+
init_from_hash(source)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def init_from_ini(filename)
|
254
|
+
if File.readable?(filename)
|
255
|
+
@ini_filename = Pathname.new(filename)
|
256
|
+
init_from_hash(IniFile.new(filename).to_h)
|
257
|
+
else
|
258
|
+
raise Error.new("NCS Navigator configuration file #{filename.inspect} does not exist or is not readable.")
|
259
|
+
end
|
260
|
+
end
|
261
|
+
private :init_from_ini
|
262
|
+
|
263
|
+
def init_from_hash(h)
|
264
|
+
h = stringify_keys(h)
|
265
|
+
self.class.configuration_attributes.each do |attr|
|
266
|
+
attr.extract_and_set(self, h)
|
267
|
+
end
|
268
|
+
@application_sections = APPLICATION_SECTIONS.inject({}) do |s, section|
|
269
|
+
s[section] = h[section].dup if h[section]
|
270
|
+
s
|
271
|
+
end
|
272
|
+
end
|
273
|
+
private :init_from_hash
|
274
|
+
|
275
|
+
def stringify_keys(h)
|
276
|
+
h.dup.tap do |z|
|
277
|
+
z.keys.each do |k|
|
278
|
+
v = z.delete(k)
|
279
|
+
z[k.to_s] =
|
280
|
+
case v
|
281
|
+
when Hash
|
282
|
+
stringify_keys(v)
|
283
|
+
else
|
284
|
+
v
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
private :stringify_keys
|
290
|
+
|
291
|
+
##
|
292
|
+
# @return [Array<SamplingUnitArea>] the areas defined in {#sampling_units_file}.
|
293
|
+
def sampling_unit_areas
|
294
|
+
@sampling_unit_areas ||= read_sampling_unit_areas
|
295
|
+
end
|
296
|
+
alias :areas :sampling_unit_areas
|
297
|
+
|
298
|
+
def read_sampling_unit_areas
|
299
|
+
psus = {}
|
300
|
+
areas = {}
|
301
|
+
ssus = {}
|
302
|
+
|
303
|
+
unless sampling_units_file.readable?
|
304
|
+
raise Error.new("Could not read sampling units CSV #{sampling_units_file}")
|
305
|
+
end
|
306
|
+
|
307
|
+
FasterCSV.foreach(sampling_units_file, :headers => true) do |row|
|
308
|
+
psu = (psus[row['PSU_ID']] ||= PrimarySamplingUnit.new(row['PSU_ID']))
|
309
|
+
area = (areas[row['AREA']] ||= SamplingUnitArea.new(row['AREA'], psu))
|
310
|
+
ssu = (ssus[row['SSU_ID']] ||= SecondarySamplingUnit.new(row['SSU_ID'], row['SSU_NAME'], area))
|
311
|
+
if row['TSU_ID']
|
312
|
+
TertiarySamplingUnit.new(row['TSU_ID'], row['TSU_NAME'], ssu)
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
areas.values
|
317
|
+
end
|
318
|
+
private :read_sampling_unit_areas
|
319
|
+
|
320
|
+
##
|
321
|
+
# @return [Array<PrimarySamplingUnit>] the PSUs defined in {#sampling_units_file}.
|
322
|
+
def primary_sampling_units
|
323
|
+
@primary_sampling_units ||= sampling_unit_areas.collect(&:primary_sampling_unit).uniq
|
324
|
+
end
|
325
|
+
alias :psus :primary_sampling_units
|
326
|
+
|
327
|
+
##
|
328
|
+
# @return [Array<SecondarySamplingUnit>] the SSUs defined in {#sampling_units_file}.
|
329
|
+
def secondary_sampling_units
|
330
|
+
@secondary_sampling_units ||= sampling_unit_areas.collect(&:secondary_sampling_units).flatten
|
331
|
+
end
|
332
|
+
alias :ssus :secondary_sampling_units
|
333
|
+
|
334
|
+
##
|
335
|
+
# Converts {#footer_text} into equivalent HTML.
|
336
|
+
#
|
337
|
+
# @return [String]
|
338
|
+
def footer_center_html
|
339
|
+
return nil unless footer_text
|
340
|
+
html = footer_text.split("\n").join("<br>\n")
|
341
|
+
if html.respond_to?(:html_safe)
|
342
|
+
html.html_safe
|
343
|
+
else
|
344
|
+
html
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
APPLICATION_SECTIONS.each do |section|
|
349
|
+
##
|
350
|
+
# Exposes all the values from the [#{section}] section. This
|
351
|
+
# allows for flexibility in adding new options, with the downside
|
352
|
+
# that they are not automatically coerced or documented.
|
353
|
+
#
|
354
|
+
# @return [Hash<String, String>]
|
355
|
+
define_method section.downcase.gsub(' ', '_').to_sym do
|
356
|
+
@application_sections[section] ||= {}
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
##
|
361
|
+
# Provides a configuration hash suitable for passing to
|
362
|
+
# `ActionMailer::Base.smtp_settings`.
|
363
|
+
#
|
364
|
+
# @return [Hash<Symbol, Object>]
|
365
|
+
def action_mailer_smtp_settings
|
366
|
+
Hash[
|
367
|
+
{
|
368
|
+
:address => smtp_host,
|
369
|
+
:port => smtp_port,
|
370
|
+
:domain => smtp_helo_domain,
|
371
|
+
:user_name => smtp_username,
|
372
|
+
:password => smtp_password,
|
373
|
+
:authentication => smtp_authentication_method,
|
374
|
+
:enable_starttls_auto => smtp_starttls
|
375
|
+
}.select { |k, v| v }
|
376
|
+
]
|
377
|
+
end
|
378
|
+
|
379
|
+
class Error < StandardError; end
|
380
|
+
end
|
381
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "ncs_navigator/configuration/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "ncs_navigator_configuration"
|
7
|
+
s.version = NcsNavigator::Configuration::VERSION
|
8
|
+
s.authors = ["Rhett Sutphin"]
|
9
|
+
s.email = ["r-sutphin@northwestern.edu"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Common configuration elements for the NCS Navigator suite}
|
12
|
+
s.description = %q{
|
13
|
+
An internal component of the NCS Navigator suite, this gem provides a common view
|
14
|
+
onto shared configuration elements.
|
15
|
+
}
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency 'ncs_mdes', '~> 0.4'
|
23
|
+
s.add_dependency 'inifile', '~> 0.4.1'
|
24
|
+
s.add_dependency 'fastercsv', '~> 1.5'
|
25
|
+
|
26
|
+
s.add_development_dependency 'rake', '~> 0.9.2'
|
27
|
+
s.add_development_dependency 'rspec', '~> 2.6'
|
28
|
+
s.add_development_dependency 'yard', '~> 0.7.2'
|
29
|
+
s.add_development_dependency 'fakefs', '~> 0.3'
|
30
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# @markup ruby
|
2
|
+
# @title sample_configuration.ini
|
3
|
+
|
4
|
+
# Sample common configuration for NCS Navigator. By default the suite
|
5
|
+
# applications will expect to find a customized version of this file
|
6
|
+
# in /etc/nubic/ncs/navigator.ini.
|
7
|
+
|
8
|
+
[Study Center]
|
9
|
+
# Information about the study center which is using this deployment of
|
10
|
+
# NCS Navigator. Each NCS Navigator instance is only for one study
|
11
|
+
# center.
|
12
|
+
|
13
|
+
# The ID for the study center from the MDES
|
14
|
+
sc_id = "20000000"
|
15
|
+
|
16
|
+
# A pointer to a CSV describing the sampling units for this study
|
17
|
+
# center. If the path is not absolute it will be resolved relative to
|
18
|
+
# this file.
|
19
|
+
#
|
20
|
+
# The CSV must have the following header (along with the contents it
|
21
|
+
# implies):
|
22
|
+
#
|
23
|
+
# PSU_ID, AREA, SSU_ID, SSU_NAME, TSU_ID, TSU_NAME
|
24
|
+
#
|
25
|
+
# While this format allows for multiple PSUs, NCS Navigator currently
|
26
|
+
# only supports one per deployment. This will change in the future
|
27
|
+
# when multiple PSUs are active per center.
|
28
|
+
#
|
29
|
+
# TSU_ID and TSU_NAME may be omitted for centers that are not on
|
30
|
+
# Hi-Lo.
|
31
|
+
#
|
32
|
+
# AREA is an intermediate concept introduced by NCS Navigator. It
|
33
|
+
# allows the grouping of one or more SSUs for ease of reporting
|
34
|
+
# something (e.g., outreach events) across all of them. If a center
|
35
|
+
# doesn't wish to make use of this concept, the AREA should be made
|
36
|
+
# the same as the SSU_NAME.
|
37
|
+
sampling_units_file = "sample_ssus.csv"
|
38
|
+
|
39
|
+
# The name of the institutional user identity used in NCS
|
40
|
+
# Navigator. E.g., for the Greater Chicago Study Center, this is the
|
41
|
+
# Northwestern NetID. The default is "Username" if nothing is
|
42
|
+
# specifed.
|
43
|
+
#username = "NetID"
|
44
|
+
|
45
|
+
# The absolute path to local files containing logos that should appear
|
46
|
+
# on either end of the footer in Staff Portal and Core.
|
47
|
+
#footer_logo_left = "/etc/nubic/ncs/logos/sc_20000000L.png"
|
48
|
+
#footer_logo_right = "/etc/nubic/ncs/logos/sc_20000000R.png"
|
49
|
+
|
50
|
+
# The text that should appear in the center of the footer in Staff
|
51
|
+
# Portal and Core. Line breaks in this text will be preserved.
|
52
|
+
footer_text = "National Children’s Study - Greater Chicago Study Center
|
53
|
+
Institute for Healthcare Studies, Feinberg School of Medicine
|
54
|
+
Northwestern University
|
55
|
+
420 East Superior, 10th Floor
|
56
|
+
Chicago, IL 60611"
|
57
|
+
|
58
|
+
[Staff Portal]
|
59
|
+
# Configuration options which are used by or which describe Staff
|
60
|
+
# Portal in this instance of the suite.
|
61
|
+
|
62
|
+
# The root URI for Staff Portal.
|
63
|
+
uri = "https://staffportal.greaterchicagoncs.org/"
|
64
|
+
|
65
|
+
# The e-mail address from which mail sent by Staff Pportal will
|
66
|
+
# appear to come.
|
67
|
+
mail_from = "staffportal@greaterchicagoncs.org"
|
68
|
+
|
69
|
+
[Core]
|
70
|
+
# Configuration options which are used by or which describe NCS
|
71
|
+
# Navigator Core in this instance of the suite.
|
72
|
+
|
73
|
+
# The root URI for NCS Navigator Core.
|
74
|
+
uri = "https://ncsnavigator.greaterchicagoncs.org/"
|
75
|
+
|
76
|
+
[PSC]
|
77
|
+
# Configuration options which describe PSC as used by this instance of
|
78
|
+
# the suite. (For now, PSC's own configuration options must be set
|
79
|
+
# through its configuration interfaces.)
|
80
|
+
|
81
|
+
# The root URI for PSC.
|
82
|
+
uri = "https://calendar.greaterchicagoncs.org/"
|
83
|
+
|
84
|
+
[SMTP]
|
85
|
+
# Configuration for the SMTP server for MDES Warehouse, Staff Portal,
|
86
|
+
# and NCS Navigator Core.
|
87
|
+
|
88
|
+
# The hostname or IP of the SMTP server to use to send mail from the
|
89
|
+
# suite. Default is localhost.
|
90
|
+
#host = "localhost"
|
91
|
+
|
92
|
+
# The port to use to communicate with the SMTP server. Default is 25.
|
93
|
+
#port = "25"
|
94
|
+
|
95
|
+
# The domain to use in SMTP HELO, if necessary. Default is none.
|
96
|
+
#domain =
|
97
|
+
|
98
|
+
# The type of authentication your SMTP server uses. Default is
|
99
|
+
# none. Legal values are "plain", "login", or "cram_md5".
|
100
|
+
#authentication =
|
101
|
+
|
102
|
+
# The username to use to authenticate to the SMTP server, if
|
103
|
+
# necessary. Default is none.
|
104
|
+
#username =
|
105
|
+
|
106
|
+
# The password to use to authenticate to the SMTP server, if
|
107
|
+
# necessary. Default is none.
|
108
|
+
#password =
|
109
|
+
|
110
|
+
# Whether to use STARTTLS if your SMTP server supports it. Default is false.
|
111
|
+
#starttls = false
|