ncs_navigator_configuration 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,19 @@
1
1
  NCS Navigator Configuration gem history
2
2
  =======================================
3
3
 
4
+ 0.3.1
5
+ -----
6
+
7
+ - Make Areas and SSUs optional for the PSU in the sampling unit CSV
8
+ file. (#7)
9
+
4
10
  0.3.0
5
11
  -----
6
12
 
7
13
  - New optional study center attribute: short_name. (#10)
14
+
8
15
  - New optional attribute for Staff Portal and Core: mail_from. (#8)
16
+
9
17
  - New optional study center attribute: `exception_email_recipients`. (#9)
10
18
 
11
19
  0.2.0
@@ -357,11 +357,11 @@ module NcsNavigator
357
357
  ##
358
358
  # @return [Array<SamplingUnitArea>] the areas defined in {#sampling_units_file}.
359
359
  def sampling_unit_areas
360
- @sampling_unit_areas ||= read_sampling_unit_areas
360
+ @sampling_unit_areas ||= primary_sampling_units.collect(&:sampling_unit_areas).flatten
361
361
  end
362
362
  alias :areas :sampling_unit_areas
363
363
 
364
- def read_sampling_unit_areas
364
+ def read_primary_sampling_units
365
365
  psus = {}
366
366
  areas = {}
367
367
  ssus = {}
@@ -377,28 +377,32 @@ module NcsNavigator
377
377
  :converters => [strip_ws], :header_converters => [strip_ws]
378
378
  ) do |row|
379
379
  psu = (psus[row['PSU_ID']] ||= PrimarySamplingUnit.new(row['PSU_ID']))
380
- area = (areas[row['AREA']] ||= SamplingUnitArea.new(row['AREA'], psu))
381
- ssu = (ssus[row['SSU_ID']] ||= SecondarySamplingUnit.new(row['SSU_ID'], row['SSU_NAME'], area))
382
- if row['TSU_ID']
383
- TertiarySamplingUnit.new(row['TSU_ID'], row['TSU_NAME'], ssu)
380
+ if row['AREA']
381
+ area = (areas[row['AREA']] ||= SamplingUnitArea.new(row['AREA'], psu))
382
+ if row['SSU_ID']
383
+ area = (areas[row['AREA']] ||= SamplingUnitArea.new(row['AREA'], psu))
384
+ ssu = (ssus[row['SSU_ID']] ||= SecondarySamplingUnit.new(row['SSU_ID'], row['SSU_NAME'], area))
385
+ if row['TSU_ID']
386
+ TertiarySamplingUnit.new(row['TSU_ID'], row['TSU_NAME'], ssu)
387
+ end
388
+ end
384
389
  end
385
390
  end
386
-
387
- areas.values
391
+ psus.values
388
392
  end
389
- private :read_sampling_unit_areas
393
+ private :read_primary_sampling_units
390
394
 
391
395
  ##
392
396
  # @return [Array<PrimarySamplingUnit>] the PSUs defined in {#sampling_units_file}.
393
397
  def primary_sampling_units
394
- @primary_sampling_units ||= sampling_unit_areas.collect(&:primary_sampling_unit).uniq
398
+ @primary_sampling_units ||= read_primary_sampling_units
395
399
  end
396
400
  alias :psus :primary_sampling_units
397
401
 
398
402
  ##
399
403
  # @return [Array<SecondarySamplingUnit>] the SSUs defined in {#sampling_units_file}.
400
404
  def secondary_sampling_units
401
- @secondary_sampling_units ||= sampling_unit_areas.collect(&:secondary_sampling_units).flatten
405
+ @secondary_sampling_units ||= primary_sampling_units.collect(&:secondary_sampling_units).flatten
402
406
  end
403
407
  alias :ssus :secondary_sampling_units
404
408
 
@@ -1,5 +1,5 @@
1
1
  module NcsNavigator
2
2
  class Configuration
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
4
4
  end
5
5
  end
@@ -228,6 +228,35 @@ module NcsNavigator
228
228
  psu.secondary_sampling_units.collect(&:id).should == %w(One Two Three)
229
229
  end
230
230
  end
231
+
232
+ context 'without Areas and SSUs' do
233
+ before do
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 }
239
+
240
+ it 'has the right number' do
241
+ subject.size.should == 1
242
+ end
243
+
244
+ describe 'an individual PSU' do
245
+ let(:psu) { subject.first }
246
+
247
+ it 'has the correct ID' do
248
+ psu.id.should == '204'
249
+ end
250
+
251
+ it 'has no Areas' do
252
+ psu.should have(0).sampling_unit_areas
253
+ end
254
+
255
+ it 'has no SSUs' do
256
+ psu.should have(0).secondary_sampling_units
257
+ end
258
+ end
259
+ end
231
260
  end
232
261
 
233
262
  describe '#secondary_sampling_units' do
@@ -0,0 +1,2 @@
1
+ PSU_ID,AREA,SSU_ID,SSU_NAME,TSU_ID,TSU_NAME
2
+ 204,,,,,
metadata CHANGED
@@ -1,152 +1,156 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ncs_navigator_configuration
3
- version: !ruby/object:Gem::Version
4
- version: 0.3.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 1
10
+ version: 0.3.1
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Rhett Sutphin
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-07-03 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: ncs_mdes
16
- requirement: !ruby/object:Gem::Requirement
17
+
18
+ date: 2012-07-10 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ prerelease: false
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
17
23
  none: false
18
- requirements:
24
+ requirements:
19
25
  - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '0.4'
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ - 4
31
+ version: "0.4"
32
+ requirement: *id001
33
+ name: ncs_mdes
22
34
  type: :runtime
35
+ - !ruby/object:Gem::Dependency
23
36
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: '0.4'
30
- - !ruby/object:Gem::Dependency
31
- name: inifile
32
- requirement: !ruby/object:Gem::Requirement
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
33
38
  none: false
34
- requirements:
39
+ requirements:
35
40
  - - ~>
36
- - !ruby/object:Gem::Version
41
+ - !ruby/object:Gem::Version
42
+ hash: 13
43
+ segments:
44
+ - 0
45
+ - 4
46
+ - 1
37
47
  version: 0.4.1
48
+ requirement: *id002
49
+ name: inifile
38
50
  type: :runtime
51
+ - !ruby/object:Gem::Dependency
39
52
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
41
54
  none: false
42
- requirements:
55
+ requirements:
43
56
  - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 0.4.1
46
- - !ruby/object:Gem::Dependency
57
+ - !ruby/object:Gem::Version
58
+ hash: 5
59
+ segments:
60
+ - 1
61
+ - 5
62
+ version: "1.5"
63
+ requirement: *id003
47
64
  name: fastercsv
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '1.5'
54
65
  type: :runtime
66
+ - !ruby/object:Gem::Dependency
55
67
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '1.5'
62
- - !ruby/object:Gem::Dependency
63
- name: rake
64
- requirement: !ruby/object:Gem::Requirement
68
+ version_requirements: &id004 !ruby/object:Gem::Requirement
65
69
  none: false
66
- requirements:
70
+ requirements:
67
71
  - - ~>
68
- - !ruby/object:Gem::Version
72
+ - !ruby/object:Gem::Version
73
+ hash: 63
74
+ segments:
75
+ - 0
76
+ - 9
77
+ - 2
69
78
  version: 0.9.2
79
+ requirement: *id004
80
+ name: rake
70
81
  type: :development
82
+ - !ruby/object:Gem::Dependency
71
83
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
84
+ version_requirements: &id005 !ruby/object:Gem::Requirement
73
85
  none: false
74
- requirements:
86
+ requirements:
75
87
  - - ~>
76
- - !ruby/object:Gem::Version
77
- version: 0.9.2
78
- - !ruby/object:Gem::Dependency
88
+ - !ruby/object:Gem::Version
89
+ hash: 15
90
+ segments:
91
+ - 2
92
+ - 6
93
+ version: "2.6"
94
+ requirement: *id005
79
95
  name: rspec
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ~>
84
- - !ruby/object:Gem::Version
85
- version: '2.6'
86
96
  type: :development
97
+ - !ruby/object:Gem::Dependency
87
98
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ~>
92
- - !ruby/object:Gem::Version
93
- version: '2.6'
94
- - !ruby/object:Gem::Dependency
95
- name: yard
96
- requirement: !ruby/object:Gem::Requirement
99
+ version_requirements: &id006 !ruby/object:Gem::Requirement
97
100
  none: false
98
- requirements:
101
+ requirements:
99
102
  - - ~>
100
- - !ruby/object:Gem::Version
103
+ - !ruby/object:Gem::Version
104
+ hash: 7
105
+ segments:
106
+ - 0
107
+ - 7
108
+ - 2
101
109
  version: 0.7.2
110
+ requirement: *id006
111
+ name: yard
102
112
  type: :development
113
+ - !ruby/object:Gem::Dependency
103
114
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ~>
108
- - !ruby/object:Gem::Version
109
- version: 0.7.2
110
- - !ruby/object:Gem::Dependency
111
- name: fakefs
112
- requirement: !ruby/object:Gem::Requirement
115
+ version_requirements: &id007 !ruby/object:Gem::Requirement
113
116
  none: false
114
- requirements:
117
+ requirements:
115
118
  - - ~>
116
- - !ruby/object:Gem::Version
119
+ - !ruby/object:Gem::Version
120
+ hash: 23
121
+ segments:
122
+ - 0
123
+ - 3
124
+ - 2
117
125
  version: 0.3.2
126
+ requirement: *id007
127
+ name: fakefs
118
128
  type: :development
129
+ - !ruby/object:Gem::Dependency
119
130
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
131
+ version_requirements: &id008 !ruby/object:Gem::Requirement
121
132
  none: false
122
- requirements:
133
+ requirements:
123
134
  - - ~>
124
- - !ruby/object:Gem::Version
125
- version: 0.3.2
126
- - !ruby/object:Gem::Dependency
135
+ - !ruby/object:Gem::Version
136
+ hash: 3
137
+ segments:
138
+ - 1
139
+ - 6
140
+ version: "1.6"
141
+ requirement: *id008
127
142
  name: ci_reporter
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ~>
132
- - !ruby/object:Gem::Version
133
- version: '1.6'
134
143
  type: :development
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ~>
140
- - !ruby/object:Gem::Version
141
- version: '1.6'
142
- description: ! "\n An internal component of the NCS Navigator suite, this gem provides
143
- a common view\n onto shared configuration elements.\n "
144
- email:
144
+ description: "\n An internal component of the NCS Navigator suite, this gem provides a common view\n onto shared configuration elements.\n "
145
+ email:
145
146
  - r-sutphin@northwestern.edu
146
147
  executables: []
148
+
147
149
  extensions: []
150
+
148
151
  extra_rdoc_files: []
149
- files:
152
+
153
+ files:
150
154
  - .gitignore
151
155
  - .rvmrc
152
156
  - .yardopts
@@ -164,44 +168,49 @@ files:
164
168
  - spec/ncs_navigator/configuration_spec.rb
165
169
  - spec/ncs_navigator/every_su.csv
166
170
  - spec/ncs_navigator/everything.ini
171
+ - spec/ncs_navigator/no_ssus.csv
167
172
  - spec/ncs_navigator/no_tsus.csv
168
173
  - spec/ncs_navigator/spaces.csv
169
174
  - spec/spec_helper.rb
170
- homepage: ''
175
+ homepage: ""
171
176
  licenses: []
177
+
172
178
  post_install_message:
173
179
  rdoc_options: []
174
- require_paths:
180
+
181
+ require_paths:
175
182
  - lib
176
- required_ruby_version: !ruby/object:Gem::Requirement
183
+ required_ruby_version: !ruby/object:Gem::Requirement
177
184
  none: false
178
- requirements:
179
- - - ! '>='
180
- - !ruby/object:Gem::Version
181
- version: '0'
182
- segments:
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ hash: 3
189
+ segments:
183
190
  - 0
184
- hash: 2522240099632272850
185
- required_rubygems_version: !ruby/object:Gem::Requirement
191
+ version: "0"
192
+ required_rubygems_version: !ruby/object:Gem::Requirement
186
193
  none: false
187
- requirements:
188
- - - ! '>='
189
- - !ruby/object:Gem::Version
190
- version: '0'
191
- segments:
194
+ requirements:
195
+ - - ">="
196
+ - !ruby/object:Gem::Version
197
+ hash: 3
198
+ segments:
192
199
  - 0
193
- hash: 2522240099632272850
200
+ version: "0"
194
201
  requirements: []
202
+
195
203
  rubyforge_project:
196
- rubygems_version: 1.8.24
204
+ rubygems_version: 1.8.15
197
205
  signing_key:
198
206
  specification_version: 3
199
207
  summary: Common configuration elements for the NCS Navigator suite
200
- test_files:
208
+ test_files:
201
209
  - spec/ncs_navigator/configuration/version_spec.rb
202
210
  - spec/ncs_navigator/configuration_spec.rb
203
211
  - spec/ncs_navigator/every_su.csv
204
212
  - spec/ncs_navigator/everything.ini
213
+ - spec/ncs_navigator/no_ssus.csv
205
214
  - spec/ncs_navigator/no_tsus.csv
206
215
  - spec/ncs_navigator/spaces.csv
207
216
  - spec/spec_helper.rb