mods 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,7 +37,8 @@ TODO: Write usage instructions here
37
37
 
38
38
  == Releases
39
39
 
40
- (0.0.14 make namespace aware processing the default)
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
@@ -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 a Nokogiri::XML::Document object
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 a Nokogiri::XML::Document object
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 a Nokogiri::XML::Document object
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, nil, Nokogiri::XML::ParseOptions::PEDANTIC)
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
 
@@ -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 ns_aware true if the XML parsing should be strict about using namespaces. Default is false
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)
@@ -1,4 +1,4 @@
1
1
  module Mods
2
2
  # this is the Ruby Gem version
3
- VERSION = "0.0.13"
3
+ VERSION = "0.0.14"
4
4
  end
@@ -18,9 +18,6 @@ describe "Mods <location> Element" do
18
18
  end
19
19
 
20
20
  context "basic location terminology pieces" do
21
- before(:all) do
22
- @mods_rec.from_str(@form_and_extent)
23
- end
24
21
 
25
22
  context "physicalLocation child element" do
26
23
  before(:all) do
@@ -161,9 +161,6 @@ describe "Mods <originInfo> Element" do
161
161
  end
162
162
 
163
163
  context "basic <originInfo> terminology pieces" do
164
- before(:all) do
165
- @mods_rec.from_str(@form_and_extent)
166
- end
167
164
 
168
165
  context "<place> child element" do
169
166
  before(:all) do
@@ -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
- version: 0.0.13
5
- prerelease:
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-15 00:00:00.000000000 Z
13
+ date: 2012-11-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
17
+ version_requirements: !ruby/object:Gem::Requirement
19
18
  requirements:
20
19
  - - ! '>='
21
20
  - !ruby/object:Gem::Version
22
- version: '0'
23
- type: :runtime
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: '0'
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
- requirement: !ruby/object:Gem::Requirement
34
- none: false
35
+ version_requirements: !ruby/object:Gem::Requirement
35
36
  requirements:
36
37
  - - ! '>='
37
38
  - !ruby/object:Gem::Version
38
- version: '0'
39
- type: :runtime
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: '0'
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
- requirement: !ruby/object:Gem::Requirement
50
- none: false
53
+ version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
55
  - - ! '>='
53
56
  - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :runtime
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: '0'
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
- requirement: !ruby/object:Gem::Requirement
66
- none: false
71
+ version_requirements: !ruby/object:Gem::Requirement
67
72
  requirements:
68
73
  - - ! '>='
69
74
  - !ruby/object:Gem::Version
70
- version: '0'
71
- type: :development
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: '0'
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
- requirement: !ruby/object:Gem::Requirement
82
- none: false
89
+ version_requirements: !ruby/object:Gem::Requirement
83
90
  requirements:
84
91
  - - ! '>='
85
92
  - !ruby/object:Gem::Version
86
- version: '0'
87
- type: :development
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: '0'
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
- requirement: !ruby/object:Gem::Requirement
98
- none: false
107
+ version_requirements: !ruby/object:Gem::Requirement
99
108
  requirements:
100
109
  - - ! '>='
101
110
  - !ruby/object:Gem::Version
102
- version: '0'
103
- type: :development
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: '0'
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
- requirement: !ruby/object:Gem::Requirement
114
- none: false
125
+ version_requirements: !ruby/object:Gem::Requirement
115
126
  requirements:
116
127
  - - ! '>='
117
128
  - !ruby/object:Gem::Version
118
- version: '0'
119
- type: :development
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: '0'
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
- requirement: !ruby/object:Gem::Requirement
130
- none: false
143
+ version_requirements: !ruby/object:Gem::Requirement
131
144
  requirements:
132
145
  - - ! '>='
133
146
  - !ruby/object:Gem::Version
134
- version: '0'
135
- type: :development
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: '0'
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
- requirement: !ruby/object:Gem::Requirement
146
- none: false
161
+ version_requirements: !ruby/object:Gem::Requirement
147
162
  requirements:
148
163
  - - ! '>='
149
164
  - !ruby/object:Gem::Version
150
- version: '0'
151
- type: :development
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: '0'
159
- description: Parse MODS (Metadata Object Description Schema) records. More information
160
- about MODS can be found at http://www.loc.gov/standards/mods/
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: 1378644879324237983
218
- required_rubygems_version: !ruby/object:Gem::Requirement
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: 1378644879324237983
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: