datacite-mapping 0.1.17.2 → 0.2.0

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.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +33 -0
  3. data/README.md +93 -150
  4. data/datacite-mapping.gemspec +1 -1
  5. data/lib/datacite/mapping.rb +12 -27
  6. data/lib/datacite/mapping/alternate_identifier.rb +2 -0
  7. data/lib/datacite/mapping/contributor.rb +6 -2
  8. data/lib/datacite/mapping/creator.rb +33 -3
  9. data/lib/datacite/mapping/date.rb +28 -76
  10. data/lib/datacite/mapping/date_value.rb +116 -0
  11. data/lib/datacite/mapping/description.rb +9 -8
  12. data/lib/datacite/mapping/funding_reference.rb +20 -5
  13. data/lib/datacite/mapping/geo_location.rb +25 -4
  14. data/lib/datacite/mapping/geo_location_box.rb +10 -8
  15. data/lib/datacite/mapping/geo_location_node.rb +68 -0
  16. data/lib/datacite/mapping/geo_location_point.rb +8 -8
  17. data/lib/datacite/mapping/geo_location_polygon.rb +76 -0
  18. data/lib/datacite/mapping/identifier.rb +23 -11
  19. data/lib/datacite/mapping/module_info.rb +3 -3
  20. data/lib/datacite/mapping/name_identifier.rb +1 -0
  21. data/lib/datacite/mapping/namespace_extensions.rb +12 -0
  22. data/lib/datacite/mapping/read_only_nodes.rb +65 -0
  23. data/lib/datacite/mapping/related_identifier.rb +28 -0
  24. data/lib/datacite/mapping/resource.rb +88 -43
  25. data/lib/datacite/mapping/rights.rb +2 -0
  26. data/lib/datacite/mapping/subject.rb +10 -9
  27. data/lib/datacite/mapping/title.rb +7 -11
  28. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r3059p-mrt-datacite.xml +0 -0
  29. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r31017-mrt-datacite.xml +0 -0
  30. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r3201j-mrt-datacite.xml +0 -0
  31. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r33w26-mrt-datacite.xml +0 -0
  32. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r34s3v-mrt-datacite.xml +0 -0
  33. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r36p4t-mrt-datacite.xml +0 -0
  34. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r39g6f-mrt-datacite.xml +0 -0
  35. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r3cc7d-mrt-datacite.xml +0 -0
  36. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r3d59d-mrt-datacite.xml +0 -0
  37. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r3f59q-mrt-datacite.xml +0 -0
  38. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r3g591-mrt-datacite.xml +0 -0
  39. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r3k016-mrt-datacite.xml +0 -0
  40. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r3kw2j-mrt-datacite.xml +0 -0
  41. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r3mw2v-mrt-datacite.xml +0 -0
  42. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r3np4v-mrt-datacite.xml +0 -0
  43. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r3pp45-mrt-datacite.xml +0 -0
  44. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r3rp4s-mrt-datacite.xml +0 -0
  45. data/spec/data/{dash1-datacite-xml → dash1}/dataone-ark+=c5146=r3tg63-mrt-datacite.xml +0 -0
  46. data/spec/data/{dash1-datacite-xml → dash1}/ucb-ark+=b6078=d1159q-mrt-datacite.xml +0 -0
  47. data/spec/data/{dash1-datacite-xml → dash1}/ucb-ark+=b6078=d17g6j-mrt-datacite.xml +0 -0
  48. data/spec/data/{dash1-datacite-xml → dash1}/ucb-ark+=b6078=d1c88g-mrt-datacite.xml +0 -0
  49. data/spec/data/{dash1-datacite-xml → dash1}/ucb-ark+=b6078=d1cc74-mrt-datacite.xml +0 -0
  50. data/spec/data/{dash1-datacite-xml → dash1}/ucb-ark+=b6078=d1h019-mrt-datacite.xml +0 -0
  51. data/spec/data/{dash1-datacite-xml → dash1}/ucb-ark+=b6078=d1ms3x-mrt-datacite.xml +0 -0
  52. data/spec/data/{dash1-datacite-xml → dash1}/ucb-ark+=b6078=d1mw2k-mrt-datacite.xml +0 -0
  53. data/spec/data/{dash1-datacite-xml → dash1}/ucb-ark+=b6078=d1rg66-mrt-datacite.xml +0 -0
  54. data/spec/data/{dash1-datacite-xml → dash1}/ucb-ark+=b6078=d1rp4h-mrt-datacite.xml +0 -0
  55. data/spec/data/{dash1-datacite-xml → dash1}/ucb-ark+=b6078=d1wc7s-mrt-datacite.xml +0 -0
  56. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1001p-mrt-datacite.xml +0 -0
  57. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1059f-mrt-datacite.xml +0 -0
  58. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d11010-mrt-datacite.xml +0 -0
  59. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1159r-mrt-datacite.xml +0 -0
  60. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d12019-mrt-datacite.xml +0 -0
  61. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d12s30-mrt-datacite.xml +0 -0
  62. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1301m-mrt-datacite.xml +0 -0
  63. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d13s39-mrt-datacite.xml +0 -0
  64. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d13w2z-mrt-datacite.xml +0 -0
  65. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d14s3m-mrt-datacite.xml +0 -0
  66. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d15k5m-mrt-datacite.xml +0 -0
  67. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d15p48-mrt-datacite.xml +0 -0
  68. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d16k5x-mrt-datacite.xml +0 -0
  69. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d16p4k-mrt-datacite.xml +0 -0
  70. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d17g6k-mrt-datacite.xml +0 -0
  71. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d17p4w-mrt-datacite.xml +0 -0
  72. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d18g6w-mrt-datacite.xml +0 -0
  73. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1988w-mrt-datacite.xml +0 -0
  74. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d19g66-mrt-datacite.xml +0 -0
  75. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1b886-mrt-datacite.xml +0 -0
  76. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1bc7v-mrt-datacite.xml +0 -0
  77. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1c88h-mrt-datacite.xml +0 -0
  78. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1cc75-mrt-datacite.xml +0 -0
  79. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1d595-mrt-datacite.xml +0 -0
  80. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1f30c-mrt-datacite.xml +0 -0
  81. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1f59g-mrt-datacite.xml +0 -0
  82. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1g011-mrt-datacite.xml +0 -0
  83. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1g59s-mrt-datacite.xml +0 -0
  84. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1h01b-mrt-datacite.xml +0 -0
  85. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1h593-mrt-datacite.xml +0 -0
  86. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1j01n-mrt-datacite.xml +0 -0
  87. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1js3b-mrt-datacite.xml +0 -0
  88. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1k01z-mrt-datacite.xml +0 -0
  89. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1ks3n-mrt-datacite.xml +0 -0
  90. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1kw29-mrt-datacite.xml +0 -0
  91. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1ms3z-mrt-datacite.xml +0 -0
  92. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1mw2m-mrt-datacite.xml +0 -0
  93. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1np4m-mrt-datacite.xml +0 -0
  94. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1pk58-mrt-datacite.xml +0 -0
  95. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1pp4x-mrt-datacite.xml +0 -0
  96. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1qg6x-mrt-datacite.xml +0 -0
  97. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1qp47-mrt-datacite.xml +0 -0
  98. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1rg67-mrt-datacite.xml +0 -0
  99. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1rp4j-mrt-datacite.xml +0 -0
  100. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1sg6j-mrt-datacite.xml +0 -0
  101. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1t88j-mrt-datacite.xml +0 -0
  102. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1tg6v-mrt-datacite.xml +0 -0
  103. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1v88v-mrt-datacite.xml +0 -0
  104. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1vc7h-mrt-datacite.xml +0 -0
  105. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1w885-mrt-datacite.xml +0 -0
  106. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1wc7t-mrt-datacite.xml +0 -0
  107. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1x59t-mrt-datacite.xml +0 -0
  108. data/spec/data/{dash1-datacite-xml → dash1}/uci-ark+=b7280=d1z594-mrt-datacite.xml +0 -0
  109. data/spec/data/{dash1-datacite-xml → dash1}/ucla-ark+=b5060=d2qr4v2t-mrt-datacite.xml +0 -0
  110. data/spec/data/{dash1-datacite-xml → dash1}/ucla-ark+=b5068=d1cc7x-mrt-datacite.xml +0 -0
  111. data/spec/data/{dash1-datacite-xml → dash1}/ucla-ark+=b5068=d1h59v-mrt-datacite.xml +0 -0
  112. data/spec/data/{dash1-datacite-xml → dash1}/ucla-ark+=b5068=d1rp49-mrt-datacite.xml +0 -0
  113. data/spec/data/{dash1-datacite-xml → dash1}/ucla-ark+=b5068=d1wc7k-mrt-datacite.xml +0 -0
  114. data/spec/data/{dash1-datacite-xml → dash1}/ucm-ark+=13030=m51g217t-mrt-datacite.xml +0 -0
  115. data/spec/data/{dash1-datacite-xml → dash1}/ucm-ark+=b6071=z7wc73-mrt-datacite.xml +0 -0
  116. data/spec/data/{dash1-datacite-xml → dash1}/ucop-ark+=b5060=d8301x-mrt-datacite.xml +0 -0
  117. data/spec/data/{dash1-datacite-xml → dash1}/ucop-ark+=b5060=d86p4w-mrt-datacite.xml +0 -0
  118. data/spec/data/{dash1-datacite-xml → dash1}/ucop-ark+=b5060=d8bc75-mrt-datacite.xml +0 -0
  119. data/spec/data/{dash1-datacite-xml → dash1}/ucop-ark+=b5060=d8g593-mrt-datacite.xml +0 -0
  120. data/spec/data/{dash1-datacite-xml → dash1}/ucop-ark+=b5060=d8h59d-mrt-datacite.xml +0 -0
  121. data/spec/data/{dash1-datacite-xml → dash1}/ucop-ark+=b5060=d8kw2m-mrt-datacite.xml +0 -0
  122. data/spec/data/{dash1-datacite-xml → dash1}/ucop-ark+=b5060=d8rp4v-mrt-datacite.xml +0 -0
  123. data/spec/data/{dash1-datacite-xml → dash1}/ucop-ark+=b5060=d8z59f-mrt-datacite.xml +0 -0
  124. data/spec/data/{dash1-datacite-xml → dash1}/ucsc-ark+=b7291=d11592-mrt-datacite.xml +0 -0
  125. data/spec/data/{dash1-datacite-xml → dash1}/ucsc-ark+=b7291=d17p46-mrt-datacite.xml +0 -0
  126. data/spec/data/{dash1-datacite-xml → dash1}/ucsc-ark+=b7291=d1h59d-mrt-datacite.xml +0 -0
  127. data/spec/data/{dash1-datacite-xml → dash1}/ucsc-ark+=b7291=d1mw2x-mrt-datacite.xml +0 -0
  128. data/spec/data/{dash1-datacite-xml → dash1}/ucsc-ark+=b7291=d1wc74-mrt-datacite.xml +0 -0
  129. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6057cv6-mrt-datacite.xml +0 -0
  130. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6154f00-mrt-datacite.xml +0 -0
  131. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q61z429d-mrt-datacite.xml +0 -0
  132. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q62z13fs-mrt-datacite.xml +0 -0
  133. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q65q4t1r-mrt-datacite.xml +0 -0
  134. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q66q1v54-mrt-datacite.xml +0 -0
  135. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q67p8w9z-mrt-datacite.xml +0 -0
  136. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q68g8hmp-mrt-datacite.xml +0 -0
  137. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6bg2kwf-mrt-datacite.xml +0 -0
  138. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6c8276k-mrt-datacite.xml +0 -0
  139. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6cc0xmh-mrt-datacite.xml +0 -0
  140. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6d798bd-mrt-datacite.xml +0 -0
  141. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6h12zxh-mrt-datacite.xml +0 -0
  142. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6h41pb7-mrt-datacite.xml +0 -0
  143. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6kw5cxv-mrt-datacite.xml +0 -0
  144. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6ms3qnx-mrt-datacite.xml +0 -0
  145. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6mw2f2n-mrt-datacite.xml +0 -0
  146. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6pn93h6-mrt-datacite.xml +0 -0
  147. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6qn64nk-mrt-datacite.xml +0 -0
  148. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6rf5rzx-mrt-datacite.xml +0 -0
  149. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6rn35sz-mrt-datacite.xml +0 -0
  150. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6sf2t3q-mrt-datacite.xml +0 -0
  151. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6td9v7j-mrt-datacite.xml +0 -0
  152. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6w66hpn-mrt-datacite.xml +0 -0
  153. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6x63jt1-mrt-datacite.xml +0 -0
  154. data/spec/data/{dash1-datacite-xml → dash1}/ucsf-ark+=b7272=q6z60kzd-mrt-datacite.xml +0 -0
  155. data/spec/data/datacite-4-synthetic.xml +110 -0
  156. data/spec/data/datacite3/datacite-example-Box_dateCollected_DataCollector-v3.0.xml +46 -0
  157. data/spec/data/datacite3/datacite-example-GeoLocation-v3.0.xml +50 -0
  158. data/spec/data/datacite3/datacite-example-HasMetadata-v3.0.xml +52 -0
  159. data/spec/data/datacite3/datacite-example-ResearchGroup_Methods-v3.0.xml +36 -0
  160. data/spec/data/datacite3/datacite-example-ResourceTypeGeneral_Collection-v3.0.xml +38 -0
  161. data/spec/data/datacite3/datacite-example-complicated-v3.0.xml +48 -0
  162. data/spec/data/datacite3/datacite-example-dataset-v3.0.xml +35 -0
  163. data/spec/data/datacite3/datacite-example-full-v3.1.xml +61 -0
  164. data/spec/data/datacite3/datacite-example-relationTypeIsIdenticalTo-v3.0.xml +48 -0
  165. data/spec/data/datacite3/datacite-example-video-v3.0.xml +26 -0
  166. data/spec/data/datacite3/datacite-example-workflow-v3.0.xml +43 -0
  167. data/spec/data/{metadata.xsd → datacite3/metadata.xsd} +0 -0
  168. data/spec/data/datacite4/datacite-example-Box_dateCollected_DataCollector-v4.0.xml +52 -0
  169. data/spec/data/datacite4/datacite-example-GeoLocation-v4.0.xml +66 -0
  170. data/spec/data/datacite4/datacite-example-HasMetadata-v4.0.xml +62 -0
  171. data/spec/data/datacite4/datacite-example-ResearchGroup_Methods-v4.0.xml +44 -0
  172. data/spec/data/datacite4/datacite-example-ResourceTypeGeneral_Collection-v4.0.xml +52 -0
  173. data/spec/data/datacite4/datacite-example-complicated-v4.0.xml +54 -0
  174. data/spec/data/datacite4/datacite-example-dataset-v4.0.xml +39 -0
  175. data/spec/data/{resource.xml → datacite4/datacite-example-full-v4.0.xml} +14 -4
  176. data/spec/data/{kernel-4.0 → datacite4}/datacite-example-fundingReference-v.4.0.xml +0 -0
  177. data/spec/data/datacite4/datacite-example-relationTypeIsIdenticalTo-v4.0.xml +65 -0
  178. data/spec/data/datacite4/datacite-example-video-v4.0.xml +31 -0
  179. data/spec/data/datacite4/datacite-example-workflow-v4.0.xml +55 -0
  180. data/spec/data/{kernel-4.0 → datacite4}/metadata.xsd +0 -0
  181. data/spec/rspec_custom_matchers.rb +5 -1
  182. data/spec/spec_helper.rb +1 -1
  183. data/spec/unit/datacite/mapping/contributor_spec.rb +7 -0
  184. data/spec/unit/datacite/mapping/creator_spec.rb +92 -0
  185. data/spec/unit/datacite/mapping/date_spec.rb +25 -214
  186. data/spec/unit/datacite/mapping/date_value_spec.rb +143 -0
  187. data/spec/unit/datacite/mapping/description_spec.rb +4 -3
  188. data/spec/unit/datacite/mapping/funding_reference_spec.rb +5 -5
  189. data/spec/unit/datacite/mapping/geo_location_box_spec.rb +0 -36
  190. data/spec/unit/datacite/mapping/geo_location_point_spec.rb +0 -25
  191. data/spec/unit/datacite/mapping/geo_location_polygon_spec.rb +47 -0
  192. data/spec/unit/datacite/mapping/geo_location_spec.rb +153 -6
  193. data/spec/unit/datacite/mapping/identifier_spec.rb +9 -0
  194. data/spec/unit/datacite/mapping/related_identifier_spec.rb +23 -0
  195. data/spec/unit/datacite/mapping/resource_spec.rb +994 -874
  196. data/spec/unit/datacite/mapping/subject_spec.rb +12 -6
  197. data/spec/unit/datacite/mapping/title_spec.rb +20 -6
  198. metadata +320 -278
  199. data/lib/datacite/mapping/nonvalidating.rb +0 -10
  200. data/lib/datacite/mapping/nonvalidating/identifier.rb +0 -40
  201. data/lib/datacite/mapping/nonvalidating/subject.rb +0 -43
  202. data/spec/data/mrt-datacite.xml +0 -61
  203. data/spec/unit/datacite/mapping/log_spec.rb +0 -23
  204. data/spec/unit/datacite/mapping/nonvalidating/identifier_spec.rb +0 -52
  205. data/spec/unit/datacite/mapping/resource_type_spec.rb +0 -68
@@ -1,5 +1,7 @@
1
1
  require 'xml/mapping_extensions'
2
2
 
3
+ require 'datacite/mapping/date_value'
4
+
3
5
  module Datacite
4
6
  module Mapping
5
7
 
@@ -35,32 +37,23 @@ module Datacite
35
37
  end
36
38
 
37
39
  # Represents a DataCite `<date/>` field, which can be a year, date (year-month-day or just year-month),
38
- # or ISO8601 datetime.
40
+ # ISO8601 datetime, or [RKMS-ISO8601](http://www.ukoln.ac.uk/metadata/dcmi/collection-RKMS-ISO8601/) date range.
39
41
  #
40
- # @!attribute [r] year
41
- # @return [Integer] The year.
42
- # @!attribute [r] month
43
- # @return [Integer, nil] The month. Can be `nil` if no month was specified.
44
- # @!attribute [r] day
45
- # @return [Integer, nil] The day. Can be `nil` if no day was specified.
46
- # @!attribute [r] hour
47
- # @return [Integer, nil] The hour. Can be `nil` if no hour was specified.
48
- # @!attribute [r] minute
49
- # @return [Integer, nil] The minutes. Can be `nil` if no minutes were specified.
50
- # @!attribute [r] sec
51
- # @return [Integer, nil] The seconds. Can be `nil` if no seconds were specified.
52
- # @!attribute [r] nsec
53
- # @return [Integer, nil] The nanoseconds. Can be `nil` if no nanoseconds were specified.
42
+ # @!attribute [r] date_value
43
+ # @return [DateValue, nil] the single date/time represented by this `<date/>` field,
44
+ # if it does not represent a ragne
45
+ # @!attribute [r] range_start
46
+ # @return [DateValue, nil] the start of the date range represented by this `<date/> field`,
47
+ # if it represents a range, and the range is not open on the lower end
48
+ # @!attribute [r] range_end
49
+ # @return [DateValue, nil] the end of the date range represented by this `<date/> field`,
50
+ # if it represents a range, and the range is not open on the upper end
54
51
  class Date
55
52
  include XML::Mapping
56
53
 
57
- attr_reader :year
58
- attr_reader :month
59
- attr_reader :day
60
- attr_reader :hour
61
- attr_reader :minute
62
- attr_reader :sec
63
- attr_reader :nsec
54
+ attr_reader :date_value
55
+ attr_reader :range_start
56
+ attr_reader :range_end
64
57
 
65
58
  # Initializes a new `Date`
66
59
  #
@@ -77,65 +70,22 @@ module Datacite
77
70
  @type = val
78
71
  end
79
72
 
80
- # Sets the value.
81
- #
82
- # @param val [DateTime, Date, Integer, String] The value, as a `DateTime`, `Date`, or `Integer`,
83
- # or as a `String` in any [W3C DateTime format](http://www.w3.org/TR/NOTE-datetime)
84
- def value=(val) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
85
- @date_time = to_datetime(val)
86
- @date = @date_time ? @date_time.to_date : to_date(val)
87
- @year = to_year(val)
88
- @month = to_month(val)
89
- @day = to_day(val)
90
- new_value = val.respond_to?(:iso8601) ? val.iso8601 : val.to_s
91
- if new_value.include?('T')
92
- @hour = @date_time.hour if @date_time
93
- @minute = @date_time.minute if @date_time
94
- @sec = @date_time.sec if @date_time
95
- @nsec = @date_time.to_time.nsec if @date_time
73
+ def value=(val) # rubocop:disable Metrics/AbcSize
74
+ parts = val.to_s.split('/', -1) # negative limit so we don't drop trailing empty string
75
+ @date_value, @range_start, @range_end = nil
76
+ if parts.size == 1
77
+ @date_value = DateValue.new(val)
78
+ elsif parts.size == 2
79
+ @range_start, @range_end = parts.map(&:strip).map { |part| DateValue.new(part) unless part == '' }
80
+ # puts "#{val} -> [#{range_start}, #{range_end}]"
81
+ else
82
+ fail ArgumentError, "Unable to parse date value #{val}"
96
83
  end
97
- fail ArgumentError, "Unable to parse date value '#{val}'" unless @year
98
- @value = new_value
84
+ @value = val
99
85
  end
100
86
 
101
87
  private
102
88
 
103
- def to_year(val)
104
- return val if val.is_a?(Integer)
105
- return val.year if val.respond_to?(:year)
106
- matchdata = val.to_s.match(/^[0-9]+/)
107
- matchdata[0].to_i if matchdata
108
- end
109
-
110
- def to_month(val)
111
- return val.month if val.respond_to?(:month)
112
- matchdata = val.to_s.match(/^[0-9]+-([0-9]{2})(?![0-9])/)
113
- matchdata[1].to_i if matchdata
114
- end
115
-
116
- def to_day(val)
117
- return val.day if val.respond_to?(:day)
118
- matchdata = val.to_s.match(/^[0-9]+-[0-9]{2}-([0-9]{2})(?![0-9])/)
119
- matchdata[1].to_i if matchdata
120
- end
121
-
122
- def to_datetime(val)
123
- return val if val.is_a?(DateTime)
124
- DateTime.parse(val.to_s)
125
- rescue ArgumentError => e
126
- Mapping.log.debug("Can't extract DateTime from date value '#{val}': #{e}")
127
- nil
128
- end
129
-
130
- def to_date(val)
131
- return val if val.is_a?(::Date)
132
- return ::Date.parse(val.iso8601) if val.respond_to?(:iso8601)
133
- ::Date.parse(val.to_s)
134
- rescue ArgumentError => e
135
- Mapping.log.debug("Can't extract Date from date value '#{val}': #{e}")
136
- nil
137
- end
138
-
139
89
  # @!attribute [rw] type
140
90
  # @return [DateType] the type of date. Cannot be nil.
141
91
  typesafe_enum_node :type, '@dateType', class: DateType
@@ -143,6 +93,8 @@ module Datacite
143
93
  # @!method value
144
94
  # @return [String] The value as a string. May be any [W3C DateTime format](http://www.w3.org/TR/NOTE-datetime).
145
95
  text_node :value, 'text()'
96
+
97
+ fallback_mapping :datacite_3, :_default
146
98
  end
147
99
  end
148
100
  end
@@ -0,0 +1,116 @@
1
+ require 'xml/mapping_extensions'
2
+
3
+ module Datacite
4
+ module Mapping
5
+
6
+ # Represents a DataCite "date" value, which can be a year, date (year-month-day or just year-month),
7
+ # or ISO8601 datetime.
8
+ #
9
+ # @!attribute [r] year
10
+ # @return [Integer] The year.
11
+ # @!attribute [r] month
12
+ # @return [Integer, nil] The month. Can be `nil` if no month was specified.
13
+ # @!attribute [r] day
14
+ # @return [Integer, nil] The day. Can be `nil` if no day was specified.
15
+ # @!attribute [r] hour
16
+ # @return [Integer, nil] The hour. Can be `nil` if no hour was specified.
17
+ # @!attribute [r] minute
18
+ # @return [Integer, nil] The minutes. Can be `nil` if no minutes were specified.
19
+ # @!attribute [r] sec
20
+ # @return [Integer, nil] The seconds. Can be `nil` if no seconds were specified.
21
+ # @!attribute [r] nsec
22
+ # @return [Integer, nil] The nanoseconds. Can be `nil` if no nanoseconds were specified.
23
+ class DateValue
24
+ include Comparable
25
+
26
+ attr_reader :year
27
+ attr_reader :month
28
+ attr_reader :day
29
+ attr_reader :hour
30
+ attr_reader :minute
31
+ attr_reader :sec
32
+ attr_reader :nsec
33
+ attr_reader :date
34
+ attr_reader :zone
35
+
36
+ # Creates a new {DateValue}.
37
+ #
38
+ # @param val [DateTime, Date, Integer, String] The value, as a `DateTime`, `Date`, or `Integer`,
39
+ # or as a `String` in any [W3C DateTime format](http://www.w3.org/TR/NOTE-datetime)
40
+ def initialize(val) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
41
+ datetime = to_datetime(val)
42
+ @date = datetime ? datetime.to_date : to_date(val)
43
+ @year = to_year(val)
44
+ @month = to_month(val)
45
+ @day = to_day(val)
46
+ iso_value = val.respond_to?(:iso8601) ? val.iso8601 : val.to_s
47
+ if datetime && iso_value.include?('T')
48
+ @hour = datetime.hour
49
+ @minute = datetime.minute
50
+ @sec = datetime.sec
51
+ @nsec = datetime.to_time.nsec
52
+ @zone = datetime.zone
53
+ end
54
+ fail ArgumentError, "Unable to parse date value '#{val}'" unless @year
55
+ end
56
+
57
+ def <=>(other)
58
+ return nil unless other.class == self.class
59
+ [:year, :month, :day, :hour, :minute, :sec, :nsec].each do |v|
60
+ order = send(v) <=> other.send(v)
61
+ return order if order.nonzero?
62
+ end
63
+ 0
64
+ end
65
+
66
+ def hash
67
+ [year, month, day, hour, minute, sec, nsec, zone].hash
68
+ end
69
+
70
+ def to_s
71
+ 'DateTime(' + [:year, :month, :day, :hour, :minute, :sec, :nsec, :zone].map do |field|
72
+ value = send(field)
73
+ value = format('%02d', value) if value && value.is_a?(Integer)
74
+ "#{field}: #{value}" if value
75
+ end.compact.join(', ') + ')'
76
+ end
77
+
78
+ private
79
+
80
+ def to_year(val)
81
+ return val if val.is_a?(Integer)
82
+ return val.year if val.respond_to?(:year)
83
+ matchdata = val.to_s.match(/^[0-9]+/)
84
+ matchdata[0].to_i if matchdata
85
+ end
86
+
87
+ def to_month(val)
88
+ return val.month if val.respond_to?(:month)
89
+ matchdata = val.to_s.match(/^[0-9]+-([0-9]{2})(?![0-9])/)
90
+ matchdata[1].to_i if matchdata
91
+ end
92
+
93
+ def to_day(val)
94
+ return val.day if val.respond_to?(:day)
95
+ matchdata = val.to_s.match(/^[0-9]+-[0-9]{2}-([0-9]{2})(?![0-9])/)
96
+ matchdata[1].to_i if matchdata
97
+ end
98
+
99
+ def to_datetime(val)
100
+ return val if val.is_a?(DateTime)
101
+ DateTime.parse(val.to_s)
102
+ rescue ArgumentError
103
+ nil
104
+ end
105
+
106
+ def to_date(val)
107
+ return val if val.is_a?(::Date)
108
+ return ::Date.parse(val.iso8601) if val.respond_to?(:iso8601)
109
+ ::Date.parse(val.to_s)
110
+ rescue ArgumentError
111
+ nil
112
+ end
113
+
114
+ end
115
+ end
116
+ end
@@ -77,28 +77,28 @@ module Datacite
77
77
  include XML::Mapping
78
78
 
79
79
  # Initializes a new {Description}
80
- # @param language [String] an IETF BCP 47, ISO 639-1 language code identifying the language.
81
- # It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
80
+ # @param language [String, nil] an IETF BCP 47, ISO 639-1 language code identifying the language.
82
81
  # @param type [DescriptionType] the description type.
83
82
  # @param value [String] the description itself. See {Description} for notes on special
84
83
  # handling of `<br/>` tags.
85
- def initialize(language: 'en', type:, value:)
84
+ def initialize(language: nil, type:, value:)
86
85
  self.language = language
87
86
  self.type = type
88
87
  self.value = value
89
88
  end
90
89
 
91
- def language
92
- @language || 'en'
90
+ def language=(value)
91
+ @language = value && value.strip
93
92
  end
94
93
 
95
- def language=(value)
96
- @language = value.strip if value
94
+ def value=(v)
95
+ new_value = v && v.strip
96
+ fail ArgumentError, 'Value cannot be empty or nil' unless new_value && !new_value.empty?
97
+ @value = new_value
97
98
  end
98
99
 
99
100
  # @!attribute [rw] language
100
101
  # @return [String] an IETF BCP 47, ISO 639-1 language code identifying the language.
101
- # It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
102
102
  text_node :language, '@xml:lang', default_value: nil
103
103
 
104
104
  # @!attribute [rw] type
@@ -110,6 +110,7 @@ module Datacite
110
110
  # handling of `<br/>` tags.
111
111
  break_preserving_value_node :value, 'node()'
112
112
 
113
+ fallback_mapping :datacite_3, :_default
113
114
  end
114
115
  end
115
116
  end
@@ -37,6 +37,10 @@ module Datacite
37
37
  @type = value
38
38
  end
39
39
 
40
+ def to_s
41
+ "#{type.value}: #{value}"
42
+ end
43
+
40
44
  # @!attribute [rw] type
41
45
  # @return [FunderIdentifierType] the identifier type. Cannot be nil.
42
46
  typesafe_enum_node :type, '@funderIdentifierType', class: FunderIdentifierType
@@ -59,6 +63,10 @@ module Datacite
59
63
  @value = value
60
64
  end
61
65
 
66
+ def to_s
67
+ "#{value} (#{uri})"
68
+ end
69
+
62
70
  # @!attribute [rw] uri
63
71
  # @return [URI, nil] The URI leading to a page provided by the funder for more information about the award
64
72
  uri_node :uri, '@awardURI', default_value: nil
@@ -81,17 +89,24 @@ module Datacite
81
89
  end
82
90
 
83
91
  def award_number=(value)
84
- if value.nil? || value.is_a?(AwardNumber)
85
- @award_number = value
86
- else
87
- @award_number = AwardNumber.new(value: value.to_s)
88
- end
92
+ @award_number = if value.nil? || value.is_a?(AwardNumber)
93
+ value
94
+ else
95
+ AwardNumber.new(value: value.to_s)
96
+ end
97
+ end
98
+
99
+ def to_s
100
+ fields = [:name, :identifier, :award_number, :award_title].map { |f| "#{f}: #{send(f)}" }
101
+ "FundingReference { #{fields.join(', ')} }"
89
102
  end
90
103
 
91
104
  text_node :name, 'funderName'
92
105
  object_node :identifier, 'funderIdentifier', class: FunderIdentifier, default_value: nil
93
106
  object_node :award_number, 'awardNumber', class: AwardNumber, default_value: nil
94
107
  text_node :award_title, 'awardTitle', default_value: nil
108
+
109
+ fallback_mapping :datacite_3, :_default
95
110
  end
96
111
  end
97
112
  end
@@ -1,6 +1,7 @@
1
1
  require 'xml/mapping_extensions'
2
2
  require 'datacite/mapping/geo_location_point'
3
3
  require 'datacite/mapping/geo_location_box'
4
+ require 'datacite/mapping/geo_location_polygon'
4
5
 
5
6
  module Datacite
6
7
  module Mapping
@@ -17,18 +18,28 @@ module Datacite
17
18
  # @param point [GeoLocationPoint, nil] the latitude and longitude at which the data was gathered or about which the data is focused.
18
19
  # @param box [GeoLocationBox, nil] the latitude-longitude quadrangle containing the area where the data was gathered or about which the data is focused.
19
20
  # @param place [String, nil] the spatial region or named place where the data was gathered or about which the data is focused.
20
- def initialize(point: nil, box: nil, place: nil)
21
+ # @param polygon [GeoLocationPolygon, nil] a drawn polygon area containing the area where the data was gathered or about which the data is focused.
22
+ def initialize(point: nil, box: nil, place: nil, polygon: nil)
21
23
  self.point = point
22
24
  self.box = box
23
25
  self.place = place
26
+ self.polygon = polygon
24
27
  end
25
28
 
26
29
  def place=(value)
27
30
  @place = value.respond_to?(:strip) ? value.strip : value
28
31
  end
29
32
 
33
+ def location?
34
+ point || box || place || polygon
35
+ end
36
+
30
37
  root_element_name 'geoLocation'
31
38
 
39
+ # @!attribute [rw] place
40
+ # @return [String, nil] the spatial region or named place where the data was gathered or about which the data is focused.
41
+ text_node :place, 'geoLocationPlace', default_value: nil
42
+
32
43
  # @!attribute [rw] point
33
44
  # @return [GeoLocationPoint, nil] the latitude and longitude at which the data was gathered or about which the data is focused.
34
45
  geo_location_point_node :point, 'geoLocationPoint', default_value: nil
@@ -37,10 +48,20 @@ module Datacite
37
48
  # @return [GeoLocationBox, nil] the latitude-longitude quadrangle containing the area where the data was gathered or about which the data is focused.
38
49
  geo_location_box_node :box, 'geoLocationBox', default_value: nil
39
50
 
40
- # @!attribute [rw] place
41
- # @return [String, nil] the spatial region or named place where the data was gathered or about which the data is focused.
42
- text_node :place, 'geoLocationPlace', default_value: nil
51
+ # # @!attribute [rw] polygon
52
+ # # @return [GeoLocationPolygon] a drawn polygon area containing the area where the data was gathered or about which the data is focused.
53
+ object_node :polygon, 'geoLocationPolygon', class: GeoLocationPolygon, default_value: nil
54
+
55
+ use_mapping :datacite_3
56
+
57
+ # Workaround for https://github.com/dmolesUC3/xml-mapping_extensions/issues/6
58
+ object_node :polygon, 'geoLocationPolygon', class: GeoLocationPolygon, default_value: nil, marshaller: (proc do |xml, value|
59
+ # TODO: Move ReadOnlyNodes.warn() somewhere more obvious
60
+ ReadOnlyNodes.warn "<geoLocationPolygon/> not supported in Datacite 3; ignoring polygon #{value}"
61
+ xml.parent.delete_element(xml)
62
+ end)
43
63
 
64
+ fallback_mapping :datacite_3, :_default
44
65
  end
45
66
  end
46
67
  end
@@ -1,4 +1,5 @@
1
1
  require 'xml/mapping'
2
+ require 'datacite/mapping/geo_location_node'
2
3
 
3
4
  module Datacite
4
5
  module Mapping
@@ -95,7 +96,7 @@ module Datacite
95
96
  return nil unless other.class == self.class
96
97
  [:south_latitude, :west_longitude, :north_latitude, :east_longitude].each do |c|
97
98
  order = send(c) <=> other.send(c)
98
- return order if order != 0
99
+ return order if order.nonzero?
99
100
  end
100
101
  0
101
102
  end
@@ -122,13 +123,14 @@ module Datacite
122
123
  end
123
124
 
124
125
  # XML mapping node for `<geoLocationBox/>`
125
- class GeoLocationBoxNode < XML::MappingExtensions::NodeBase
126
- # Converts a whitespace-separated list of coordinates to a {GeoLocationBox}.
127
- # @param xml_text [String] the coordinates, in the order `lat long lat long`.
128
- def to_value(xml_text)
129
- stripped = xml_text.strip
130
- coords = stripped.split(/\s+/).map(&:to_f)
131
- GeoLocationBox.new(*coords)
126
+ class GeoLocationBoxNode < GeoLocationNode
127
+ def initialize(*args)
128
+ @geom_class = GeoLocationBox
129
+ @coord_elements = { west_longitude: 'westBoundLongitude',
130
+ east_longitude: 'eastBoundLongitude',
131
+ south_latitude: 'southBoundLatitude',
132
+ north_latitude: 'northBoundLatitude' }.freeze
133
+ super
132
134
  end
133
135
  end
134
136
  XML::Mapping.add_node_class GeoLocationBoxNode