modsulator 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +202 -0
  3. data/README.md +7 -0
  4. data/Rakefile +43 -0
  5. data/bin/modsulator +16 -0
  6. data/lib/doc/Modsulator.html +725 -0
  7. data/lib/doc/_index.html +101 -0
  8. data/lib/doc/class_list.html +58 -0
  9. data/lib/doc/css/common.css +1 -0
  10. data/lib/doc/css/full_list.css +57 -0
  11. data/lib/doc/css/style.css +339 -0
  12. data/lib/doc/file_list.html +57 -0
  13. data/lib/doc/frames.html +26 -0
  14. data/lib/doc/index.html +101 -0
  15. data/lib/doc/js/app.js +219 -0
  16. data/lib/doc/js/full_list.js +181 -0
  17. data/lib/doc/js/jquery.js +4 -0
  18. data/lib/doc/method_list.html +87 -0
  19. data/lib/doc/top-level-namespace.html +112 -0
  20. data/lib/modsulator.rb +193 -0
  21. data/lib/modsulator/mods-3-5.xsd +1463 -0
  22. data/lib/modsulator/modsulator.xsd +35 -0
  23. data/lib/modsulator/modsulator_sheet.rb +62 -0
  24. data/lib/modsulator/modsulator_template.xlsx +0 -0
  25. data/lib/modsulator/modsulator_template.xml +198 -0
  26. data/lib/modsulator/normalizer.rb +218 -0
  27. data/lib/modsulator/validator.rb +37 -0
  28. data/spec/features/modsulator_sheet_unit_spec.rb +18 -0
  29. data/spec/features/normalizer_unit_spec.rb +152 -0
  30. data/spec/features/process_template_spec.rb +29 -0
  31. data/spec/features/validator_unit_spec.rb +43 -0
  32. data/spec/fixtures/Fitch_Chavez.xlsx +0 -0
  33. data/spec/fixtures/Fitch_Chavez.xml +2806 -0
  34. data/spec/fixtures/Fitch_King.xlsx +0 -0
  35. data/spec/fixtures/Fitch_King.xml +2560 -0
  36. data/spec/fixtures/M1463_AV_manifest.xlsx +0 -0
  37. data/spec/fixtures/M1463_AV_manifest.xml +2373 -0
  38. data/spec/fixtures/Matter_manifest.csv +295 -0
  39. data/spec/fixtures/Matter_manifest.xml +3309 -0
  40. data/spec/fixtures/PosadaSpreadsheet.xlsx +0 -0
  41. data/spec/fixtures/PosadaSpreadsheet.xml +1259 -0
  42. data/spec/fixtures/ars0056_manifest.csv +1 -0
  43. data/spec/fixtures/ars0056_manifest.xml +9728 -0
  44. data/spec/fixtures/crowdsourcing_bridget_1.xlsx +0 -0
  45. data/spec/fixtures/crowdsourcing_bridget_1.xml +606 -0
  46. data/spec/fixtures/crowdsourcing_bridget_2.xlsx +0 -0
  47. data/spec/fixtures/crowdsourcing_bridget_2.xml +3433 -0
  48. data/spec/fixtures/filled_template.xlsx +0 -0
  49. data/spec/fixtures/invalid_crowdsourcing_bridget_1.xml +606 -0
  50. data/spec/fixtures/manifest_v0174.csv +34 -0
  51. data/spec/fixtures/manifest_v0174.xml +1026 -0
  52. data/spec/fixtures/roman_coins_mods_manifest.csv +176 -0
  53. data/spec/fixtures/roman_coins_mods_manifest.xml +3025 -0
  54. data/spec/fixtures/test:002.xml +63 -0
  55. data/spec/fixtures/test_002.csv +4 -0
  56. data/spec/fixtures/test_002.xlsx +0 -0
  57. data/spec/integration_tests/integration_spec.rb +40 -0
  58. data/spec/lib/modsulator_spec.rb +21 -0
  59. data/spec/spec_helper.rb +97 -0
  60. metadata +261 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 41d0c66fa2c6fd513ed3bd7d7ab65a731268d0de
4
+ data.tar.gz: 166193e97d18acfbd9529bc091ee9d74ef41d641
5
+ SHA512:
6
+ metadata.gz: 8a2bec49fa83f340d4f420fdfa8078e0d78b61fbe5b112009830b270db7ba4d2d625d4e70ad27847b83d2a7000dd0a2321c39b997324e7c961985812b598e7ed
7
+ data.tar.gz: 90ab38bf5ddb58a47b67530f109a0aea6005d6e1979e42fc1b142f3db0c042cb0c2d0998864f7046a1eba12336c007173892a6ec04d299a6bf16c44e555d5659
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
data/README.md ADDED
@@ -0,0 +1,7 @@
1
+ [![Build Status](https://travis-ci.org/sul-dlss/modsulator.svg?branch=master)](https://travis-ci.org/sul-dlss/modsulator) [![Coverage Status](https://coveralls.io/repos/sul-dlss/modsulator/badge.png)](https://coveralls.io/r/sul-dlss/modsulator) [![Dependency Status](https://gemnasium.com/sul-dlss/modsulator.svg)](https://gemnasium.com/sul-dlss/modsulator) [![Gem Version](https://badge.fury.io/rb/modsulator.svg)](http://badge.fury.io/rb/modsulator) [![Code Climate](https://codeclimate.com/github/sul-dlss/modsulator/badges/gpa.svg)](https://codeclimate.com/github/sul-dlss/modsulator)
2
+
3
+ # modsulator
4
+ Produce Stanford MODS from spreadsheets.
5
+
6
+ Note that only .xlsx and .csv formats work with the latest template, which has more columns than
7
+ .xls allows (> 256).
data/Rakefile ADDED
@@ -0,0 +1,43 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'yard'
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |spec|
5
+ spec.pattern = 'spec/**/*_spec.rb'
6
+ spec.exclude_pattern = 'spec/integration_tests/**/*_spec.rb'
7
+ end
8
+
9
+
10
+ # Larger integration/acceptance style tests (take several minutes to complete)
11
+ RSpec::Core::RakeTask.new(:integration_tests) do |spec|
12
+ spec.pattern = 'spec/integration_tests/**/*_spec.rb'
13
+ end
14
+
15
+
16
+ YARD::Rake::YardocTask.new(:yard) do |t|
17
+ t.files = ['lib/**/*.rb'] # optional
18
+ t.stats_options = ['--list-undoc'] # optional
19
+ end
20
+
21
+ task :lint do
22
+ sh "ruby-lint lib/ bin/"
23
+ end
24
+
25
+ task :default => :spec # Default task is to just run shorter (unit) tests
26
+
27
+ task :all do
28
+ Rake::Task["spec"].invoke
29
+ Rake::Task["yard"].invoke
30
+ Rake::Task["integration_tests"].invoke
31
+ Rake::Task["lint"].invoke
32
+ end
33
+
34
+
35
+
36
+
37
+ # Set up default Rake tasks for cutting gems etc.
38
+ begin
39
+ require 'bundler/setup'
40
+ rescue LoadError
41
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
42
+ end
43
+ Bundler::GemHelper.install_tasks
data/bin/modsulator ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This is a command line script that generates <xmlDocs> using the modsulator methods.
4
+
5
+ require 'modsulator'
6
+
7
+ abort 'Usage: modsulator <spreadsheet>' unless ARGV.length == 1
8
+
9
+ unless File.exist?(ARGV[0]) && File.readable?(ARGV[0])
10
+ abort "*** The file #{ARGV[0]} does not exist or is not readable to the current user? - Terminating."
11
+ end
12
+
13
+ modsulator = Modsulator.new(File.new(ARGV[0]), File.basename(ARGV[0]))
14
+ xml_string = modsulator.convert_rows()
15
+
16
+ puts xml_string
@@ -0,0 +1,725 @@
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
+ &mdash; 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> &raquo;
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&lt;String&gt;) <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
+ &mdash;
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
+ &mdash;
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
+ &mdash;
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'>&#39;</span><span class='tstring_content'>sourceId</span><span class='tstring_end'>&#39;</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'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</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'>&quot;</span><span class='tstring_content'>.xml</span><span class='tstring_end'>&quot;</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'>&quot;</span><span class='tstring_end'>&quot;</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'>&#39;</span><span class='tstring_content'>w</span><span class='tstring_end'>&#39;</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&#39;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'>&#39;</span><span class='tstring_end'>&#39;</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 &#39;%&gt;&#39;
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'>&#39;</span><span class='tstring_content'>&gt;</span><span class='tstring_end'>&#39;</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: &quot;blah [[column_name]] blah&quot;.
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'>&quot;</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'>&quot;</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!(&quot;[[#{k}]]&quot;, v.to_s.strip)
476
+ </span> <span class='comment'># puts(&quot;rx = #{replaced_xml}&quot;)
477
+ </span> <span class='comment'># if(replaced_xml == nil)
478
+ </span> <span class='comment'># puts(&quot;*** 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?&quot;)
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 &quot;super header&quot; 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'>&quot;</span><span class='tstring_content'>.csv</span><span class='tstring_end'>&quot;</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'>&quot;</span><span class='tstring_content'>.xls</span><span class='tstring_end'>&quot;</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'>&quot;</span><span class='tstring_content'>.xlsx</span><span class='tstring_end'>&quot;</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'>&quot;</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'>&quot;</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&lt;String&gt;</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&lt;String&gt;</tt>)</span>
625
+
626
+
627
+
628
+ &mdash;
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
+ &mdash;
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&lt;String&gt;</tt>)</span>
660
+
661
+
662
+
663
+ &mdash;
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'>&amp;&amp;</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'>&quot;</span><span class='tstring_content'>sourceId</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</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>