revs-utils 2.1.13 → 2.1.14
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 +5 -13
- data/.gitignore +1 -0
- data/.travis.yml +18 -0
- data/Gemfile +5 -1
- data/Gemfile.lock +39 -22
- data/README.rdoc +4 -0
- data/Rakefile +0 -3
- data/lib/revs-utils/version.rb +1 -1
- data/lib/revs-utils.rb +52 -51
- data/revs-utils.gemspec +1 -1
- data/spec/revs-utils_spec.rb +78 -84
- data/spec/spec_helper.rb +3 -0
- metadata +27 -26
checksums.yaml
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
|
|
5
|
-
data.tar.gz: !binary |-
|
|
6
|
-
NTgxYjhiN2Q3NmRiN2NhNWY2MGM3MGFkM2U5NzgyYjQ0OTg5MDM3YQ==
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: b3a789d7280f0e88ed8e96f707d573f77b68837f
|
|
4
|
+
data.tar.gz: b0d04db28185e3d3060ce44f66960865b34be7ac
|
|
7
5
|
SHA512:
|
|
8
|
-
metadata.gz:
|
|
9
|
-
|
|
10
|
-
MTc1NzM3MzdlZDI4MGNiMjgxNGU1NTczY2IzYTBlYjFiZTEwNjA5NzBiMGY3
|
|
11
|
-
OGQzMjdmNTg3NGU4YjU1MGZhNDIxZGQwNzE4NzM0MGUyZThjNjE=
|
|
12
|
-
data.tar.gz: !binary |-
|
|
13
|
-
MDM5ZGU5MDgzM2JhNzE0N2VmNjM3NjJmZTBkMDQ2YWI4YWZlZmQ5YjMwODA2
|
|
14
|
-
ZDEwOWIyMzQyOWJjZTFhZDA4YjM5OWE4NmFjODMyM2ZkNzIxMGRmNmYwODJi
|
|
15
|
-
YmVhNGU2NDRmZmQzYmFjNjllZGU0NzMwMWIzNzc1NjYzMTY0YTg=
|
|
6
|
+
metadata.gz: dc43d1111eab3e2138a78f4469955808c6b6f9085b2e846194c914d731a9e5f0bed3f32386c7794ff1fac2362af1f203977d1b1a2d7a8ba2e8edb2816ace9889
|
|
7
|
+
data.tar.gz: fbf9bdbb4bd34b297cf8027d72ac5b26f1ee484b3531eb4eecc88fb0723ea13feed0c3d1ba2dafba206bf498814c58c62f24fb49139c1f768a3a92b376359d4f
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
revs-utils (2.1.
|
|
4
|
+
revs-utils (2.1.14)
|
|
5
5
|
actionpack (>= 4.1.6)
|
|
6
6
|
chronic
|
|
7
7
|
countries (= 0.9.2)
|
|
8
|
+
rake
|
|
8
9
|
rdf
|
|
9
10
|
|
|
10
11
|
GEM
|
|
11
12
|
remote: http://rubygems.org/
|
|
12
|
-
remote: http://sul-gems.stanford.edu/
|
|
13
13
|
specs:
|
|
14
|
-
actionpack (4.2.
|
|
15
|
-
actionview (= 4.2.
|
|
16
|
-
activesupport (= 4.2.
|
|
14
|
+
actionpack (4.2.5.1)
|
|
15
|
+
actionview (= 4.2.5.1)
|
|
16
|
+
activesupport (= 4.2.5.1)
|
|
17
17
|
rack (~> 1.6)
|
|
18
18
|
rack-test (~> 0.6.2)
|
|
19
19
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
20
20
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
21
|
-
actionview (4.2.
|
|
22
|
-
activesupport (= 4.2.
|
|
21
|
+
actionview (4.2.5.1)
|
|
22
|
+
activesupport (= 4.2.5.1)
|
|
23
23
|
builder (~> 3.1)
|
|
24
24
|
erubis (~> 2.7.0)
|
|
25
25
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
26
26
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
27
|
-
activesupport (4.2.
|
|
27
|
+
activesupport (4.2.5.1)
|
|
28
28
|
i18n (~> 0.7)
|
|
29
29
|
json (~> 1.7, >= 1.7.7)
|
|
30
30
|
minitest (~> 5.1)
|
|
@@ -34,9 +34,16 @@ GEM
|
|
|
34
34
|
chronic (0.10.2)
|
|
35
35
|
countries (0.9.2)
|
|
36
36
|
currencies (>= 0.4.0)
|
|
37
|
+
coveralls (0.8.2)
|
|
38
|
+
json (~> 1.8)
|
|
39
|
+
rest-client (>= 1.6.8, < 2)
|
|
40
|
+
simplecov (~> 0.10.0)
|
|
41
|
+
term-ansicolor (~> 1.3)
|
|
42
|
+
thor (~> 0.19.1)
|
|
37
43
|
currencies (0.4.2)
|
|
38
44
|
diff-lcs (1.2.5)
|
|
39
|
-
|
|
45
|
+
docile (1.1.5)
|
|
46
|
+
domain_name (0.5.24)
|
|
40
47
|
unf (>= 0.0.5, < 1.0.0)
|
|
41
48
|
erubis (2.7.0)
|
|
42
49
|
http-cookie (1.0.2)
|
|
@@ -44,17 +51,14 @@ GEM
|
|
|
44
51
|
i18n (0.7.0)
|
|
45
52
|
json (1.8.3)
|
|
46
53
|
link_header (0.0.8)
|
|
47
|
-
loofah (2.0.
|
|
54
|
+
loofah (2.0.3)
|
|
48
55
|
nokogiri (>= 1.5.9)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
mime-types (2.4.3)
|
|
53
|
-
mini_portile (0.6.2)
|
|
54
|
-
minitest (5.8.0)
|
|
56
|
+
mime-types (2.6.2)
|
|
57
|
+
mini_portile2 (2.0.0)
|
|
58
|
+
minitest (5.8.4)
|
|
55
59
|
netrc (0.10.3)
|
|
56
|
-
nokogiri (1.6.
|
|
57
|
-
|
|
60
|
+
nokogiri (1.6.7.2)
|
|
61
|
+
mini_portile2 (~> 2.0.0.rc2)
|
|
58
62
|
rack (1.6.4)
|
|
59
63
|
rack-test (0.6.3)
|
|
60
64
|
rack (>= 1.0)
|
|
@@ -64,10 +68,10 @@ GEM
|
|
|
64
68
|
activesupport (>= 4.2.0.beta, < 5.0)
|
|
65
69
|
nokogiri (~> 1.6.0)
|
|
66
70
|
rails-deprecated_sanitizer (>= 1.0.1)
|
|
67
|
-
rails-html-sanitizer (1.0.
|
|
71
|
+
rails-html-sanitizer (1.0.3)
|
|
68
72
|
loofah (~> 2.0)
|
|
69
73
|
rake (10.4.2)
|
|
70
|
-
rdf (1.1
|
|
74
|
+
rdf (1.99.1)
|
|
71
75
|
link_header (~> 0.0, >= 0.0.8)
|
|
72
76
|
rest-client (1.8.0)
|
|
73
77
|
http-cookie (>= 1.0.2, < 2.0)
|
|
@@ -81,19 +85,32 @@ GEM
|
|
|
81
85
|
rspec-expectations (2.99.2)
|
|
82
86
|
diff-lcs (>= 1.1.3, < 2.0)
|
|
83
87
|
rspec-mocks (2.99.3)
|
|
88
|
+
simplecov (0.10.0)
|
|
89
|
+
docile (~> 1.1.0)
|
|
90
|
+
json (~> 1.8)
|
|
91
|
+
simplecov-html (~> 0.10.0)
|
|
92
|
+
simplecov-html (0.10.0)
|
|
93
|
+
term-ansicolor (1.3.2)
|
|
94
|
+
tins (~> 1.0)
|
|
95
|
+
thor (0.19.1)
|
|
84
96
|
thread_safe (0.3.5)
|
|
97
|
+
tins (1.6.0)
|
|
85
98
|
tzinfo (1.2.2)
|
|
86
99
|
thread_safe (~> 0.1)
|
|
87
100
|
unf (0.1.4)
|
|
88
101
|
unf_ext
|
|
89
|
-
unf_ext (0.0.
|
|
102
|
+
unf_ext (0.0.7.1)
|
|
90
103
|
yard (0.8.7.6)
|
|
91
104
|
|
|
92
105
|
PLATFORMS
|
|
93
106
|
ruby
|
|
94
107
|
|
|
95
108
|
DEPENDENCIES
|
|
96
|
-
|
|
109
|
+
coveralls
|
|
110
|
+
rake
|
|
97
111
|
revs-utils!
|
|
98
112
|
rspec (~> 2.6)
|
|
99
113
|
yard
|
|
114
|
+
|
|
115
|
+
BUNDLED WITH
|
|
116
|
+
1.11.2
|
data/README.rdoc
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
{<img src="https://travis-ci.org/sul-dlss/revs-utils.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/sul-dlss/revs-utils] {<img src="https://coveralls.io/repos/sul-dlss/revs-utils/badge.svg?branch=master&service=github" alt="Coverage Status" />}[https://coveralls.io/github/sul-dlss/revs-utils?branch=master]
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
1
5
|
= Revs::Utils
|
|
2
6
|
|
|
3
7
|
Shared methods and functions used by revs-indexer, pre-assembly and bulk metadata loading code.
|
data/Rakefile
CHANGED
data/lib/revs-utils/version.rb
CHANGED
data/lib/revs-utils.rb
CHANGED
|
@@ -19,7 +19,7 @@ FORMATS = "known_formats"
|
|
|
19
19
|
|
|
20
20
|
module Revs
|
|
21
21
|
module Utils
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
# a hash of LC Subject Heading terms and their IDs for linking for "Automobiles" http://id.loc.gov/authorities/subjects/sh85010201.html
|
|
24
24
|
# this is cached and loaded from disk and deserialized back into a hash for performance reasons, then stored as a module
|
|
25
25
|
# level constant so it can be reused throughout the pre-assembly run as a constant
|
|
@@ -31,7 +31,7 @@ module Revs
|
|
|
31
31
|
ARCHIVE_DRUIDS={:revs=>'nt028fd5773',:roadandtrack=>'mr163sv5231'} # a hash of druids of the master archives, keys are arbitrary but druids must match the druids in DOR
|
|
32
32
|
# these druids will be used to set the archive name in each document
|
|
33
33
|
MULTI_COLLECTION_ARCHIVES=[:revs] # list the keys from the hash above for any archives that contain multiple collections (like Revs), for which each item in DOR belongs to both a parent collection and the master archive collection ... since we do not want to also add the master archive name as another collection druid to each record, we skip them
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
# these are used in the revs solr document in the main revs digital library rails app, as well as the revs-indexing-service app
|
|
36
36
|
def revs_field_mappings
|
|
37
37
|
{
|
|
@@ -60,6 +60,7 @@ module Revs
|
|
|
60
60
|
:current_owner=>{:field=>'current_owner_tsi', :weight => 1},
|
|
61
61
|
:entrant=>{:field=>'entrant_ssim', :multi_valued => true, :weight => 1},
|
|
62
62
|
:venue=>{:field=>'venue_ssi'},
|
|
63
|
+
:engine_type=>{:field=>'engine_type_ssi'},
|
|
63
64
|
:track=>{:field=>'track_ssi', :weight => 1},
|
|
64
65
|
:event=>{:field=>'event_ssi'},
|
|
65
66
|
:group_class=>{:field=>'group_class_tsi', :weight => 1},
|
|
@@ -73,15 +74,15 @@ module Revs
|
|
|
73
74
|
:score=>{:field=>'score_isi', :editstore=>false},
|
|
74
75
|
:timestamp=>{:field=>'timestamp', :editstore=>false},
|
|
75
76
|
:resaved_at=>{:field=>'resaved_at_ssi', :editstore=>false}
|
|
76
|
-
}
|
|
77
|
-
end
|
|
77
|
+
}
|
|
78
|
+
end
|
|
78
79
|
|
|
79
80
|
# these are used in the revs solr document in the main revs digital library rails app, as well as the revs-indexing-service app
|
|
80
81
|
def revs_location(doc_hash)
|
|
81
82
|
doc_hash=doc_hash.with_indifferent_access
|
|
82
83
|
[doc_hash[:city_sections_ssi],doc_hash[:cities_ssi],doc_hash[:states_ssi],doc_hash[:countries_ssi]].reject(&:blank?).join(', ')
|
|
83
|
-
end
|
|
84
|
-
|
|
84
|
+
end
|
|
85
|
+
|
|
85
86
|
# these are used in the revs solr document in the main revs digital library rails app, as well as the revs-indexing-service app
|
|
86
87
|
def revs_compute_score(doc_hash)
|
|
87
88
|
|
|
@@ -100,80 +101,80 @@ module Revs
|
|
|
100
101
|
location_weight = 3
|
|
101
102
|
total_weights += location_weight
|
|
102
103
|
total_score += (location_score * location_weight)
|
|
103
|
-
|
|
104
|
+
|
|
104
105
|
return ((total_score/total_weights)*100).ceil
|
|
105
106
|
|
|
106
107
|
end
|
|
107
108
|
|
|
108
109
|
# tells you if have a blank value or an array that has just blank values
|
|
109
110
|
def blank_value?(value)
|
|
110
|
-
value.class == Array ? !value.delete_if(&:blank?).any? : value.blank?
|
|
111
|
+
value.class == Array ? !value.delete_if(&:blank?).any? : value.blank?
|
|
111
112
|
end
|
|
112
|
-
|
|
113
|
+
|
|
113
114
|
def revs_known_formats
|
|
114
115
|
get_manifest_section(FORMATS)
|
|
115
116
|
end
|
|
116
|
-
|
|
117
|
+
|
|
117
118
|
def get_manifest_section(section)
|
|
118
119
|
return REVS_MANIFEST_HEADERS[section]
|
|
119
120
|
end
|
|
120
|
-
|
|
121
|
+
|
|
121
122
|
def manifest_headers_file()
|
|
122
123
|
return REVS_MANIFEST_HEADERS_FILE
|
|
123
124
|
end
|
|
124
|
-
|
|
125
|
+
|
|
125
126
|
def manifest_headers_path()
|
|
126
127
|
return MAINFEST_HEADERS_FILEPATH
|
|
127
128
|
end
|
|
128
|
-
|
|
129
|
+
|
|
129
130
|
def manifest_register_section_name()
|
|
130
131
|
return REGISTER
|
|
131
132
|
end
|
|
132
|
-
|
|
133
|
+
|
|
133
134
|
def manifest_metadata_section_name()
|
|
134
135
|
return METADATA
|
|
135
136
|
end
|
|
136
|
-
|
|
137
|
+
|
|
137
138
|
def read_csv_with_headers(file)
|
|
138
139
|
# load CSV into an array of hashes, allowing UTF-8 to pass through, deleting blank columns
|
|
139
|
-
#file_contents = IO.read(file).force_encoding("ISO-8859-1").encode("utf-8", replace: nil)
|
|
140
|
+
#file_contents = IO.read(file).force_encoding("ISO-8859-1").encode("utf-8", replace: nil)
|
|
140
141
|
file_contents = IO.read(file)
|
|
141
142
|
csv = CSV.parse(file_contents, :headers => true)
|
|
142
143
|
return csv.map { |row| row.to_hash.with_indifferent_access }
|
|
143
144
|
end
|
|
144
|
-
|
|
145
|
-
#Pass this function a list of all CSVs containing metadata for files you are about to register and it will ensure each sourceid is unique
|
|
145
|
+
|
|
146
|
+
#Pass this function a list of all CSVs containing metadata for files you are about to register and it will ensure each sourceid is unique
|
|
146
147
|
def unique_source_ids(file_paths)
|
|
147
148
|
files = Array.new
|
|
148
149
|
file_paths.each do |fp|
|
|
149
150
|
files << read_csv_with_headers(fp)
|
|
150
151
|
end
|
|
151
|
-
|
|
152
|
+
|
|
152
153
|
sources = Array.new
|
|
153
154
|
files.each do |file|
|
|
154
155
|
file.each do |row|
|
|
155
156
|
#Make sure the sourceid and filename are the same
|
|
156
157
|
fname = row[get_manifest_section(REGISTER)['filename']].chomp(File.extname(row[get_manifest_section(REGISTER)['filename']]))
|
|
157
|
-
return false if ((row[get_manifest_section(REGISTER)['sourceid']] != fname) || ((/\s/ =~ row[get_manifest_section(REGISTER)['sourceid']].strip) != nil))
|
|
158
|
+
return false if ((row[get_manifest_section(REGISTER)['sourceid']] != fname) || ((/\s/ =~ row[get_manifest_section(REGISTER)['sourceid']].strip) != nil))
|
|
158
159
|
sources << row[get_manifest_section(REGISTER)['sourceid']]
|
|
159
|
-
end
|
|
160
|
+
end
|
|
160
161
|
end
|
|
161
162
|
return sources.uniq.size == sources.size
|
|
162
|
-
|
|
163
|
+
|
|
163
164
|
end
|
|
164
|
-
|
|
165
|
+
|
|
165
166
|
#Pass this function a CSV file and it will return true if the proper headers are there and each entry has the required fields filled in
|
|
166
167
|
def valid_to_register(file_path)
|
|
167
168
|
file = read_csv_with_headers(file_path)
|
|
168
169
|
return check_valid_to_register(file)
|
|
169
170
|
end
|
|
170
|
-
|
|
171
|
-
#Pass this function a CSV file and it will return true if the proper headers are there and each entry has the required fields filled in.
|
|
171
|
+
|
|
172
|
+
#Pass this function a CSV file and it will return true if the proper headers are there and each entry has the required fields filled in.
|
|
172
173
|
def valid_for_metadata(file_path)
|
|
173
174
|
file = read_csv_with_headers(file_path)
|
|
174
175
|
return check_headers(file)
|
|
175
176
|
end
|
|
176
|
-
|
|
177
|
+
|
|
177
178
|
# 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
|
|
178
179
|
def check_valid_to_register(csv_data)
|
|
179
180
|
#Make sure all the required headers are there
|
|
@@ -186,27 +187,27 @@ module Revs
|
|
|
186
187
|
#Make sure all files have entries for those required headers
|
|
187
188
|
csv_data.each do |row|
|
|
188
189
|
get_manifest_section(REGISTER).keys.each do |header| # label should be there as a column but does not always need a value
|
|
189
|
-
if header.downcase !='label' && row[header].blank?
|
|
190
|
+
if header.downcase !='label' && row[header].blank?
|
|
190
191
|
puts "#{row[get_manifest_section(REGISTER)['sourceid']]} does not have a value for a required registration field"
|
|
191
192
|
result2=false
|
|
192
193
|
end
|
|
193
194
|
end
|
|
194
195
|
fname = row[get_manifest_section(REGISTER)['filename']].chomp(File.extname(row[get_manifest_section(REGISTER)['filename']]))
|
|
195
|
-
if ((row[get_manifest_section(REGISTER)['sourceid']] != fname) || ((/\s/ =~ row[get_manifest_section(REGISTER)['sourceid']].strip) != nil))
|
|
196
|
-
puts "#{row[get_manifest_section(REGISTER)['sourceid']]} does not match the filename or has a space in it"
|
|
196
|
+
if ((row[get_manifest_section(REGISTER)['sourceid']] != fname) || ((/\s/ =~ row[get_manifest_section(REGISTER)['sourceid']].strip) != nil))
|
|
197
|
+
puts "#{row[get_manifest_section(REGISTER)['sourceid']]} does not match the filename or has a space in it"
|
|
197
198
|
result3=false
|
|
198
199
|
end
|
|
199
200
|
sources << row[get_manifest_section(REGISTER)['sourceid']]
|
|
200
201
|
end
|
|
201
202
|
result4 = (sources.uniq.size == sources.size)
|
|
202
203
|
unless result4
|
|
203
|
-
puts "sourceIDs are not all unique"
|
|
204
|
+
puts "sourceIDs are not all unique"
|
|
204
205
|
puts sources.uniq.map { | e | [sources.count(e), e] }.select { | c, _ | c > 1 }.sort.reverse.map { | c, e | "#{e}: #{c}" } # show all non-unique sourceIDs and their frequency
|
|
205
206
|
end
|
|
206
207
|
return (result1 && result2 && result3 && result4)
|
|
207
|
-
|
|
208
|
+
|
|
208
209
|
end
|
|
209
|
-
|
|
210
|
+
|
|
210
211
|
# looks at certain metadata fields in manifest to confirm validity (such as dates and formats)
|
|
211
212
|
def check_metadata(csv_data)
|
|
212
213
|
bad_rows=0
|
|
@@ -214,20 +215,20 @@ module Revs
|
|
|
214
215
|
valid_date=revs_is_valid_datestring?(row[get_manifest_section(METADATA)['year']] || row[get_manifest_section(METADATA)['date']])
|
|
215
216
|
valid_format=revs_is_valid_format?(row[get_manifest_section(METADATA)['format']])
|
|
216
217
|
unless (valid_date && valid_format)
|
|
217
|
-
bad_rows+=1
|
|
218
|
+
bad_rows+=1
|
|
218
219
|
puts "#{row[get_manifest_section(REGISTER)['sourceid']]} has a bad year/date or format"
|
|
219
220
|
end
|
|
220
221
|
end
|
|
221
222
|
return bad_rows
|
|
222
223
|
end
|
|
223
|
-
|
|
224
|
+
|
|
224
225
|
# pass in csv data from a file read in and it will tell you if the headers are valid
|
|
225
226
|
def check_headers(csv_data)
|
|
226
|
-
|
|
227
|
+
|
|
227
228
|
result1=result2=true
|
|
228
229
|
file_headers=csv_data[0].keys.reject(&:blank?).collect(&:downcase)
|
|
229
230
|
#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
|
|
230
|
-
if file_headers.include?('date') && file_headers.include?('year') # can't have both date and year
|
|
231
|
+
if file_headers.include?('date') && file_headers.include?('year') # can't have both date and year
|
|
231
232
|
puts "has both year and date columns"
|
|
232
233
|
result1=false
|
|
233
234
|
end
|
|
@@ -239,11 +240,11 @@ module Revs
|
|
|
239
240
|
has_extra_columns = (extra_columns == [])
|
|
240
241
|
puts "has unknown columns: #{extra_columns.join(', ')}" unless has_extra_columns
|
|
241
242
|
result3 = has_extra_columns
|
|
242
|
-
|
|
243
|
+
|
|
243
244
|
return (result1 && result2 && result3)
|
|
244
|
-
|
|
245
|
+
|
|
245
246
|
end
|
|
246
|
-
|
|
247
|
+
|
|
247
248
|
def clean_collection_name(name)
|
|
248
249
|
return "" if name.blank? || name.nil?
|
|
249
250
|
name=name.to_s
|
|
@@ -262,12 +263,12 @@ module Revs
|
|
|
262
263
|
name.gsub!(/(automobile)\z/i,'')
|
|
263
264
|
return name.strip
|
|
264
265
|
end
|
|
265
|
-
|
|
266
|
+
|
|
266
267
|
def parse_location(row, location)
|
|
267
268
|
row[location].split(/[,|]/).reverse.each do |local|
|
|
268
269
|
country = revs_get_country(local)
|
|
269
|
-
city_state = revs_get_city_state(local)
|
|
270
|
-
row['country'] = country.strip if country
|
|
270
|
+
city_state = revs_get_city_state(local)
|
|
271
|
+
row['country'] = country.strip if country
|
|
271
272
|
if city_state
|
|
272
273
|
row['state'] = revs_get_state_name(city_state[1].strip)
|
|
273
274
|
row['city'] = city_state[0].strip
|
|
@@ -286,12 +287,12 @@ module Revs
|
|
|
286
287
|
formats=format.split("|").collect{|f| f.strip}
|
|
287
288
|
!formats.collect {|f| revs_known_formats.include?(f)}.uniq.include?(false)
|
|
288
289
|
end
|
|
289
|
-
|
|
290
|
+
|
|
290
291
|
# check a single format and fix some common issues
|
|
291
292
|
def revs_check_format(format)
|
|
292
293
|
return revs_check_formats([format]).first
|
|
293
294
|
end
|
|
294
|
-
|
|
295
|
+
|
|
295
296
|
# check the incoming array of formats and fix some common issues
|
|
296
297
|
def revs_check_formats(format)
|
|
297
298
|
known_fixes = {"black-and-white negative"=>"black-and-white negatives",
|
|
@@ -300,14 +301,14 @@ module Revs
|
|
|
300
301
|
"color negatives/slides"=>"color negatives",
|
|
301
302
|
"black-and-white negative strips"=>"black-and-white negatives",
|
|
302
303
|
"black and white"=>"black-and-white negatives",
|
|
303
|
-
"black-and-white"=>"black-and-white negatives",
|
|
304
|
+
"black-and-white"=>"black-and-white negatives",
|
|
304
305
|
"black and white negative"=>"black-and-white negatives",
|
|
305
306
|
"black and white negatives"=>"black-and-white negatives",
|
|
306
307
|
"color transparency"=>"color transparencies",
|
|
307
308
|
"slide"=>"slides",
|
|
308
309
|
"color transparancies"=>"color transparencies"
|
|
309
310
|
}
|
|
310
|
-
count = 0
|
|
311
|
+
count = 0
|
|
311
312
|
format.each do |f|
|
|
312
313
|
format[count] = known_fixes[f.downcase] || f.downcase
|
|
313
314
|
count += 1
|
|
@@ -320,8 +321,8 @@ module Revs
|
|
|
320
321
|
result=false
|
|
321
322
|
variants1=[marque,marque.capitalize,marque.singularize,marque.pluralize,marque.capitalize.singularize,marque.capitalize.pluralize]
|
|
322
323
|
variants2=[]
|
|
323
|
-
variants1.each do |name|
|
|
324
|
-
variants2 << "#{name} automobile"
|
|
324
|
+
variants1.each do |name|
|
|
325
|
+
variants2 << "#{name} automobile"
|
|
325
326
|
variants2 << "#{name} automobiles"
|
|
326
327
|
end
|
|
327
328
|
(variants1+variants2).each do |variant|
|
|
@@ -339,7 +340,7 @@ module Revs
|
|
|
339
340
|
name='US' if name=='USA' # special case; USA is not recognized by the country gem, but US is
|
|
340
341
|
country=Country.find_country_by_name(name.strip) # find it by name
|
|
341
342
|
code=Country.new(name.strip) # find it by code
|
|
342
|
-
if country.nil? && code.data.nil?
|
|
343
|
+
if country.nil? && code.data.nil?
|
|
343
344
|
return false
|
|
344
345
|
else
|
|
345
346
|
return (code.data.nil? ? country.name : code.name)
|
|
@@ -385,7 +386,7 @@ module Revs
|
|
|
385
386
|
is_year=!parse_years(date_string).empty?
|
|
386
387
|
return is_year || is_full_date
|
|
387
388
|
end
|
|
388
|
-
|
|
389
|
+
|
|
389
390
|
# tell us if the string passed is in is a full date of the format M/D/YYYY or m-d-yyyy or m-d-yy or M/D/YY, and returns the date object if it is valid
|
|
390
391
|
def get_full_date(date_string)
|
|
391
392
|
begin
|
|
@@ -413,7 +414,7 @@ module Revs
|
|
|
413
414
|
if year.scan(/[1-2][0-9][0-9][0-9][-][0-9][0-9]/).size > 0 && year.size == 7 # if we have a year that looks like "1961-62" or "1961-73", lets deal with it turning it into [1961,1962] or [1961,1962,1963,1964,1965,1966,1967...etc]
|
|
414
415
|
start_year=year[2..3]
|
|
415
416
|
end_year=year[5..6]
|
|
416
|
-
stem=year[0..1]
|
|
417
|
+
stem=year[0..1]
|
|
417
418
|
for n in start_year..end_year
|
|
418
419
|
years_to_add << "#{stem}#{n}"
|
|
419
420
|
end
|
data/revs-utils.gemspec
CHANGED
|
@@ -22,9 +22,9 @@ Gem::Specification.new do |gem|
|
|
|
22
22
|
gem.add_dependency "rdf"
|
|
23
23
|
gem.add_dependency "actionpack", '>= 4.1.6'
|
|
24
24
|
gem.add_dependency "chronic"
|
|
25
|
+
gem.add_dependency "rake"
|
|
25
26
|
|
|
26
27
|
gem.add_development_dependency "rspec", "~> 2.6"
|
|
27
|
-
gem.add_development_dependency "lyberteam-gems-devel", "> 1.0.0"
|
|
28
28
|
gem.add_development_dependency "yard"
|
|
29
29
|
|
|
30
30
|
end
|
data/spec/revs-utils_spec.rb
CHANGED
|
@@ -3,9 +3,9 @@ require 'spec_helper'
|
|
|
3
3
|
describe "Revs-Utils" do
|
|
4
4
|
|
|
5
5
|
before(:each) do
|
|
6
|
-
|
|
7
|
-
@revs=RevsUtilsTester.new # a class defined in the spec_helper which includes the module methods we need to test
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
@revs=RevsUtilsTester.new # a class defined in the spec_helper which includes the module methods we need to test
|
|
8
|
+
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
it "should clean up collection names" do
|
|
@@ -20,13 +20,13 @@ describe "Revs-Utils" do
|
|
|
20
20
|
@revs.clean_collection_name('The Dugdale Collection of the Revs Institute').should == 'Dugdale Collection'
|
|
21
21
|
@revs.clean_collection_name('the Dugdale Collection of the revs institute').should == 'Dugdale Collection'
|
|
22
22
|
@revs.clean_collection_name('Dugdale Collection of the Revs Institute').should == 'Dugdale Collection'
|
|
23
|
-
@revs.clean_collection_name('Dugdale Collection OF THE REVS INSTITUTE').should == 'Dugdale Collection'
|
|
24
|
-
@revs.clean_collection_name('Dugdale Collection of The Revs Institute').should == 'Dugdale Collection'
|
|
25
|
-
@revs.clean_collection_name('Dugdale Collection of the Revs institute for Automotive Research, Inc.').should == 'Dugdale Collection'
|
|
23
|
+
@revs.clean_collection_name('Dugdale Collection OF THE REVS INSTITUTE').should == 'Dugdale Collection'
|
|
24
|
+
@revs.clean_collection_name('Dugdale Collection of The Revs Institute').should == 'Dugdale Collection'
|
|
25
|
+
@revs.clean_collection_name('Dugdale Collection of the Revs institute for Automotive Research, Inc.').should == 'Dugdale Collection'
|
|
26
26
|
@revs.clean_collection_name('Dugdale Collection of the Revs Institute for Automotive Research, Inc').should == 'Dugdale Collection'
|
|
27
|
-
@revs.clean_collection_name('Dugdale Collection of Some Other Institute for Automotive Research, Inc').should == 'Dugdale Collection of Some Other Institute for Automotive Research, Inc'
|
|
28
|
-
@revs.clean_collection_name('Revs Institute Dugdale Collection of the Revs Institute').should == 'Revs Institute Dugdale Collection'
|
|
29
|
-
@revs.clean_collection_name('of the Revs Institute The Dugdale Collection of the Revs Institute').should == 'of the Revs Institute The Dugdale Collection'
|
|
27
|
+
@revs.clean_collection_name('Dugdale Collection of Some Other Institute for Automotive Research, Inc').should == 'Dugdale Collection of Some Other Institute for Automotive Research, Inc'
|
|
28
|
+
@revs.clean_collection_name('Revs Institute Dugdale Collection of the Revs Institute').should == 'Revs Institute Dugdale Collection'
|
|
29
|
+
@revs.clean_collection_name('of the Revs Institute The Dugdale Collection of the Revs Institute').should == 'of the Revs Institute The Dugdale Collection'
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
it "should clean up marque names" do
|
|
@@ -40,7 +40,7 @@ describe "Revs-Utils" do
|
|
|
40
40
|
@revs.clean_marque_name('ford automobile').should == 'ford'
|
|
41
41
|
@revs.clean_marque_name('ford').should == 'ford'
|
|
42
42
|
end
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
it "should parse locations" do
|
|
45
45
|
row={'other'=>'value','location'=>'123 Street | Palo Alto | United States'}
|
|
46
46
|
@revs.parse_location(row,'location').should == row.merge('city_section'=>'123 Street ','country'=>'United States')
|
|
@@ -50,7 +50,7 @@ describe "Revs-Utils" do
|
|
|
50
50
|
row={'other'=>'value','location'=>'Paris, France'}
|
|
51
51
|
@revs.parse_location(row,'location').should == row.merge('city_section'=>'Paris','country'=>'France')
|
|
52
52
|
end
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
it "should lookup marques" do
|
|
55
55
|
@revs.revs_lookup_marque('Ford').should == {"url"=>"http://id.loc.gov/authorities/subjects/sh85050464", "value"=>"Ford automobile"}
|
|
56
56
|
@revs.revs_lookup_marque('Fords').should == {"url"=>"http://id.loc.gov/authorities/subjects/sh85050464", "value"=>"Ford automobile"}
|
|
@@ -59,35 +59,35 @@ describe "Revs-Utils" do
|
|
|
59
59
|
@revs.revs_lookup_marque('Bogus').should be_falsey
|
|
60
60
|
@revs.revs_lookup_marque('').should be_falsey
|
|
61
61
|
end
|
|
62
|
-
|
|
63
|
-
it "should clean up some common format errors from an array" do
|
|
62
|
+
|
|
63
|
+
it "should clean up some common format errors from an array" do
|
|
64
64
|
@revs.revs_check_formats(['black-and-white negative','color negative','leave alone']).should == ['black-and-white negatives','color negatives','leave alone']
|
|
65
65
|
@revs.revs_check_formats(['black and white','color negative','black-and-white negative']).should == ['black-and-white negatives','color negatives','black-and-white negatives']
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
it "should clean up some common format errors from a string" do
|
|
68
|
+
it "should clean up some common format errors from a string" do
|
|
69
69
|
@revs.revs_check_format('black-and-white negative').should == 'black-and-white negatives'
|
|
70
70
|
@revs.revs_check_format('leave alone').should == 'leave alone'
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
it "should clean up some common format errors from that are uppercase and then lower case everything" do
|
|
73
|
+
it "should clean up some common format errors from that are uppercase and then lower case everything" do
|
|
74
74
|
@revs.revs_check_format('Color Transparency').should == 'color transparencies'
|
|
75
75
|
@revs.revs_check_format('Leave Alone').should == 'leave alone'
|
|
76
76
|
end
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
it "should indicate if a date is valid" do
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
# formats that are ok
|
|
81
81
|
@revs.get_full_date('5/1/1959').should == Date.strptime("5/1/1959", '%m/%d/%Y')
|
|
82
82
|
@revs.get_full_date('5-1-1959').should == Date.strptime("5/1/1959", '%m/%d/%Y')
|
|
83
83
|
@revs.get_full_date('5-1-2014').should == Date.strptime("5/1/2014", '%m/%d/%Y')
|
|
84
|
-
@revs.get_full_date('5-1-59').should == Date.strptime("5/1/1959", '%m/%d/%Y')
|
|
85
|
-
@revs.get_full_date('1/1/71').should == Date.strptime("1/1/1971", '%m/%d/%Y')
|
|
86
|
-
@revs.get_full_date('5-1-14').should == Date.strptime("5/1/2014", '%m/%d/%Y')
|
|
87
|
-
@revs.get_full_date('5-1-21').should == Date.strptime("5/1/1921", '%m/%d/%Y')
|
|
88
|
-
@revs.get_full_date('1966-02-27').should == Date.strptime("2/27/1966", '%m/%d/%Y')
|
|
89
|
-
@revs.get_full_date('1966-2-5').should == Date.strptime("2/5/1966", '%m/%d/%Y')
|
|
90
|
-
|
|
84
|
+
@revs.get_full_date('5-1-59').should == Date.strptime("5/1/1959", '%m/%d/%Y')
|
|
85
|
+
@revs.get_full_date('1/1/71').should == Date.strptime("1/1/1971", '%m/%d/%Y')
|
|
86
|
+
@revs.get_full_date('5-1-14').should == Date.strptime("5/1/2014", '%m/%d/%Y')
|
|
87
|
+
@revs.get_full_date('5-1-21').should == Date.strptime("5/1/1921", '%m/%d/%Y')
|
|
88
|
+
@revs.get_full_date('1966-02-27').should == Date.strptime("2/27/1966", '%m/%d/%Y')
|
|
89
|
+
@revs.get_full_date('1966-2-5').should == Date.strptime("2/5/1966", '%m/%d/%Y')
|
|
90
|
+
|
|
91
91
|
# bad full dates
|
|
92
92
|
@revs.get_full_date('1966-14-11').should be_falsey# bad month
|
|
93
93
|
@revs.get_full_date('1966\4\11').should be_falsey# slashes are the wrong way
|
|
@@ -111,15 +111,15 @@ describe "Revs-Utils" do
|
|
|
111
111
|
|
|
112
112
|
it "should indicate if we have unknown formats" do
|
|
113
113
|
@revs.revs_is_valid_format?(nil).should be_truthy
|
|
114
|
-
@revs.revs_is_valid_format?('').should be_truthy
|
|
114
|
+
@revs.revs_is_valid_format?('').should be_truthy
|
|
115
115
|
@revs.revs_is_valid_format?('slides').should be_truthy
|
|
116
116
|
@revs.revs_is_valid_format?('slide').should be_falsey
|
|
117
117
|
@revs.revs_is_valid_format?('slides | slide').should be_falsey
|
|
118
118
|
@revs.revs_is_valid_format?('slides | black-and-white negatives').should be_truthy
|
|
119
119
|
@revs.revs_is_valid_format?('black-and-white-negatives').should be_falsey
|
|
120
|
-
@revs.revs_is_valid_format?('black-and-white negatives').should be_truthy
|
|
120
|
+
@revs.revs_is_valid_format?('black-and-white negatives').should be_truthy
|
|
121
121
|
end
|
|
122
|
-
|
|
122
|
+
|
|
123
123
|
it "should indicate if we have a valid datestring" do
|
|
124
124
|
@revs.revs_is_valid_datestring?('1959').should be_truthy
|
|
125
125
|
@revs.revs_is_valid_datestring?('bogus').should be_falsey
|
|
@@ -130,8 +130,8 @@ describe "Revs-Utils" do
|
|
|
130
130
|
@revs.revs_is_valid_datestring?('2/31/1950').should be_falsey
|
|
131
131
|
@revs.revs_is_valid_datestring?('2/2/50').should be_truthy
|
|
132
132
|
@revs.revs_is_valid_datestring?('195x').should be_truthy
|
|
133
|
-
end
|
|
134
|
-
|
|
133
|
+
end
|
|
134
|
+
|
|
135
135
|
it "should lookup the country correctly" do
|
|
136
136
|
@revs.revs_get_country('USA').should == "United States"
|
|
137
137
|
@revs.revs_get_country('US').should == "United States"
|
|
@@ -149,100 +149,94 @@ describe "Revs-Utils" do
|
|
|
149
149
|
it "should lookup a state correctly" do
|
|
150
150
|
@revs.revs_get_state_name('Calif').should == "California"
|
|
151
151
|
@revs.revs_get_state_name('Calif.').should == "California"
|
|
152
|
-
@revs.revs_get_state_name('calif').should == "California"
|
|
153
|
-
@revs.revs_get_state_name('Ind').should == "Indiana"
|
|
152
|
+
@revs.revs_get_state_name('calif').should == "California"
|
|
153
|
+
@revs.revs_get_state_name('Ind').should == "Indiana"
|
|
154
154
|
@revs.revs_get_state_name('Bogus').should == "Bogus"
|
|
155
|
-
@revs.revs_get_state_name('IN').should == "Indiana"
|
|
156
|
-
@revs.revs_get_state_name('IN').should == "Indiana"
|
|
155
|
+
@revs.revs_get_state_name('IN').should == "Indiana"
|
|
156
|
+
@revs.revs_get_state_name('IN').should == "Indiana"
|
|
157
157
|
end
|
|
158
|
-
|
|
158
|
+
|
|
159
159
|
it "should parse locations" do
|
|
160
160
|
@revs.revs_location({:cities_ssi=>'Paris',:countries_ssi=>'France'}).should == 'Paris, France'
|
|
161
161
|
@revs.revs_location({:id=>'123',:title_tsi=>'Test'}).should == ''
|
|
162
162
|
@revs.revs_location({:city_sections_ssi=>'Rue Cool 123',:cities_ssi=>'Paris',:countries_ssi=>'France'}).should == 'Rue Cool 123, Paris, France'
|
|
163
163
|
@revs.revs_location({:city_sections_ssi=>'Cool Street',:cities_ssi=>'Paris',:states_ssi=>'Texas',:countries_ssi=>'USA'}).should == 'Cool Street, Paris, Texas, USA'
|
|
164
164
|
end
|
|
165
|
-
|
|
165
|
+
|
|
166
166
|
it "should parse 1950s and 1950's correctly" do
|
|
167
|
-
|
|
168
|
-
@revs.parse_years('1950s').should == ['1950','1951','1952','1953','1954','1955','1956','1957','1958','1959']
|
|
169
|
-
@revs.parse_years("1950's").should == ['1950','1951','1952','1953','1954','1955','1956','1957','1958','1959']
|
|
170
|
-
|
|
167
|
+
|
|
168
|
+
@revs.parse_years('1950s').should == ['1950','1951','1952','1953','1954','1955','1956','1957','1958','1959']
|
|
169
|
+
@revs.parse_years("1950's").should == ['1950','1951','1952','1953','1954','1955','1956','1957','1958','1959']
|
|
170
|
+
|
|
171
171
|
end
|
|
172
172
|
|
|
173
173
|
it "should parse 1955-57 correctly" do
|
|
174
|
-
|
|
175
|
-
@revs.parse_years('1955-57').should == ['1955','1956','1957']
|
|
176
|
-
|
|
174
|
+
|
|
175
|
+
@revs.parse_years('1955-57').should == ['1955','1956','1957']
|
|
176
|
+
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
it "should parse 1955 | 1955 and not produce a duplicate year" do
|
|
180
|
-
|
|
181
|
-
@revs.parse_years('1955|1955').should == ['1955']
|
|
182
|
-
|
|
180
|
+
|
|
181
|
+
@revs.parse_years('1955|1955').should == ['1955']
|
|
182
|
+
|
|
183
183
|
end
|
|
184
184
|
|
|
185
185
|
it "should parse 1955-1957 | 1955-1957 and not produce duplicate years" do
|
|
186
|
-
|
|
187
|
-
@revs.parse_years('1955-1957 | 1955-1957').should == ['1955','1956','1957']
|
|
188
|
-
|
|
189
|
-
end
|
|
190
186
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
@revs.parse_years('1800-1802').should == ['1800','1801','1802']
|
|
194
|
-
|
|
187
|
+
@revs.parse_years('1955-1957 | 1955-1957').should == ['1955','1956','1957']
|
|
188
|
+
|
|
195
189
|
end
|
|
196
|
-
|
|
190
|
+
|
|
197
191
|
it "should parse 1955-1957 | 1955 | 1955 and not produce duplicate years" do
|
|
198
|
-
|
|
199
|
-
@revs.parse_years('1955-1957 | 1955 | 1955').should == ['1955','1956','1957']
|
|
200
|
-
|
|
192
|
+
|
|
193
|
+
@revs.parse_years('1955-1957 | 1955 | 1955').should == ['1955','1956','1957']
|
|
194
|
+
|
|
201
195
|
end
|
|
202
196
|
|
|
203
197
|
it "should parse 1955-1957 | 1955 | 1954 and not produce duplicate years" do
|
|
204
|
-
|
|
205
|
-
@revs.parse_years('1955-1957 | 1955 | 1954').should == ['1954','1955','1956','1957']
|
|
206
|
-
|
|
198
|
+
|
|
199
|
+
@revs.parse_years('1955-1957 | 1955 | 1954').should == ['1954','1955','1956','1957']
|
|
200
|
+
|
|
207
201
|
end
|
|
208
202
|
|
|
209
203
|
it "should parse 1800-1802" do
|
|
210
|
-
|
|
211
|
-
@revs.parse_years('1800-1802').should == ['1800','1801','1802']
|
|
212
|
-
|
|
204
|
+
|
|
205
|
+
@revs.parse_years('1800-1802').should == ['1800','1801','1802']
|
|
206
|
+
|
|
213
207
|
end
|
|
214
|
-
|
|
208
|
+
|
|
215
209
|
it "should parse 1955-1957 correctly" do
|
|
216
|
-
|
|
217
|
-
@revs.parse_years('1955-1957').should == ['1955','1956','1957']
|
|
218
|
-
|
|
210
|
+
|
|
211
|
+
@revs.parse_years('1955-1957').should == ['1955','1956','1957']
|
|
212
|
+
|
|
219
213
|
end
|
|
220
|
-
|
|
214
|
+
|
|
221
215
|
it "should be able to read the manifest headers file and load it as a hash" do
|
|
222
216
|
file_status = File.exists? @revs.manifest_headers_file()
|
|
223
|
-
file_status.should == true
|
|
224
|
-
|
|
217
|
+
file_status.should == true
|
|
218
|
+
|
|
225
219
|
YAML.load(File.open(@revs.manifest_headers_file())).class.should == Hash
|
|
226
220
|
end
|
|
227
|
-
|
|
221
|
+
|
|
228
222
|
it "should have a list of headers required for registration in the manifest headers file" do
|
|
229
223
|
@revs.get_manifest_section(@revs.manifest_register_section_name()).size.should > 0
|
|
230
224
|
(@revs.get_manifest_section(@revs.manifest_register_section_name()).keys - ["sourceid", "label", "filename"]).should == [] #headers required to register
|
|
231
225
|
end
|
|
232
|
-
|
|
226
|
+
|
|
233
227
|
it "should have a list of headers required for metadata updating in the manifest headers file" do
|
|
234
228
|
@revs.get_manifest_section(@revs.manifest_metadata_section_name()).size.should > 0
|
|
235
229
|
(@revs.get_manifest_section(@revs.manifest_metadata_section_name()).keys - ["marque", "model", "people", "entrant", "photographer", "current_owner", "venue", "track", "event",
|
|
236
230
|
"location", "year", "description", "model_year", "model_year", "group_or_class", "race_data", "metadata_sources","state", "country", "city", "date",
|
|
237
231
|
"vehicle_markings", "inst_notes", "prod_notes", "has_more_metadata", "hide", "format", "collection_name"]).should == []
|
|
238
232
|
end
|
|
239
|
-
|
|
233
|
+
|
|
240
234
|
it "should return when true when given a clean sheet to check for headers required for registration and metadata updating" do
|
|
241
235
|
sheet = Dir.pwd + "/spec/sample-csv-files/clean-sheet.csv"
|
|
242
236
|
@revs.valid_to_register(sheet).should == true
|
|
243
237
|
@revs.valid_for_metadata(sheet).should == true
|
|
244
238
|
end
|
|
245
|
-
|
|
239
|
+
|
|
246
240
|
it "should return true for registration, and should be ok for metadata if date exists instead of year" do
|
|
247
241
|
sheet = Dir.pwd + "/spec/sample-csv-files/date-instead-of-year.csv"
|
|
248
242
|
@revs.valid_to_register(sheet).should == true
|
|
@@ -253,14 +247,14 @@ describe "Revs-Utils" do
|
|
|
253
247
|
sheet = Dir.pwd + "/spec/sample-csv-files/blank-label.csv"
|
|
254
248
|
@revs.valid_to_register(sheet).should == true
|
|
255
249
|
sheet = Dir.pwd + "/spec/sample-csv-files/no-blank-label.csv"
|
|
256
|
-
@revs.valid_to_register(sheet).should == true
|
|
250
|
+
@revs.valid_to_register(sheet).should == true
|
|
257
251
|
end
|
|
258
252
|
|
|
259
253
|
it "should return false for registration if label column does not exist" do
|
|
260
254
|
sheet = Dir.pwd + "/spec/sample-csv-files/no-label-column.csv"
|
|
261
255
|
@revs.valid_to_register(sheet).should == false
|
|
262
256
|
end
|
|
263
|
-
|
|
257
|
+
|
|
264
258
|
it "should return true for registration, and should be ok for metadata even if year exists, but not date" do
|
|
265
259
|
sheet = Dir.pwd + "/spec/sample-csv-files/date-instead-of-year.csv"
|
|
266
260
|
@revs.valid_to_register(sheet).should == true
|
|
@@ -278,7 +272,7 @@ describe "Revs-Utils" do
|
|
|
278
272
|
@revs.valid_to_register(sheet).should == true
|
|
279
273
|
@revs.valid_for_metadata(sheet).should == false
|
|
280
274
|
end
|
|
281
|
-
|
|
275
|
+
|
|
282
276
|
it "should return false for registration and metadata when source_id is mislabeled" do
|
|
283
277
|
sheet = Dir.pwd + "/spec/sample-csv-files/bad-source_id.csv"
|
|
284
278
|
@revs.valid_to_register(sheet).should == false
|
|
@@ -290,22 +284,22 @@ describe "Revs-Utils" do
|
|
|
290
284
|
@revs.valid_to_register(sheet).should == false
|
|
291
285
|
@revs.valid_for_metadata(sheet).should == false
|
|
292
286
|
end
|
|
293
|
-
|
|
287
|
+
|
|
294
288
|
it "should return false when a row does not have a sourceid" do
|
|
295
289
|
sheet = Dir.pwd + "/spec/sample-csv-files/blank-sourceid.csv"
|
|
296
290
|
@revs.valid_to_register(sheet).should == false
|
|
297
291
|
end
|
|
298
|
-
|
|
292
|
+
|
|
299
293
|
it "should return true when each souceid is unique and properly formed from the filename" do
|
|
300
294
|
sheets = [Dir.pwd + "/spec/sample-csv-files/clean-sheet.csv"]
|
|
301
295
|
@revs.unique_source_ids(sheets).should == true
|
|
302
296
|
end
|
|
303
|
-
|
|
297
|
+
|
|
304
298
|
it "should return false when there are duplicate sourceids" do
|
|
305
299
|
sheets = [Dir.pwd + "/spec/sample-csv-files/clean-sheet.csv",Dir.pwd + "/spec/sample-csv-files/clean-sheet.csv"]
|
|
306
300
|
@revs.unique_source_ids(sheets).should == false
|
|
307
301
|
end
|
|
308
|
-
|
|
302
|
+
|
|
309
303
|
it "should return false when a sourceid is not properly based off the filename" do
|
|
310
304
|
sheets = [Dir.pwd + "/spec/sample-csv-files/malformed-sourceid.csv"]
|
|
311
305
|
@revs.unique_source_ids(sheets).should == false
|
|
@@ -314,7 +308,7 @@ describe "Revs-Utils" do
|
|
|
314
308
|
it "should return false when a sourceid has a space in it" do
|
|
315
309
|
sheets = [Dir.pwd + "/spec/sample-csv-files/space-sourceid.csv"]
|
|
316
310
|
@revs.unique_source_ids(sheets).should == false
|
|
317
|
-
end
|
|
318
|
-
|
|
319
|
-
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
|
|
320
314
|
end
|
data/spec/spec_helper.rb
CHANGED
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.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter Mangiafico
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-02-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: countries
|
|
@@ -28,84 +28,84 @@ dependencies:
|
|
|
28
28
|
name: rdf
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- -
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- -
|
|
38
|
+
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: actionpack
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- -
|
|
45
|
+
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
47
|
version: 4.1.6
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- -
|
|
52
|
+
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: 4.1.6
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: chronic
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- -
|
|
59
|
+
- - ">="
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
61
|
version: '0'
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- -
|
|
66
|
+
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
70
|
+
name: rake
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
|
-
- -
|
|
73
|
+
- - ">="
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
76
|
-
type: :
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
|
-
- -
|
|
80
|
+
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
82
|
+
version: '0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
84
|
+
name: rspec
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
|
-
- -
|
|
87
|
+
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version:
|
|
89
|
+
version: '2.6'
|
|
90
90
|
type: :development
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
|
-
- -
|
|
94
|
+
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version:
|
|
96
|
+
version: '2.6'
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: yard
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
|
-
- -
|
|
101
|
+
- - ">="
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
103
|
version: '0'
|
|
104
104
|
type: :development
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
|
-
- -
|
|
108
|
+
- - ">="
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
111
|
description: Shared methods and functions used by revs-indexer, pre-assembly and bulk
|
|
@@ -119,8 +119,9 @@ executables:
|
|
|
119
119
|
extensions: []
|
|
120
120
|
extra_rdoc_files: []
|
|
121
121
|
files:
|
|
122
|
-
- .gitignore
|
|
123
|
-
- .rvmrc.example
|
|
122
|
+
- ".gitignore"
|
|
123
|
+
- ".rvmrc.example"
|
|
124
|
+
- ".travis.yml"
|
|
124
125
|
- Gemfile
|
|
125
126
|
- Gemfile.lock
|
|
126
127
|
- LICENSE
|
|
@@ -159,17 +160,17 @@ require_paths:
|
|
|
159
160
|
- lib
|
|
160
161
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
161
162
|
requirements:
|
|
162
|
-
- -
|
|
163
|
+
- - ">="
|
|
163
164
|
- !ruby/object:Gem::Version
|
|
164
165
|
version: '0'
|
|
165
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
167
|
requirements:
|
|
167
|
-
- -
|
|
168
|
+
- - ">="
|
|
168
169
|
- !ruby/object:Gem::Version
|
|
169
170
|
version: '0'
|
|
170
171
|
requirements: []
|
|
171
172
|
rubyforge_project:
|
|
172
|
-
rubygems_version: 2.4.
|
|
173
|
+
rubygems_version: 2.4.6
|
|
173
174
|
signing_key:
|
|
174
175
|
specification_version: 4
|
|
175
176
|
summary: Shared methods and functions used by revs-indexer, pre-assembly and bulk
|