ncs_navigator_configuration 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
NCS Navigator Configuration gem history
|
2
2
|
=======================================
|
3
3
|
|
4
|
+
0.4.0
|
5
|
+
-----
|
6
|
+
|
7
|
+
- New optional Core attribute: conflict_email_recipients. (#12)
|
8
|
+
|
9
|
+
- New optional Core attribute: machine_account_username. (#14)
|
10
|
+
|
11
|
+
- Make sc_id optional. (#16)
|
12
|
+
|
13
|
+
- Make sampling_units_file optional. (#17)
|
14
|
+
|
15
|
+
- Make recruitment_type_id optional. (#18)
|
16
|
+
|
17
|
+
- Make core uri optional. (#19)
|
18
|
+
|
4
19
|
0.3.2
|
5
20
|
-----
|
6
21
|
|
@@ -166,8 +166,7 @@ module NcsNavigator
|
|
166
166
|
# @macro [attach] configuration_attribute
|
167
167
|
# Read from the `[$2]` section, key `$3`.
|
168
168
|
# @return [$4]
|
169
|
-
configuration_attribute :study_center_id, 'Study Center', 'sc_id', String
|
170
|
-
:required => true
|
169
|
+
configuration_attribute :study_center_id, 'Study Center', 'sc_id', String
|
171
170
|
|
172
171
|
alias :sc_id :study_center_id
|
173
172
|
|
@@ -175,8 +174,7 @@ module NcsNavigator
|
|
175
174
|
# The recruitment strategy for this study center. The acceptable
|
176
175
|
# values are those from the code list `recruit_type_cl1` in the
|
177
176
|
# MDES.
|
178
|
-
configuration_attribute :recruitment_type_id, 'Study Center', 'recruitment_type_id', String
|
179
|
-
:required => true
|
177
|
+
configuration_attribute :recruitment_type_id, 'Study Center', 'recruitment_type_id', String
|
180
178
|
|
181
179
|
##
|
182
180
|
# A short, human-readable name or abbreviation for the Study
|
@@ -203,8 +201,7 @@ module NcsNavigator
|
|
203
201
|
#
|
204
202
|
# The format is described in the comments in the
|
205
203
|
# {file:sample_configuration.ini sample INI}.
|
206
|
-
configuration_attribute :sampling_units_file, 'Study Center', 'sampling_units_file', Pathname
|
207
|
-
:required => true
|
204
|
+
configuration_attribute :sampling_units_file, 'Study Center', 'sampling_units_file', Pathname
|
208
205
|
|
209
206
|
##
|
210
207
|
# The image that should appear on the left side of the footer in
|
@@ -237,10 +234,13 @@ module NcsNavigator
|
|
237
234
|
##
|
238
235
|
# The root URI for the NCS Navigator Core deployment in this instance of
|
239
236
|
# the suite.
|
240
|
-
configuration_attribute :core_uri, 'Core', 'uri', URI
|
237
|
+
configuration_attribute :core_uri, 'Core', 'uri', URI
|
241
238
|
|
242
239
|
##
|
243
240
|
# Machine account for Cases.
|
241
|
+
configuration_attribute :core_machine_account_username, 'Core',
|
242
|
+
'machine_account_username', String
|
243
|
+
|
244
244
|
configuration_attribute :core_machine_account_password, 'Core',
|
245
245
|
'machine_account_password', String
|
246
246
|
|
@@ -249,6 +249,11 @@ module NcsNavigator
|
|
249
249
|
configuration_attribute :core_mail_from, 'Core', 'mail_from', String,
|
250
250
|
:default => 'cases@navigator.example.edu'
|
251
251
|
|
252
|
+
##
|
253
|
+
# When a merge conflict occurs in Cases, send emails to these addresses.
|
254
|
+
configuration_attribute :core_conflict_email_recipients, 'Core',
|
255
|
+
'conflict_email_recipients', Array, :default => []
|
256
|
+
|
252
257
|
##
|
253
258
|
# The root URI for the PSC deployment in this instance of
|
254
259
|
# the suite.
|
@@ -371,12 +376,13 @@ module NcsNavigator
|
|
371
376
|
areas = {}
|
372
377
|
ssus = {}
|
373
378
|
|
374
|
-
|
379
|
+
if sampling_units_file && !sampling_units_file.readable?
|
375
380
|
raise Error.new("Could not read sampling units CSV #{sampling_units_file}")
|
376
381
|
end
|
377
382
|
|
378
383
|
strip_ws = lambda { |h| h.nil? ? nil : h.strip }
|
379
384
|
|
385
|
+
return [] unless sampling_units_file
|
380
386
|
faster_csv_class.foreach(sampling_units_file,
|
381
387
|
:headers => true, :encoding => 'utf-8',
|
382
388
|
:converters => [strip_ws], :header_converters => [strip_ws]
|
data/sample_configuration.ini
CHANGED
@@ -91,6 +91,13 @@ uri = "https://ncsnavigator.greaterchicagoncs.org/"
|
|
91
91
|
# appear to come.
|
92
92
|
mail_from = "ncs-navigator@greaterchicagoncs.org"
|
93
93
|
|
94
|
+
# The password used by Cases to log into other NCS-related applications.
|
95
|
+
machine_account_password = "supersecret"
|
96
|
+
|
97
|
+
# If a merge conflict is detected in Cases, emails will be sent to these
|
98
|
+
# addresses. Separate multiple addresses with commas.
|
99
|
+
conflict_email_recipients = "Foo Example <foo@example.org>"
|
100
|
+
|
94
101
|
[PSC]
|
95
102
|
# Configuration options which describe PSC as used by this instance of
|
96
103
|
# the suite. (For now, PSC's own configuration options must be set
|
@@ -54,6 +54,7 @@ module NcsNavigator
|
|
54
54
|
let(:everything_file) { File.expand_path('../everything.ini', __FILE__) }
|
55
55
|
|
56
56
|
# input_hash should be kept minimally valid
|
57
|
+
# ToDo: update minimally valid input_hash with required fields only.
|
57
58
|
let(:input_hash) {
|
58
59
|
{
|
59
60
|
'Study Center' => {
|
@@ -64,15 +65,24 @@ module NcsNavigator
|
|
64
65
|
'Staff Portal' => {
|
65
66
|
'uri' => 'https://sp.example.edu/'
|
66
67
|
},
|
67
|
-
'Core' => {
|
68
|
-
'uri' => 'https://ncsn.example.edu/',
|
69
|
-
},
|
70
68
|
'PSC' => {
|
71
69
|
'uri' => 'https://psc.example.edu/'
|
72
70
|
}
|
73
71
|
}
|
74
72
|
}
|
75
73
|
let(:from_hash) { Configuration.new(input_hash) }
|
74
|
+
let(:minimum_valid_hash) {
|
75
|
+
{
|
76
|
+
'Staff Portal' => {
|
77
|
+
'uri' => 'https://sp.example.edu/'
|
78
|
+
},
|
79
|
+
'PSC' => {
|
80
|
+
'uri' => 'https://psc.example.edu/'
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
let(:from_minimum_valid_hash) { Configuration.new(minimum_valid_hash) }
|
85
|
+
|
76
86
|
|
77
87
|
describe '#initialize' do
|
78
88
|
describe 'from an INI file' do
|
@@ -107,16 +117,15 @@ module NcsNavigator
|
|
107
117
|
from_hash.study_center_id.should == '234'
|
108
118
|
end
|
109
119
|
|
110
|
-
it 'is mandatory' do
|
111
|
-
|
112
|
-
|
113
|
-
should raise_error("Please set a value for [Study Center]: sc_id")
|
120
|
+
it 'is not mandatory' do
|
121
|
+
lambda { from_minimum_valid_hash }.
|
122
|
+
should_not raise_error
|
114
123
|
end
|
115
124
|
end
|
116
125
|
|
117
126
|
describe '#recruitment_type_id' do
|
118
127
|
it 'reflects the configured value' do
|
119
|
-
|
128
|
+
everything.recruitment_type_id.should == '1'
|
120
129
|
end
|
121
130
|
|
122
131
|
it 'is always a string' do
|
@@ -124,10 +133,9 @@ module NcsNavigator
|
|
124
133
|
from_hash.recruitment_type_id.should == '234'
|
125
134
|
end
|
126
135
|
|
127
|
-
it 'is mandatory' do
|
128
|
-
|
129
|
-
|
130
|
-
should raise_error("Please set a value for [Study Center]: recruitment_type_id")
|
136
|
+
it 'is not mandatory' do
|
137
|
+
lambda { from_minimum_valid_hash }.
|
138
|
+
should_not raise_error
|
131
139
|
end
|
132
140
|
end
|
133
141
|
|
@@ -179,63 +187,53 @@ module NcsNavigator
|
|
179
187
|
everything.sampling_units_file.should be_a(Pathname)
|
180
188
|
end
|
181
189
|
|
182
|
-
it 'is required' do
|
183
|
-
|
184
|
-
|
185
|
-
should raise_error "Please set a value for [Study Center]: sampling_units_file"
|
190
|
+
it 'is not required' do
|
191
|
+
lambda { from_minimum_valid_hash }.
|
192
|
+
should_not raise_error
|
186
193
|
end
|
187
194
|
end
|
188
195
|
|
189
196
|
describe '#sampling_unit_areas' do
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
197
|
+
describe 'when no sampling_unit_file' do
|
198
|
+
it 'is an empty array' do
|
199
|
+
from_minimum_valid_hash.sampling_unit_areas.should be_empty
|
200
|
+
end
|
194
201
|
end
|
195
202
|
|
196
|
-
describe '
|
197
|
-
|
203
|
+
describe 'when sampling_units_file is present' do
|
204
|
+
subject { everything.sampling_unit_areas }
|
198
205
|
|
199
|
-
it 'has
|
200
|
-
|
206
|
+
it 'has the right number' do
|
207
|
+
subject.size.should == 2
|
201
208
|
end
|
202
209
|
|
203
|
-
|
204
|
-
area.
|
205
|
-
|
210
|
+
describe 'an individual area' do
|
211
|
+
let(:area) { subject.sort_by { |a| a.name }.last }
|
212
|
+
|
213
|
+
it 'has a name' do
|
214
|
+
area.name.should == 'Uptown'
|
215
|
+
end
|
206
216
|
|
207
|
-
|
208
|
-
|
217
|
+
it 'has the right number of SSUs' do
|
218
|
+
area.secondary_sampling_units.size.should == 2
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'has the right PSU' do
|
222
|
+
area.primary_sampling_unit.id.should == '204'
|
223
|
+
end
|
209
224
|
end
|
210
225
|
end
|
211
226
|
end
|
212
227
|
|
213
228
|
describe '#primary_sampling_units' do
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
subject.size.should == 1
|
218
|
-
end
|
219
|
-
|
220
|
-
describe 'an individual PSU' do
|
221
|
-
let(:psu) { subject.first }
|
222
|
-
|
223
|
-
it 'has the correct ID' do
|
224
|
-
psu.id.should == '204'
|
225
|
-
end
|
226
|
-
|
227
|
-
it 'has the correct SSUs' do
|
228
|
-
psu.secondary_sampling_units.collect(&:id).should == %w(One Two Three)
|
229
|
+
describe 'when no sampling_unit_file' do
|
230
|
+
it 'is an empty array' do
|
231
|
+
from_minimum_valid_hash.primary_sampling_units.should be_empty
|
229
232
|
end
|
230
233
|
end
|
231
234
|
|
232
|
-
|
233
|
-
|
234
|
-
input_hash['Study Center']['sampling_units_file'] =
|
235
|
-
File.expand_path('../no_ssus.csv', __FILE__)
|
236
|
-
end
|
237
|
-
|
238
|
-
subject { from_hash.primary_sampling_units }
|
235
|
+
describe 'when sampling_units_file is present' do
|
236
|
+
subject { everything.primary_sampling_units }
|
239
237
|
|
240
238
|
it 'has the right number' do
|
241
239
|
subject.size.should == 1
|
@@ -248,102 +246,135 @@ module NcsNavigator
|
|
248
246
|
psu.id.should == '204'
|
249
247
|
end
|
250
248
|
|
251
|
-
it 'has
|
252
|
-
psu.should
|
249
|
+
it 'has the correct SSUs' do
|
250
|
+
psu.secondary_sampling_units.collect(&:id).should == %w(One Two Three)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
context 'without Areas and SSUs' do
|
255
|
+
before do
|
256
|
+
input_hash['Study Center']['sampling_units_file'] =
|
257
|
+
File.expand_path('../no_ssus.csv', __FILE__)
|
258
|
+
end
|
259
|
+
|
260
|
+
subject { from_hash.primary_sampling_units }
|
261
|
+
|
262
|
+
it 'has the right number' do
|
263
|
+
subject.size.should == 1
|
253
264
|
end
|
254
265
|
|
255
|
-
|
256
|
-
psu.
|
266
|
+
describe 'an individual PSU' do
|
267
|
+
let(:psu) { subject.first }
|
268
|
+
|
269
|
+
it 'has the correct ID' do
|
270
|
+
psu.id.should == '204'
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'has no Areas' do
|
274
|
+
psu.should have(0).sampling_unit_areas
|
275
|
+
end
|
276
|
+
|
277
|
+
it 'has no SSUs' do
|
278
|
+
psu.should have(0).secondary_sampling_units
|
279
|
+
end
|
257
280
|
end
|
258
281
|
end
|
259
282
|
end
|
260
283
|
end
|
261
284
|
|
262
285
|
describe '#secondary_sampling_units' do
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
286
|
+
describe 'when no sampling_unit_file' do
|
287
|
+
it 'is an empty array' do
|
288
|
+
from_minimum_valid_hash.secondary_sampling_units.should be_empty
|
289
|
+
end
|
267
290
|
end
|
268
291
|
|
269
|
-
describe '
|
270
|
-
|
292
|
+
describe 'when sampling_units_file is present' do
|
293
|
+
subject { everything.secondary_sampling_units }
|
271
294
|
|
272
|
-
it 'has the
|
273
|
-
|
295
|
+
it 'has the right number' do
|
296
|
+
subject.size.should == 3
|
274
297
|
end
|
275
298
|
|
276
|
-
|
277
|
-
ssu.
|
278
|
-
end
|
299
|
+
describe 'an individual SSU' do
|
300
|
+
let(:ssu) { subject.sort_by { |ssu| ssu.id }.first }
|
279
301
|
|
280
|
-
|
281
|
-
|
282
|
-
|
302
|
+
it 'has the correct ID' do
|
303
|
+
ssu.id.should == 'One'
|
304
|
+
end
|
283
305
|
|
284
|
-
|
285
|
-
|
286
|
-
|
306
|
+
it 'has the correct name' do
|
307
|
+
ssu.name.should == 'West Side'
|
308
|
+
end
|
287
309
|
|
288
|
-
|
289
|
-
|
290
|
-
|
310
|
+
it 'has the correct area' do
|
311
|
+
ssu.area.name.should == 'Uptown'
|
312
|
+
end
|
291
313
|
|
292
|
-
|
293
|
-
|
294
|
-
|
314
|
+
it 'has the same area as another SSU in the same area' do
|
315
|
+
ssu.area.should eql(subject.find { |ssu| ssu.name == 'West Side' }.area)
|
316
|
+
end
|
295
317
|
|
296
|
-
|
297
|
-
|
318
|
+
it 'has the correct PSU' do
|
319
|
+
ssu.primary_sampling_unit.id.should == '204'
|
320
|
+
end
|
298
321
|
|
299
|
-
it 'has
|
300
|
-
|
322
|
+
it 'has the correct TSUs' do
|
323
|
+
ssu.should have(1).tertiary_sampling_units
|
301
324
|
end
|
302
325
|
|
303
|
-
|
304
|
-
tsu.
|
326
|
+
describe 'a TSU' do
|
327
|
+
let(:tsu) { ssu.tertiary_sampling_units.first }
|
328
|
+
|
329
|
+
it 'has a name' do
|
330
|
+
tsu.name.should == 'Center'
|
331
|
+
end
|
332
|
+
|
333
|
+
it 'has an ID' do
|
334
|
+
tsu.id.should == '1-1'
|
335
|
+
end
|
305
336
|
end
|
306
337
|
end
|
307
|
-
end
|
308
338
|
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
339
|
+
context 'without TSUs' do
|
340
|
+
before do
|
341
|
+
input_hash['Study Center']['sampling_units_file'] =
|
342
|
+
File.expand_path('../no_tsus.csv', __FILE__)
|
343
|
+
end
|
314
344
|
|
315
|
-
|
345
|
+
subject { from_hash.secondary_sampling_units }
|
316
346
|
|
317
|
-
|
318
|
-
|
319
|
-
|
347
|
+
it 'has the right number' do
|
348
|
+
subject.size.should == 3
|
349
|
+
end
|
320
350
|
|
321
|
-
|
322
|
-
|
351
|
+
describe 'an individual SSU' do
|
352
|
+
let(:ssu) { subject.first }
|
323
353
|
|
324
|
-
|
325
|
-
|
354
|
+
it 'has no TSUs' do
|
355
|
+
ssu.should have(0).tertiary_sampling_units
|
356
|
+
end
|
326
357
|
end
|
327
358
|
end
|
328
|
-
end
|
329
359
|
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
360
|
+
context 'with extra whitespace' do
|
361
|
+
before do
|
362
|
+
input_hash['Study Center']['sampling_units_file'] =
|
363
|
+
File.expand_path('../spaces.csv', __FILE__)
|
364
|
+
end
|
335
365
|
|
336
|
-
|
366
|
+
subject { from_hash.secondary_sampling_units }
|
337
367
|
|
338
|
-
|
339
|
-
|
340
|
-
|
368
|
+
it 'has the right number' do
|
369
|
+
subject.size.should == 3
|
370
|
+
end
|
341
371
|
|
342
|
-
|
343
|
-
|
372
|
+
describe 'an individual SSU' do
|
373
|
+
let(:ssu) { subject.detect { |s| s.id == 'One' } }
|
344
374
|
|
345
|
-
|
346
|
-
|
375
|
+
it 'has the name' do
|
376
|
+
ssu.name.should == 'West Side'
|
377
|
+
end
|
347
378
|
end
|
348
379
|
end
|
349
380
|
end
|
@@ -440,12 +471,27 @@ module NcsNavigator
|
|
440
471
|
end
|
441
472
|
end
|
442
473
|
|
474
|
+
describe '#core_machine_account_username' do
|
475
|
+
it 'is the configured value' do
|
476
|
+
everything.core_machine_account_username.should == 'ncs_navigator_cases_foobar'
|
477
|
+
end
|
478
|
+
end
|
479
|
+
|
443
480
|
describe '#core_machine_account_password' do
|
444
481
|
it 'is the configured value' do
|
445
482
|
everything.core_machine_account_password.should == 'foobar'
|
446
483
|
end
|
447
484
|
end
|
448
485
|
|
486
|
+
describe '#core_conflict_email_recipients' do
|
487
|
+
it 'is the configured value' do
|
488
|
+
everything.core_conflict_email_recipients.should == [
|
489
|
+
'Foo Bar <foobar@example.edu>',
|
490
|
+
'Baz Quux <bazquux@example.edu>'
|
491
|
+
]
|
492
|
+
end
|
493
|
+
end
|
494
|
+
|
449
495
|
describe '#core' do
|
450
496
|
it 'exposes all the raw values in the Staff Portal section' do
|
451
497
|
everything.core['uri'].should == "https://ncsnavigator.greaterchicagoncs.org/"
|
@@ -22,7 +22,9 @@ mail_from = "staffportal@greaterchicagoncs.org"
|
|
22
22
|
[Core]
|
23
23
|
uri = "https://ncsnavigator.greaterchicagoncs.org/"
|
24
24
|
mail_from = "ncs-navigator@greaterchicagoncs.org"
|
25
|
+
machine_account_username = "ncs_navigator_cases_foobar"
|
25
26
|
machine_account_password = "foobar"
|
27
|
+
conflict_email_recipients="Foo Bar <foobar@example.edu>, Baz Quux <bazquux@example.edu>"
|
26
28
|
|
27
29
|
[PSC]
|
28
30
|
uri = "https://calendar.greaterchicagoncs.org/"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ncs_navigator_configuration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ncs_mdes
|
@@ -182,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
182
|
version: '0'
|
183
183
|
segments:
|
184
184
|
- 0
|
185
|
-
hash:
|
185
|
+
hash: 4406372814249112619
|
186
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
187
|
none: false
|
188
188
|
requirements:
|
@@ -191,10 +191,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
191
|
version: '0'
|
192
192
|
segments:
|
193
193
|
- 0
|
194
|
-
hash:
|
194
|
+
hash: 4406372814249112619
|
195
195
|
requirements: []
|
196
196
|
rubyforge_project:
|
197
|
-
rubygems_version: 1.8.
|
197
|
+
rubygems_version: 1.8.25
|
198
198
|
signing_key:
|
199
199
|
specification_version: 3
|
200
200
|
summary: Common configuration elements for the NCS Navigator suite
|