modsulator 1.0.7 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/modsulator.rb +21 -6
- data/spec/lib/modsulator_spec.rb +12 -4
- metadata +46 -46
- data/lib/doc/Modsulator.html +0 -725
- data/lib/doc/_index.html +0 -101
- data/lib/doc/class_list.html +0 -58
- data/lib/doc/css/common.css +0 -1
- data/lib/doc/css/full_list.css +0 -57
- data/lib/doc/css/style.css +0 -339
- data/lib/doc/file_list.html +0 -57
- data/lib/doc/frames.html +0 -26
- data/lib/doc/index.html +0 -101
- data/lib/doc/js/app.js +0 -219
- data/lib/doc/js/full_list.js +0 -181
- data/lib/doc/js/jquery.js +0 -4
- data/lib/doc/method_list.html +0 -87
- data/lib/doc/top-level-namespace.html +0 -112
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3233a0697828fef131d04c823f26e0ba4c0e6ad801866acb37b38cf6b3d41ef
|
4
|
+
data.tar.gz: 55325e212b9ead23a751873a9c08de5630ad3bb2eaf02801cb9ad55efdb805b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e6b198514ba6b636ea09fd4b69e0cbfddde9292fb30cdd05ee1a443956f5c8777ab07c743ad16c1c67cb061d00c4791c47958de7b46c14ab996084f69114b1e
|
7
|
+
data.tar.gz: ef29e80059adafba49db70c2f16669cff81a343770f4cadf2669c0590314b63ca25e37f4c1ca0802f773814ed5a36390e2fb11ce96736fe0da7858faf53d3f6c
|
data/lib/modsulator.rb
CHANGED
@@ -8,11 +8,14 @@ require 'nokogiri'
|
|
8
8
|
require 'roo'
|
9
9
|
require 'stanford/mods/normalizer'
|
10
10
|
require 'modsulator/modsulator_sheet'
|
11
|
-
|
11
|
+
require 'deprecation'
|
12
12
|
|
13
13
|
# The main class for the MODSulator API, which lets you work with metadata spreadsheets and MODS XML.
|
14
14
|
# @see https://consul.stanford.edu/display/chimera/MODS+bulk+loading Requirements (Stanford Consul page)
|
15
15
|
class Modsulator
|
16
|
+
extend Deprecation
|
17
|
+
self.deprecation_horizon = 'modsulator version 2.0.0'
|
18
|
+
|
16
19
|
# We define our own namespace for <xmlDocs>
|
17
20
|
NAMESPACE = 'http://library.stanford.edu/xmlDocs'
|
18
21
|
|
@@ -180,10 +183,22 @@ class Modsulator
|
|
180
183
|
end
|
181
184
|
|
182
185
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
186
|
+
class << self
|
187
|
+
# Returns the template spreadsheet that's built into this gem.
|
188
|
+
#
|
189
|
+
# @return [String] The template spreadsheet, in binary form.
|
190
|
+
def get_template_spreadsheet
|
191
|
+
IO.read(File.expand_path('../modsulator/modsulator_template.xlsx', __FILE__), mode: 'rb')
|
192
|
+
end
|
193
|
+
deprecation_deprecate :get_template_spreadsheet
|
194
|
+
|
195
|
+
# This can be used by modsulator-rails-app so we can do:
|
196
|
+
# send_file Modsulator.template_spreadsheet_path
|
197
|
+
# which is more memory efficient than:
|
198
|
+
# render body: Modsulator.get_template_spreadsheet
|
199
|
+
# @return [String] the path to the spreadsheet template.
|
200
|
+
def template_spreadsheet_path
|
201
|
+
File.expand_path('../modsulator/modsulator_template.xlsx', __FILE__)
|
202
|
+
end
|
188
203
|
end
|
189
204
|
end
|
data/spec/lib/modsulator_spec.rb
CHANGED
@@ -2,17 +2,25 @@ RSpec.describe Modsulator do
|
|
2
2
|
describe "#validate_headers" do
|
3
3
|
subject { Modsulator.new File.join(FIXTURES_DIR, 'test_002.csv'), 'test_002.csv', template_string: "abc def ghi"}
|
4
4
|
let(:template_xml) { "abc def ghi"}
|
5
|
-
it "
|
5
|
+
it "includes headers not in the template string" do
|
6
6
|
expect(subject.validate_headers(["abc", "phi"])).not_to include "abc"
|
7
7
|
expect(subject.validate_headers(["abc", "phi"])).to include "phi"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "#get_template_spreadsheet" do
|
12
|
-
|
13
|
-
|
12
|
+
subject { Modsulator.get_template_spreadsheet }
|
13
|
+
it "returns the correct spreadsheet" do
|
14
14
|
expected_binary_string = IO.read(File.join(File.expand_path("../../../lib/modsulator/", __FILE__), "modsulator_template.xlsx"), mode: 'rb')
|
15
|
-
expect(
|
15
|
+
expect(Deprecation).to receive(:warn)
|
16
|
+
expect(subject).to eq(expected_binary_string)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#template_spreadsheet_path" do
|
21
|
+
subject { Modsulator.template_spreadsheet_path }
|
22
|
+
it "returns the path to the spreadsheet" do
|
23
|
+
expect(subject).to eq(File.join(File.expand_path("../../../lib/modsulator/", __FILE__), "modsulator_template.xlsx"))
|
16
24
|
end
|
17
25
|
end
|
18
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modsulator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommy Ingulfsen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: roo
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: deprecation
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -161,20 +175,6 @@ files:
|
|
161
175
|
- README.md
|
162
176
|
- Rakefile
|
163
177
|
- bin/modsulator
|
164
|
-
- lib/doc/Modsulator.html
|
165
|
-
- lib/doc/_index.html
|
166
|
-
- lib/doc/class_list.html
|
167
|
-
- lib/doc/css/common.css
|
168
|
-
- lib/doc/css/full_list.css
|
169
|
-
- lib/doc/css/style.css
|
170
|
-
- lib/doc/file_list.html
|
171
|
-
- lib/doc/frames.html
|
172
|
-
- lib/doc/index.html
|
173
|
-
- lib/doc/js/app.js
|
174
|
-
- lib/doc/js/full_list.js
|
175
|
-
- lib/doc/js/jquery.js
|
176
|
-
- lib/doc/method_list.html
|
177
|
-
- lib/doc/top-level-namespace.html
|
178
178
|
- lib/modsulator.rb
|
179
179
|
- lib/modsulator/mods-3-5.xsd
|
180
180
|
- lib/modsulator/modsulator.xsd
|
@@ -243,49 +243,49 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
243
|
version: '0'
|
244
244
|
requirements: []
|
245
245
|
rubyforge_project:
|
246
|
-
rubygems_version: 2.7.
|
246
|
+
rubygems_version: 2.7.6
|
247
247
|
signing_key:
|
248
248
|
specification_version: 4
|
249
249
|
summary: Produces (Stanford) MODS XML from spreadsheets.
|
250
250
|
test_files:
|
251
|
+
- spec/spec_helper.rb
|
252
|
+
- spec/integration_tests/integration_spec.rb
|
253
|
+
- spec/features/validator_unit_spec.rb
|
251
254
|
- spec/features/modsulator_sheet_unit_spec.rb
|
252
255
|
- spec/features/process_template_spec.rb
|
253
|
-
- spec/
|
254
|
-
- spec/fixtures/ars0056_manifest.csv
|
255
|
-
- spec/fixtures/ars0056_manifest.xml
|
256
|
-
- spec/fixtures/crowdsourcing_bridget_1.xlsx
|
257
|
-
- spec/fixtures/crowdsourcing_bridget_1.xml
|
258
|
-
- spec/fixtures/crowdsourcing_bridget_2.xlsx
|
259
|
-
- spec/fixtures/crowdsourcing_bridget_2.xml
|
260
|
-
- spec/fixtures/edition_physLoc_intmediatype.xlsx
|
261
|
-
- spec/fixtures/edition_physLoc_intmediatype.xml
|
256
|
+
- spec/lib/modsulator_spec.rb
|
262
257
|
- spec/fixtures/filled_template_20160711.xlsx
|
258
|
+
- spec/fixtures/SC1049_metadata.xlsx
|
263
259
|
- spec/fixtures/filled_template_20160711.xml
|
260
|
+
- spec/fixtures/crowdsourcing_bridget_2.xlsx
|
261
|
+
- spec/fixtures/SC1049_metadata.xml
|
262
|
+
- spec/fixtures/Matter_manifest.csv
|
264
263
|
- spec/fixtures/Fitch_Chavez.xlsx
|
265
|
-
- spec/fixtures/
|
264
|
+
- spec/fixtures/crowdsourcing_bridget_2.xml
|
266
265
|
- spec/fixtures/Fitch_King.xlsx
|
266
|
+
- spec/fixtures/manifest_v0174.csv
|
267
|
+
- spec/fixtures/crowdsourcing_bridget_1.xml
|
268
|
+
- spec/fixtures/M1463_AV_manifest.xml
|
269
|
+
- spec/fixtures/roman_coins_mods.xlsx
|
270
|
+
- spec/fixtures/Fitch_Chavez.xml
|
271
|
+
- spec/fixtures/ars0056_manifest.xml
|
272
|
+
- spec/fixtures/invalid_crowdsourcing_bridget_1.xml
|
267
273
|
- spec/fixtures/Fitch_King.xml
|
268
|
-
- spec/fixtures/
|
274
|
+
- spec/fixtures/M1463_AV_manifest.xlsx
|
275
|
+
- spec/fixtures/location_url.xml
|
276
|
+
- spec/fixtures/roman_coins_mods.xml
|
277
|
+
- spec/fixtures/edition_physLoc_intmediatype.xml
|
278
|
+
- spec/fixtures/PosadaSpreadsheet.xlsx
|
269
279
|
- spec/fixtures/Heckrotte_ChartsOfCoastSurvey.xml
|
270
|
-
- spec/fixtures/
|
280
|
+
- spec/fixtures/ars0056_manifest.csv
|
281
|
+
- spec/fixtures/edition_physLoc_intmediatype.xlsx
|
282
|
+
- spec/fixtures/Heckrotte_ChartsOfCoastSurvey.xlsx
|
271
283
|
- spec/fixtures/location_url.xlsx
|
272
|
-
- spec/fixtures/
|
273
|
-
- spec/fixtures/
|
274
|
-
- spec/fixtures/
|
275
|
-
- spec/fixtures/
|
284
|
+
- spec/fixtures/PosadaSpreadsheet.xml
|
285
|
+
- spec/fixtures/point_coord_test.xml
|
286
|
+
- spec/fixtures/test_002.xlsx
|
287
|
+
- spec/fixtures/test_002.csv
|
276
288
|
- spec/fixtures/manifest_v0174.xml
|
277
|
-
- spec/fixtures/Matter_manifest.csv
|
278
289
|
- spec/fixtures/Matter_manifest.xml
|
290
|
+
- spec/fixtures/crowdsourcing_bridget_1.xlsx
|
279
291
|
- spec/fixtures/point_coord_test.xlsx
|
280
|
-
- spec/fixtures/point_coord_test.xml
|
281
|
-
- spec/fixtures/PosadaSpreadsheet.xlsx
|
282
|
-
- spec/fixtures/PosadaSpreadsheet.xml
|
283
|
-
- spec/fixtures/roman_coins_mods.xlsx
|
284
|
-
- spec/fixtures/roman_coins_mods.xml
|
285
|
-
- spec/fixtures/SC1049_metadata.xlsx
|
286
|
-
- spec/fixtures/SC1049_metadata.xml
|
287
|
-
- spec/fixtures/test_002.csv
|
288
|
-
- spec/fixtures/test_002.xlsx
|
289
|
-
- spec/integration_tests/integration_spec.rb
|
290
|
-
- spec/lib/modsulator_spec.rb
|
291
|
-
- spec/spec_helper.rb
|
data/lib/doc/Modsulator.html
DELETED
@@ -1,725 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
-
<head>
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
-
<title>
|
7
|
-
Class: Modsulator
|
8
|
-
|
9
|
-
— Documentation by YARD 0.8.7.6
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
-
|
17
|
-
<script type="text/javascript" charset="utf-8">
|
18
|
-
hasFrames = window.top.frames.main ? true : false;
|
19
|
-
relpath = '';
|
20
|
-
framesUrl = "frames.html#!Modsulator.html";
|
21
|
-
</script>
|
22
|
-
|
23
|
-
|
24
|
-
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
25
|
-
|
26
|
-
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
27
|
-
|
28
|
-
|
29
|
-
</head>
|
30
|
-
<body>
|
31
|
-
<div id="header">
|
32
|
-
<div id="menu">
|
33
|
-
|
34
|
-
<a href="_index.html">Index (M)</a> »
|
35
|
-
|
36
|
-
|
37
|
-
<span class="title">Modsulator</span>
|
38
|
-
|
39
|
-
|
40
|
-
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
-
</div>
|
42
|
-
|
43
|
-
<div id="search">
|
44
|
-
|
45
|
-
<a class="full_list_link" id="class_list_link"
|
46
|
-
href="class_list.html">
|
47
|
-
Class List
|
48
|
-
</a>
|
49
|
-
|
50
|
-
<a class="full_list_link" id="method_list_link"
|
51
|
-
href="method_list.html">
|
52
|
-
Method List
|
53
|
-
</a>
|
54
|
-
|
55
|
-
<a class="full_list_link" id="file_list_link"
|
56
|
-
href="file_list.html">
|
57
|
-
File List
|
58
|
-
</a>
|
59
|
-
|
60
|
-
</div>
|
61
|
-
<div class="clear"></div>
|
62
|
-
</div>
|
63
|
-
|
64
|
-
<iframe id="search_frame"></iframe>
|
65
|
-
|
66
|
-
<div id="content"><h1>Class: Modsulator
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
</h1>
|
71
|
-
|
72
|
-
<dl class="box">
|
73
|
-
|
74
|
-
<dt class="r1">Inherits:</dt>
|
75
|
-
<dd class="r1">
|
76
|
-
<span class="inheritName">Object</span>
|
77
|
-
|
78
|
-
<ul class="fullTree">
|
79
|
-
<li>Object</li>
|
80
|
-
|
81
|
-
<li class="next">Modsulator</li>
|
82
|
-
|
83
|
-
</ul>
|
84
|
-
<a href="#" class="inheritanceTree">show all</a>
|
85
|
-
|
86
|
-
</dd>
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
<dt class="r2 last">Defined in:</dt>
|
97
|
-
<dd class="r2 last">modsulator.rb</dd>
|
98
|
-
|
99
|
-
</dl>
|
100
|
-
<div class="clear"></div>
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
<h2>
|
111
|
-
Instance Method Summary
|
112
|
-
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
113
|
-
</h2>
|
114
|
-
|
115
|
-
<ul class="summary">
|
116
|
-
|
117
|
-
<li class="public ">
|
118
|
-
<span class="summary_signature">
|
119
|
-
|
120
|
-
<a href="#generate_normalized_mods-instance_method" title="#generate_normalized_mods (instance method)">- (Object) <strong>generate_normalized_mods</strong>(template_filename, spreadsheet_filename, output_directory) </a>
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
</span>
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
<span class="summary_desc"><div class='inline'>
|
135
|
-
<p>Generates normalized (Stanford) MODS XML, writing to files.</p>
|
136
|
-
</div></span>
|
137
|
-
|
138
|
-
</li>
|
139
|
-
|
140
|
-
|
141
|
-
<li class="public ">
|
142
|
-
<span class="summary_signature">
|
143
|
-
|
144
|
-
<a href="#generate_xml-instance_method" title="#generate_xml (instance method)">- (Object) <strong>generate_xml</strong>(mf, template_xml, row_number) </a>
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
</span>
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
<span class="summary_desc"><div class='inline'>
|
159
|
-
<p>Write XML to file.</p>
|
160
|
-
</div></span>
|
161
|
-
|
162
|
-
</li>
|
163
|
-
|
164
|
-
|
165
|
-
<li class="public ">
|
166
|
-
<span class="summary_signature">
|
167
|
-
|
168
|
-
<a href="#load_spreadsheet-instance_method" title="#load_spreadsheet (instance method)">- (Object) <strong>load_spreadsheet</strong>(filename) </a>
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
</span>
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
183
|
-
|
184
|
-
</li>
|
185
|
-
|
186
|
-
|
187
|
-
<li class="public ">
|
188
|
-
<span class="summary_signature">
|
189
|
-
|
190
|
-
<a href="#open_spreadsheet-instance_method" title="#open_spreadsheet (instance method)">- (Object) <strong>open_spreadsheet</strong>(filename) </a>
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
</span>
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
<span class="summary_desc"><div class='inline'>
|
205
|
-
<p>Open spreadsheet based on filename extension.</p>
|
206
|
-
</div></span>
|
207
|
-
|
208
|
-
</li>
|
209
|
-
|
210
|
-
|
211
|
-
<li class="public ">
|
212
|
-
<span class="summary_signature">
|
213
|
-
|
214
|
-
<a href="#validate_headers-instance_method" title="#validate_headers (instance method)">- (Array<String>) <strong>validate_headers</strong>(spreadsheet_headers, template_xml) </a>
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
</span>
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
<span class="summary_desc"><div class='inline'>
|
229
|
-
<p>Checks that all the headers in the spreadsheet has a corresponding entry in
|
230
|
-
the XML template.</p>
|
231
|
-
</div></span>
|
232
|
-
|
233
|
-
</li>
|
234
|
-
|
235
|
-
|
236
|
-
</ul>
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
<div id="instance_method_details" class="method_details_list">
|
242
|
-
<h2>Instance Method Details</h2>
|
243
|
-
|
244
|
-
|
245
|
-
<div class="method_details first">
|
246
|
-
<h3 class="signature first" id="generate_normalized_mods-instance_method">
|
247
|
-
|
248
|
-
- (<tt>Object</tt>) <strong>generate_normalized_mods</strong>(template_filename, spreadsheet_filename, output_directory)
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
</h3><div class="docstring">
|
255
|
-
<div class="discussion">
|
256
|
-
|
257
|
-
<p>Generates normalized (Stanford) MODS XML, writing to files.</p>
|
258
|
-
|
259
|
-
|
260
|
-
</div>
|
261
|
-
</div>
|
262
|
-
<div class="tags">
|
263
|
-
<p class="tag_title">Parameters:</p>
|
264
|
-
<ul class="param">
|
265
|
-
|
266
|
-
<li>
|
267
|
-
|
268
|
-
<span class='name'>template_filename</span>
|
269
|
-
|
270
|
-
|
271
|
-
<span class='type'>(<tt>String</tt>)</span>
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
—
|
276
|
-
<div class='inline'>
|
277
|
-
<p>The full path to the desired template file (a spreadsheet).</p>
|
278
|
-
</div>
|
279
|
-
|
280
|
-
</li>
|
281
|
-
|
282
|
-
<li>
|
283
|
-
|
284
|
-
<span class='name'>spreadsheet_filename</span>
|
285
|
-
|
286
|
-
|
287
|
-
<span class='type'>(<tt>String</tt>)</span>
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
—
|
292
|
-
<div class='inline'>
|
293
|
-
<p>The full path to the input spreadsheet. One XML file will be generated per
|
294
|
-
data row in this spreadsheet.</p>
|
295
|
-
</div>
|
296
|
-
|
297
|
-
</li>
|
298
|
-
|
299
|
-
<li>
|
300
|
-
|
301
|
-
<span class='name'>output_directory</span>
|
302
|
-
|
303
|
-
|
304
|
-
<span class='type'>(<tt>String</tt>)</span>
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
—
|
309
|
-
<div class='inline'>
|
310
|
-
<p>The directory where output files should be stored.</p>
|
311
|
-
</div>
|
312
|
-
|
313
|
-
</li>
|
314
|
-
|
315
|
-
</ul>
|
316
|
-
|
317
|
-
|
318
|
-
</div><table class="source_code">
|
319
|
-
<tr>
|
320
|
-
<td>
|
321
|
-
<pre class="lines">
|
322
|
-
|
323
|
-
|
324
|
-
101
|
325
|
-
102
|
326
|
-
103
|
327
|
-
104
|
328
|
-
105
|
329
|
-
106
|
330
|
-
107
|
331
|
-
108
|
332
|
-
109
|
333
|
-
110
|
334
|
-
111
|
335
|
-
112
|
336
|
-
113
|
337
|
-
114
|
338
|
-
115
|
339
|
-
116
|
340
|
-
117
|
341
|
-
118
|
342
|
-
119
|
343
|
-
120
|
344
|
-
121
|
345
|
-
122
|
346
|
-
123
|
347
|
-
124
|
348
|
-
125
|
349
|
-
126
|
350
|
-
127
|
351
|
-
128</pre>
|
352
|
-
</td>
|
353
|
-
<td>
|
354
|
-
<pre class="code"><span class="info file"># File 'modsulator.rb', line 101</span>
|
355
|
-
|
356
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_generate_normalized_mods'>generate_normalized_mods</span><span class='lparen'>(</span><span class='id identifier rubyid_template_filename'>template_filename</span><span class='comma'>,</span> <span class='id identifier rubyid_spreadsheet_filename'>spreadsheet_filename</span><span class='comma'>,</span> <span class='id identifier rubyid_output_directory'>output_directory</span><span class='rparen'>)</span>
|
357
|
-
|
358
|
-
<span class='id identifier rubyid_spreadsheet_rows'>spreadsheet_rows</span> <span class='op'>=</span> <span class='id identifier rubyid_load_spreadsheet'>load_spreadsheet</span><span class='lparen'>(</span><span class='id identifier rubyid_spreadsheet_filename'>spreadsheet_filename</span><span class='rparen'>)</span>
|
359
|
-
<span class='id identifier rubyid_mods_template_xml'>mods_template_xml</span> <span class='op'>=</span> <span class='const'>IO</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='id identifier rubyid_template_filename'>template_filename</span><span class='rparen'>)</span>
|
360
|
-
<span class='id identifier rubyid_invalid_headers'>invalid_headers</span> <span class='op'>=</span> <span class='id identifier rubyid_validate_headers'>validate_headers</span><span class='lparen'>(</span><span class='id identifier rubyid_spreadsheet_rows'>spreadsheet_rows</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='comma'>,</span> <span class='id identifier rubyid_mods_template_xml'>mods_template_xml</span><span class='rparen'>)</span>
|
361
|
-
|
362
|
-
<span class='comment'># To do: generate a warning if there are invalid headers
|
363
|
-
</span>
|
364
|
-
<span class='comment'># Write one XML file per data row in the input spreadsheet
|
365
|
-
</span> <span class='lparen'>(</span><span class='int'>0</span><span class='op'>..</span><span class='lparen'>(</span><span class='id identifier rubyid_spreadsheet_rows'>spreadsheet_rows</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='op'>-</span><span class='int'>1</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span>
|
366
|
-
<span class='id identifier rubyid_sourceid'>sourceid</span> <span class='op'>=</span> <span class='id identifier rubyid_spreadsheet_rows'>spreadsheet_rows</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>sourceId</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
|
367
|
-
<span class='id identifier rubyid_output_filename'>output_filename</span> <span class='op'>=</span> <span class='id identifier rubyid_output_directory'>output_directory</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/</span><span class='tstring_end'>"</span></span> <span class='op'>+</span> <span class='id identifier rubyid_sourceid'>sourceid</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>.xml</span><span class='tstring_end'>"</span></span>
|
368
|
-
|
369
|
-
<span class='comment'># Generate an XML string, then remove any text carried over from the template
|
370
|
-
</span> <span class='id identifier rubyid_generated_xml'>generated_xml</span> <span class='op'>=</span> <span class='id identifier rubyid_generate_xml'>generate_xml</span><span class='lparen'>(</span><span class='id identifier rubyid_spreadsheet_rows'>spreadsheet_rows</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_mods_template_xml'>mods_template_xml</span><span class='comma'>,</span> <span class='id identifier rubyid_i'>i</span><span class='op'>+</span><span class='int'>1</span><span class='rparen'>)</span>
|
371
|
-
<span class='id identifier rubyid_generated_xml'>generated_xml</span><span class='period'>.</span><span class='id identifier rubyid_gsub!'>gsub!</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\[\[[^\]]+\]\]</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
372
|
-
|
373
|
-
<span class='comment'># Create an XML Document and normalize it
|
374
|
-
</span> <span class='id identifier rubyid_xml_doc'>xml_doc</span> <span class='op'>=</span> <span class='const'>Nokogiri</span><span class='op'>::</span><span class='const'>XML</span><span class='lparen'>(</span><span class='id identifier rubyid_generated_xml'>generated_xml</span><span class='rparen'>)</span>
|
375
|
-
<span class='id identifier rubyid_root_node'>root_node</span> <span class='op'>=</span> <span class='id identifier rubyid_xml_doc'>xml_doc</span><span class='period'>.</span><span class='id identifier rubyid_root'>root</span>
|
376
|
-
<span class='id identifier rubyid_normalizer'>normalizer</span> <span class='op'>=</span> <span class='const'>Normalizer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
377
|
-
<span class='id identifier rubyid_normalizer'>normalizer</span><span class='period'>.</span><span class='id identifier rubyid_remove_empty_nodes'>remove_empty_nodes</span><span class='lparen'>(</span><span class='id identifier rubyid_root_node'>root_node</span><span class='rparen'>)</span>
|
378
|
-
|
379
|
-
<span class='comment'># To do: notify of errors to the resulting XML
|
380
|
-
</span>
|
381
|
-
<span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_output_filename'>output_filename</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>w</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_fh'>fh</span><span class='op'>|</span> <span class='id identifier rubyid_fh'>fh</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='id identifier rubyid_root_node'>root_node</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
382
|
-
<span class='kw'>end</span>
|
383
|
-
<span class='kw'>end</span></pre>
|
384
|
-
</td>
|
385
|
-
</tr>
|
386
|
-
</table>
|
387
|
-
</div>
|
388
|
-
|
389
|
-
<div class="method_details ">
|
390
|
-
<h3 class="signature " id="generate_xml-instance_method">
|
391
|
-
|
392
|
-
- (<tt>Object</tt>) <strong>generate_xml</strong>(mf, template_xml, row_number)
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
</h3><div class="docstring">
|
399
|
-
<div class="discussion">
|
400
|
-
|
401
|
-
<p>Write XML to file</p>
|
402
|
-
|
403
|
-
|
404
|
-
</div>
|
405
|
-
</div>
|
406
|
-
<div class="tags">
|
407
|
-
|
408
|
-
|
409
|
-
</div><table class="source_code">
|
410
|
-
<tr>
|
411
|
-
<td>
|
412
|
-
<pre class="lines">
|
413
|
-
|
414
|
-
|
415
|
-
62
|
416
|
-
63
|
417
|
-
64
|
418
|
-
65
|
419
|
-
66
|
420
|
-
67
|
421
|
-
68
|
422
|
-
69
|
423
|
-
70
|
424
|
-
71
|
425
|
-
72
|
426
|
-
73
|
427
|
-
74
|
428
|
-
75
|
429
|
-
76
|
430
|
-
77
|
431
|
-
78
|
432
|
-
79
|
433
|
-
80
|
434
|
-
81
|
435
|
-
82
|
436
|
-
83
|
437
|
-
84
|
438
|
-
85
|
439
|
-
86
|
440
|
-
87
|
441
|
-
88
|
442
|
-
89
|
443
|
-
90
|
444
|
-
91
|
445
|
-
92
|
446
|
-
93</pre>
|
447
|
-
</td>
|
448
|
-
<td>
|
449
|
-
<pre class="code"><span class="info file"># File 'modsulator.rb', line 62</span>
|
450
|
-
|
451
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_generate_xml'>generate_xml</span><span class='lparen'>(</span><span class='id identifier rubyid_mf'>mf</span><span class='comma'>,</span> <span class='id identifier rubyid_template_xml'>template_xml</span><span class='comma'>,</span> <span class='id identifier rubyid_row_number'>row_number</span><span class='rparen'>)</span>
|
452
|
-
<span class='id identifier rubyid_manifest_row'>manifest_row</span> <span class='op'>=</span> <span class='id identifier rubyid_mf'>mf</span>
|
453
|
-
<span class='id identifier rubyid_mods_template_xml'>mods_template_xml</span> <span class='op'>=</span> <span class='id identifier rubyid_template_xml'>template_xml</span>
|
454
|
-
|
455
|
-
<span class='comment'># XML escape all of the entries in the manifest row so they won't break the XML
|
456
|
-
</span> <span class='id identifier rubyid_manifest_row'>manifest_row</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_manifest_row'>manifest_row</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span><span class='op'>=</span><span class='const'>Nokogiri</span><span class='op'>::</span><span class='const'>XML</span><span class='op'>::</span><span class='const'>Text</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='comma'>,</span><span class='const'>Nokogiri</span><span class='op'>::</span><span class='const'>XML</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='kw'>if</span> <span class='id identifier rubyid_v'>v</span> <span class='rbrace'>}</span>
|
457
|
-
|
458
|
-
<span class='comment'># Enable access with symbol or string keys
|
459
|
-
</span> <span class='id identifier rubyid_manifest_row'>manifest_row</span> <span class='op'>=</span> <span class='id identifier rubyid_manifest_row'>manifest_row</span><span class='period'>.</span><span class='id identifier rubyid_with_indifferent_access'>with_indifferent_access</span>
|
460
|
-
|
461
|
-
<span class='comment'># Run the XML template through ERB. This creates a new ERB object from the template XML,
|
462
|
-
</span> <span class='comment'># NOT creating a separate thread, and omitting newlines for lines ending with '%>'
|
463
|
-
</span> <span class='id identifier rubyid_template'>template</span> <span class='op'>=</span> <span class='const'>ERB</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_mods_template_xml'>mods_template_xml</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>></span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
464
|
-
|
465
|
-
<span class='comment'># ERB.result() actually computes the template. This just passes the top level binding.
|
466
|
-
</span> <span class='id identifier rubyid_descriptive_metadata_xml'>descriptive_metadata_xml</span> <span class='op'>=</span> <span class='id identifier rubyid_template'>template</span><span class='period'>.</span><span class='id identifier rubyid_result'>result</span><span class='lparen'>(</span><span class='id identifier rubyid_binding'>binding</span><span class='rparen'>)</span>
|
467
|
-
|
468
|
-
<span class='comment'># The manifest_row is a hash, with column names as the key.
|
469
|
-
</span> <span class='comment'># In the template, as a convenience we allow users to put specific column placeholders inside
|
470
|
-
</span> <span class='comment'># double brackets: "blah [[column_name]] blah".
|
471
|
-
</span> <span class='comment'># Here we replace those placeholders with the corresponding value
|
472
|
-
</span> <span class='comment'># from the manifest row.
|
473
|
-
</span> <span class='id identifier rubyid_manifest_row'>manifest_row</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_descriptive_metadata_xml'>descriptive_metadata_xml</span><span class='period'>.</span><span class='id identifier rubyid_gsub!'>gsub!</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>[[</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_k'>k</span><span class='embexpr_end'>}</span><span class='tstring_content'>]]</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span> <span class='rbrace'>}</span>
|
474
|
-
<span class='comment'># manifest_row.each do |k,v|
|
475
|
-
</span> <span class='comment'># replaced_xml = descriptive_metadata_xml.gsub!("[[#{k}]]", v.to_s.strip)
|
476
|
-
</span> <span class='comment'># puts("rx = #{replaced_xml}")
|
477
|
-
</span> <span class='comment'># if(replaced_xml == nil)
|
478
|
-
</span> <span class='comment'># puts("*** Warning: On line #{row_number}, there were no matches for the header #{k} within the master template. Do you have an error in your spreadsheet?")
|
479
|
-
</span> <span class='comment'># end
|
480
|
-
</span> <span class='comment'># end
|
481
|
-
</span> <span class='kw'>return</span> <span class='id identifier rubyid_descriptive_metadata_xml'>descriptive_metadata_xml</span>
|
482
|
-
<span class='kw'>end</span></pre>
|
483
|
-
</td>
|
484
|
-
</tr>
|
485
|
-
</table>
|
486
|
-
</div>
|
487
|
-
|
488
|
-
<div class="method_details ">
|
489
|
-
<h3 class="signature " id="load_spreadsheet-instance_method">
|
490
|
-
|
491
|
-
- (<tt>Object</tt>) <strong>load_spreadsheet</strong>(filename)
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
</h3><table class="source_code">
|
498
|
-
<tr>
|
499
|
-
<td>
|
500
|
-
<pre class="lines">
|
501
|
-
|
502
|
-
|
503
|
-
30
|
504
|
-
31
|
505
|
-
32
|
506
|
-
33
|
507
|
-
34
|
508
|
-
35
|
509
|
-
36
|
510
|
-
37
|
511
|
-
38
|
512
|
-
39
|
513
|
-
40
|
514
|
-
41
|
515
|
-
42
|
516
|
-
43
|
517
|
-
44
|
518
|
-
45
|
519
|
-
46</pre>
|
520
|
-
</td>
|
521
|
-
<td>
|
522
|
-
<pre class="code"><span class="info file"># File 'modsulator.rb', line 30</span>
|
523
|
-
|
524
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_load_spreadsheet'>load_spreadsheet</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='rparen'>)</span>
|
525
|
-
<span class='id identifier rubyid_spreadsheet'>spreadsheet</span> <span class='op'>=</span> <span class='id identifier rubyid_open_spreadsheet'>open_spreadsheet</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='rparen'>)</span>
|
526
|
-
|
527
|
-
<span class='comment'># The MODS spreadsheet starts with a "super header" in the first row, followed by individual
|
528
|
-
</span> <span class='comment'># column headers in the second row. The third row is the start of the actual data.
|
529
|
-
</span> <span class='id identifier rubyid_header'>header</span> <span class='op'>=</span> <span class='id identifier rubyid_spreadsheet'>spreadsheet</span><span class='period'>.</span><span class='id identifier rubyid_row'>row</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span>
|
530
|
-
|
531
|
-
<span class='comment'># need to build up an array here and return it
|
532
|
-
</span> <span class='id identifier rubyid_rows'>rows</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
533
|
-
|
534
|
-
<span class='lparen'>(</span><span class='int'>3</span><span class='op'>..</span><span class='id identifier rubyid_spreadsheet'>spreadsheet</span><span class='period'>.</span><span class='id identifier rubyid_last_row'>last_row</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span>
|
535
|
-
<span class='id identifier rubyid_row'>row</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='lbracket'>[</span><span class='lbracket'>[</span><span class='id identifier rubyid_header'>header</span><span class='comma'>,</span> <span class='id identifier rubyid_spreadsheet'>spreadsheet</span><span class='period'>.</span><span class='id identifier rubyid_row'>row</span><span class='lparen'>(</span><span class='id identifier rubyid_i'>i</span><span class='rparen'>)</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_transpose'>transpose</span><span class='rbracket'>]</span>
|
536
|
-
<span class='id identifier rubyid_rows'>rows</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_row'>row</span><span class='rparen'>)</span>
|
537
|
-
<span class='kw'>end</span>
|
538
|
-
|
539
|
-
<span class='kw'>return</span> <span class='id identifier rubyid_rows'>rows</span>
|
540
|
-
<span class='kw'>end</span></pre>
|
541
|
-
</td>
|
542
|
-
</tr>
|
543
|
-
</table>
|
544
|
-
</div>
|
545
|
-
|
546
|
-
<div class="method_details ">
|
547
|
-
<h3 class="signature " id="open_spreadsheet-instance_method">
|
548
|
-
|
549
|
-
- (<tt>Object</tt>) <strong>open_spreadsheet</strong>(filename)
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
</h3><div class="docstring">
|
556
|
-
<div class="discussion">
|
557
|
-
|
558
|
-
<p>Open spreadsheet based on filename extension</p>
|
559
|
-
|
560
|
-
|
561
|
-
</div>
|
562
|
-
</div>
|
563
|
-
<div class="tags">
|
564
|
-
|
565
|
-
|
566
|
-
</div><table class="source_code">
|
567
|
-
<tr>
|
568
|
-
<td>
|
569
|
-
<pre class="lines">
|
570
|
-
|
571
|
-
|
572
|
-
50
|
573
|
-
51
|
574
|
-
52
|
575
|
-
53
|
576
|
-
54
|
577
|
-
55
|
578
|
-
56
|
579
|
-
57</pre>
|
580
|
-
</td>
|
581
|
-
<td>
|
582
|
-
<pre class="code"><span class="info file"># File 'modsulator.rb', line 50</span>
|
583
|
-
|
584
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_open_spreadsheet'>open_spreadsheet</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='rparen'>)</span>
|
585
|
-
<span class='kw'>case</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_extname'>extname</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='rparen'>)</span>
|
586
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>.csv</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='const'>Roo</span><span class='op'>::</span><span class='const'>CSV</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='rparen'>)</span>
|
587
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>.xls</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='const'>Roo</span><span class='op'>::</span><span class='const'>Excel</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='rparen'>)</span>
|
588
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>.xlsx</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='const'>Roo</span><span class='op'>::</span><span class='const'>Excelx</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='rparen'>)</span>
|
589
|
-
<span class='kw'>else</span> <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Unknown file type: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_filename'>filename</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
590
|
-
<span class='kw'>end</span>
|
591
|
-
<span class='kw'>end</span></pre>
|
592
|
-
</td>
|
593
|
-
</tr>
|
594
|
-
</table>
|
595
|
-
</div>
|
596
|
-
|
597
|
-
<div class="method_details ">
|
598
|
-
<h3 class="signature " id="validate_headers-instance_method">
|
599
|
-
|
600
|
-
- (<tt>Array<String></tt>) <strong>validate_headers</strong>(spreadsheet_headers, template_xml)
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
</h3><div class="docstring">
|
607
|
-
<div class="discussion">
|
608
|
-
|
609
|
-
<p>Checks that all the headers in the spreadsheet has a corresponding entry in
|
610
|
-
the XML template.</p>
|
611
|
-
|
612
|
-
|
613
|
-
</div>
|
614
|
-
</div>
|
615
|
-
<div class="tags">
|
616
|
-
<p class="tag_title">Parameters:</p>
|
617
|
-
<ul class="param">
|
618
|
-
|
619
|
-
<li>
|
620
|
-
|
621
|
-
<span class='name'>spreadsheet_headers</span>
|
622
|
-
|
623
|
-
|
624
|
-
<span class='type'>(<tt>Array<String></tt>)</span>
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
—
|
629
|
-
<div class='inline'>
|
630
|
-
<p>A list of all the headers in the spreadsheet</p>
|
631
|
-
</div>
|
632
|
-
|
633
|
-
</li>
|
634
|
-
|
635
|
-
<li>
|
636
|
-
|
637
|
-
<span class='name'>template_xml</span>
|
638
|
-
|
639
|
-
|
640
|
-
<span class='type'>(<tt>String</tt>)</span>
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
—
|
645
|
-
<div class='inline'>
|
646
|
-
<p>The XML template in a single string</p>
|
647
|
-
</div>
|
648
|
-
|
649
|
-
</li>
|
650
|
-
|
651
|
-
</ul>
|
652
|
-
|
653
|
-
<p class="tag_title">Returns:</p>
|
654
|
-
<ul class="return">
|
655
|
-
|
656
|
-
<li>
|
657
|
-
|
658
|
-
|
659
|
-
<span class='type'>(<tt>Array<String></tt>)</span>
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
—
|
664
|
-
<div class='inline'>
|
665
|
-
<p>A list of spreadsheet headers that did not appear in the XML template. This
|
666
|
-
list will be empty if all the headers were present.</p>
|
667
|
-
</div>
|
668
|
-
|
669
|
-
</li>
|
670
|
-
|
671
|
-
</ul>
|
672
|
-
|
673
|
-
</div><table class="source_code">
|
674
|
-
<tr>
|
675
|
-
<td>
|
676
|
-
<pre class="lines">
|
677
|
-
|
678
|
-
|
679
|
-
137
|
680
|
-
138
|
681
|
-
139
|
682
|
-
140
|
683
|
-
141
|
684
|
-
142
|
685
|
-
143
|
686
|
-
144
|
687
|
-
145
|
688
|
-
146
|
689
|
-
147
|
690
|
-
148
|
691
|
-
149</pre>
|
692
|
-
</td>
|
693
|
-
<td>
|
694
|
-
<pre class="code"><span class="info file"># File 'modsulator.rb', line 137</span>
|
695
|
-
|
696
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_validate_headers'>validate_headers</span><span class='lparen'>(</span><span class='id identifier rubyid_spreadsheet_headers'>spreadsheet_headers</span><span class='comma'>,</span> <span class='id identifier rubyid_template_xml'>template_xml</span><span class='rparen'>)</span>
|
697
|
-
<span class='id identifier rubyid_missing_headers'>missing_headers</span> <span class='op'>=</span> <span class='const'>Array</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
698
|
-
|
699
|
-
<span class='id identifier rubyid_spreadsheet_headers'>spreadsheet_headers</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_header'>header</span><span class='op'>|</span>
|
700
|
-
<span class='kw'>if</span><span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_header'>header</span> <span class='op'>!=</span> <span class='kw'>nil</span><span class='rparen'>)</span> <span class='op'>&&</span>
|
701
|
-
<span class='op'>!</span><span class='lparen'>(</span><span class='id identifier rubyid_header'>header</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>sourceId</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='op'>&&</span>
|
702
|
-
<span class='op'>!</span><span class='lparen'>(</span><span class='id identifier rubyid_template_xml'>template_xml</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_header'>header</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
703
|
-
<span class='id identifier rubyid_missing_headers'>missing_headers</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_header'>header</span><span class='rparen'>)</span>
|
704
|
-
<span class='kw'>end</span>
|
705
|
-
<span class='kw'>end</span>
|
706
|
-
|
707
|
-
<span class='kw'>return</span> <span class='id identifier rubyid_missing_headers'>missing_headers</span>
|
708
|
-
<span class='kw'>end</span></pre>
|
709
|
-
</td>
|
710
|
-
</tr>
|
711
|
-
</table>
|
712
|
-
</div>
|
713
|
-
|
714
|
-
</div>
|
715
|
-
|
716
|
-
</div>
|
717
|
-
|
718
|
-
<div id="footer">
|
719
|
-
Generated on Fri Mar 13 17:20:28 2015 by
|
720
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
721
|
-
0.8.7.6 (ruby-2.2.0).
|
722
|
-
</div>
|
723
|
-
|
724
|
-
</body>
|
725
|
-
</html>
|