ncs_navigator_configuration 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -0
- data/lib/ncs_navigator/configuration.rb +13 -1
- data/lib/ncs_navigator/configuration/version.rb +1 -1
- data/sample_configuration.ini +10 -0
- data/spec/ncs_navigator/configuration_spec.rb +40 -0
- data/spec/ncs_navigator/everything.ini +1 -0
- data/spec/ncs_navigator/spaces.csv +4 -0
- metadata +22 -19
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
NCS Navigator Configuration gem history
|
2
2
|
=======================================
|
3
3
|
|
4
|
+
0.2.0
|
5
|
+
-----
|
6
|
+
|
7
|
+
- New mandatory study center attribute: recruitment_type_id.
|
8
|
+
|
9
|
+
- Be more flexible about whitespace when parsing sampling unit CSV.
|
10
|
+
|
4
11
|
0.1.0
|
5
12
|
-----
|
6
13
|
|
@@ -165,6 +165,13 @@ module NcsNavigator
|
|
165
165
|
|
166
166
|
alias :sc_id :study_center_id
|
167
167
|
|
168
|
+
##
|
169
|
+
# The recruitment strategy for this study center. The acceptable
|
170
|
+
# values are those from the code list `recruit_type_cl1` in the
|
171
|
+
# MDES.
|
172
|
+
configuration_attribute :recruitment_type_id, 'Study Center', 'recruitment_type_id', String,
|
173
|
+
:required => true
|
174
|
+
|
168
175
|
##
|
169
176
|
# The name for the institutional identity used in this deployment
|
170
177
|
# of NCS Navigator. For instance, for the Greater Chicago Study
|
@@ -335,7 +342,12 @@ module NcsNavigator
|
|
335
342
|
raise Error.new("Could not read sampling units CSV #{sampling_units_file}")
|
336
343
|
end
|
337
344
|
|
338
|
-
|
345
|
+
strip_ws = lambda { |h| h.nil? ? nil : h.strip }
|
346
|
+
|
347
|
+
faster_csv_class.foreach(sampling_units_file,
|
348
|
+
:headers => true, :encoding => 'utf-8',
|
349
|
+
:converters => [strip_ws], :header_converters => [strip_ws]
|
350
|
+
) do |row|
|
339
351
|
psu = (psus[row['PSU_ID']] ||= PrimarySamplingUnit.new(row['PSU_ID']))
|
340
352
|
area = (areas[row['AREA']] ||= SamplingUnitArea.new(row['AREA'], psu))
|
341
353
|
ssu = (ssus[row['SSU_ID']] ||= SecondarySamplingUnit.new(row['SSU_ID'], row['SSU_NAME'], area))
|
data/sample_configuration.ini
CHANGED
@@ -13,6 +13,16 @@
|
|
13
13
|
# The ID for the study center from the MDES
|
14
14
|
sc_id = "20000000"
|
15
15
|
|
16
|
+
# The recruitment strategy code for the center from the MDES. The
|
17
|
+
# acceptable values for this element are the values in the code list
|
18
|
+
# recruit_type_cl1 in the MDES. In MDES 2.0, these are the values:
|
19
|
+
#
|
20
|
+
# 1 => Enhanced Household Enumeration
|
21
|
+
# 2 => Provider-Based
|
22
|
+
# 3 => Two-Tier
|
23
|
+
# 4 => Original VC
|
24
|
+
recruitment_type_id = "3"
|
25
|
+
|
16
26
|
# A pointer to a CSV describing the sampling units for this study
|
17
27
|
# center. If the path is not absolute it will be resolved relative to
|
18
28
|
# this file.
|
@@ -22,6 +22,7 @@ describe NcsNavigator do
|
|
22
22
|
File.open('/etc/nubic/ncs/navigator.ini', 'w') do |f|
|
23
23
|
f.puts '[Study Center]'
|
24
24
|
f.puts 'sc_id = 18'
|
25
|
+
f.puts 'recruitment_type_id = 2'
|
25
26
|
f.puts 'sampling_units_file = foo.csv'
|
26
27
|
f.puts '[Staff Portal]'
|
27
28
|
f.puts 'uri = https://foo.example.com/sp'
|
@@ -57,6 +58,7 @@ module NcsNavigator
|
|
57
58
|
{
|
58
59
|
'Study Center' => {
|
59
60
|
'sc_id' => '23000000',
|
61
|
+
'recruitment_type_id' => '3',
|
60
62
|
'sampling_units_file' => 'foo.csv'
|
61
63
|
},
|
62
64
|
'Staff Portal' => {
|
@@ -112,6 +114,23 @@ module NcsNavigator
|
|
112
114
|
end
|
113
115
|
end
|
114
116
|
|
117
|
+
describe '#recruitment_type_id' do
|
118
|
+
it 'reflects the configured value' do
|
119
|
+
from_hash.recruitment_type_id.should == '3'
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'is always a string' do
|
123
|
+
input_hash['Study Center']['recruitment_type_id'] = 234
|
124
|
+
from_hash.recruitment_type_id.should == '234'
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'is mandatory' do
|
128
|
+
input_hash['Study Center'].delete 'recruitment_type_id'
|
129
|
+
lambda { from_hash }.
|
130
|
+
should raise_error("Please set a value for [Study Center]: recruitment_type_id")
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
115
134
|
describe '#study_center_username' do
|
116
135
|
it 'reflects the configured value' do
|
117
136
|
everything.study_center_username.should == 'NetID'
|
@@ -254,6 +273,27 @@ module NcsNavigator
|
|
254
273
|
end
|
255
274
|
end
|
256
275
|
end
|
276
|
+
|
277
|
+
context 'with extra whitespace' do
|
278
|
+
before do
|
279
|
+
input_hash['Study Center']['sampling_units_file'] =
|
280
|
+
File.expand_path('../spaces.csv', __FILE__)
|
281
|
+
end
|
282
|
+
|
283
|
+
subject { from_hash.secondary_sampling_units }
|
284
|
+
|
285
|
+
it 'has the right number' do
|
286
|
+
subject.size.should == 3
|
287
|
+
end
|
288
|
+
|
289
|
+
describe 'an individual SSU' do
|
290
|
+
let(:ssu) { subject.detect { |s| s.id == 'One' } }
|
291
|
+
|
292
|
+
it 'has the name' do
|
293
|
+
ssu.name.should == 'West Side'
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
257
297
|
end
|
258
298
|
|
259
299
|
describe 'footer' do
|
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.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-11-17 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ncs_mdes
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153498680 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.4'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153498680
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: inifile
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153498160 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.4.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153498160
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: fastercsv
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153497680 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '1.5'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153497680
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &2153497000 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.9.2
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2153497000
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &2153487960 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '2.6'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2153487960
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
|
-
requirement: &
|
71
|
+
requirement: &2153487480 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.7.2
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2153487480
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: fakefs
|
82
|
-
requirement: &
|
82
|
+
requirement: &2153486920 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 0.3.2
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2153486920
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: ci_reporter
|
93
|
-
requirement: &
|
93
|
+
requirement: &2153486340 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '1.6'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2153486340
|
102
102
|
description: ! "\n An internal component of the NCS Navigator suite, this gem provides
|
103
103
|
a common view\n onto shared configuration elements.\n "
|
104
104
|
email:
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- spec/ncs_navigator/every_su.csv
|
126
126
|
- spec/ncs_navigator/everything.ini
|
127
127
|
- spec/ncs_navigator/no_tsus.csv
|
128
|
+
- spec/ncs_navigator/spaces.csv
|
128
129
|
- spec/spec_helper.rb
|
129
130
|
homepage: ''
|
130
131
|
licenses: []
|
@@ -146,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
147
|
version: '0'
|
147
148
|
requirements: []
|
148
149
|
rubyforge_project:
|
149
|
-
rubygems_version: 1.8.
|
150
|
+
rubygems_version: 1.8.10
|
150
151
|
signing_key:
|
151
152
|
specification_version: 3
|
152
153
|
summary: Common configuration elements for the NCS Navigator suite
|
@@ -156,4 +157,6 @@ test_files:
|
|
156
157
|
- spec/ncs_navigator/every_su.csv
|
157
158
|
- spec/ncs_navigator/everything.ini
|
158
159
|
- spec/ncs_navigator/no_tsus.csv
|
160
|
+
- spec/ncs_navigator/spaces.csv
|
159
161
|
- spec/spec_helper.rb
|
162
|
+
has_rdoc:
|