mods 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -1
- data/lib/mods/reader.rb +8 -6
- data/lib/mods/record.rb +2 -2
- data/lib/mods/version.rb +1 -1
- data/spec/location_spec.rb +0 -3
- data/spec/origin_info_spec.rb +0 -3
- data/spec/reader_spec.rb +17 -0
- metadata +98 -79
data/README.rdoc
CHANGED
@@ -37,7 +37,8 @@ TODO: Write usage instructions here
|
|
37
37
|
|
38
38
|
== Releases
|
39
39
|
|
40
|
-
(0.0.
|
40
|
+
(0.0.15 make namespace aware processing the default)
|
41
|
+
0.0.14 don't lose xml encoding in reader.normalize_mods under jruby
|
41
42
|
0.0.13 really really fix removal of xsi:schemaLocation in jruby
|
42
43
|
0.0.12 fix failing jruby test
|
43
44
|
0.0.11 fix remove xsi:schemaLocation attribute from mods element when not using namespaces
|
data/lib/mods/reader.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
module Mods
|
2
4
|
class Reader
|
3
5
|
|
@@ -13,15 +15,15 @@ module Mods
|
|
13
15
|
end
|
14
16
|
|
15
17
|
# @param str - a string containing mods xml
|
16
|
-
# @return
|
18
|
+
# @return Nokogiri::XML::Document
|
17
19
|
def from_str(str)
|
18
|
-
@mods_ng_xml = Nokogiri::XML(str)
|
20
|
+
@mods_ng_xml = Nokogiri::XML(str, nil, str.encoding.to_s)
|
19
21
|
normalize_mods
|
20
22
|
@mods_ng_xml
|
21
23
|
end
|
22
24
|
|
23
25
|
# @param url (String) - url that has mods xml as its content
|
24
|
-
# @return
|
26
|
+
# @return Nokogiri::XML::Document
|
25
27
|
def from_url(url, encoding = nil, options = Nokogiri::XML::ParseOptions::DEFAULT_XML)
|
26
28
|
require 'open-uri'
|
27
29
|
@mods_ng_xml = Nokogiri::XML(open(url).read)
|
@@ -30,7 +32,7 @@ module Mods
|
|
30
32
|
end
|
31
33
|
|
32
34
|
# @param node (Nokogiri::XML::Node) - Nokogiri::XML::Node that is the top level element of a mods record
|
33
|
-
# @return
|
35
|
+
# @return Nokogiri::XML::Document
|
34
36
|
def from_nk_node(node)
|
35
37
|
@mods_ng_xml = Nokogiri::XML(node.to_s)
|
36
38
|
normalize_mods
|
@@ -48,8 +50,8 @@ module Mods
|
|
48
50
|
end
|
49
51
|
# doing weird re-reading of xml for jruby, which gets confused by its own cache
|
50
52
|
# using pedantic is helpful for debugging
|
51
|
-
# @mods_ng_xml = Nokogiri::XML(@mods_ng_xml.to_s, nil,
|
52
|
-
@mods_ng_xml = Nokogiri::XML(@mods_ng_xml.to_s)
|
53
|
+
# @mods_ng_xml = Nokogiri::XML(@mods_ng_xml.to_s, nil, @mods_ng_xml.encoding, Nokogiri::XML::ParseOptions::PEDANTIC)
|
54
|
+
@mods_ng_xml = Nokogiri::XML(@mods_ng_xml.to_s, nil, @mods_ng_xml.encoding)
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
data/lib/mods/record.rb
CHANGED
@@ -14,7 +14,7 @@ module Mods
|
|
14
14
|
|
15
15
|
ATTRIBUTES = ['id', 'version']
|
16
16
|
|
17
|
-
# @param (String) what to use when combining a title and subtitle, e.g.
|
17
|
+
# @param (String) title_delimiter what to use when combining a title and subtitle, e.g.
|
18
18
|
# for title "MODS" and subtitle "Metadata Odious Delimited Stuff" and delimiter " : "
|
19
19
|
# we get "MODS : Metadata Odious Delimited Stuff"
|
20
20
|
def initialize(title_delimiter = Mods::TitleInfo::DEFAULT_TITLE_DELIM)
|
@@ -34,7 +34,7 @@ module Mods
|
|
34
34
|
end
|
35
35
|
|
36
36
|
# convenience method to call Mods::Reader.new.from_url and to nom
|
37
|
-
# @param
|
37
|
+
# @param namespace_aware true if the XML parsing should be strict about using namespaces. Default is false
|
38
38
|
# @param url (String) - url that has mods xml as its content
|
39
39
|
def from_url(url, namespace_aware = false)
|
40
40
|
@mods_ng_xml = Mods::Reader.new(ns_aware).from_url(url)
|
data/lib/mods/version.rb
CHANGED
data/spec/location_spec.rb
CHANGED
data/spec/origin_info_spec.rb
CHANGED
data/spec/reader_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe "Mods::Reader" do
|
@@ -21,6 +23,21 @@ describe "Mods::Reader" do
|
|
21
23
|
@from_url.class.should == Nokogiri::XML::Document
|
22
24
|
end
|
23
25
|
|
26
|
+
context "normalizing mods" do
|
27
|
+
it "should not lose UTF-8 encoding" do
|
28
|
+
utf_mods = '<?xml version="1.0" encoding="UTF-8"?>
|
29
|
+
<mods:mods xmlns:mods="http://www.loc.gov/mods/v3" xmlns:xlink="http://www.w3.org/1999/xlink"
|
30
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.3"
|
31
|
+
xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd">
|
32
|
+
<mods:name authority="local" type="personal">
|
33
|
+
<mods:namePart>Gravé par Denise Macquart.</mods:namePart>
|
34
|
+
</mods:name>
|
35
|
+
</mods:mods>'
|
36
|
+
reader = Mods::Reader.new.from_str(utf_mods)
|
37
|
+
reader.encoding.should eql("UTF-8")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
24
41
|
context "from_nk_node" do
|
25
42
|
before(:all) do
|
26
43
|
oai_resp = '<?xml version="1.0" encoding="UTF-8"?>
|
metadata
CHANGED
@@ -1,163 +1,180 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.14
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Naomi Dushay
|
9
9
|
- Bess Sadler
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-11-
|
13
|
+
date: 2012-11-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
17
|
-
|
18
|
-
none: false
|
17
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
18
|
requirements:
|
20
19
|
- - ! '>='
|
21
20
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
23
|
-
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
version: !binary |-
|
22
|
+
MA==
|
26
23
|
none: false
|
24
|
+
requirement: !ruby/object:Gem::Requirement
|
27
25
|
requirements:
|
28
26
|
- - ! '>='
|
29
27
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
28
|
+
version: !binary |-
|
29
|
+
MA==
|
30
|
+
none: false
|
31
|
+
prerelease: false
|
32
|
+
type: :runtime
|
31
33
|
- !ruby/object:Gem::Dependency
|
32
34
|
name: nom-xml
|
33
|
-
|
34
|
-
none: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
35
36
|
requirements:
|
36
37
|
- - ! '>='
|
37
38
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
39
|
-
|
40
|
-
prerelease: false
|
41
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
version: !binary |-
|
40
|
+
MA==
|
42
41
|
none: false
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - ! '>='
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: !binary |-
|
47
|
+
MA==
|
48
|
+
none: false
|
49
|
+
prerelease: false
|
50
|
+
type: :runtime
|
47
51
|
- !ruby/object:Gem::Dependency
|
48
52
|
name: iso-639
|
49
|
-
|
50
|
-
none: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
55
|
- - ! '>='
|
53
56
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
version: !binary |-
|
58
|
+
MA==
|
58
59
|
none: false
|
60
|
+
requirement: !ruby/object:Gem::Requirement
|
59
61
|
requirements:
|
60
62
|
- - ! '>='
|
61
63
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
64
|
+
version: !binary |-
|
65
|
+
MA==
|
66
|
+
none: false
|
67
|
+
prerelease: false
|
68
|
+
type: :runtime
|
63
69
|
- !ruby/object:Gem::Dependency
|
64
70
|
name: rake
|
65
|
-
|
66
|
-
none: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
72
|
requirements:
|
68
73
|
- - ! '>='
|
69
74
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
71
|
-
|
72
|
-
prerelease: false
|
73
|
-
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
version: !binary |-
|
76
|
+
MA==
|
74
77
|
none: false
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
75
79
|
requirements:
|
76
80
|
- - ! '>='
|
77
81
|
- !ruby/object:Gem::Version
|
78
|
-
version:
|
82
|
+
version: !binary |-
|
83
|
+
MA==
|
84
|
+
none: false
|
85
|
+
prerelease: false
|
86
|
+
type: :development
|
79
87
|
- !ruby/object:Gem::Dependency
|
80
88
|
name: rdoc
|
81
|
-
|
82
|
-
none: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
90
|
requirements:
|
84
91
|
- - ! '>='
|
85
92
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
87
|
-
|
88
|
-
prerelease: false
|
89
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
version: !binary |-
|
94
|
+
MA==
|
90
95
|
none: false
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
91
97
|
requirements:
|
92
98
|
- - ! '>='
|
93
99
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
100
|
+
version: !binary |-
|
101
|
+
MA==
|
102
|
+
none: false
|
103
|
+
prerelease: false
|
104
|
+
type: :development
|
95
105
|
- !ruby/object:Gem::Dependency
|
96
106
|
name: yard
|
97
|
-
|
98
|
-
none: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
108
|
requirements:
|
100
109
|
- - ! '>='
|
101
110
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
103
|
-
|
104
|
-
prerelease: false
|
105
|
-
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
version: !binary |-
|
112
|
+
MA==
|
106
113
|
none: false
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
107
115
|
requirements:
|
108
116
|
- - ! '>='
|
109
117
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
118
|
+
version: !binary |-
|
119
|
+
MA==
|
120
|
+
none: false
|
121
|
+
prerelease: false
|
122
|
+
type: :development
|
111
123
|
- !ruby/object:Gem::Dependency
|
112
124
|
name: rspec
|
113
|
-
|
114
|
-
none: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
126
|
requirements:
|
116
127
|
- - ! '>='
|
117
128
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
119
|
-
|
120
|
-
prerelease: false
|
121
|
-
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
version: !binary |-
|
130
|
+
MA==
|
122
131
|
none: false
|
132
|
+
requirement: !ruby/object:Gem::Requirement
|
123
133
|
requirements:
|
124
134
|
- - ! '>='
|
125
135
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
136
|
+
version: !binary |-
|
137
|
+
MA==
|
138
|
+
none: false
|
139
|
+
prerelease: false
|
140
|
+
type: :development
|
127
141
|
- !ruby/object:Gem::Dependency
|
128
142
|
name: simplecov
|
129
|
-
|
130
|
-
none: false
|
143
|
+
version_requirements: !ruby/object:Gem::Requirement
|
131
144
|
requirements:
|
132
145
|
- - ! '>='
|
133
146
|
- !ruby/object:Gem::Version
|
134
|
-
version:
|
135
|
-
|
136
|
-
prerelease: false
|
137
|
-
version_requirements: !ruby/object:Gem::Requirement
|
147
|
+
version: !binary |-
|
148
|
+
MA==
|
138
149
|
none: false
|
150
|
+
requirement: !ruby/object:Gem::Requirement
|
139
151
|
requirements:
|
140
152
|
- - ! '>='
|
141
153
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
154
|
+
version: !binary |-
|
155
|
+
MA==
|
156
|
+
none: false
|
157
|
+
prerelease: false
|
158
|
+
type: :development
|
143
159
|
- !ruby/object:Gem::Dependency
|
144
160
|
name: simplecov-rcov
|
145
|
-
|
146
|
-
none: false
|
161
|
+
version_requirements: !ruby/object:Gem::Requirement
|
147
162
|
requirements:
|
148
163
|
- - ! '>='
|
149
164
|
- !ruby/object:Gem::Version
|
150
|
-
version:
|
151
|
-
|
152
|
-
prerelease: false
|
153
|
-
version_requirements: !ruby/object:Gem::Requirement
|
165
|
+
version: !binary |-
|
166
|
+
MA==
|
154
167
|
none: false
|
168
|
+
requirement: !ruby/object:Gem::Requirement
|
155
169
|
requirements:
|
156
170
|
- - ! '>='
|
157
171
|
- !ruby/object:Gem::Version
|
158
|
-
version:
|
159
|
-
|
160
|
-
|
172
|
+
version: !binary |-
|
173
|
+
MA==
|
174
|
+
none: false
|
175
|
+
prerelease: false
|
176
|
+
type: :development
|
177
|
+
description: Parse MODS (Metadata Object Description Schema) records. More information about MODS can be found at http://www.loc.gov/standards/mods/
|
161
178
|
email:
|
162
179
|
- ndushay AT stanford.edu
|
163
180
|
- bess AT stanford.edu
|
@@ -202,32 +219,34 @@ files:
|
|
202
219
|
- spec/top_level_elmnts_simple_spec.rb
|
203
220
|
homepage: https://github.com/sul-dlss/mods
|
204
221
|
licenses: []
|
205
|
-
post_install_message:
|
222
|
+
post_install_message:
|
206
223
|
rdoc_options: []
|
207
224
|
require_paths:
|
208
225
|
- lib
|
209
226
|
required_ruby_version: !ruby/object:Gem::Requirement
|
210
|
-
none: false
|
211
227
|
requirements:
|
212
228
|
- - ! '>='
|
213
229
|
- !ruby/object:Gem::Version
|
214
|
-
version: '0'
|
215
230
|
segments:
|
216
231
|
- 0
|
217
|
-
hash:
|
218
|
-
|
232
|
+
hash: 2
|
233
|
+
version: !binary |-
|
234
|
+
MA==
|
219
235
|
none: false
|
236
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
237
|
requirements:
|
221
238
|
- - ! '>='
|
222
239
|
- !ruby/object:Gem::Version
|
223
|
-
version: '0'
|
224
240
|
segments:
|
225
241
|
- 0
|
226
|
-
hash:
|
242
|
+
hash: 2
|
243
|
+
version: !binary |-
|
244
|
+
MA==
|
245
|
+
none: false
|
227
246
|
requirements: []
|
228
|
-
rubyforge_project:
|
247
|
+
rubyforge_project:
|
229
248
|
rubygems_version: 1.8.24
|
230
|
-
signing_key:
|
249
|
+
signing_key:
|
231
250
|
specification_version: 3
|
232
251
|
summary: Parse MODS (Metadata Object Description Schema) records.
|
233
252
|
test_files:
|
@@ -245,4 +264,4 @@ test_files:
|
|
245
264
|
- spec/subject_spec.rb
|
246
265
|
- spec/title_spec.rb
|
247
266
|
- spec/top_level_elmnts_simple_spec.rb
|
248
|
-
has_rdoc:
|
267
|
+
has_rdoc:
|