revs-utils 2.1.9 → 2.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/revs-utils/version.rb +1 -1
- data/lib/revs-utils.rb +36 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWY0NmMxMWFmY2FiODZkNjFjZjU2OGVhMjRlNGJiZmVlNWJjYzc3Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWFkNjhhNTA4M2VmODhiZDdkYmQ0ZjRjOTgyMjNiMjc1MDgwYTRhNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTEwNmNlZTA2MDc3MjczM2Q4ZWViYzFkNDE4NjY2YWYxMGIyZWQyMDU4YjEx
|
10
|
+
OTFjZTZhNjFjYjBjYTg4MDYyZmM0ZDU0YzdjNWM2ZDRmY2Y2NzhmZjM4OWRi
|
11
|
+
NmY3ZWZjMzJmZDBjOGEzMjgzY2UzMjg5NjFiZWEwOWViY2JhYjY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjcxYTQxMzQyMDRmOTFmNTlhY2VmOTI2ZjliOTc2Nzk3Y2YyYzc0M2Y0Mjcz
|
14
|
+
OTYwYTcwNzg1M2NlNmVlMjViOGJjZTA0OWMzZWY3OGI3YjY4NmJkZmU5ZGQ2
|
15
|
+
ZTZlNDg3ZTljZjQzMjQwOTJkYzY1YTUyODIxYWRlMDkwNWMzOTU=
|
data/lib/revs-utils/version.rb
CHANGED
data/lib/revs-utils.rb
CHANGED
@@ -174,18 +174,31 @@ module Revs
|
|
174
174
|
# pass in csv data and it will tell if you everything is safe to register based on having labels, unique sourceIDs and filenames matching sourceIDs
|
175
175
|
def check_valid_to_register(csv_data)
|
176
176
|
#Make sure all the required headers are there
|
177
|
-
|
177
|
+
result1=result2=result3=result4=true
|
178
|
+
if not get_manifest_section(REGISTER).values-csv_data[0].keys == []
|
179
|
+
puts "missing headers required for registration"
|
180
|
+
result1=false
|
181
|
+
end
|
178
182
|
sources=Array.new
|
179
183
|
#Make sure all files have entries for those required headers
|
180
184
|
csv_data.each do |row|
|
181
185
|
get_manifest_section(REGISTER).keys.each do |header| # label should be there as a column but does not always need a value
|
182
|
-
|
186
|
+
if header.downcase !='label' && row[header].blank?
|
187
|
+
puts "#{row[get_manifest_section(REGISTER)['sourceid']]} does not have a value for a required registration field"
|
188
|
+
result2=false
|
189
|
+
end
|
183
190
|
end
|
184
191
|
fname = row[get_manifest_section(REGISTER)['filename']].chomp(File.extname(row[get_manifest_section(REGISTER)['filename']]))
|
185
|
-
|
192
|
+
if ((row[get_manifest_section(REGISTER)['sourceid']] != fname) || ((/\s/ =~ row[get_manifest_section(REGISTER)['sourceid']].strip) != nil))
|
193
|
+
puts "#{row[get_manifest_section(REGISTER)['sourceid']]} does not match the filename or has a space in it"
|
194
|
+
result3=false
|
195
|
+
end
|
186
196
|
sources << row[get_manifest_section(REGISTER)['sourceid']]
|
187
197
|
end
|
188
|
-
|
198
|
+
result4 = (sources.uniq.size == sources.size)
|
199
|
+
puts "sourceIDs are not all unique" unless result4
|
200
|
+
return (result1 && result2 && result3 && result4)
|
201
|
+
|
189
202
|
end
|
190
203
|
|
191
204
|
# looks at certain metadata fields in manifest to confirm validity (such as dates and formats)
|
@@ -194,22 +207,35 @@ module Revs
|
|
194
207
|
csv_data.each do |row|
|
195
208
|
valid_date=revs_is_valid_datestring?(row[get_manifest_section(METADATA)['year']] || row[get_manifest_section(METADATA)['date']])
|
196
209
|
valid_format=revs_is_valid_format?(row[get_manifest_section(METADATA)['format']])
|
197
|
-
|
210
|
+
unless (valid_date && valid_format)
|
211
|
+
bad_rows+=1
|
212
|
+
puts "#{row[get_manifest_section(REGISTER)['sourceid']]} has a bad year/date or format"
|
213
|
+
end
|
198
214
|
end
|
199
215
|
return bad_rows
|
200
216
|
end
|
201
217
|
|
202
218
|
# pass in csv data from a file read in and it will tell you if the headers are valid
|
203
219
|
def check_headers(csv_data)
|
220
|
+
|
221
|
+
result1=result2=true
|
204
222
|
file_headers=csv_data[0].keys.reject(&:blank?).collect(&:downcase)
|
205
223
|
#The file doesn't need to have all the metadata values, it just can't have headers that aren't used for metadata or registration
|
206
224
|
if file_headers.include?('date') && file_headers.include?('year') # can't have both date and year
|
207
|
-
|
208
|
-
|
209
|
-
return false
|
210
|
-
else
|
211
|
-
return file_headers-get_manifest_section(METADATA).values-get_manifest_section(REGISTER).values == []
|
225
|
+
puts "has both year and date columns"
|
226
|
+
result1=false
|
212
227
|
end
|
228
|
+
if file_headers.include?('location') && file_headers.include?('state') && file_headers.include?('city') && file_headers.include?('country') # can't have both location and the specific fields
|
229
|
+
puts "has location column as well as specific state,city,country columns"
|
230
|
+
result2=false
|
231
|
+
end
|
232
|
+
extra_columns = file_headers-get_manifest_section(METADATA).values-get_manifest_section(REGISTER).values
|
233
|
+
has_extra_columns = (extra_columns == [])
|
234
|
+
puts "has unknown columns: #{extra_columns.join(', ')}" unless has_extra_columns
|
235
|
+
result3 = has_extra_columns
|
236
|
+
|
237
|
+
return (result1 && result2 && result3)
|
238
|
+
|
213
239
|
end
|
214
240
|
|
215
241
|
def clean_collection_name(name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: revs-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Mangiafico
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: countries
|