pubid 2.0.0.pre.alpha.7 → 2.0.0.pre.alpha.9

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 (485) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +9 -50
  3. data/data/bipm/update_codes.yaml +9 -0
  4. data/data/iec/update_codes.yaml +3 -0
  5. data/data/ieee/update_codes.yaml +107 -1
  6. data/data/nist/series.yaml +155 -0
  7. data/data/nist/update_codes.yaml +8 -0
  8. data/lib/pubid/adobe/builder.rb +52 -0
  9. data/lib/pubid/adobe/identifier.rb +49 -0
  10. data/lib/pubid/adobe/identifiers/publication.rb +31 -0
  11. data/lib/pubid/adobe/identifiers/tech_note.rb +32 -0
  12. data/lib/pubid/adobe/identifiers.rb +10 -0
  13. data/lib/pubid/adobe/parser.rb +128 -0
  14. data/lib/pubid/adobe/renderer.rb +39 -0
  15. data/lib/pubid/adobe/urn_generator.rb +42 -0
  16. data/lib/pubid/adobe/urn_parser.rb +69 -0
  17. data/lib/pubid/adobe.rb +60 -0
  18. data/lib/pubid/amca/builder.rb +2 -2
  19. data/lib/pubid/amca/identifier.rb +1 -3
  20. data/lib/pubid/amca/identifiers/base.rb +1 -6
  21. data/lib/pubid/amca/identifiers/interpretation.rb +1 -1
  22. data/lib/pubid/amca/identifiers/publication.rb +1 -1
  23. data/lib/pubid/amca/identifiers/standard.rb +1 -1
  24. data/lib/pubid/amca/identifiers.rb +0 -1
  25. data/lib/pubid/amca/single_identifier.rb +1 -1
  26. data/lib/pubid/amca.rb +3 -3
  27. data/lib/pubid/ashrae/builder.rb +22 -22
  28. data/lib/pubid/ashrae/identifier.rb +3 -4
  29. data/lib/pubid/ashrae/identifiers/addenda_package.rb +1 -1
  30. data/lib/pubid/ashrae/identifiers/addendum.rb +1 -1
  31. data/lib/pubid/ashrae/identifiers/base.rb +14 -8
  32. data/lib/pubid/ashrae/identifiers/combined_addenda.rb +1 -1
  33. data/lib/pubid/ashrae/identifiers.rb +0 -1
  34. data/lib/pubid/ashrae/parser.rb +14 -9
  35. data/lib/pubid/ashrae/renderer.rb +19 -19
  36. data/lib/pubid/ashrae/single_identifier.rb +1 -1
  37. data/lib/pubid/ashrae/supplement_identifier.rb +6 -6
  38. data/lib/pubid/ashrae.rb +3 -3
  39. data/lib/pubid/bipm/builder.rb +107 -0
  40. data/lib/pubid/bipm/identifier.rb +160 -0
  41. data/lib/pubid/bipm/identifiers/committee_document.rb +24 -0
  42. data/lib/pubid/bipm/identifiers/guide.rb +24 -0
  43. data/lib/pubid/bipm/identifiers/meeting.rb +41 -0
  44. data/lib/pubid/bipm/identifiers/mep.rb +21 -0
  45. data/lib/pubid/bipm/identifiers/metrologia_article.rb +24 -0
  46. data/lib/pubid/bipm/identifiers/si_brochure.rb +20 -0
  47. data/lib/pubid/bipm/identifiers.rb +15 -0
  48. data/lib/pubid/bipm/parser.rb +184 -0
  49. data/lib/pubid/bipm/renderer.rb +110 -0
  50. data/lib/pubid/bipm/urn_generator.rb +58 -0
  51. data/lib/pubid/bipm/urn_parser.rb +52 -0
  52. data/lib/pubid/bipm.rb +86 -0
  53. data/lib/pubid/bsi/builder.rb +14 -14
  54. data/lib/pubid/bsi/identifier.rb +0 -1
  55. data/lib/pubid/bsi/identifiers/addendum_document.rb +2 -2
  56. data/lib/pubid/bsi/identifiers/amendment.rb +4 -4
  57. data/lib/pubid/bsi/identifiers/consolidated_identifier.rb +6 -0
  58. data/lib/pubid/bsi/identifiers/corrigendum.rb +4 -4
  59. data/lib/pubid/bsi/identifiers/expert_commentary.rb +5 -5
  60. data/lib/pubid/bsi/identifiers/supplement_document.rb +2 -2
  61. data/lib/pubid/bsi/identifiers/value_added_publication.rb +6 -6
  62. data/lib/pubid/bsi/renderer.rb +8 -8
  63. data/lib/pubid/bsi/single_identifier.rb +48 -0
  64. data/lib/pubid/builder/base.rb +5 -3
  65. data/lib/pubid/bundled_identifier.rb +3 -3
  66. data/lib/pubid/calconnect/builder.rb +38 -0
  67. data/lib/pubid/calconnect/identifier.rb +117 -0
  68. data/lib/pubid/calconnect/identifiers/standard.rb +29 -0
  69. data/lib/pubid/calconnect/identifiers.rb +9 -0
  70. data/lib/pubid/calconnect/parser.rb +54 -0
  71. data/lib/pubid/calconnect/renderer.rb +36 -0
  72. data/lib/pubid/calconnect/urn_generator.rb +33 -0
  73. data/lib/pubid/calconnect/urn_parser.rb +34 -0
  74. data/lib/pubid/calconnect.rb +77 -0
  75. data/lib/pubid/ccsds/builder.rb +1 -1
  76. data/lib/pubid/ccsds/identifier.rb +1 -1
  77. data/lib/pubid/ccsds/identifiers/corrigendum.rb +2 -2
  78. data/lib/pubid/ccsds/supplement_identifier.rb +6 -6
  79. data/lib/pubid/ccsds/urn_generator.rb +3 -3
  80. data/lib/pubid/cen_cenelec/builder.rb +46 -12
  81. data/lib/pubid/cen_cenelec/identifiers/amendment.rb +2 -2
  82. data/lib/pubid/cen_cenelec/identifiers/consolidated_identifier.rb +6 -0
  83. data/lib/pubid/cen_cenelec/identifiers/corrigendum.rb +2 -2
  84. data/lib/pubid/cen_cenelec/identifiers/european_norm.rb +60 -3
  85. data/lib/pubid/cen_cenelec/identifiers/fragment.rb +2 -2
  86. data/lib/pubid/cen_cenelec/renderer.rb +5 -5
  87. data/lib/pubid/cen_cenelec/supplement_identifier.rb +5 -5
  88. data/lib/pubid/cen_cenelec/urn_generator.rb +1 -1
  89. data/lib/pubid/cen_cenelec.rb +76 -72
  90. data/lib/pubid/cie/builder.rb +139 -24
  91. data/lib/pubid/cie/identifier.rb +7 -3
  92. data/lib/pubid/cie/identifiers/bundle.rb +32 -4
  93. data/lib/pubid/cie/identifiers/code_attributes.rb +52 -0
  94. data/lib/pubid/cie/identifiers/conference.rb +9 -4
  95. data/lib/pubid/cie/identifiers/corrigendum.rb +17 -23
  96. data/lib/pubid/cie/identifiers/dual_published.rb +4 -4
  97. data/lib/pubid/cie/identifiers/identical.rb +7 -7
  98. data/lib/pubid/cie/identifiers/joint_published.rb +8 -8
  99. data/lib/pubid/cie/identifiers/proceedings.rb +39 -0
  100. data/lib/pubid/cie/identifiers/standard.rb +33 -7
  101. data/lib/pubid/cie/identifiers/supplement.rb +24 -22
  102. data/lib/pubid/cie/identifiers/tutorial_bundle.rb +6 -2
  103. data/lib/pubid/cie/identifiers.rb +2 -0
  104. data/lib/pubid/cie/parser.rb +54 -5
  105. data/lib/pubid/cie/single_identifier.rb +40 -1
  106. data/lib/pubid/cie/supplement_identifier.rb +29 -16
  107. data/lib/pubid/cie/urn_generator.rb +11 -8
  108. data/lib/pubid/cie.rb +0 -1
  109. data/lib/pubid/components/date.rb +21 -5
  110. data/lib/pubid/csa/builder.rb +1 -1
  111. data/lib/pubid/csa/composite_identifier.rb +17 -1
  112. data/lib/pubid/csa/identifier.rb +48 -3
  113. data/lib/pubid/csa/identifiers/bundled.rb +6 -0
  114. data/lib/pubid/csa/identifiers/combined.rb +6 -0
  115. data/lib/pubid/csa/identifiers/package.rb +2 -2
  116. data/lib/pubid/csa/parser.rb +6 -6
  117. data/lib/pubid/csa/wrapper_identifier.rb +17 -0
  118. data/lib/pubid/doi/builder.rb +18 -0
  119. data/lib/pubid/doi/identifier.rb +46 -0
  120. data/lib/pubid/doi/identifiers/resource.rb +30 -0
  121. data/lib/pubid/doi/identifiers.rb +9 -0
  122. data/lib/pubid/doi/parser.rb +52 -0
  123. data/lib/pubid/doi/renderer.rb +13 -0
  124. data/lib/pubid/doi.rb +55 -0
  125. data/lib/pubid/easc/builder.rb +55 -0
  126. data/lib/pubid/easc/identifier.rb +61 -0
  127. data/lib/pubid/easc/identifiers/pmg.rb +20 -0
  128. data/lib/pubid/easc/identifiers/rmg.rb +19 -0
  129. data/lib/pubid/easc/identifiers.rb +10 -0
  130. data/lib/pubid/easc/parser.rb +80 -0
  131. data/lib/pubid/easc/renderer.rb +48 -0
  132. data/lib/pubid/easc/urn_generator.rb +46 -0
  133. data/lib/pubid/easc/urn_parser.rb +57 -0
  134. data/lib/pubid/easc.rb +52 -0
  135. data/lib/pubid/ecma/builder.rb +31 -0
  136. data/lib/pubid/ecma/identifier.rb +76 -0
  137. data/lib/pubid/ecma/identifiers/memento.rb +30 -0
  138. data/lib/pubid/ecma/identifiers/standard.rb +31 -0
  139. data/lib/pubid/ecma/identifiers/technical_report.rb +31 -0
  140. data/lib/pubid/ecma/identifiers.rb +11 -0
  141. data/lib/pubid/ecma/parser.rb +41 -0
  142. data/lib/pubid/ecma/renderer.rb +46 -0
  143. data/lib/pubid/ecma/urn_generator.rb +25 -0
  144. data/lib/pubid/ecma/urn_parser.rb +35 -0
  145. data/lib/pubid/ecma.rb +67 -0
  146. data/lib/pubid/etsi/builder.rb +7 -3
  147. data/lib/pubid/etsi/identifier.rb +1 -3
  148. data/lib/pubid/etsi/identifiers/base.rb +28 -10
  149. data/lib/pubid/etsi/identifiers/etsi_standard.rb +128 -4
  150. data/lib/pubid/etsi/identifiers/supplement_identifier.rb +35 -3
  151. data/lib/pubid/etsi/identifiers.rb +0 -1
  152. data/lib/pubid/etsi/parser.rb +8 -2
  153. data/lib/pubid/etsi/renderer.rb +8 -2
  154. data/lib/pubid/etsi.rb +5 -5
  155. data/lib/pubid/export/exporter.rb +2 -1
  156. data/lib/pubid/export/flavor_exporter.rb +18 -3
  157. data/lib/pubid/gb/builder.rb +45 -0
  158. data/lib/pubid/gb/identifier.rb +64 -0
  159. data/lib/pubid/gb/identifiers/standard.rb +34 -0
  160. data/lib/pubid/gb/identifiers.rb +9 -0
  161. data/lib/pubid/gb/parser.rb +63 -0
  162. data/lib/pubid/gb/renderer.rb +35 -0
  163. data/lib/pubid/gb.rb +87 -0
  164. data/lib/pubid/gost/builder.rb +148 -0
  165. data/lib/pubid/gost/identifier.rb +49 -0
  166. data/lib/pubid/gost/identifiers/foreign_reference.rb +25 -0
  167. data/lib/pubid/gost/identifiers/harmonized.rb +39 -0
  168. data/lib/pubid/gost/identifiers/identical_adoption.rb +39 -0
  169. data/lib/pubid/gost/identifiers/interstate_standard.rb +20 -0
  170. data/lib/pubid/gost/identifiers/national_standard.rb +19 -0
  171. data/lib/pubid/gost/identifiers.rb +13 -0
  172. data/lib/pubid/gost/parser.rb +97 -0
  173. data/lib/pubid/gost/renderer.rb +48 -0
  174. data/lib/pubid/gost/urn_generator.rb +46 -0
  175. data/lib/pubid/gost/urn_parser.rb +52 -0
  176. data/lib/pubid/gost.rb +49 -0
  177. data/lib/pubid/iala/builder.rb +22 -27
  178. data/lib/pubid/iala/identifier.rb +27 -2
  179. data/lib/pubid/iala/identifiers/advice.rb +1 -1
  180. data/lib/pubid/iala/identifiers/annex.rb +14 -12
  181. data/lib/pubid/iala/identifiers/general_assembly.rb +5 -2
  182. data/lib/pubid/iala/identifiers/guideline.rb +3 -1
  183. data/lib/pubid/iala/identifiers/letter.rb +1 -1
  184. data/lib/pubid/iala/identifiers/manual.rb +3 -1
  185. data/lib/pubid/iala/identifiers/model_course.rb +3 -1
  186. data/lib/pubid/iala/identifiers/recommendation.rb +3 -1
  187. data/lib/pubid/iala/identifiers/report.rb +1 -1
  188. data/lib/pubid/iala/identifiers/resolution.rb +1 -1
  189. data/lib/pubid/iala/identifiers/standard.rb +3 -1
  190. data/lib/pubid/iala/identifiers.rb +0 -1
  191. data/lib/pubid/iala/renderer.rb +1 -1
  192. data/lib/pubid/iala/urn_generator.rb +1 -1
  193. data/lib/pubid/iala/urn_parser.rb +19 -2
  194. data/lib/pubid/iala.rb +4 -4
  195. data/lib/pubid/iana/builder.rb +20 -0
  196. data/lib/pubid/iana/identifier.rb +72 -0
  197. data/lib/pubid/iana/identifiers/registry.rb +33 -0
  198. data/lib/pubid/iana/identifiers.rb +9 -0
  199. data/lib/pubid/iana/parser.rb +38 -0
  200. data/lib/pubid/iana/renderer.rb +29 -0
  201. data/lib/pubid/iana/urn_generator.rb +15 -0
  202. data/lib/pubid/iana/urn_parser.rb +24 -0
  203. data/lib/pubid/iana.rb +69 -0
  204. data/lib/pubid/identifier.rb +210 -23
  205. data/lib/pubid/idf/builder.rb +1 -1
  206. data/lib/pubid/idf/parser.rb +2 -2
  207. data/lib/pubid/idf/renderer.rb +1 -1
  208. data/lib/pubid/idf/supplement_identifier.rb +3 -3
  209. data/lib/pubid/iec/builder.rb +35 -25
  210. data/lib/pubid/iec/identifier.rb +47 -2
  211. data/lib/pubid/iec/identifiers/base.rb +2 -2
  212. data/lib/pubid/iec/identifiers/consolidated_identifier.rb +6 -0
  213. data/lib/pubid/iec/identifiers/fragment_identifier.rb +11 -11
  214. data/lib/pubid/iec/identifiers/international_standard.rb +8 -5
  215. data/lib/pubid/iec/identifiers/sheet_identifier.rb +12 -12
  216. data/lib/pubid/iec/identifiers/technical_group.rb +30 -0
  217. data/lib/pubid/iec/identifiers/technical_report.rb +1 -1
  218. data/lib/pubid/iec/identifiers/technical_specification.rb +1 -1
  219. data/lib/pubid/iec/identifiers/vap_identifier.rb +12 -12
  220. data/lib/pubid/iec/identifiers.rb +1 -0
  221. data/lib/pubid/iec/parser.rb +51 -10
  222. data/lib/pubid/iec/renderer.rb +18 -8
  223. data/lib/pubid/iec/single_identifier.rb +1 -1
  224. data/lib/pubid/iec/supplement_identifier.rb +32 -19
  225. data/lib/pubid/iec.rb +1 -6
  226. data/lib/pubid/ieee/aiee/builder.rb +17 -3
  227. data/lib/pubid/ieee/aiee/identifier.rb +45 -61
  228. data/lib/pubid/ieee/builder.rb +341 -68
  229. data/lib/pubid/ieee/compaction.rb +121 -0
  230. data/lib/pubid/ieee/components/draft.rb +47 -7
  231. data/lib/pubid/ieee/identifier.rb +1 -3
  232. data/lib/pubid/ieee/identifiers/adopted_standard.rb +30 -5
  233. data/lib/pubid/ieee/identifiers/amendment.rb +40 -0
  234. data/lib/pubid/ieee/identifiers/base.rb +106 -13
  235. data/lib/pubid/ieee/identifiers/code_number.rb +82 -0
  236. data/lib/pubid/ieee/identifiers/conformance_identifier.rb +6 -2
  237. data/lib/pubid/ieee/identifiers/corrigendum.rb +17 -2
  238. data/lib/pubid/ieee/identifiers/csa_dual_published.rb +3 -3
  239. data/lib/pubid/ieee/identifiers/dual_identifier.rb +3 -3
  240. data/lib/pubid/ieee/identifiers/dual_published.rb +3 -3
  241. data/lib/pubid/ieee/identifiers/iec_ieee_copublished.rb +102 -5
  242. data/lib/pubid/ieee/identifiers/interpretation_identifier.rb +2 -1
  243. data/lib/pubid/ieee/identifiers/joint_development.rb +56 -11
  244. data/lib/pubid/ieee/identifiers/multi_numbered_identifier.rb +1 -1
  245. data/lib/pubid/ieee/identifiers/nesc/base.rb +90 -19
  246. data/lib/pubid/ieee/identifiers/nesc/draft.rb +20 -5
  247. data/lib/pubid/ieee/identifiers/nesc/edition.rb +32 -0
  248. data/lib/pubid/ieee/identifiers/nesc/handbook.rb +16 -5
  249. data/lib/pubid/ieee/identifiers/nesc/redline.rb +11 -2
  250. data/lib/pubid/ieee/identifiers/nesc/standard.rb +18 -3
  251. data/lib/pubid/ieee/identifiers/nesc.rb +1 -0
  252. data/lib/pubid/ieee/identifiers/parenthetical_identifier.rb +3 -3
  253. data/lib/pubid/ieee/identifiers/project_draft_identifier.rb +14 -6
  254. data/lib/pubid/ieee/identifiers/redlined_standard.rb +4 -4
  255. data/lib/pubid/ieee/identifiers/si_standard.rb +4 -1
  256. data/lib/pubid/ieee/identifiers/standard.rb +4 -1
  257. data/lib/pubid/ieee/identifiers/supplement_identifier.rb +26 -7
  258. data/lib/pubid/ieee/identifiers.rb +2 -1
  259. data/lib/pubid/ieee/ire/builder.rb +7 -6
  260. data/lib/pubid/ieee/ire/identifier.rb +48 -33
  261. data/lib/pubid/ieee/nesc/builder.rb +33 -20
  262. data/lib/pubid/ieee/nesc/parser.rb +15 -14
  263. data/lib/pubid/ieee/parser.rb +461 -43
  264. data/lib/pubid/ieee/pre_parser.rb +1 -1
  265. data/lib/pubid/ieee/renderer.rb +154 -57
  266. data/lib/pubid/ieee/typed_stages.rb +12 -1
  267. data/lib/pubid/ieee/urn_generator.rb +3 -5
  268. data/lib/pubid/ieee.rb +56 -3
  269. data/lib/pubid/ietf/builder.rb +62 -0
  270. data/lib/pubid/ietf/identifier.rb +5 -0
  271. data/lib/pubid/ietf/identifiers/base.rb +75 -0
  272. data/lib/pubid/ietf/identifiers/bcp.rb +25 -0
  273. data/lib/pubid/ietf/identifiers/fyi.rb +25 -0
  274. data/lib/pubid/ietf/identifiers/internet_draft.rb +29 -0
  275. data/lib/pubid/ietf/identifiers/rfc.rb +25 -0
  276. data/lib/pubid/ietf/identifiers/std.rb +25 -0
  277. data/lib/pubid/ietf/identifiers.rb +13 -0
  278. data/lib/pubid/ietf/parser.rb +43 -0
  279. data/lib/pubid/ietf/renderer.rb +26 -0
  280. data/lib/pubid/ietf/urn_generator.rb +23 -0
  281. data/lib/pubid/ietf/urn_parser.rb +35 -0
  282. data/lib/pubid/ietf.rb +76 -0
  283. data/lib/pubid/iho/identifier.rb +1 -3
  284. data/lib/pubid/iho/identifiers/base.rb +1 -7
  285. data/lib/pubid/iho/identifiers/bibliographic.rb +1 -1
  286. data/lib/pubid/iho/identifiers/circular_letter.rb +1 -1
  287. data/lib/pubid/iho/identifiers/miscellaneous.rb +1 -1
  288. data/lib/pubid/iho/identifiers/publication.rb +1 -1
  289. data/lib/pubid/iho/identifiers/standard.rb +1 -1
  290. data/lib/pubid/iho/identifiers.rb +0 -1
  291. data/lib/pubid/iho.rb +7 -7
  292. data/lib/pubid/isbn/builder.rb +44 -0
  293. data/lib/pubid/isbn/check_digit.rb +53 -0
  294. data/lib/pubid/isbn/identifier.rb +63 -0
  295. data/lib/pubid/isbn/identifiers/book.rb +30 -0
  296. data/lib/pubid/isbn/identifiers.rb +9 -0
  297. data/lib/pubid/isbn/parser.rb +45 -0
  298. data/lib/pubid/isbn/renderer.rb +16 -0
  299. data/lib/pubid/isbn.rb +52 -0
  300. data/lib/pubid/iso/builder.rb +9 -4
  301. data/lib/pubid/iso/combined_identifier.rb +2 -2
  302. data/lib/pubid/iso/identifier.rb +17 -1
  303. data/lib/pubid/iso/identifiers/directives_supplement.rb +8 -8
  304. data/lib/pubid/iso/normalizer.rb +2 -2
  305. data/lib/pubid/iso/parser.rb +16 -12
  306. data/lib/pubid/iso/supplement_identifier.rb +19 -6
  307. data/lib/pubid/iso/urn_generator.rb +4 -1
  308. data/lib/pubid/iso/urn_parser.rb +1 -1
  309. data/lib/pubid/itu/builder.rb +230 -29
  310. data/lib/pubid/itu/components/code.rb +48 -5
  311. data/lib/pubid/itu/components/designation.rb +35 -0
  312. data/lib/pubid/itu/components.rb +1 -0
  313. data/lib/pubid/itu/identifier.rb +1 -3
  314. data/lib/pubid/itu/identifiers/addendum.rb +15 -0
  315. data/lib/pubid/itu/identifiers/amendment.rb +6 -28
  316. data/lib/pubid/itu/identifiers/annex.rb +13 -2
  317. data/lib/pubid/itu/identifiers/annex_of_recommendation.rb +87 -0
  318. data/lib/pubid/itu/identifiers/appendix_of_recommendation.rb +92 -0
  319. data/lib/pubid/itu/identifiers/base.rb +341 -23
  320. data/lib/pubid/itu/identifiers/combined_identifier.rb +99 -23
  321. data/lib/pubid/itu/identifiers/corrigendum.rb +16 -23
  322. data/lib/pubid/itu/identifiers/errata.rb +15 -0
  323. data/lib/pubid/itu/identifiers/handbook.rb +38 -0
  324. data/lib/pubid/itu/identifiers/question.rb +63 -0
  325. data/lib/pubid/itu/identifiers/recommendation.rb +3 -2
  326. data/lib/pubid/itu/identifiers/report.rb +39 -0
  327. data/lib/pubid/itu/identifiers/special_publication.rb +3 -1
  328. data/lib/pubid/itu/identifiers/standard_serialization.rb +58 -0
  329. data/lib/pubid/itu/identifiers/supplement.rb +119 -14
  330. data/lib/pubid/itu/identifiers.rb +10 -1
  331. data/lib/pubid/itu/model.rb +1 -1
  332. data/lib/pubid/itu/parser.rb +480 -26
  333. data/lib/pubid/itu/urn_generator.rb +36 -6
  334. data/lib/pubid/itu/urn_parser.rb +8 -0
  335. data/lib/pubid/itu.rb +11 -3
  336. data/lib/pubid/jcgm/builder.rb +23 -13
  337. data/lib/pubid/jcgm/identifiers/amendment.rb +0 -2
  338. data/lib/pubid/jcgm/identifiers/corrigendum.rb +34 -0
  339. data/lib/pubid/jcgm/identifiers/gum_guide.rb +3 -3
  340. data/lib/pubid/jcgm/identifiers/meeting.rb +47 -0
  341. data/lib/pubid/jcgm/identifiers.rb +2 -0
  342. data/lib/pubid/jcgm/parser.rb +66 -6
  343. data/lib/pubid/jcgm/renderer.rb +26 -12
  344. data/lib/pubid/jcgm/single_identifier.rb +74 -5
  345. data/lib/pubid/jcgm/supplement_identifier.rb +39 -4
  346. data/lib/pubid/jcgm/urn_generator.rb +21 -13
  347. data/lib/pubid/jcgm/urn_parser.rb +15 -3
  348. data/lib/pubid/jis/identifier.rb +52 -0
  349. data/lib/pubid/nist/builder.rb +29 -9
  350. data/lib/pubid/nist/caster.rb +7 -45
  351. data/lib/pubid/nist/circular_supplement_builder.rb +7 -5
  352. data/lib/pubid/nist/components/supplement.rb +5 -2
  353. data/lib/pubid/nist/configuration.rb +7 -1
  354. data/lib/pubid/nist/identifier.rb +1 -3
  355. data/lib/pubid/nist/identifiers/base.rb +121 -37
  356. data/lib/pubid/nist/identifiers/circular.rb +1 -1
  357. data/lib/pubid/nist/identifiers/commercial_standard.rb +1 -1
  358. data/lib/pubid/nist/identifiers/commercial_standard_emergency.rb +1 -1
  359. data/lib/pubid/nist/identifiers/commercial_standards_monthly.rb +1 -1
  360. data/lib/pubid/nist/identifiers/crpl_report.rb +1 -1
  361. data/lib/pubid/nist/identifiers/dated_document.rb +1 -1
  362. data/lib/pubid/nist/identifiers/federal_information_processing_standards.rb +1 -1
  363. data/lib/pubid/nist/identifiers/grant_contractor_report.rb +1 -1
  364. data/lib/pubid/nist/identifiers/handbook.rb +1 -1
  365. data/lib/pubid/nist/identifiers/internal_report.rb +1 -1
  366. data/lib/pubid/nist/identifiers/letter_circular.rb +1 -1
  367. data/lib/pubid/nist/identifiers/miscellaneous_publication.rb +1 -1
  368. data/lib/pubid/nist/identifiers/monograph.rb +1 -1
  369. data/lib/pubid/nist/identifiers/ncstar.rb +2 -2
  370. data/lib/pubid/nist/identifiers/nsrds.rb +1 -1
  371. data/lib/pubid/nist/identifiers/owmwp.rb +1 -1
  372. data/lib/pubid/nist/identifiers/report.rb +1 -1
  373. data/lib/pubid/nist/identifiers/special_publication.rb +10 -1
  374. data/lib/pubid/nist/identifiers/technical_note.rb +1 -1
  375. data/lib/pubid/nist/identifiers.rb +0 -1
  376. data/lib/pubid/nist/parser.rb +29 -4
  377. data/lib/pubid/nist/preprocessor.rb +15 -0
  378. data/lib/pubid/nist/router.rb +3 -2
  379. data/lib/pubid/nist/series/ir.rb +0 -3
  380. data/lib/pubid/nist/supplement_identifier.rb +9 -9
  381. data/lib/pubid/nist.rb +13 -12
  382. data/lib/pubid/oasis/builder.rb +77 -0
  383. data/lib/pubid/oasis/identifier.rb +82 -0
  384. data/lib/pubid/oasis/identifiers/standard.rb +29 -0
  385. data/lib/pubid/oasis/identifiers.rb +9 -0
  386. data/lib/pubid/oasis/parser.rb +34 -0
  387. data/lib/pubid/oasis/renderer.rb +29 -0
  388. data/lib/pubid/oasis/urn_generator.rb +25 -0
  389. data/lib/pubid/oasis/urn_parser.rb +22 -0
  390. data/lib/pubid/oasis.rb +74 -0
  391. data/lib/pubid/ogc/builder.rb +33 -0
  392. data/lib/pubid/ogc/identifier.rb +77 -0
  393. data/lib/pubid/ogc/identifiers/document.rb +26 -0
  394. data/lib/pubid/ogc/identifiers.rb +10 -0
  395. data/lib/pubid/ogc/parser.rb +40 -0
  396. data/lib/pubid/ogc/renderer.rb +33 -0
  397. data/lib/pubid/ogc/urn_generator.rb +14 -0
  398. data/lib/pubid/ogc/urn_parser.rb +22 -0
  399. data/lib/pubid/ogc.rb +71 -0
  400. data/lib/pubid/oiml/builder.rb +31 -7
  401. data/lib/pubid/oiml/identifier.rb +9 -1
  402. data/lib/pubid/oiml/parser.rb +11 -12
  403. data/lib/pubid/oiml/renderer.rb +13 -13
  404. data/lib/pubid/oiml/single_identifier.rb +20 -0
  405. data/lib/pubid/oiml/supplement_identifier.rb +9 -9
  406. data/lib/pubid/oiml/urn_parser.rb +23 -6
  407. data/lib/pubid/oiml.rb +4 -0
  408. data/lib/pubid/omg/builder.rb +19 -0
  409. data/lib/pubid/omg/identifier.rb +44 -0
  410. data/lib/pubid/omg/identifiers/specification.rb +32 -0
  411. data/lib/pubid/omg/identifiers.rb +9 -0
  412. data/lib/pubid/omg/parser.rb +40 -0
  413. data/lib/pubid/omg/renderer.rb +19 -0
  414. data/lib/pubid/omg.rb +51 -0
  415. data/lib/pubid/parsers/mr_string.rb +101 -7
  416. data/lib/pubid/plateau/builder.rb +8 -4
  417. data/lib/pubid/plateau/identifier.rb +1 -3
  418. data/lib/pubid/plateau/identifiers/base.rb +1 -6
  419. data/lib/pubid/plateau/identifiers/handbook.rb +1 -1
  420. data/lib/pubid/plateau/identifiers/technical_report.rb +1 -1
  421. data/lib/pubid/plateau/identifiers.rb +0 -1
  422. data/lib/pubid/plateau/parser.rb +15 -5
  423. data/lib/pubid/plateau/renderer.rb +1 -1
  424. data/lib/pubid/plateau/supplement_identifier.rb +11 -11
  425. data/lib/pubid/plateau.rb +4 -4
  426. data/lib/pubid/renderers/human_readable.rb +3 -1
  427. data/lib/pubid/renderers/mr_string.rb +46 -4
  428. data/lib/pubid/renderers/supplement_renderer.rb +1 -1
  429. data/lib/pubid/rendering/supplement.rb +4 -4
  430. data/lib/pubid/sae/builder.rb +1 -1
  431. data/lib/pubid/sae/identifier.rb +1 -3
  432. data/lib/pubid/sae/identifiers/base.rb +10 -7
  433. data/lib/pubid/sae/identifiers.rb +0 -1
  434. data/lib/pubid/sae.rb +3 -3
  435. data/lib/pubid/tgpp/builder.rb +41 -0
  436. data/lib/pubid/tgpp/identifier.rb +91 -0
  437. data/lib/pubid/tgpp/identifiers/technical_report.rb +32 -0
  438. data/lib/pubid/tgpp/identifiers/technical_specification.rb +33 -0
  439. data/lib/pubid/tgpp/identifiers.rb +11 -0
  440. data/lib/pubid/tgpp/parser.rb +62 -0
  441. data/lib/pubid/tgpp/renderer.rb +36 -0
  442. data/lib/pubid/tgpp/urn_generator.rb +20 -0
  443. data/lib/pubid/tgpp/urn_parser.rb +28 -0
  444. data/lib/pubid/tgpp.rb +78 -0
  445. data/lib/pubid/type_resolver.rb +59 -0
  446. data/lib/pubid/un/builder.rb +42 -0
  447. data/lib/pubid/un/identifier.rb +37 -0
  448. data/lib/pubid/un/identifiers/document.rb +24 -0
  449. data/lib/pubid/un/identifiers.rb +9 -0
  450. data/lib/pubid/un/parser.rb +25 -0
  451. data/lib/pubid/un/renderer.rb +11 -0
  452. data/lib/pubid/un.rb +46 -0
  453. data/lib/pubid/version.rb +1 -1
  454. data/lib/pubid/w3c/builder.rb +55 -0
  455. data/lib/pubid/w3c/identifier.rb +101 -0
  456. data/lib/pubid/w3c/identifiers/candidate_recommendation.rb +31 -0
  457. data/lib/pubid/w3c/identifiers/candidate_recommendation_draft.rb +31 -0
  458. data/lib/pubid/w3c/identifiers/draft_note.rb +31 -0
  459. data/lib/pubid/w3c/identifiers/note.rb +30 -0
  460. data/lib/pubid/w3c/identifiers/obsolete_recommendation.rb +31 -0
  461. data/lib/pubid/w3c/identifiers/proposed_edited_recommendation.rb +31 -0
  462. data/lib/pubid/w3c/identifiers/proposed_recommendation.rb +31 -0
  463. data/lib/pubid/w3c/identifiers/recommendation.rb +31 -0
  464. data/lib/pubid/w3c/identifiers/standard.rb +12 -0
  465. data/lib/pubid/w3c/identifiers/superseded_recommendation.rb +31 -0
  466. data/lib/pubid/w3c/identifiers/working_draft.rb +30 -0
  467. data/lib/pubid/w3c/identifiers.rb +25 -0
  468. data/lib/pubid/w3c/parser.rb +43 -0
  469. data/lib/pubid/w3c/renderer.rb +35 -0
  470. data/lib/pubid/w3c/urn_generator.rb +18 -0
  471. data/lib/pubid/w3c/urn_parser.rb +36 -0
  472. data/lib/pubid/w3c.rb +67 -0
  473. data/lib/pubid/xsf/builder.rb +17 -0
  474. data/lib/pubid/xsf/identifier.rb +62 -0
  475. data/lib/pubid/xsf/identifiers/xep.rb +31 -0
  476. data/lib/pubid/xsf/identifiers.rb +9 -0
  477. data/lib/pubid/xsf/parser.rb +25 -0
  478. data/lib/pubid/xsf/renderer.rb +23 -0
  479. data/lib/pubid/xsf/urn_generator.rb +13 -0
  480. data/lib/pubid/xsf/urn_parser.rb +18 -0
  481. data/lib/pubid/xsf.rb +76 -0
  482. data/lib/pubid.rb +25 -1
  483. metadata +205 -4
  484. data/lib/pubid/cie/components/code.rb +0 -80
  485. data/lib/pubid/iala/identifiers/base.rb +0 -14
@@ -3,9 +3,7 @@
3
3
  module Pubid
4
4
  module Ashrae
5
5
  # Base class for all ASHRAE identifiers. Canonical name
6
- # Pubid::Ashrae::Identifier; every concrete ASHRAE identifier descends from
7
- # it, and Identifiers::Base — aliased at the foot of this file — points back
8
- # to it.
6
+ # Pubid::Ashrae::Identifier; every concrete ASHRAE identifier descends from it.
9
7
  class Identifier < ::Pubid::Identifier
10
8
  # Parse an ASHRAE identifier string into an identifier object
11
9
  # @param identifier [String] The ASHRAE identifier string to parse
@@ -26,12 +24,20 @@ module Pubid
26
24
  attribute :amendment, :string
27
25
  attribute :reaffirmed, :string
28
26
  attribute :copublisher, :string
29
- end
30
27
 
31
- module Identifiers
32
- # Backward-compatible alias: ASHRAE's base class used to be
33
- # Pubid::Ashrae::Identifiers::Base. It is now Pubid::Ashrae::Identifier.
34
- Base = Pubid::Ashrae::Identifier
28
+ # ASHRAE stores the publication year in a plain :string scalar, not a
29
+ # Components::Date, so the base #exclude's :year->:date remap cannot nil
30
+ # it. Reset the scalar directly (mirroring CSA/BIPM) so a year-less
31
+ # partial reference is a year wildcard under
32
+ # matches?(other, ignore: [:year]). super still recurses into the nested
33
+ # `base` of wrapper types (Errata/Addendum/…), which carry no year scalar.
34
+ def exclude(*args)
35
+ result = super
36
+ year_keys = args & %i[year date]
37
+ result.year = nil if !year_keys.empty? && result.respond_to?(:year=)
38
+ result
39
+ end
35
40
  end
41
+
36
42
  end
37
43
  end
@@ -28,7 +28,7 @@ module Pubid
28
28
  end
29
29
 
30
30
  def copublisher
31
- base_identifier&.copublisher
31
+ base&.copublisher
32
32
  end
33
33
  end
34
34
  end
@@ -5,7 +5,6 @@ module Pubid
5
5
  module Identifiers
6
6
  autoload :AddendaPackage, "#{__dir__}/identifiers/addenda_package"
7
7
  autoload :Addendum, "#{__dir__}/identifiers/addendum"
8
- autoload :Base, "#{__dir__}/identifiers/base"
9
8
  autoload :CombinedAddenda, "#{__dir__}/identifiers/combined_addenda"
10
9
  autoload :Errata, "#{__dir__}/identifiers/errata"
11
10
  autoload :Guideline, "#{__dir__}/identifiers/guideline"
@@ -166,7 +166,7 @@ module Pubid
166
166
  (space >> additional_copublisher).maybe >>
167
167
  suffix.maybe >>
168
168
  reaffirmed.maybe
169
- ).as(:base_identifier) >>
169
+ ).as(:base) >>
170
170
  space >>
171
171
  str("Errata").as(:errata_keyword) >>
172
172
  (
@@ -188,7 +188,7 @@ module Pubid
188
188
  (space >> additional_copublisher).maybe >>
189
189
  suffix.maybe >>
190
190
  reaffirmed.maybe
191
- ).as(:base_identifier) >>
191
+ ).as(:base) >>
192
192
  space >>
193
193
  str("Errata").as(:errata_keyword) >>
194
194
  (
@@ -207,7 +207,7 @@ module Pubid
207
207
  (space >> additional_copublisher).maybe >>
208
208
  suffix.maybe >>
209
209
  reaffirmed.maybe
210
- ).as(:base_identifier) >>
210
+ ).as(:base) >>
211
211
  space >>
212
212
  str("Errata").as(:errata_keyword) >>
213
213
  errata_date.maybe >>
@@ -219,7 +219,7 @@ module Pubid
219
219
  rule(:interpretation_identifier) do
220
220
  str("Interpretations") >> space >>
221
221
  str("for") >> space >>
222
- (type.as(:type) >> space >> code >> (dash >> year_digits.as(:year)).maybe).as(:base_identifier)
222
+ (type.as(:type) >> space >> code >> (dash >> year_digits.as(:year)).maybe).as(:base)
223
223
  end
224
224
 
225
225
  # Combined Addenda pattern (multiple addendums grouped together)
@@ -607,9 +607,12 @@ module Pubid
607
607
  year_first_addenda_package_identifier |
608
608
  addenda_package_identifier |
609
609
  addendum_identifier |
610
- # Standalone copublisher pattern (ANSI/AMCA 210-99, AMCA 210-99)
611
- (((str("ANSI") >> slash).maybe >> letter.repeat(2,
612
- 10)).as(:copublisher) >>
610
+ # Standalone copublisher pattern (ANSI/AMCA 210-99, AMCA 210-99).
611
+ # The literal "ASHRAE" is excluded here so a bare "ASHRAE <code>-<year>"
612
+ # is not swallowed as a copublisher and instead falls through to the
613
+ # ASHRAE-publisher branch below.
614
+ (((str("ANSI") >> slash).maybe >> (str("ASHRAE").absent? >> letter).repeat(2,
615
+ 10)).as(:copublisher) >>
613
616
  space >>
614
617
  code_with_year >>
615
618
  optional_suffix.repeat(0, 2)) |
@@ -635,9 +638,11 @@ module Pubid
635
638
  suffix.maybe >>
636
639
  reaffirmed.maybe >>
637
640
  optional_suffix.repeat(0, 2)) |
638
- # Standard ASHRAE pattern
641
+ # Standard ASHRAE pattern. The type keyword is optional so a bare
642
+ # partial reference "ASHRAE <code>" (no "Standard"/"Guideline") parses;
643
+ # the builder defaults the absent type to "Standard".
639
644
  (publisher.as(:publisher) >> space >>
640
- type.as(:type) >> space >>
645
+ (type.as(:type) >> space).maybe >>
641
646
  code >>
642
647
  (space?.maybe >> dash >> year_digits.as(:year)).maybe >>
643
648
  (space >> additional_copublisher).maybe >>
@@ -56,48 +56,48 @@ module Pubid
56
56
 
57
57
  # Addendum: "ASHRAE Addendum a to Standard 15-2001"
58
58
  def render_addendum(id)
59
- return id.base_identifier.to_s unless id.base_identifier
59
+ return id.base.to_s unless id.base
60
60
 
61
- base_type = id.base_identifier.type || "Standard"
61
+ base_type = id.base.type || "Standard"
62
62
 
63
63
  if id.copublisher
64
- "#{id.copublisher} Addendum #{id.addendum_code} to #{id.base_identifier}"
64
+ "#{id.copublisher} Addendum #{id.addendum_code} to #{id.base}"
65
65
  else
66
- result = "ASHRAE Addendum #{id.addendum_code} to #{base_type} #{id.base_identifier.code}"
67
- result += "-#{id.base_identifier.year}" if id.base_identifier.year
66
+ result = "ASHRAE Addendum #{id.addendum_code} to #{base_type} #{id.base.code}"
67
+ result += "-#{id.base.year}" if id.base.year
68
68
  result
69
69
  end.tap { |r| r << " (#{id.addendum_date})" if id.addendum_date }
70
70
  end
71
71
 
72
72
  # AddendaPackage: "ASHRAE Standard 52.2-1999: Addenda Supplement Package"
73
73
  def render_addenda_package(id)
74
- return id.base_identifier.to_s unless id.base_identifier
74
+ return id.base.to_s unless id.base
75
75
 
76
- result = "ASHRAE #{id.base_identifier.type || 'Standard'} #{id.base_identifier.code}"
77
- result += "-#{id.base_identifier.year}" if id.base_identifier.year
76
+ result = "ASHRAE #{id.base.type || 'Standard'} #{id.base.code}"
77
+ result += "-#{id.base.year}" if id.base.year
78
78
  result += ": Addenda #{id.package_description}" if id.package_description
79
79
  result
80
80
  end
81
81
 
82
82
  # CombinedAddenda: "ASHRAE Addenda c and d to Standard 15-1994"
83
83
  def render_combined_addenda(id)
84
- return id.base_identifier.to_s unless id.base_identifier
84
+ return id.base.to_s unless id.base
85
85
 
86
- base_type = id.base_identifier.type || "Standard"
86
+ base_type = id.base.type || "Standard"
87
87
  if id.addendum_codes
88
- result = "ASHRAE Addenda #{id.addendum_codes} to #{base_type} #{id.base_identifier.code}"
88
+ result = "ASHRAE Addenda #{id.addendum_codes} to #{base_type} #{id.base.code}"
89
89
  else
90
- result = "ASHRAE Addenda to #{base_type} #{id.base_identifier.code}"
90
+ result = "ASHRAE Addenda to #{base_type} #{id.base.code}"
91
91
  end
92
- result += "-#{id.base_identifier.year}" if id.base_identifier.year
92
+ result += "-#{id.base.year}" if id.base.year
93
93
  result
94
94
  end
95
95
 
96
96
  # Errata: "ASHRAE Guideline 0-2005 Errata (September 28, 2011)"
97
97
  def render_errata(id)
98
- return id.base_identifier.to_s unless id.base_identifier
98
+ return id.base.to_s unless id.base
99
99
 
100
- result = id.base_identifier.to_s
100
+ result = id.base.to_s
101
101
  result += " Errata"
102
102
  result += " (#{id.errata_date})" if id.errata_date
103
103
  result
@@ -105,11 +105,11 @@ module Pubid
105
105
 
106
106
  # Interpretation: "Interpretations for Standard 15.2-2022"
107
107
  def render_interpretation(id)
108
- return id.base_identifier.to_s unless id.base_identifier
108
+ return id.base.to_s unless id.base
109
109
 
110
- base_type = id.base_identifier.type || "Standard"
111
- result = "Interpretations for #{base_type} #{id.base_identifier.code}"
112
- result += "-#{id.base_identifier.year}" if id.base_identifier.year
110
+ base_type = id.base.type || "Standard"
111
+ result = "Interpretations for #{base_type} #{id.base.code}"
112
+ result += "-#{id.base.year}" if id.base.year
113
113
  result
114
114
  end
115
115
  end
@@ -4,7 +4,7 @@ module Pubid
4
4
  module Ashrae
5
5
  # Base class for single (non-supplement) ASHRAE identifiers
6
6
  # Includes: Guideline, Standard
7
- class SingleIdentifier < Identifiers::Base
7
+ class SingleIdentifier < Identifier
8
8
  end
9
9
  end
10
10
  end
@@ -6,17 +6,17 @@ module Pubid
6
6
  module Ashrae
7
7
  # Base class for supplement identifiers (addendums, errata, interpretations)
8
8
  # Supplements modify or add to a base document
9
- class SupplementIdentifier < Identifiers::Base
10
- attribute :base_identifier, Identifiers::Base, polymorphic: true
9
+ class SupplementIdentifier < Identifier
10
+ attribute :base, Identifier, polymorphic: true
11
11
 
12
- # Delegate publisher to base_identifier
12
+ # Delegate publisher to base
13
13
  def publisher
14
- base_identifier&.publisher
14
+ base&.publisher
15
15
  end
16
16
 
17
- # Delegate code to base_identifier
17
+ # Delegate code to base
18
18
  def code
19
- base_identifier&.code
19
+ base&.code
20
20
  end
21
21
  end
22
22
  end
data/lib/pubid/ashrae.rb CHANGED
@@ -9,7 +9,7 @@ module Pubid
9
9
  PREFIXES = ["ASHRAE"].freeze
10
10
 
11
11
  autoload :Builder, "#{__dir__}/ashrae/builder"
12
- autoload :Identifier, "#{__dir__}/ashrae/identifier"
12
+ autoload :Identifier, "#{__dir__}/ashrae/identifiers/base"
13
13
  autoload :Identifiers, "#{__dir__}/ashrae/identifiers"
14
14
  autoload :Parser, "#{__dir__}/ashrae/parser"
15
15
  autoload :Renderer, "#{__dir__}/ashrae/renderer"
@@ -68,5 +68,5 @@ end
68
68
  Pubid::Registry.register(:ashrae, Pubid::Ashrae)
69
69
 
70
70
  # Per-flavor format registry: inherits global formats, overrides :human
71
- Pubid::Ashrae::Identifiers::Base.format_registry = Pubid::FormatRegistry.new(parent: Pubid::Identifier.format_registry)
72
- Pubid::Ashrae::Identifiers::Base.format_registry.register(:human, renderer: Pubid::Ashrae::Renderer)
71
+ Pubid::Ashrae::Identifier.format_registry = Pubid::FormatRegistry.new(parent: Pubid::Identifier.format_registry)
72
+ Pubid::Ashrae::Identifier.format_registry.register(:human, renderer: Pubid::Ashrae::Renderer)
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Bipm
5
+ # Turns the parse tree into the matching concrete identifier. Each root
6
+ # branch tags its subtree with a distinct key, so dispatch is a lookup on
7
+ # which key the parser produced.
8
+ class Builder
9
+ def self.build(parsed_data)
10
+ new.build(parsed_data)
11
+ end
12
+
13
+ def build(data)
14
+ if data[:committee_short]
15
+ build_committee(data[:committee_short], form: "short")
16
+ elsif data[:committee_long_en]
17
+ build_committee(data[:committee_long_en], form: "long", language: "E")
18
+ elsif data[:committee_bare]
19
+ # Bare MRA form: no type word, so build_committee yields nil type.
20
+ build_committee(data[:committee_bare], form: "short")
21
+ elsif data[:committee_long_fr]
22
+ build_committee(data[:committee_long_fr], form: "long", language: "F")
23
+ elsif data[:meeting_en]
24
+ build_meeting(data[:meeting_en])
25
+ elsif data[:meeting_fr]
26
+ build_meeting(data[:meeting_fr], language: "F")
27
+ elsif data.key?(:metrologia)
28
+ build_metrologia(data[:metrologia])
29
+ elsif data[:si_brochure]
30
+ build_si_brochure(data[:si_brochure])
31
+ elsif data[:si_brochure_variant]
32
+ build_si_brochure_variant(data[:si_brochure_variant])
33
+ elsif data[:mep]
34
+ build_mep(data[:mep])
35
+ elsif data[:guide]
36
+ build_guide(data[:guide])
37
+ else
38
+ raise "Unrecognized BIPM parse tree: #{data.inspect}"
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def build_committee(node, form:, language: nil)
45
+ Identifiers::CommitteeDocument.new(
46
+ group: node[:group].to_s,
47
+ type_code: Identifier::TYPE_WORD_TO_CODE[node[:type_word].to_s],
48
+ number: node[:number]&.to_s,
49
+ year: node[:year]&.to_s&.to_i,
50
+ language: language || node[:language]&.to_s,
51
+ form: form,
52
+ )
53
+ end
54
+
55
+ def build_meeting(node, language: nil)
56
+ Identifiers::Meeting.new(
57
+ group: node[:group].to_s,
58
+ number: node[:number].to_s,
59
+ year: node[:year]&.to_s&.to_i,
60
+ language: language || node[:language]&.to_s,
61
+ )
62
+ end
63
+
64
+ def build_metrologia(node)
65
+ node = {} unless node.is_a?(Hash)
66
+ Identifiers::MetrologiaArticle.new(
67
+ volume: node[:volume]&.to_s&.to_i,
68
+ issue: node[:issue]&.to_s,
69
+ article: node[:article]&.to_s,
70
+ )
71
+ end
72
+
73
+ def build_si_brochure(node)
74
+ Identifiers::SiBrochure.new(
75
+ edition: node[:edition].to_s,
76
+ version: node[:version].to_s,
77
+ years: node[:years].to_s,
78
+ language: node[:language]&.to_s,
79
+ )
80
+ end
81
+
82
+ def build_si_brochure_variant(node)
83
+ Identifiers::SiBrochure.new(variant: node[:variant].to_s)
84
+ end
85
+
86
+ def build_mep(node)
87
+ Identifiers::Mep.new(
88
+ mep_code: node[:mep_code]&.to_s,
89
+ report_code: node[:report_code]&.to_s,
90
+ appendix: node[:appendix]&.to_s,
91
+ annex: node[:annex]&.to_s,
92
+ part: node[:part]&.to_s,
93
+ )
94
+ end
95
+
96
+ def build_guide(node)
97
+ Identifiers::Guide.new(
98
+ group: node[:group].to_s,
99
+ guide_kind: node[:guide_kind].to_s,
100
+ number: node[:number].to_s,
101
+ appendix: node[:appendix]&.to_s,
102
+ part: node[:part]&.to_s,
103
+ )
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,160 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Bipm
5
+ # Base class for every BIPM identifier AND the flavor's parse/create entry
6
+ # point — mirrors Pubid::Jis::Identifier. Concrete identifiers under
7
+ # Pubid::Bipm::Identifiers descend from this class.
8
+ #
9
+ # BIPM has several unrelated document families (committee documents,
10
+ # meetings, the Metrologia journal, the SI Brochure and its appendices,
11
+ # mises en pratique, and Consultative-Committee guides) with no shared
12
+ # numbering, so every family-specific attribute lives here as a flat,
13
+ # nil-defaulted attribute and is used only by the classes that need it. The
14
+ # canonical `to_hash` drops any attribute at its default/empty value, so an
15
+ # unused attribute never appears in a family's serialized hash.
16
+ class Identifier < ::Pubid::Identifier
17
+ # Committee acronyms BIPM owns (JCGM excluded — see Pubid::Jcgm).
18
+ GROUPS = %w[
19
+ CIPM CGPM JCRB CCTF CCQM CCT CCL CCAUV CCU CCM CCEM CCPR CCRI
20
+ ].freeze
21
+
22
+ # Committee document type codes and their printed long-form names. Note
23
+ # DECL prints as "Statement" in BOTH languages in the source data.
24
+ TYPE_CODES = %w[REC RES DECN ACT DECL].freeze
25
+ TYPE_NAME_EN = {
26
+ "REC" => "Recommendation", "RES" => "Resolution",
27
+ "DECN" => "Decision", "ACT" => "Action", "DECL" => "Statement"
28
+ }.freeze
29
+ TYPE_NAME_FR = {
30
+ "REC" => "Recommandation", "RES" => "Résolution",
31
+ "DECN" => "Décision", "ACT" => "Action", "DECL" => "Statement"
32
+ }.freeze
33
+ # Every printed type word (abbrev + English + French) → canonical code.
34
+ TYPE_WORD_TO_CODE = TYPE_CODES.each_with_object({}) do |code, map|
35
+ map[code] = code
36
+ map[TYPE_NAME_EN[code]] = code
37
+ map[TYPE_NAME_FR[code]] = code
38
+ end.freeze
39
+
40
+ # Shared attributes (flat). Booleans/strings carry no default so they stay
41
+ # nil and drop from the serialized hash unless set.
42
+ attribute :group, :string
43
+ attribute :type_code, :string # REC/RES/DECN/ACT/DECL (avoids base `type`)
44
+ attribute :number, :string # may be hyphenated ("10-1") or nil
45
+ attribute :year, :integer
46
+ attribute :language, :string # "E"/"F"; nil = language-neutral
47
+ # Surface style of committee documents: "short" (abbreviated key form) vs
48
+ # "long" (full type-word name). Defaults to "short" so it drops from the
49
+ # canonical hash for the indexed primary form.
50
+ attribute :form, :string, default: "short"
51
+ # Metrologia journal fields.
52
+ attribute :volume, :integer
53
+ attribute :issue, :string # may be alphanumeric ("1A")
54
+ attribute :article, :string
55
+ # SI Brochure fields.
56
+ attribute :edition, :string # "9e"
57
+ attribute :version, :string # "v3.01"
58
+ attribute :years, :string # "2019/2024"
59
+ # SI Brochure appendix/derived variant: "Appendix 3", "Concise", "FAQ".
60
+ attribute :variant, :string
61
+ # Mise en pratique (MEP) fields.
62
+ attribute :mep_code, :string # "S1", "KUPRTM"
63
+ attribute :report_code, :string # MEP report variant: "BIPM-2019/05"
64
+ # Consultative-Committee guide kind ("MeP"/"RSI"); group + number reused.
65
+ attribute :guide_kind, :string
66
+ # Full-content "Appendix N [Annex N] Part N.M" tail shared by MEP + guide
67
+ # primary-docidentifier forms (nil for the bare short docnumber spelling).
68
+ attribute :appendix, :string
69
+ attribute :annex, :string
70
+ attribute :part, :string
71
+
72
+ # Polymorphic type map for lutaml::Model key_value (de)serialization:
73
+ # maps each subclass's polymorphic_name to its class name so a stored hash
74
+ # rebuilds the correct identifier type via from_hash.
75
+ BIPM_TYPE_MAP = {
76
+ "pubid:bipm:committee-document" =>
77
+ "Pubid::Bipm::Identifiers::CommitteeDocument",
78
+ "pubid:bipm:meeting" => "Pubid::Bipm::Identifiers::Meeting",
79
+ "pubid:bipm:metrologia-article" =>
80
+ "Pubid::Bipm::Identifiers::MetrologiaArticle",
81
+ "pubid:bipm:si-brochure" => "Pubid::Bipm::Identifiers::SiBrochure",
82
+ "pubid:bipm:mep" => "Pubid::Bipm::Identifiers::Mep",
83
+ "pubid:bipm:guide" => "Pubid::Bipm::Identifiers::Guide",
84
+ }.freeze
85
+
86
+ key_value do
87
+ map "_type", to: :_type, polymorphic_map: BIPM_TYPE_MAP
88
+ map "group", to: :group
89
+ map "type_code", to: :type_code
90
+ map "number", to: :number
91
+ map "year", to: :year
92
+ map "language", to: :language
93
+ map "form", to: :form
94
+ map "volume", to: :volume
95
+ map "issue", to: :issue
96
+ map "article", to: :article
97
+ map "edition", to: :edition
98
+ map "version", to: :version
99
+ map "years", to: :years
100
+ map "variant", to: :variant
101
+ map "mep_code", to: :mep_code
102
+ map "report_code", to: :report_code
103
+ map "guide_kind", to: :guide_kind
104
+ map "appendix", to: :appendix
105
+ map "annex", to: :annex
106
+ map "part", to: :part
107
+ end
108
+
109
+ # Publisher is always "BIPM". A plain constant (not a `publisher` method)
110
+ # so it doesn't shadow the inherited lutaml `publisher` attribute, which
111
+ # would otherwise fail serialization type validation.
112
+ PUBLISHER = "BIPM"
113
+
114
+ # French connective before a committee acronym: "de la" for the (feminine)
115
+ # CGPM, "du" for every other (masculine) committee.
116
+ def self.french_connective(group)
117
+ group == "CGPM" ? "de la" : "du"
118
+ end
119
+
120
+ def long?
121
+ form == "long"
122
+ end
123
+
124
+ # BIPM keeps the publication year in its own `year` integer attribute
125
+ # rather than the base `date` component, so the base #exclude's
126
+ # :year->:date remap would nil the (unused) inherited `date` and leave
127
+ # `year` intact. Clear `year` directly when either alias is excluded so
128
+ # `matches?(row, ignore: [:year])` treats a partial (date-less) reference
129
+ # as a year wildcard.
130
+ def exclude(*args)
131
+ result = super
132
+ result.year = nil if args.include?(:year) || args.include?(:date)
133
+ result
134
+ end
135
+
136
+ # Basic string representation. Delegates to renderer.
137
+ def to_s(**opts)
138
+ render(format: :human, **opts)
139
+ end
140
+
141
+ # Parse a BIPM identifier string into an identifier object.
142
+ # @param identifier [String] the BIPM identifier string
143
+ # @return [Identifier] the appropriate identifier object
144
+ # @raise [RuntimeError] if parsing fails
145
+ def self.parse(identifier)
146
+ if identifier.length > Pubid::MAX_INPUT_LENGTH
147
+ raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
148
+ end
149
+
150
+ # Normalize legacy/docnumber-style spellings before parsing
151
+ # (data/bipm/update_codes.yaml), mirroring Pubid::Ccsds / Pubid::Plateau.
152
+ normalized = Core::UpdateCodes.apply(identifier, :bipm)
153
+ parsed = Parser.parse(normalized)
154
+ Builder.build(parsed)
155
+ rescue Parslet::ParseFailed => e
156
+ raise "Failed to parse BIPM identifier '#{identifier}': #{e.message}"
157
+ end
158
+ end
159
+ end
160
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Bipm
5
+ module Identifiers
6
+ # A committee document: a Recommendation (REC), Resolution (RES),
7
+ # Decision (DECN), Action (ACT) or Declaration (DECL) issued by one of the
8
+ # BIPM committees.
9
+ #
10
+ # Printed forms (all round-trip):
11
+ # "CCTF REC 2 (2012)" short, language-neutral
12
+ # "CCTF REC 2 (2012, E)" short, with language
13
+ # "CGPM DECL (1889)" number-less
14
+ # "CCL Recommendation 1 (2001)" full English name (form: "long")
15
+ # "Recommandation 1 du CCL (2001)" full French name (form: "long")
16
+ class CommitteeDocument < Identifier
17
+ def self.type
18
+ { key: :committee_document, web: :committee_document,
19
+ title: "Committee Document", short: "committee-document" }
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Bipm
5
+ module Identifiers
6
+ # A Consultative-Committee guideline document (realization / calibration
7
+ # guide). Printed from its short docnumber form, the relaton index key.
8
+ #
9
+ # Printed forms (all round-trip):
10
+ # "CCL-GD-MeP-1" metre realization guide
11
+ # "CCEM-GD-RSI-1" ampere realization guide
12
+ # "CCM-GD-RSI-2" kilogram dissemination guide
13
+ #
14
+ # Shape: <committee>-GD-<kind>-<number>, where <kind> is "MeP" (mise en
15
+ # pratique guide) or "RSI" (réalisation du SI guide). The committee reuses
16
+ # the shared `group` attribute; the trailing sequence reuses `number`.
17
+ class Guide < Identifier
18
+ def self.type
19
+ { key: :guide, web: :guide, title: "Guide", short: "guide" }
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Bipm
5
+ module Identifiers
6
+ # A committee meeting (proceedings). Printed with a naive ordinal derived
7
+ # from the first number component's last digit (as the source data
8
+ # generates it: "11st", "12nd", "13rd"), and ranges keep that first
9
+ # component's ordinal ("100-1th").
10
+ #
11
+ # Printed forms (all round-trip):
12
+ # "CGPM 17th Meeting (1983)" English (language nil)
13
+ # "CCAUV 11st Meeting (2017)" naive ordinal
14
+ # "CIPM 100-1th Meeting (2011)" range
15
+ # "CCAUV 10<sup>e</sup> réunion (2015)" French (language "F")
16
+ class Meeting < Identifier
17
+ def self.type
18
+ { key: :meeting, web: :meeting, title: "Meeting", short: "meeting" }
19
+ end
20
+
21
+ # English ordinal suffix from the first number component's last digit.
22
+ # Naive (matches the source data): 1→st, 2→nd, 3→rd, else→th — no
23
+ # 11/12/13 exception, so "11" → "11st", and a range "22-23" → "22-23nd".
24
+ def self.ordinal_suffix(number)
25
+ first = number.to_s.split("-").first.to_s
26
+ case first[-1]
27
+ when "1" then "st"
28
+ when "2" then "nd"
29
+ when "3" then "rd"
30
+ else "th"
31
+ end
32
+ end
33
+
34
+ # "15" → "15th", "100-1" → "100-1th".
35
+ def ordinal_en
36
+ "#{number}#{self.class.ordinal_suffix(number)}"
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Bipm
5
+ module Identifiers
6
+ # A mise en pratique (MEP) of an SI base-unit definition, and the related
7
+ # BIPM report variant. Printed from the short docnumber form that relaton
8
+ # uses as the index key — NOT the long "Appendix 2 Part x" content string.
9
+ #
10
+ # Printed forms (all round-trip):
11
+ # "SI MEP S1" standard MEP code (unit letter + number)
12
+ # "SI MEP KUPRTM" alphabetic MEP code
13
+ # "Rapport BIPM-2019/05" report variant (mep_code absent, report_code set)
14
+ class Mep < Identifier
15
+ def self.type
16
+ { key: :mep, web: :mep, title: "Mise en pratique", short: "mep" }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Bipm
5
+ module Identifiers
6
+ # A Metrologia journal reference, at volume, volume+issue, or
7
+ # volume+issue+article granularity. Issue may be alphanumeric ("1A") and
8
+ # the article keeps its printed form ("06007", "S138").
9
+ #
10
+ # Printed forms (all round-trip):
11
+ # "Metrologia 51" volume only
12
+ # "Metrologia 1 1" volume + issue
13
+ # "Metrologia 51 1 128" volume + issue + article
14
+ class MetrologiaArticle < Identifier
15
+ GROUP = "Metrologia"
16
+
17
+ def self.type
18
+ { key: :metrologia_article, web: :metrologia_article,
19
+ title: "Metrologia Article", short: "metrologia-article" }
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end