mods 0.0.9 → 0.0.10

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.
data/README.rdoc CHANGED
@@ -37,6 +37,7 @@ TODO: Write usage instructions here
37
37
 
38
38
  == Releases
39
39
 
40
+ 0.0.10 remove xsi:schemaLocation attribute from mods element when not using namespaces
40
41
  0.0.9 implement from_nk_node as way to load record object
41
42
  0.0.8 implement relatedItem and attributes on all simple top level elements
42
43
  0.0.7 implement part
data/Rakefile CHANGED
@@ -29,7 +29,7 @@ end
29
29
 
30
30
  # Use yard to build docs
31
31
  begin
32
- project_root = File.expand_path(File.dirname(__FILE__) + "/../..")
32
+ project_root = File.expand_path(File.dirname(__FILE__))
33
33
  doc_dest_dir = File.join(project_root, 'doc')
34
34
 
35
35
  YARD::Rake::YardocTask.new(:doc) do |yt|
@@ -318,38 +318,38 @@ module Mods
318
318
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
319
319
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
320
320
  }
321
- n.topic :path => 'topic' do |n|
321
+ n.topic :path => 'topic' do |n1|
322
322
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
323
- n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
323
+ n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
324
324
  }
325
325
  end
326
- n.geographic :path => 'geographic' do |n|
326
+ n.geographic :path => 'geographic' do |n1|
327
327
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
328
- n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
328
+ n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
329
329
  }
330
330
  end
331
- n.temporal :path => 'temporal' do |n|
331
+ n.temporal :path => 'temporal' do |n1|
332
332
  # date attributes as elements
333
333
  Mods::DATE_ATTRIBS.each { |attr_name|
334
- n.send attr_name, :path => "#{attr_name}"
334
+ n1.send attr_name, :path => "#{attr_name}"
335
335
  }
336
336
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
337
- n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
337
+ n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
338
338
  }
339
339
  # date attributes as attributes
340
340
  Mods::DATE_ATTRIBS.each { |attr_name|
341
- n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
341
+ n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
342
342
  }
343
343
  end
344
- n.titleInfo :path => 'titleInfo' do |t|
344
+ n.titleInfo :path => 'titleInfo' do |t1|
345
345
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
346
- t.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
346
+ t1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
347
347
  }
348
348
  end
349
349
  # Note: 'name' is used by Nokogiri
350
- n.name_el :path => 'name' do |t|
350
+ n.name_el :path => 'name' do |t1|
351
351
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
352
- t.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
352
+ t1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
353
353
  }
354
354
  end
355
355
  n.personal_name :path => 'name[@type="personal"]'
@@ -360,30 +360,30 @@ module Mods
360
360
  g.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
361
361
  }
362
362
  end
363
- n.genre :path => 'genre' do |n|
363
+ n.genre :path => 'genre' do |n1|
364
364
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
365
- n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
365
+ n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
366
366
  }
367
367
  end
368
- n.hierarchicalGeographic :path => 'hierarchicalGeographic' do |n|
368
+ n.hierarchicalGeographic :path => 'hierarchicalGeographic' do |n1|
369
369
  Mods::Subject::HIER_GEO_CHILD_ELEMENTS.each { |elname|
370
- n.send elname, :path => "#{elname}"
370
+ n1.send elname, :path => "#{elname}"
371
371
  }
372
372
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
373
- n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
373
+ n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
374
374
  }
375
375
  end
376
- n.cartographics :path => 'cartographics' do |n|
377
- n.scale :path => 'scale'
378
- n.projection :path => 'projection'
379
- n.coordinates :path => 'coordinates'
376
+ n.cartographics :path => 'cartographics' do |n1|
377
+ n1.scale :path => 'scale'
378
+ n1.projection :path => 'projection'
379
+ n1.coordinates :path => 'coordinates'
380
380
  Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.each { |elname|
381
- n.send elname, :path => "#{elname}"
381
+ n1.send elname, :path => "#{elname}"
382
382
  }
383
383
  end
384
- n.occupation :path => 'occupation' do |n|
384
+ n.occupation :path => 'occupation' do |n1|
385
385
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
386
- n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
386
+ n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
387
387
  }
388
388
  end
389
389
  end # t.subject
data/lib/mods/reader.rb CHANGED
@@ -42,6 +42,8 @@ module Mods
42
42
  def normalize_mods
43
43
  if !@namespace_aware
44
44
  @mods_ng_xml.remove_namespaces!
45
+ # xsi:schemaLocation attribute will cause problems in JRuby
46
+ @mods_ng_xml.root.remove_attribute('schemaLocation') if @mods_ng_xml.has_attribute?('schemaLocation')
45
47
  # doing weird re-reading of xml for jruby, which gets confused by its own cache
46
48
  @mods_ng_xml = Nokogiri::XML(@mods_ng_xml.to_s)
47
49
  end
data/lib/mods/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Mods
2
2
  # this is the Ruby Gem version
3
- VERSION = "0.0.9"
3
+ VERSION = "0.0.10"
4
4
  end
data/spec/reader_spec.rb CHANGED
@@ -84,6 +84,18 @@ describe "Mods::Reader" do
84
84
  my_from_str_wrong_ns.xpath('/mods:mods/mods:note', @ns_hash).text.should_not == "hi"
85
85
  my_from_str_wrong_ns.xpath('/mods/note').text.should_not == "hi"
86
86
  end
87
+
88
+ it "should remove xsi:schemaLocation attribute from mods element if removing namespaces" do
89
+ str = '<ns3:mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="http://www.loc.gov/mods/v3" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
90
+ <ns3:note>be very frightened</ns3:note></ns3:mods>'
91
+ ng_xml = Nokogiri::XML(str)
92
+ ng_xml.root.has_attribute?('schemaLocation').should == true
93
+ r = Mods::Reader.new
94
+ r.namespace_aware = true
95
+ r.from_nk_node(ng_xml)
96
+ r.mods_ng_xml.has_attribute?('schemaLocation').should == false
97
+ r.mods_ng_xml.has_attribute?('xsi:schemaLocation').should == false
98
+ end
87
99
  end
88
100
 
89
101
  it "should do something useful when it gets unparseable XML" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mods
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-13 00:00:00.000000000 Z
13
+ date: 2012-11-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -214,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
214
214
  version: '0'
215
215
  segments:
216
216
  - 0
217
- hash: -681303896929700435
217
+ hash: -2366641569606885765
218
218
  required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  none: false
220
220
  requirements:
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  version: '0'
224
224
  segments:
225
225
  - 0
226
- hash: -681303896929700435
226
+ hash: -2366641569606885765
227
227
  requirements: []
228
228
  rubyforge_project:
229
229
  rubygems_version: 1.8.24