datacite-mapping 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +5 -0
  3. data/README.md +21 -0
  4. data/datacite-mapping.gemspec +1 -1
  5. data/lib/datacite/mapping/date.rb +2 -2
  6. data/lib/datacite/mapping/identifier.rb +19 -3
  7. data/lib/datacite/mapping/module_info.rb +1 -1
  8. data/lib/datacite/mapping/nonvalidating/identifier.rb +40 -0
  9. data/lib/datacite/mapping/nonvalidating/subject.rb +43 -0
  10. data/lib/datacite/mapping/nonvalidating.rb +10 -0
  11. data/lib/datacite/mapping/resource.rb +19 -14
  12. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r3059p-mrt-datacite.xml +42 -0
  13. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r31017-mrt-datacite.xml +37 -0
  14. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r3201j-mrt-datacite.xml +50 -0
  15. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r33w26-mrt-datacite.xml +45 -0
  16. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r34s3v-mrt-datacite.xml +35 -0
  17. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r36p4t-mrt-datacite.xml +53 -0
  18. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r39g6f-mrt-datacite.xml +68 -0
  19. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r3cc7d-mrt-datacite.xml +42 -0
  20. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r3d59d-mrt-datacite.xml +45 -0
  21. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r3f59q-mrt-datacite.xml +68 -0
  22. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r3g591-mrt-datacite.xml +35 -0
  23. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r3k016-mrt-datacite.xml +68 -0
  24. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r3kw2j-mrt-datacite.xml +58 -0
  25. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r3mw2v-mrt-datacite.xml +33 -0
  26. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r3np4v-mrt-datacite.xml +40 -0
  27. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r3pp45-mrt-datacite.xml +47 -0
  28. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r3rp4s-mrt-datacite.xml +34 -0
  29. data/spec/data/dash1-datacite-xml/dataone-ark+=c5146=r3tg63-mrt-datacite.xml +36 -0
  30. data/spec/data/dash1-datacite-xml/ucb-ark+=b6078=d1159q-mrt-datacite.xml +53 -0
  31. data/spec/data/dash1-datacite-xml/ucb-ark+=b6078=d17g6j-mrt-datacite.xml +50 -0
  32. data/spec/data/dash1-datacite-xml/ucb-ark+=b6078=d1c88g-mrt-datacite.xml +47 -0
  33. data/spec/data/dash1-datacite-xml/ucb-ark+=b6078=d1cc74-mrt-datacite.xml +71 -0
  34. data/spec/data/dash1-datacite-xml/ucb-ark+=b6078=d1h019-mrt-datacite.xml +38 -0
  35. data/spec/data/dash1-datacite-xml/ucb-ark+=b6078=d1ms3x-mrt-datacite.xml +42 -0
  36. data/spec/data/dash1-datacite-xml/ucb-ark+=b6078=d1mw2k-mrt-datacite.xml +39 -0
  37. data/spec/data/dash1-datacite-xml/ucb-ark+=b6078=d1rg66-mrt-datacite.xml +39 -0
  38. data/spec/data/dash1-datacite-xml/ucb-ark+=b6078=d1rp4h-mrt-datacite.xml +53 -0
  39. data/spec/data/dash1-datacite-xml/ucb-ark+=b6078=d1wc7s-mrt-datacite.xml +49 -0
  40. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1001p-mrt-datacite.xml +51 -0
  41. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1059f-mrt-datacite.xml +65 -0
  42. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d11010-mrt-datacite.xml +49 -0
  43. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1159r-mrt-datacite.xml +79 -0
  44. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d12019-mrt-datacite.xml +60 -0
  45. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d12s30-mrt-datacite.xml +51 -0
  46. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1301m-mrt-datacite.xml +66 -0
  47. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d13s39-mrt-datacite.xml +49 -0
  48. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d13w2z-mrt-datacite.xml +60 -0
  49. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d14s3m-mrt-datacite.xml +64 -0
  50. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d15k5m-mrt-datacite.xml +66 -0
  51. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d15p48-mrt-datacite.xml +60 -0
  52. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d16k5x-mrt-datacite.xml +49 -0
  53. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d16p4k-mrt-datacite.xml +62 -0
  54. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d17g6k-mrt-datacite.xml +50 -0
  55. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d17p4w-mrt-datacite.xml +69 -0
  56. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d18g6w-mrt-datacite.xml +69 -0
  57. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1988w-mrt-datacite.xml +66 -0
  58. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d19g66-mrt-datacite.xml +74 -0
  59. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1b886-mrt-datacite.xml +53 -0
  60. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1bc7v-mrt-datacite.xml +67 -0
  61. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1c88h-mrt-datacite.xml +59 -0
  62. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1cc75-mrt-datacite.xml +62 -0
  63. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1d595-mrt-datacite.xml +50 -0
  64. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1f30c-mrt-datacite.xml +115 -0
  65. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1f59g-mrt-datacite.xml +71 -0
  66. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1g011-mrt-datacite.xml +52 -0
  67. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1g59s-mrt-datacite.xml +81 -0
  68. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1h01b-mrt-datacite.xml +66 -0
  69. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1h593-mrt-datacite.xml +62 -0
  70. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1j01n-mrt-datacite.xml +60 -0
  71. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1js3b-mrt-datacite.xml +55 -0
  72. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1k01z-mrt-datacite.xml +67 -0
  73. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1ks3n-mrt-datacite.xml +50 -0
  74. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1kw29-mrt-datacite.xml +82 -0
  75. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1ms3z-mrt-datacite.xml +48 -0
  76. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1mw2m-mrt-datacite.xml +67 -0
  77. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1np4m-mrt-datacite.xml +51 -0
  78. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1pk58-mrt-datacite.xml +47 -0
  79. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1pp4x-mrt-datacite.xml +67 -0
  80. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1qg6x-mrt-datacite.xml +53 -0
  81. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1qp47-mrt-datacite.xml +68 -0
  82. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1rg67-mrt-datacite.xml +48 -0
  83. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1rp4j-mrt-datacite.xml +70 -0
  84. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1sg6j-mrt-datacite.xml +85 -0
  85. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1t88j-mrt-datacite.xml +53 -0
  86. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1tg6v-mrt-datacite.xml +66 -0
  87. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1v88v-mrt-datacite.xml +53 -0
  88. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1vc7h-mrt-datacite.xml +64 -0
  89. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1w885-mrt-datacite.xml +50 -0
  90. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1wc7t-mrt-datacite.xml +71 -0
  91. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1x59t-mrt-datacite.xml +47 -0
  92. data/spec/data/dash1-datacite-xml/uci-ark+=b7280=d1z594-mrt-datacite.xml +62 -0
  93. data/spec/data/dash1-datacite-xml/ucla-ark+=b5060=d2qr4v2t-mrt-datacite.xml +57 -0
  94. data/spec/data/dash1-datacite-xml/ucla-ark+=b5068=d1cc7x-mrt-datacite.xml +41 -0
  95. data/spec/data/dash1-datacite-xml/ucla-ark+=b5068=d1h59v-mrt-datacite.xml +33 -0
  96. data/spec/data/dash1-datacite-xml/ucla-ark+=b5068=d1rp49-mrt-datacite.xml +36 -0
  97. data/spec/data/dash1-datacite-xml/ucla-ark+=b5068=d1wc7k-mrt-datacite.xml +46 -0
  98. data/spec/data/dash1-datacite-xml/ucm-ark+=13030=m51g217t-mrt-datacite.xml +28 -0
  99. data/spec/data/dash1-datacite-xml/ucm-ark+=b6071=z7wc73-mrt-datacite.xml +83 -0
  100. data/spec/data/dash1-datacite-xml/ucop-ark+=b5060=d8301x-mrt-datacite.xml +39 -0
  101. data/spec/data/dash1-datacite-xml/ucop-ark+=b5060=d86p4w-mrt-datacite.xml +38 -0
  102. data/spec/data/dash1-datacite-xml/ucop-ark+=b5060=d8bc75-mrt-datacite.xml +40 -0
  103. data/spec/data/dash1-datacite-xml/ucop-ark+=b5060=d8g593-mrt-datacite.xml +39 -0
  104. data/spec/data/dash1-datacite-xml/ucop-ark+=b5060=d8h59d-mrt-datacite.xml +53 -0
  105. data/spec/data/dash1-datacite-xml/ucop-ark+=b5060=d8kw2m-mrt-datacite.xml +39 -0
  106. data/spec/data/dash1-datacite-xml/ucop-ark+=b5060=d8rp4v-mrt-datacite.xml +52 -0
  107. data/spec/data/dash1-datacite-xml/ucop-ark+=b5060=d8z59f-mrt-datacite.xml +42 -0
  108. data/spec/data/dash1-datacite-xml/ucsc-ark+=b7291=d11592-mrt-datacite.xml +38 -0
  109. data/spec/data/dash1-datacite-xml/ucsc-ark+=b7291=d17p46-mrt-datacite.xml +43 -0
  110. data/spec/data/dash1-datacite-xml/ucsc-ark+=b7291=d1h59d-mrt-datacite.xml +43 -0
  111. data/spec/data/dash1-datacite-xml/ucsc-ark+=b7291=d1mw2x-mrt-datacite.xml +54 -0
  112. data/spec/data/dash1-datacite-xml/ucsc-ark+=b7291=d1wc74-mrt-datacite.xml +55 -0
  113. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6057cv6-mrt-datacite.xml +96 -0
  114. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6154f00-mrt-datacite.xml +73 -0
  115. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q61z429d-mrt-datacite.xml +29 -0
  116. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q62z13fs-mrt-datacite.xml +43 -0
  117. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q65q4t1r-mrt-datacite.xml +25 -0
  118. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q66q1v54-mrt-datacite.xml +42 -0
  119. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q67p8w9z-mrt-datacite.xml +63 -0
  120. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q68g8hmp-mrt-datacite.xml +24 -0
  121. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6bg2kwf-mrt-datacite.xml +63 -0
  122. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6c8276k-mrt-datacite.xml +43 -0
  123. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6cc0xmh-mrt-datacite.xml +63 -0
  124. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6d798bd-mrt-datacite.xml +26 -0
  125. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6h12zxh-mrt-datacite.xml +46 -0
  126. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6h41pb7-mrt-datacite.xml +60 -0
  127. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6kw5cxv-mrt-datacite.xml +43 -0
  128. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6ms3qnx-mrt-datacite.xml +42 -0
  129. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6mw2f2n-mrt-datacite.xml +61 -0
  130. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6pn93h6-mrt-datacite.xml +52 -0
  131. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6qn64nk-mrt-datacite.xml +46 -0
  132. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6rf5rzx-mrt-datacite.xml +60 -0
  133. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6rn35sz-mrt-datacite.xml +63 -0
  134. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6sf2t3q-mrt-datacite.xml +21 -0
  135. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6td9v7j-mrt-datacite.xml +29 -0
  136. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6w66hpn-mrt-datacite.xml +23 -0
  137. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6x63jt1-mrt-datacite.xml +27 -0
  138. data/spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6z60kzd-mrt-datacite.xml +45 -0
  139. data/spec/data/metadata.xsd +380 -0
  140. data/spec/data/mrt-datacite.xml +61 -0
  141. data/spec/unit/datacite/mapping/date_spec.rb +23 -15
  142. data/spec/unit/datacite/mapping/nonvalidating/identifier_spec.rb +38 -0
  143. data/spec/unit/datacite/mapping/resource_spec.rb +69 -12
  144. metadata +267 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a753380743d789df5d3214db54f1b43daf688641
4
- data.tar.gz: ad610478535b7a3302582a54a010c503f7f7aca1
3
+ metadata.gz: c35c9f94314bc0e78dda05e9beda10bfc951bce4
4
+ data.tar.gz: 18be63217a380ad07d52f595a879666c8e91e82f
5
5
  SHA512:
6
- metadata.gz: 8616c242e6d01ce1e724b5e71a0aa917c5697a99ca80c4ad8d83afcb401541aa75fb14f581ccf358396ab4dda134cc3485993e0e1474313aef4525968e0339d3
7
- data.tar.gz: e8821e91c2ab7da19dc740a43dd114192f91267f4520b73d02838d807e0da2e94452ae39e81eb0d3e96660ee45e258a4c871e2bd4a590c8102d4adaf326f6ac9
6
+ metadata.gz: 8e9e340a00e87133162816aad8e9bd7da0449cc5028ed39e13e0c98e1b23b92b5042574e774ee734abd0cf5b79f873257556e5b7df3ed6fb01fef770b79135a0
7
+ data.tar.gz: 319ffcbfb5c3f1c850e87c2d461452c176166e3232ee95bd5b024ecc50dab1dc85941f004d165703dd4a8a763474bbd78ec2d0edc0f4497013221581b74445ed
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.1.16 (14 July 2016)
2
+
3
+ - Add new `:nonvalidating` mapping for less strict parsing of problem files.
4
+ - Provide better error messages for missing identifier values.
5
+
1
6
  ## 0.1.15 (18 May 2016)
2
7
 
3
8
  - Update to XML::MappingExtensions 0.4.1
data/README.md CHANGED
@@ -165,3 +165,24 @@ Results:
165
165
  </descriptions>
166
166
  </resource>
167
167
  ```
168
+
169
+ ## Nonvalidating mapping (experimental)
170
+
171
+ Version 0.1.16 adds a `:nonvalidating` mapping, meant to deal with some issues we ran into with
172
+ old, noncompliant data files. Specifically, it parses identifiers and subjects without values:
173
+
174
+ ```xml
175
+ <identifier type="DOI"/>
176
+ <subject schemeURI="http://www.nlm.nih.gov/mesh/" subjectScheme="MeSH"/>
177
+ ```
178
+
179
+ The former are imported with a nil value; the latter are skipped.
180
+
181
+ ```ruby
182
+ resource = Resource.parse_xml(xml_text, mapping: :nonvalidating)
183
+ resource.write_xml(mapping: :nonvalidating)
184
+ ```
185
+
186
+ This isn't meant to be exhaustive, only to handle some specific cases we ran into with importing
187
+ old data. If you have additional cases, please file an issue, attaching sample documents, and
188
+ we'll try to accommodate them.
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ['lib']
26
26
 
27
27
  spec.add_dependency 'typesafe_enum', '~> 0.1', '>= 0.1.7'
28
- spec.add_dependency 'xml-mapping_extensions', '~> 0.4', '>= 0.4.1'
28
+ spec.add_dependency 'xml-mapping_extensions', '~> 0.4', '>= 0.4.5'
29
29
 
30
30
  spec.add_development_dependency 'bundler', '~> 1.7'
31
31
  spec.add_development_dependency 'equivalent-xml', '~> 0.6.0'
@@ -109,13 +109,13 @@ module Datacite
109
109
 
110
110
  def to_month(val)
111
111
  return val.month if val.respond_to?(:month)
112
- matchdata = val.to_s.match(/^[0-9]+-([0-9]+)/)
112
+ matchdata = val.to_s.match(/^[0-9]+-([0-9]{2})(?![0-9])/)
113
113
  matchdata[1].to_i if matchdata
114
114
  end
115
115
 
116
116
  def to_day(val)
117
117
  return val.day if val.respond_to?(:day)
118
- matchdata = val.to_s.match(/^[0-9]+-[0-9]+-([0-9]+)/)
118
+ matchdata = val.to_s.match(/^[0-9]+-[0-9]{2}-([0-9]{2})(?![0-9])/)
119
119
  matchdata[1].to_i if matchdata
120
120
  end
121
121
 
@@ -13,15 +13,18 @@ module Datacite
13
13
  class Identifier
14
14
  include XML::Mapping
15
15
 
16
+ DOI = 'DOI'.freeze
17
+
16
18
  # Initializes a new {Identifier}
17
19
  # @param value [String]
18
20
  # the identifier value. Must be a valid DOI value (`10.`_registrant code_`/`_suffix_)
19
21
  def initialize(value:)
20
- self.identifier_type = 'DOI'
22
+ self.identifier_type = DOI
21
23
  self.value = value
22
24
  end
23
25
 
24
26
  def value=(v)
27
+ fail ArgumentError, 'Identifier must have a non-nil value' unless v
25
28
  fail ArgumentError, "Identifier value '#{v}' is not a valid DOI" unless v.match(DOI_PATTERN)
26
29
  @value = v
27
30
  end
@@ -30,10 +33,15 @@ module Datacite
30
33
  # @param v [String]
31
34
  # the identifier type (always 'DOI')
32
35
  def identifier_type=(v)
33
- fail ArgumentError, "Identifier type '#{v}' must be 'DOI'" unless 'DOI' == v
36
+ fail ArgumentError, "Identifier type '#{v}' must be 'DOI'" unless DOI == v
34
37
  @identifier_type = v
35
38
  end
36
39
 
40
+ # Gets the identifiery type.
41
+ def identifier_type
42
+ @identifier_type ||= DOI
43
+ end
44
+
37
45
  # Converts a string DOI value to an `Identifier`.
38
46
  # @param doi_string [String]
39
47
  def self.from_doi(doi_string)
@@ -42,8 +50,16 @@ module Datacite
42
50
  Identifier.new(value: match[0])
43
51
  end
44
52
 
53
+ def self.extract_and_set_value(obj, xml)
54
+ obj.value = xml.text
55
+ end
56
+ private_class_method :extract_and_set_value
57
+
45
58
  text_node :identifier_type, '@identifierType'
46
- text_node :value, 'text()'
59
+
60
+ # The default reader throws an opaque XPath error if there's no element text,
61
+ # so we extract it manually and let the accessor raise an error instead
62
+ text_node :value, 'text()', reader: method(:extract_and_set_value)
47
63
  end
48
64
  end
49
65
  end
@@ -4,7 +4,7 @@ module Datacite
4
4
  NAME = 'datacite-mapping'
5
5
 
6
6
  # The version of this gem
7
- VERSION = '0.1.15'
7
+ VERSION = '0.1.16'
8
8
 
9
9
  # The copyright notice for this gem
10
10
  COPYRIGHT = 'Copyright (c) 2016 The Regents of the University of California'
@@ -0,0 +1,40 @@
1
+ require 'xml/mapping'
2
+
3
+ module Datacite
4
+ module Mapping
5
+ module Nonvalidating
6
+
7
+ # The persistent identifier that identifies the resource.
8
+ #
9
+ # @!attribute [r] identifier_type
10
+ # @return [String] the identifier type (always 'DOI')
11
+ # @!attribute [rw] value
12
+ # @return [String] the identifier value. Must be a valid DOI value (`10.`_registrant code_`/`_suffix_)
13
+ class Identifier
14
+ include XML::Mapping
15
+
16
+ DOI = 'DOI'.freeze
17
+
18
+ use_mapping :nonvalidating
19
+
20
+ text_node :identifier_type, '@identifierType'
21
+ text_node :value, 'text()', default_value: nil
22
+
23
+ fallback_mapping(:_default, :nonvalidating)
24
+
25
+ # Initializes a new {Identifier}
26
+ # @param value [String]
27
+ # the identifier value. Must be a valid DOI value (`10.`_registrant code_`/`_suffix_)
28
+ def initialize(value:)
29
+ self.identifier_type = DOI
30
+ self.value = value
31
+ end
32
+
33
+ # Gets the identifiery type.
34
+ def identifier_type
35
+ @identifier_type ||= DOI
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,43 @@
1
+ require 'xml/mapping'
2
+
3
+ module Datacite
4
+ module Mapping
5
+ module Nonvalidating
6
+ # Subject, keyword, classification code, or key phrase describing the {Resource}.
7
+ class Subject
8
+ include XML::Mapping
9
+
10
+ use_mapping :nonvalidating
11
+
12
+ text_node :scheme, '@subjectScheme', default_value: nil
13
+ uri_node :scheme_uri, '@schemeURI', default_value: nil
14
+ text_node :language, '@xml:lang', default_value: 'en'
15
+ text_node :value, 'text()', default_value: nil
16
+
17
+ fallback_mapping(:_default, :nonvalidating)
18
+
19
+ # Initializes a new {Subject}
20
+ # @param scheme [String, nil] the subject scheme or classification code or authority if one is used. Optional.
21
+ # @param scheme_uri [URI, nil] the URI of the subject scheme or classification code or authority if one is used. Optional.
22
+ # @param language [String] an IETF BCP 47, ISO 639-1 language code identifying the language.
23
+ # It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
24
+ # @param value [String] the subject itself.
25
+ def initialize(scheme: nil, scheme_uri: nil, language: 'en', value: nil)
26
+ self.scheme = scheme
27
+ self.scheme_uri = scheme_uri
28
+ self.language = language
29
+ self.value = value
30
+ end
31
+
32
+ def language
33
+ @language || 'en'
34
+ end
35
+
36
+ def language=(value)
37
+ @language = value.strip if value
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,10 @@
1
+ require 'logger'
2
+
3
+ module Datacite
4
+ module Mapping
5
+ # Nonvalidating types for non-strict parsing
6
+ module Nonvalidating
7
+ Dir.glob(File.expand_path('../nonvalidating/*.rb', __FILE__)).sort.each(&method(:require))
8
+ end
9
+ end
10
+ end
@@ -1,12 +1,13 @@
1
1
  require 'xml/mapping_extensions'
2
- require 'datacite/mapping/identifier'
3
- require 'datacite/mapping/creator'
4
- require 'datacite/mapping/title'
5
- require 'datacite/mapping/subject'
6
- require 'datacite/mapping/resource_type'
7
2
  require 'datacite/mapping/alternate_identifier'
3
+ require 'datacite/mapping/creator'
4
+ require 'datacite/mapping/identifier'
5
+ require 'datacite/mapping/nonvalidating'
8
6
  require 'datacite/mapping/related_identifier'
7
+ require 'datacite/mapping/resource_type'
9
8
  require 'datacite/mapping/rights'
9
+ require 'datacite/mapping/subject'
10
+ require 'datacite/mapping/title'
10
11
 
11
12
  module Datacite
12
13
  module Mapping
@@ -105,15 +106,9 @@ module Datacite
105
106
  @publication_year = value.to_i
106
107
  end
107
108
 
108
- # # Overrides +::XML::Mapping.pre_save+ to write namespace information.
109
- # # Used for writing.
110
- # def pre_save(options = { mapping: :_default })
111
- # xml = super(options)
112
- # xml.add_namespace('http://datacite.org/schema/kernel-3')
113
- # xml.add_namespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance')
114
- # xml.add_attribute('xsi:schemaLocation', 'http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd')
115
- # xml
116
- # end
109
+ def subject
110
+ (@subjects ||= []).select(&:value)
111
+ end
117
112
 
118
113
  # @!attribute [rw] identifier
119
114
  # @return [Identifier] a persistent identifier that identifies a resource.
@@ -225,6 +220,16 @@ module Datacite
225
220
  funder_id.value if funder_id
226
221
  end
227
222
 
223
+ use_mapping :nonvalidating
224
+
225
+ # Ignore missing or invalid values
226
+ object_node :identifier, 'identifier', class: Nonvalidating::Identifier
227
+ array_node :subjects, 'subjects', 'subject', class: Nonvalidating::Subject, default_value: []
228
+ text_node :language, 'language', default_value: nil
229
+
230
+ # TODO: Handle nested contributors, date ranges (e.g. spec/data/dash1-datacite-xml/ucsf-ark+=b7272=q6bg2kwf-mrt-datacite.xml)
231
+
232
+ fallback_mapping :nonvalidating, :_default
228
233
  end
229
234
  end
230
235
  end
@@ -0,0 +1,42 @@
1
+ <?xml version="1.0" encoding="utf-8"?><resource xmlns="http://datacite.org/schema/kernel-3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
2
+ <identifier identifierType="DOI"/>
3
+ <creators>
4
+ <creator>
5
+ <creatorName>Lai, Chun-Ta</creatorName>
6
+ </creator>
7
+ </creators>
8
+ <titles>
9
+ <title>Linking evapotranspiration, boundary-layer processes and atmospheric moisture using isotope tracer modeling and data</title>
10
+ </titles>
11
+ <publisher>DataONE</publisher>
12
+ <publicationYear>2015</publicationYear>
13
+ <subjects>
14
+ <subject>oxygen isotopes</subject>
15
+ <subject>hydrogen isotopes</subject>
16
+ <subject>water vapor</subject>
17
+ <subject>Wind River Field Station</subject>
18
+ </subjects>
19
+ <contributors>
20
+ <contributor contributorType="DataManager">
21
+ <contributorName>Lai, Chun-Ta</contributorName>
22
+ </contributor>
23
+ <contributor contributorType="Funder">
24
+ <contributorName>National Science Foundation, Division of Atmospheric and Geospace Sciences</contributorName>
25
+ </contributor>
26
+ </contributors>
27
+ <relatedIdentifiers>
28
+ <relatedIdentifier relatedIdentifierType="URL" relationType="IsPartOf">http://www.sci.sdsu.edu/biomet/pmwiki.php/PmWiki/Home</relatedIdentifier>
29
+ </relatedIdentifiers>
30
+ <resourceType resourceTypeGeneral="Other">Other</resourceType>
31
+ <sizes>
32
+ <size>4898073</size>
33
+ </sizes>
34
+ <rightsList>
35
+ <rights rightsURI="http://creativecommons.org/publicdomain/zero/1.0/">Creative Commons Public Domain Dedication (CC0)</rights>
36
+ </rightsList>
37
+ <descriptions>
38
+ <description descriptionType="Abstract">This study uses high-quality spectroscopy measurements to place local constraints on the isotopic composition of near-surface water vapor in an isotope-incorporated land surface model. A full-year, near continuous observation of hourly oxygen-18 and deuterium isotope ratios in atmospheric water vapor at Wind River field station, WA, USA, reveals times of strong influence from surface ET versus times when convective mixing dominates. These surface isotope measurements provide a robust foundation to improve the representation of the kinetic isotopic effects arising from ET and source water partitioning. Nudged, isotope-enabled GCM (IsoGSM) simulations reproduce isotopic variations influenced by large-scale, synoptic weather cycles, but are less successful in capturing variations associated with sub-grid processes. Specifically, the model is unable to produce the large and consistent variability in the deuterium excess (dx) values of near-surface water vapor. This ‘terrestrial feedback’ to the atmosphere is poorly parameterized in the IsoGSM. This work provides a summary of general findings for a DataOne dataset 'Stable Isotopologues of Atmospheric Moisture at Wind River Field Station (USA), doi:10.15146/R33W26'.</description>
39
+ <description descriptionType="Methods">Stable oxygen and hydrogen isotope ratios measurements were made by using an off-axis cavity-enhanced absorption spectroscopy analyzer (Los Gatos Research). Poster presented at 2013 AGU Fall Meeting #A51B-0024.</description>
40
+ <description descriptionType="Other"> AGS-0956425</description>
41
+ </descriptions>
42
+ </resource>
@@ -0,0 +1,37 @@
1
+ <?xml version="1.0" encoding="utf-8"?><resource xmlns="http://datacite.org/schema/kernel-3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
2
+ <identifier identifierType="DOI"/>
3
+ <creators>
4
+ <creator>
5
+ <creatorName>Silva, Sérgio Gomes da</creatorName>
6
+ </creator>
7
+ </creators>
8
+ <titles>
9
+ <title>Maternal Exercise during Pregnancy Increases BDNF Levels and Cell Numbers in the Hippocampal Formation but Not in the Cerebral Cortex of Adult Rat Offspring</title>
10
+ </titles>
11
+ <publisher>DataONE</publisher>
12
+ <publicationYear>2016</publicationYear>
13
+ <subjects>
14
+ <subject>brain-derived neurotrophic factor</subject>
15
+ </subjects>
16
+ <contributors>
17
+ <contributor contributorType="DataManager">
18
+ <contributorName>Wilson, James</contributorName>
19
+ </contributor>
20
+ </contributors>
21
+ <relatedIdentifiers>
22
+ <relatedIdentifier relatedIdentifierType="URL" relationType="IsDocumentedBy">http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0147200</relatedIdentifier>
23
+ <relatedIdentifier relatedIdentifierType="DOI" relationType="Documents">10.1371/journal.pone.0147200</relatedIdentifier>
24
+ </relatedIdentifiers>
25
+ <resourceType resourceTypeGeneral="Collection">Collection</resourceType>
26
+ <sizes>
27
+ <size>931734</size>
28
+ </sizes>
29
+ <rightsList>
30
+ <rights rightsURI="http://creativecommons.org/publicdomain/zero/1.0/">Creative Commons Public Domain Dedication (CC0)</rights>
31
+ </rightsList>
32
+ <descriptions>
33
+ <description descriptionType="Abstract">Clinical evidence has shown that physical exercise during pregnancy may alter brain devel- opment and improve cognitive function of offspring. However, the mechanisms through which maternal exercise might promote such effects are not well understood. The present study examined levels of brain-derived neurotrophic factor (BDNF) and absolute cell num- bers in the hippocampal formation and cerebral cortex of rat pups born from mothers exer- cised during pregnancy. Additionally, we evaluated the cognitive abilities of adult offspring in different behavioral paradigms (exploratory activity and habituation in open field tests, spatial memory in a water maze test, and aversive memory in a step-down inhibitory avoid- ance task). Results showed that maternal exercise during pregnancy increased BDNF lev- els and absolute numbers of neuronal and non-neuronal cells in the hippocampal formation of offspring. No differences in BDNF levels or cell numbers were detected in the cerebral cortex. It was also observed that offspring from exercised mothers exhibited better cognitive performance in nonassociative (habituation) and associative (spatial learning) mnemonic tasks than did offspring from sedentary mothers. Our findings indicate that maternal exer- cise during pregnancy enhances offspring cognitive function (habituation behavior and spa- tial learning) and increases BDNF levels and cell numbers in the hippocampal formation of offspring.
34
+ </description>
35
+ <description descriptionType="Other"/>
36
+ </descriptions>
37
+ </resource>
@@ -0,0 +1,50 @@
1
+ <?xml version="1.0" encoding="utf-8"?><resource xmlns="http://datacite.org/schema/kernel-3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
2
+ <identifier identifierType="DOI"/>
3
+ <creators>
4
+ <creator>
5
+ <creatorName>Britten, Kenneth H.</creatorName>
6
+ </creator>
7
+ <creator>
8
+ <creatorName>Thatcher, Timothy D.</creatorName>
9
+ </creator>
10
+ <creator>
11
+ <creatorName>Caro, Tim</creatorName>
12
+ </creator>
13
+ </creators>
14
+ <titles>
15
+ <title>Data associated with Britten, Thatcher and Caro (PLOS One, 2016). &quot;Zebras and biting flies: quantitative analysis of reflected light from zebra coats in their natural habitat.&quot;</title>
16
+ </titles>
17
+ <publisher>DataONE</publisher>
18
+ <publicationYear>2016</publicationYear>
19
+ <subjects>
20
+ <subject>zebra</subject>
21
+ <subject>tabanid</subject>
22
+ <subject>light polarization</subject>
23
+ <subject>predator-prey interaction</subject>
24
+ <subject>parasite</subject>
25
+ <subject>Africa</subject>
26
+ <subject>horseflies</subject>
27
+ <subject>glossinid</subject>
28
+ </subjects>
29
+ <contributors>
30
+ <contributor contributorType="DataManager">
31
+ <contributorName>Britten, Kenneth</contributorName>
32
+ </contributor>
33
+ <contributor contributorType="Funder">
34
+ <contributorName>National Geographic Society and National Eye Institute, NIH, US.</contributorName>
35
+ </contributor>
36
+ </contributors>
37
+ <relatedIdentifiers/>
38
+ <resourceType resourceTypeGeneral="Image">Image</resourceType>
39
+ <sizes>
40
+ <size>783494600</size>
41
+ </sizes>
42
+ <rightsList>
43
+ <rights rightsURI="http://creativecommons.org/publicdomain/zero/1.0/">Creative Commons Public Domain Dedication (CC0)</rights>
44
+ </rightsList>
45
+ <descriptions>
46
+ <description descriptionType="Abstract">The images are of 21 scenes containing plains zebras (Equus burchelli) taken in their natural habitat in Katavi National Park, Tanzania. Each scene was photographed 7 times through a polarizing filter set to angles varying by 30 degrees, to allow the reconstruction of the polarized light signature emitted from different regions and stripes on the zebras' pelage. The scenes contain either individual zebras or small groups of zebras against a background of low vegetation dominated by dry grass. The images were captured in the dry season, July-September, 2012. </description>
47
+ <description descriptionType="Methods">A Nikon D50 was used with a Digital Quantaray polarizing filter. The images are in 14-bit resolution, RGB mode. Each series was captured using full manual control, and the images are in Nikon's raw format, containing full metadata. Additional methods can be found in the PLOS One paper. The files are stored in a zip-compressed file, and the directory 'nef_files/' contains the image data, with each of the 21 image series in a separate subdirectory. Additional metadata is in the 'metadata.[xls,csv]' files in the package. </description>
48
+ <description descriptionType="Other">NGS W104-10 and NIH EY022087</description>
49
+ </descriptions>
50
+ </resource>
@@ -0,0 +1,45 @@
1
+ <?xml version="1.0" encoding="utf-8"?><resource xmlns="http://datacite.org/schema/kernel-3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
2
+ <identifier identifierType="DOI"/>
3
+ <creators>
4
+ <creator>
5
+ <creatorName>Lai, Chun-Ta</creatorName>
6
+ </creator>
7
+ </creators>
8
+ <titles>
9
+ <title>Stable Isotopologues of Atmospheric Moisture at Wind River Field Station (USA)</title>
10
+ </titles>
11
+ <publisher>DataONE</publisher>
12
+ <publicationYear>2015</publicationYear>
13
+ <subjects>
14
+ <subject>water vapor</subject>
15
+ <subject>oxygen isotopes</subject>
16
+ <subject>hydrogen isotopes</subject>
17
+ <subject>deuterium excess</subject>
18
+ <subject>old growth coniferous forests</subject>
19
+ <subject>Pacific Northwest</subject>
20
+ <subject>laser spectrascopy</subject>
21
+ </subjects>
22
+ <contributors>
23
+ <contributor contributorType="DataManager">
24
+ <contributorName>Lai, Chun-Ta</contributorName>
25
+ </contributor>
26
+ <contributor contributorType="Funder">
27
+ <contributorName>National Science Foundation, Division of Atmospheric and Geospace Sciences</contributorName>
28
+ </contributor>
29
+ </contributors>
30
+ <relatedIdentifiers>
31
+ <relatedIdentifier relatedIdentifierType="URL" relationType="IsPartOf">http://www.sci.sdsu.edu/biomet/pmwiki.php/PmWiki/Home</relatedIdentifier>
32
+ </relatedIdentifiers>
33
+ <resourceType resourceTypeGeneral="Dataset">Dataset</resourceType>
34
+ <sizes>
35
+ <size>1333357</size>
36
+ </sizes>
37
+ <rightsList>
38
+ <rights rightsURI="http://creativecommons.org/publicdomain/zero/1.0/">Creative Commons Public Domain Dedication (CC0)</rights>
39
+ </rightsList>
40
+ <descriptions>
41
+ <description descriptionType="Abstract">This dataset includes stable oxygen and hydrogen isotope ratios of near-surface water vapor measured at Wind River Field Station, WA, USA (45.8205N, 121.9519W, 371m asl). Near-continuous hourly averages are available from 3 heights (1m, 10m and 60m above ground) for the entire year in 2012. General findings learned from this dataset have been published at 2013 AGU Fall meeting (Linking evapotranspiration, boundary-layer processes and atmospheric moisture using isotope tracer modeling and data, #A51B-0024). </description>
42
+ <description descriptionType="Methods">High-precision isotope data were made possible by an off-axis cavity-enhanced absorption spectroscopy analyzer (Los Gatos Research). Data correction and quality control follow the protocol described by Rambo et al. (2011) Journal of Atmospheric and Oceanic Technology, 28(11), 1448-1457, doi:10.1175/JTECH-D-11-00053.1.</description>
43
+ <description descriptionType="Other">AGS-0956425</description>
44
+ </descriptions>
45
+ </resource>