revs-utils 1.0.18 → 1.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWU1YmRiOTA5YWE3ODU0NGIyZWVmMWQyZmI4NzI4MDBjOWY3NmNhNQ==
4
+ YzAzNjMxYjAzOTE5YTcwOTJjYTc1MDkyOTg4NDM0MTA4NzU4ZDBjMw==
5
5
  data.tar.gz: !binary |-
6
- NWExZjZmYTQyMzIxMGUxMjg3YjI3MjM1NjI5Zjc5YjE3YWFhOTNiNg==
6
+ MmRhMjIzYTcwMmUxM2ZiYmFhODY2NzA2MzhlNDcyNDAwZTRlNzA1Yw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZmQxNmM3YjZhODQzYzJhYTNlN2ZkZmMwNDEyY2YwMmU0ZTVhMDZkYjMzN2Ux
10
- ZWNlNzQ1YWI4OTBkNjg3OGViMjU3OWIzYWE0NjA0ZjIzZjcyZjFiOWNhYjBi
11
- MWExZjMwMDFiNDJlODgzMTRkNjQzOTMyZmYzMzhhOTJjNTNkYWE=
9
+ ODdiMDBmYmZmNTkyMzhlOGJiZmRlYTMwOTdkN2E2MzdmNmM5YjdlNWMwMTg0
10
+ OTJjYTk2NzczMTJjYWMzZDU4MjhmNjE1NWNhNWFlNjRlOTk0M2JiZDI4OTBk
11
+ MzI0MzkzNzRhODZiODYxYjdhZTkyNDg3ZWFjY2QxODMxMjVmYjY=
12
12
  data.tar.gz: !binary |-
13
- MDU3OTY1MTZkMzM3MGJlNmRiODVhODQ5M2VjYTQ5NmU0NWI2YzlmOTJhMTgx
14
- YTBiMjBiYjhhZTUzMzgxN2JiOTdiMjE2MTNhYWE3MzY2ZDllNzQ2MmQ0MTIz
15
- MDk3NmIyODgwZmI2MDJjZThjYjNkYzkyMDk3ODVlZTM4NjMxOTI=
13
+ Nzg1OTQ1OTk1OGNmMWI2ODY0ZWE4M2Y1NDNlNWEzYWFhZGVhZTRhY2FiMjE4
14
+ ZDRhOWE4NjY3NjVjZWJiYWQ3N2U1OTYyOGI1ZTY5MTc5OTFiYzE2ODU3MDkz
15
+ NzFiMjE1Njg4NmZlMjVkMDI2NDM3ZDVhOGJiZTMzYThhY2MzNTM=
@@ -1,5 +1,5 @@
1
1
  module Revs
2
2
  module Utils
3
- VERSION = "1.0.18"
3
+ VERSION = "1.0.19"
4
4
  end
5
5
  end
data/lib/revs-utils.rb CHANGED
@@ -95,18 +95,31 @@ module Revs
95
95
  # 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
96
96
  def check_valid_to_register(csv_data)
97
97
  #Make sure all the required headers are there
98
- return false if not get_manifest_section(REGISTER).values-csv_data[0].keys == []
98
+ result1=result2=result3=result4=true
99
+ if not get_manifest_section(REGISTER).values-csv_data[0].keys == []
100
+ puts "missing headers required for registration"
101
+ result1=false
102
+ end
99
103
  sources=Array.new
100
104
  #Make sure all files have entries for those required headers
101
105
  csv_data.each do |row|
102
106
  get_manifest_section(REGISTER).keys.each do |header| # label should be there as a column but does not always need a value
103
- return false if header.downcase !='label' && row[header].blank? #Alternatively consider row[header].class != String or row[header].size <= 0
107
+ if header.downcase !='label' && row[header].blank?
108
+ puts "#{row[get_manifest_section(REGISTER)['sourceid']]} does not have a value for a required registration field"
109
+ result2=false
110
+ end
104
111
  end
105
112
  fname = row[get_manifest_section(REGISTER)['filename']].chomp(File.extname(row[get_manifest_section(REGISTER)['filename']]))
106
- return false if ((row[get_manifest_section(REGISTER)['sourceid']] != fname) || ((/\s/ =~ row[get_manifest_section(REGISTER)['sourceid']].strip) != nil))
113
+ if ((row[get_manifest_section(REGISTER)['sourceid']] != fname) || ((/\s/ =~ row[get_manifest_section(REGISTER)['sourceid']].strip) != nil))
114
+ puts "#{row[get_manifest_section(REGISTER)['sourceid']]} does not match the filename or has a space in it"
115
+ result3=false
116
+ end
107
117
  sources << row[get_manifest_section(REGISTER)['sourceid']]
108
118
  end
109
- return sources.uniq.size == sources.size
119
+ result4 = (sources.uniq.size == sources.size)
120
+ puts "sourceIDs are not all unique" unless result4
121
+ return (result1 && result2 && result3 && result4)
122
+
110
123
  end
111
124
 
112
125
  # looks at certain metadata fields in manifest to confirm validity (such as dates and formats)
@@ -115,22 +128,35 @@ module Revs
115
128
  csv_data.each do |row|
116
129
  valid_date=revs_is_valid_datestring?(row[get_manifest_section(METADATA)['year']] || row[get_manifest_section(METADATA)['date']])
117
130
  valid_format=revs_is_valid_format?(row[get_manifest_section(METADATA)['format']])
118
- bad_rows+=1 unless (valid_date && valid_format)
131
+ unless (valid_date && valid_format)
132
+ bad_rows+=1
133
+ puts "#{row[get_manifest_section(REGISTER)['sourceid']]} has a bad year/date or format"
134
+ end
119
135
  end
120
136
  return bad_rows
121
137
  end
122
138
 
123
139
  # pass in csv data from a file read in and it will tell you if the headers are valid
124
140
  def check_headers(csv_data)
141
+
142
+ result1=result2=true
125
143
  file_headers=csv_data[0].keys.reject(&:blank?).collect(&:downcase)
126
144
  #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
127
145
  if file_headers.include?('date') && file_headers.include?('year') # can't have both date and year
128
- return false
129
- elsif 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
130
- return false
131
- else
132
- return file_headers-get_manifest_section(METADATA).values-get_manifest_section(REGISTER).values == []
146
+ puts "has both year and date columns"
147
+ result1=false
133
148
  end
149
+ 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
150
+ puts "has location column as well as specific state,city,country columns"
151
+ result2=false
152
+ end
153
+ extra_columns = file_headers-get_manifest_section(METADATA).values-get_manifest_section(REGISTER).values
154
+ has_extra_columns = (extra_columns == [])
155
+ puts "has unknown columns: #{extra_columns.join(', ')}" unless has_extra_columns
156
+ result3 = has_extra_columns
157
+
158
+ return (result1 && result2 && result3)
159
+
134
160
  end
135
161
 
136
162
  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: 1.0.18
4
+ version: 1.0.19
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-04-21 00:00:00.000000000 Z
11
+ date: 2015-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: countries