mods 0.0.21 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -38,6 +38,8 @@ TODO: Write usage instructions here
38
38
 
39
39
  == Releases
40
40
 
41
+ * <b>0.0.22</b> add displayLabel and lang attributes to every element
42
+ * <b>0.0.21</b> Check for the possibility that name_node.display_value is nil
41
43
  * <b>0.0.20</b> added translated_value convenience method to geographicCode (mods.subject.geographicCode.translated_value)
42
44
  * <b>0.0.19</b> term_values and term_value method added to Record object
43
45
  * <b>0.0.18</b> <subject><temporal> cannot have subelements
data/lib/mods/name.rb CHANGED
@@ -5,7 +5,7 @@ module Mods
5
5
  CHILD_ELEMENTS = ['namePart', 'displayForm', 'affiliation', 'role', 'description']
6
6
 
7
7
  # attributes on name node
8
- ATTRIBUTES = Mods::AUTHORITY_ATTRIBS + ['type', 'displayLabel', 'usage', 'altRepGroup', 'nameTitleGroup']
8
+ ATTRIBUTES = Mods::AUTHORITY_ATTRIBS + Mods::LANG_ATTRIBS + ['type', 'displayLabel', 'usage', 'altRepGroup', 'nameTitleGroup']
9
9
 
10
10
  # valid values for type attribute on name node <name type="val"/>
11
11
  TYPES = ['personal', 'corporate', 'conference', 'family']
@@ -2,7 +2,9 @@ module Mods
2
2
 
3
3
  # from: http://www.loc.gov/standards/mods/v3/mods-userguide-generalapp.html
4
4
 
5
- LANG_ATTRIBS = ['lang', 'xml:lang', 'script', 'transliteration']
5
+ # FIXME: didn't figure out a good way to deal with namespaced attribute for non-namespaced terminology
6
+ # LANG_ATTRIBS = ['lang', 'xml:lang', 'script', 'transliteration']
7
+ LANG_ATTRIBS = ['lang', 'script', 'transliteration']
6
8
 
7
9
  LINKING_ATTRIBS = ['xlink', 'ID']
8
10
 
@@ -34,6 +36,9 @@ module Mods
34
36
  t._abstract :path => '//m:abstract' do |n|
35
37
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
36
38
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
39
+ Mods::LANG_ATTRIBS.each { |attr_name|
40
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
41
+ }
37
42
  end
38
43
 
39
44
  # ACCESS_CONDITION -----------------------------------------------------------------------
@@ -41,6 +46,9 @@ module Mods
41
46
  t._accessCondition :path => '//m:accessCondition' do |n|
42
47
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
43
48
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
49
+ Mods::LANG_ATTRIBS.each { |attr_name|
50
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
51
+ }
44
52
  end
45
53
 
46
54
  # CLASSIFICATION -------------------------------------------------------------------------
@@ -51,6 +59,9 @@ module Mods
51
59
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
52
60
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
53
61
  }
62
+ Mods::LANG_ATTRIBS.each { |attr_name|
63
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
64
+ }
54
65
  end
55
66
 
56
67
  # EXTENSION ------------------------------------------------------------------------------
@@ -68,6 +79,9 @@ module Mods
68
79
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
69
80
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
70
81
  }
82
+ Mods::LANG_ATTRIBS.each { |attr_name|
83
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
84
+ }
71
85
  end
72
86
 
73
87
  # IDENTIIER ------------------------------------------------------------------------------
@@ -76,11 +90,20 @@ module Mods
76
90
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
77
91
  n.invalid :path => '@invalid', :accessor => lambda { |a| a.text }
78
92
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
93
+ Mods::LANG_ATTRIBS.each { |attr_name|
94
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
95
+ }
79
96
  end
80
97
 
81
98
  # LANGUAGE -------------------------------------------------------------------------------
82
99
  t.language :path => '/m:mods/m:language'
83
100
  t._language :path => '//m:language' do |n|
101
+ # attributes
102
+ n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
103
+ Mods::LANG_ATTRIBS.each { |attr_name|
104
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
105
+ }
106
+ # child elements
84
107
  n.languageTerm :path => 'm:languageTerm'
85
108
  n.code_term :path => 'm:languageTerm[@type="code"]'
86
109
  n.text_term :path => 'm:languageTerm[@type="text"]'
@@ -96,6 +119,12 @@ module Mods
96
119
  # LOCATION -------------------------------------------------------------------------------
97
120
  t.location :path => '/m:mods/m:location'
98
121
  t._location :path => '//m:location' do |n|
122
+ # attributes
123
+ n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
124
+ Mods::LANG_ATTRIBS.each { |attr_name|
125
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
126
+ }
127
+ # child elements
99
128
  n.physicalLocation :path => 'm:physicalLocation' do |e|
100
129
  e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
101
130
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
@@ -247,11 +276,20 @@ module Mods
247
276
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
248
277
  n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
249
278
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
279
+ Mods::LANG_ATTRIBS.each { |attr_name|
280
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
281
+ }
250
282
  end
251
283
 
252
284
  # ORIGIN_INFO --------------------------------------------------------------------------
253
285
  t.origin_info :path => '/m:mods/m:originInfo'
254
286
  t._origin_info :path => '//m:originInfo' do |n|
287
+ # attributes
288
+ n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
289
+ Mods::LANG_ATTRIBS.each { |attr_name|
290
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
291
+ }
292
+ # child elements
255
293
  n.place :path => 'm:place' do |e|
256
294
  e.placeTerm :path => 'm:placeTerm' do |ee|
257
295
  ee.type_at :path => '@type', :accessor => lambda { |a| a.text }
@@ -287,6 +325,10 @@ module Mods
287
325
  n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
288
326
  n.order :path => '@order', :accessor => lambda { |a| a.text }
289
327
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
328
+ n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
329
+ Mods::LANG_ATTRIBS.each { |attr_name|
330
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
331
+ }
290
332
  # child elements
291
333
  n.detail :path => 'm:detail' do |e|
292
334
  # attributes
@@ -320,6 +362,12 @@ module Mods
320
362
  # PHYSICAL_DESCRIPTION -------------------------------------------------------------------
321
363
  t.physical_description :path => '/m:mods/m:physicalDescription'
322
364
  t._physical_description :path => '//m:physicalDescription' do |n|
365
+ # attributes
366
+ n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
367
+ Mods::LANG_ATTRIBS.each { |attr_name|
368
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
369
+ }
370
+ # child elements
323
371
  n.digitalOrigin :path => 'm:digitalOrigin'
324
372
  n.extent :path => 'm:extent'
325
373
  n.form :path => 'm:form' do |f|
@@ -412,9 +460,15 @@ module Mods
412
460
  # SUBJECT -----------------------------------------------------------------------------
413
461
  t.subject :path => '/m:mods/m:subject'
414
462
  t._subject :path => '//m:subject' do |n|
463
+ # attributes
464
+ n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
415
465
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
416
466
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
417
467
  }
468
+ Mods::LANG_ATTRIBS.each { |attr_name|
469
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
470
+ }
471
+ # child elements
418
472
  n.cartographics :path => 'm:cartographics' do |n1|
419
473
  n1.scale :path => 'm:scale'
420
474
  n1.projection :path => 'm:projection'
@@ -501,6 +555,9 @@ module Mods
501
555
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
502
556
  n.shareable :path => '@shareable', :accessor => lambda { |a| a.text }
503
557
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
558
+ Mods::LANG_ATTRIBS.each { |attr_name|
559
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
560
+ }
504
561
  end
505
562
 
506
563
  # TARGET_AUDIENCE -----------------------------------------------------------------------
@@ -510,6 +567,9 @@ module Mods
510
567
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
511
568
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
512
569
  }
570
+ Mods::LANG_ATTRIBS.each { |attr_name|
571
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
572
+ }
513
573
  end
514
574
 
515
575
  # TITLE_INFO ----------------------------------------------------------------------------
@@ -589,6 +649,9 @@ module Mods
589
649
  t._abstract :path => '//abstract' do |n|
590
650
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
591
651
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
652
+ Mods::LANG_ATTRIBS.each { |attr_name|
653
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
654
+ }
592
655
  end
593
656
 
594
657
  # ACCESS_CONDITION -----------------------------------------------------------------------
@@ -596,6 +659,9 @@ module Mods
596
659
  t._accessCondition :path => '//accessCondition' do |n|
597
660
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
598
661
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
662
+ Mods::LANG_ATTRIBS.each { |attr_name|
663
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
664
+ }
599
665
  end
600
666
 
601
667
  # CLASSIFICATION -------------------------------------------------------------------------
@@ -606,6 +672,9 @@ module Mods
606
672
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
607
673
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
608
674
  }
675
+ Mods::LANG_ATTRIBS.each { |attr_name|
676
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
677
+ }
609
678
  end
610
679
 
611
680
  # EXTENSION ------------------------------------------------------------------------------
@@ -623,6 +692,9 @@ module Mods
623
692
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
624
693
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
625
694
  }
695
+ Mods::LANG_ATTRIBS.each { |attr_name|
696
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
697
+ }
626
698
  end
627
699
 
628
700
  # IDENTIIER ------------------------------------------------------------------------------
@@ -631,11 +703,20 @@ module Mods
631
703
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
632
704
  n.invalid :path => '@invalid', :accessor => lambda { |a| a.text }
633
705
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
706
+ Mods::LANG_ATTRIBS.each { |attr_name|
707
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
708
+ }
634
709
  end
635
710
 
636
711
  # LANGUAGE -------------------------------------------------------------------------------
637
712
  t.language :path => '/mods/language'
638
713
  t._language :path => '//language' do |n|
714
+ # attributes
715
+ n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
716
+ Mods::LANG_ATTRIBS.each { |attr_name|
717
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
718
+ }
719
+ # child elements
639
720
  n.languageTerm :path => 'languageTerm'
640
721
  n.code_term :path => 'languageTerm[@type="code"]'
641
722
  n.text_term :path => 'languageTerm[@type="text"]'
@@ -651,6 +732,12 @@ module Mods
651
732
  # LOCATION -------------------------------------------------------------------------------
652
733
  t.location :path => '/mods/location'
653
734
  t._location :path => '//location' do |n|
735
+ # attributes
736
+ n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
737
+ Mods::LANG_ATTRIBS.each { |attr_name|
738
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
739
+ }
740
+ # child elements
654
741
  n.physicalLocation :path => 'physicalLocation' do |e|
655
742
  e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
656
743
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
@@ -801,11 +888,20 @@ module Mods
801
888
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
802
889
  n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
803
890
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
891
+ Mods::LANG_ATTRIBS.each { |attr_name|
892
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
893
+ }
804
894
  end
805
895
 
806
896
  # ORIGIN_INFO --------------------------------------------------------------------------
807
897
  t.origin_info :path => '/mods/originInfo'
808
898
  t._origin_info :path => '//originInfo' do |n|
899
+ # attributes
900
+ n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
901
+ Mods::LANG_ATTRIBS.each { |attr_name|
902
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
903
+ }
904
+ # child elements
809
905
  n.place :path => 'place' do |e|
810
906
  e.placeTerm :path => 'placeTerm' do |ee|
811
907
  ee.type_at :path => '@type', :accessor => lambda { |a| a.text }
@@ -841,6 +937,10 @@ module Mods
841
937
  n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
842
938
  n.order :path => '@order', :accessor => lambda { |a| a.text }
843
939
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
940
+ n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
941
+ Mods::LANG_ATTRIBS.each { |attr_name|
942
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
943
+ }
844
944
  # child elements
845
945
  n.detail :path => 'detail' do |e|
846
946
  # attributes
@@ -874,6 +974,12 @@ module Mods
874
974
  # PHYSICAL_DESCRIPTION -------------------------------------------------------------------
875
975
  t.physical_description :path => '/mods/physicalDescription'
876
976
  t._physical_description :path => '//physicalDescription' do |n|
977
+ # attributes
978
+ n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
979
+ Mods::LANG_ATTRIBS.each { |attr_name|
980
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
981
+ }
982
+ # child elements
877
983
  n.digitalOrigin :path => 'digitalOrigin'
878
984
  n.extent :path => 'extent'
879
985
  n.form :path => 'form' do |f|
@@ -966,9 +1072,15 @@ module Mods
966
1072
  # SUBJECT -----------------------------------------------------------------------------
967
1073
  t.subject :path => '/mods/subject'
968
1074
  t._subject :path => '//subject' do |n|
1075
+ # attributes
1076
+ n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
969
1077
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
970
1078
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
971
1079
  }
1080
+ Mods::LANG_ATTRIBS.each { |attr_name|
1081
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
1082
+ }
1083
+ # child elements
972
1084
  n.cartographics :path => 'cartographics' do |n1|
973
1085
  n1.scale :path => 'scale'
974
1086
  n1.projection :path => 'projection'
@@ -1055,6 +1167,9 @@ module Mods
1055
1167
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
1056
1168
  n.shareable :path => '@shareable', :accessor => lambda { |a| a.text }
1057
1169
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
1170
+ Mods::LANG_ATTRIBS.each { |attr_name|
1171
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
1172
+ }
1058
1173
  end
1059
1174
 
1060
1175
  # TARGET_AUDIENCE -----------------------------------------------------------------------
@@ -1064,6 +1179,9 @@ module Mods
1064
1179
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
1065
1180
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
1066
1181
  }
1182
+ Mods::LANG_ATTRIBS.each { |attr_name|
1183
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
1184
+ }
1067
1185
  end
1068
1186
 
1069
1187
  # TITLE_INFO ----------------------------------------------------------------------------
@@ -5,7 +5,7 @@ module Mods
5
5
  CHILD_ELEMENTS = ['title', 'subTitle', 'partNumber', 'partName', 'nonSort']
6
6
 
7
7
  # attributes on titleInfo node
8
- ATTRIBUTES = Mods::AUTHORITY_ATTRIBS + ['type', 'displayLabel', 'supplied', 'usage', 'altRepGroup', 'nameTitleGroup']
8
+ ATTRIBUTES = Mods::AUTHORITY_ATTRIBS + Mods::LANG_ATTRIBS + ['type', 'displayLabel', 'supplied', 'usage', 'altRepGroup', 'nameTitleGroup']
9
9
 
10
10
  # valid values for type attribute on titleInfo node <titleInfo type="val">
11
11
  TYPES = ['abbreviated', 'translated', 'alternative', 'uniform']
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.21"
3
+ VERSION = "0.0.22"
4
4
  end
data/spec/record_spec.rb CHANGED
@@ -112,21 +112,9 @@ describe "Mods::Record" do
112
112
  it "should work with an Array of messages passed as the argument" do
113
113
  @mods_rec.term_value([:subject, 'topic']).should == 'topic1 topic2 topic3'
114
114
  end
115
- it "should work with a String passed as the argument" do
116
- @mods_rec.term_value('abstract').should == 'single'
117
- end
118
115
  it "should take a separator argument" do
119
116
  @mods_rec.term_value(:note, ' -|-').should == 'mult1 -|-mult2'
120
117
  end
121
- it "should raise an error for an unrecognized message symbol" do
122
- expect { @mods_rec.term_value(:not_there) }.to raise_error(ArgumentError, "term_values called with unknown argument: :not_there")
123
- end
124
- it "should raise an error if the argument is an Array containing non-symbols" do
125
- expect { @mods_rec.term_value([:subject, @mods_rec.subject]) }.to raise_error(ArgumentError, /term_values called with Array containing unrecognized class:.*NodeSet.*/)
126
- end
127
- it "should raise an error if the argument isn't a Symbol or an Array" do
128
- expect { @mods_rec.term_value(@mods_rec.subject) }.to raise_error(ArgumentError, /term_values called with unrecognized argument class:.*NodeSet.*/)
129
- end
130
118
  end
131
119
 
132
120
  context "term_values (multiple values)" 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.21
4
+ version: 0.0.22
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: 2013-01-15 00:00:00.000000000 Z
13
+ date: 2013-02-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -232,7 +232,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
232
232
  version: '0'
233
233
  segments:
234
234
  - 0
235
- hash: -3106764460292902756
235
+ hash: 2304160584269815561
236
236
  required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  none: false
238
238
  requirements:
@@ -241,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  version: '0'
242
242
  segments:
243
243
  - 0
244
- hash: -3106764460292902756
244
+ hash: 2304160584269815561
245
245
  requirements: []
246
246
  rubyforge_project:
247
247
  rubygems_version: 1.8.24