pubid 2.0.0.pre.alpha.9 → 2.0.0.pre.alpha.11
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.
- checksums.yaml +4 -4
- data/README.adoc +33 -11
- data/conformance/pending.yaml +4 -0
- data/lib/pubid/adobe/identifier.rb +1 -3
- data/lib/pubid/adobe/parser.rb +10 -2
- data/lib/pubid/adobe.rb +1 -0
- data/lib/pubid/amca/builder.rb +2 -2
- data/lib/pubid/amca/identifiers/base.rb +49 -27
- data/lib/pubid/amca/identifiers/interpretation.rb +17 -9
- data/lib/pubid/amca/identifiers/publication.rb +13 -9
- data/lib/pubid/amca/identifiers/standard.rb +2 -0
- data/lib/pubid/amca/parser.rb +1 -1
- data/lib/pubid/amca/renderer.rb +4 -4
- data/lib/pubid/amca/urn_generator.rb +2 -2
- data/lib/pubid/amca.rb +2 -1
- data/lib/pubid/ansi/builder.rb +2 -2
- data/lib/pubid/ansi/identifier.rb +18 -0
- data/lib/pubid/ansi/parser.rb +1 -1
- data/lib/pubid/ansi/renderer.rb +2 -2
- data/lib/pubid/ansi.rb +5 -5
- data/lib/pubid/api/builder.rb +16 -2
- data/lib/pubid/api/identifier.rb +25 -4
- data/lib/pubid/api/identifiers/mpms.rb +10 -8
- data/lib/pubid/api/parser.rb +1 -1
- data/lib/pubid/api/renderer.rb +16 -7
- data/lib/pubid/api/single_identifier.rb +5 -12
- data/lib/pubid/api.rb +1 -0
- data/lib/pubid/ashrae/builder.rb +31 -10
- data/lib/pubid/ashrae/identifiers/addenda_package.rb +6 -0
- data/lib/pubid/ashrae/identifiers/addendum.rb +8 -0
- data/lib/pubid/ashrae/identifiers/base.rb +81 -5
- data/lib/pubid/ashrae/identifiers/combined_addenda.rb +7 -0
- data/lib/pubid/ashrae/identifiers/errata.rb +9 -0
- data/lib/pubid/ashrae/identifiers/guideline.rb +3 -0
- data/lib/pubid/ashrae/identifiers/interpretation.rb +16 -0
- data/lib/pubid/ashrae/identifiers/standard.rb +3 -0
- data/lib/pubid/ashrae/parser.rb +23 -8
- data/lib/pubid/ashrae/renderer.rb +6 -6
- data/lib/pubid/ashrae/supplement_identifier.rb +17 -2
- data/lib/pubid/ashrae/urn_generator.rb +8 -2
- data/lib/pubid/ashrae.rb +7 -1
- data/lib/pubid/asme/builder.rb +11 -2
- data/lib/pubid/asme/identifier.rb +9 -0
- data/lib/pubid/asme/identifiers/standard.rb +86 -2
- data/lib/pubid/asme/parser.rb +1 -1
- data/lib/pubid/asme/renderer.rb +3 -3
- data/lib/pubid/asme/single_identifier.rb +8 -1
- data/lib/pubid/asme/urn_generator.rb +2 -2
- data/lib/pubid/asme.rb +1 -0
- data/lib/pubid/astm/builder.rb +10 -3
- data/lib/pubid/astm/identifier.rb +9 -0
- data/lib/pubid/astm/identifiers/adjunct.rb +16 -1
- data/lib/pubid/astm/identifiers/code_number.rb +81 -0
- data/lib/pubid/astm/identifiers/data_series.rb +2 -0
- data/lib/pubid/astm/identifiers/iso_dual_published.rb +16 -0
- data/lib/pubid/astm/identifiers/manual.rb +10 -0
- data/lib/pubid/astm/identifiers/monograph.rb +2 -0
- data/lib/pubid/astm/identifiers/research_report.rb +10 -0
- data/lib/pubid/astm/identifiers/standard.rb +10 -0
- data/lib/pubid/astm/identifiers/technical_report.rb +2 -0
- data/lib/pubid/astm/identifiers/work_in_progress.rb +2 -0
- data/lib/pubid/astm/identifiers.rb +1 -0
- data/lib/pubid/astm/parser.rb +1 -1
- data/lib/pubid/astm/renderer.rb +1 -1
- data/lib/pubid/astm/single_identifier.rb +31 -1
- data/lib/pubid/astm/urn_generator.rb +7 -5
- data/lib/pubid/astm.rb +1 -0
- data/lib/pubid/bipm/builder.rb +66 -10
- data/lib/pubid/bipm/identifier.rb +134 -9
- data/lib/pubid/bipm/identifiers/committee_document.rb +12 -0
- data/lib/pubid/bipm/identifiers/guide.rb +11 -0
- data/lib/pubid/bipm/identifiers/meeting.rb +12 -0
- data/lib/pubid/bipm/identifiers/mep.rb +12 -0
- data/lib/pubid/bipm/identifiers/metrologia_article.rb +24 -0
- data/lib/pubid/bipm/identifiers/si_brochure.rb +13 -0
- data/lib/pubid/bipm/parser.rb +65 -12
- data/lib/pubid/bipm/renderer.rb +8 -0
- data/lib/pubid/bipm/urn_parser.rb +11 -3
- data/lib/pubid/bipm.rb +7 -1
- data/lib/pubid/bsi/builder.rb +48 -38
- data/lib/pubid/bsi/identifiers/adopted_european_norm.rb +36 -7
- data/lib/pubid/bsi/identifiers/adopted_international_standard.rb +7 -6
- data/lib/pubid/bsi/identifiers/british_industrial_practice.rb +0 -1
- data/lib/pubid/bsi/identifiers/bundled_identifier.rb +10 -0
- data/lib/pubid/bsi/identifiers/committee_document.rb +10 -1
- data/lib/pubid/bsi/identifiers/handbook.rb +0 -2
- data/lib/pubid/bsi/identifiers/practice_guide.rb +0 -1
- data/lib/pubid/bsi/identifiers/set.rb +11 -0
- data/lib/pubid/bsi/identifiers/standalone_amendment.rb +10 -1
- data/lib/pubid/bsi/parser.rb +1 -1
- data/lib/pubid/bsi/renderer.rb +63 -51
- data/lib/pubid/bsi/single_identifier.rb +16 -7
- data/lib/pubid/bsi/urn_generator.rb +11 -2
- data/lib/pubid/bsi.rb +7 -1
- data/lib/pubid/builder/base.rb +18 -8
- data/lib/pubid/bundled_identifier.rb +16 -6
- data/lib/pubid/calconnect/identifier.rb +9 -5
- data/lib/pubid/calconnect/parser.rb +1 -1
- data/lib/pubid/calconnect.rb +7 -1
- data/lib/pubid/ccsds/identifier.rb +9 -2
- data/lib/pubid/ccsds/identifiers/base.rb +4 -2
- data/lib/pubid/ccsds/identifiers/corrigendum.rb +2 -2
- data/lib/pubid/ccsds/parser.rb +1 -1
- data/lib/pubid/ccsds/single_identifier.rb +2 -2
- data/lib/pubid/ccsds.rb +1 -0
- data/lib/pubid/cen_cenelec/builder.rb +101 -76
- data/lib/pubid/cen_cenelec/identifier.rb +115 -3
- data/lib/pubid/cen_cenelec/identifiers/adopted_european_norm.rb +27 -16
- data/lib/pubid/cen_cenelec/identifiers/amendment.rb +46 -6
- data/lib/pubid/cen_cenelec/identifiers/base.rb +8 -9
- data/lib/pubid/cen_cenelec/identifiers/cen_report.rb +1 -1
- data/lib/pubid/cen_cenelec/identifiers/cen_workshop_agreement.rb +1 -1
- data/lib/pubid/cen_cenelec/identifiers/cenelec_harmonization_document.rb +1 -1
- data/lib/pubid/cen_cenelec/identifiers/consolidated_identifier.rb +29 -20
- data/lib/pubid/cen_cenelec/identifiers/corrigendum.rb +47 -8
- data/lib/pubid/cen_cenelec/identifiers/european_prestandard.rb +27 -2
- data/lib/pubid/cen_cenelec/identifiers/european_specification.rb +1 -1
- data/lib/pubid/cen_cenelec/identifiers/fragment.rb +15 -5
- data/lib/pubid/cen_cenelec/identifiers/guide.rb +1 -1
- data/lib/pubid/cen_cenelec/identifiers/harmonization_document.rb +1 -1
- data/lib/pubid/cen_cenelec/identifiers/technical_report.rb +1 -1
- data/lib/pubid/cen_cenelec/identifiers/technical_specification.rb +1 -1
- data/lib/pubid/cen_cenelec/parser.rb +1 -1
- data/lib/pubid/cen_cenelec/renderer.rb +55 -60
- data/lib/pubid/cen_cenelec/single_identifier.rb +20 -2
- data/lib/pubid/cen_cenelec/urn_generator.rb +66 -44
- data/lib/pubid/cen_cenelec.rb +28 -10
- data/lib/pubid/cie/builder.rb +10 -0
- data/lib/pubid/cie/identifier.rb +6 -1
- data/lib/pubid/cie/identifiers/bundle.rb +4 -2
- data/lib/pubid/cie/identifiers/conference.rb +2 -2
- data/lib/pubid/cie/identifiers/corrigendum.rb +2 -2
- data/lib/pubid/cie/identifiers/dual_published.rb +2 -2
- data/lib/pubid/cie/identifiers/identical.rb +2 -2
- data/lib/pubid/cie/identifiers/joint_published.rb +2 -2
- data/lib/pubid/cie/identifiers/proceedings.rb +8 -6
- data/lib/pubid/cie/identifiers/standard.rb +22 -13
- data/lib/pubid/cie/identifiers/supplement.rb +2 -2
- data/lib/pubid/cie/identifiers/tutorial_bundle.rb +2 -2
- data/lib/pubid/cie/parser.rb +1 -1
- data/lib/pubid/cie.rb +7 -1
- data/lib/pubid/conformance/checks.rb +72 -0
- data/lib/pubid/conformance/corpus/case.rb +55 -0
- data/lib/pubid/conformance/corpus.rb +36 -0
- data/lib/pubid/conformance/generator.rb +212 -0
- data/lib/pubid/conformance/pending.rb +63 -0
- data/lib/pubid/conformance/runner.rb +153 -0
- data/lib/pubid/conformance.rb +55 -0
- data/lib/pubid/core.rb +2 -0
- data/lib/pubid/csa/builder.rb +47 -47
- data/lib/pubid/csa/composite_identifier.rb +14 -19
- data/lib/pubid/csa/identifier.rb +143 -81
- data/lib/pubid/csa/identifiers/bundled.rb +23 -13
- data/lib/pubid/csa/identifiers/canadian_adopted.rb +13 -13
- data/lib/pubid/csa/identifiers/cec.rb +44 -4
- data/lib/pubid/csa/identifiers/combined.rb +95 -73
- data/lib/pubid/csa/identifiers/csa_adopted.rb +4 -4
- data/lib/pubid/csa/identifiers/package.rb +2 -2
- data/lib/pubid/csa/parser.rb +6 -2
- data/lib/pubid/csa/renderer.rb +13 -5
- data/lib/pubid/csa/single_identifier.rb +93 -4
- data/lib/pubid/csa/urn_generator.rb +9 -2
- data/lib/pubid/csa/wrapper_identifier.rb +39 -23
- data/lib/pubid/csa.rb +7 -1
- data/lib/pubid/doi/identifier.rb +6 -3
- data/lib/pubid/doi/parser.rb +1 -1
- data/lib/pubid/doi.rb +1 -0
- data/lib/pubid/easc/identifier.rb +0 -2
- data/lib/pubid/easc/parser.rb +10 -2
- data/lib/pubid/easc.rb +1 -0
- data/lib/pubid/ecma/builder.rb +23 -9
- data/lib/pubid/ecma/identifier.rb +81 -10
- data/lib/pubid/ecma/parser.rb +39 -4
- data/lib/pubid/ecma/renderer.rb +29 -8
- data/lib/pubid/ecma/urn_generator.rb +34 -13
- data/lib/pubid/ecma/urn_parser.rb +30 -14
- data/lib/pubid/ecma.rb +1 -0
- data/lib/pubid/errors.rb +80 -0
- data/lib/pubid/etsi/builder.rb +6 -1
- data/lib/pubid/etsi/identifiers/base.rb +34 -20
- data/lib/pubid/etsi/identifiers/etsi_standard.rb +120 -41
- data/lib/pubid/etsi/identifiers/supplement_identifier.rb +10 -0
- data/lib/pubid/etsi/parser.rb +1 -1
- data/lib/pubid/etsi.rb +1 -0
- data/lib/pubid/evs/builder.rb +26 -0
- data/lib/pubid/evs/identifier.rb +37 -0
- data/lib/pubid/evs/identifiers/national_adoption.rb +17 -0
- data/lib/pubid/evs/identifiers.rb +9 -0
- data/lib/pubid/evs/parser.rb +27 -0
- data/lib/pubid/evs/renderer.rb +30 -0
- data/lib/pubid/evs/urn_generator.rb +30 -0
- data/lib/pubid/evs/urn_parser.rb +80 -0
- data/lib/pubid/evs.rb +90 -0
- data/lib/pubid/export.rb +1 -0
- data/lib/pubid/format_detector.rb +1 -0
- data/lib/pubid/gb/identifier.rb +6 -3
- data/lib/pubid/gb/parser.rb +1 -1
- data/lib/pubid/gb.rb +1 -0
- data/lib/pubid/gost/builder.rb +46 -9
- data/lib/pubid/gost/identifier.rb +0 -2
- data/lib/pubid/gost/identifiers/foreign_reference.rb +1 -1
- data/lib/pubid/gost/parser.rb +10 -2
- data/lib/pubid/gost.rb +1 -0
- data/lib/pubid/iala/identifier.rb +9 -6
- data/lib/pubid/iala/parser.rb +10 -2
- data/lib/pubid/iala/urn_parser.rb +6 -2
- data/lib/pubid/iala.rb +1 -0
- data/lib/pubid/iana/builder.rb +3 -1
- data/lib/pubid/iana/identifier.rb +74 -6
- data/lib/pubid/iana/identifiers/registry.rb +36 -0
- data/lib/pubid/iana/parser.rb +1 -1
- data/lib/pubid/iana/renderer.rb +3 -0
- data/lib/pubid/iana/urn_generator.rb +5 -1
- data/lib/pubid/iana.rb +1 -0
- data/lib/pubid/identifier.rb +594 -10
- data/lib/pubid/identifier_metadata.rb +1 -0
- data/lib/pubid/idf/builder.rb +3 -3
- data/lib/pubid/idf/identifier.rb +18 -9
- data/lib/pubid/idf/parser.rb +1 -1
- data/lib/pubid/idf/renderer.rb +4 -4
- data/lib/pubid/idf/urn_generator.rb +1 -1
- data/lib/pubid/idf.rb +7 -1
- data/lib/pubid/iec/builder.rb +14 -7
- data/lib/pubid/iec/components.rb +0 -1
- data/lib/pubid/iec/identifier.rb +73 -83
- data/lib/pubid/iec/identifiers/amendment.rb +6 -2
- data/lib/pubid/iec/identifiers/component_specification.rb +0 -10
- data/lib/pubid/iec/identifiers/conformity_assessment.rb +0 -10
- data/lib/pubid/iec/identifiers/corrigendum.rb +2 -2
- data/lib/pubid/iec/identifiers/fragment_identifier.rb +2 -4
- data/lib/pubid/iec/identifiers/guide.rb +0 -16
- data/lib/pubid/iec/identifiers/international_standard.rb +15 -2
- data/lib/pubid/iec/identifiers/operational_document.rb +0 -10
- data/lib/pubid/iec/identifiers/publicly_available_specification.rb +0 -12
- data/lib/pubid/iec/identifiers/societal_technology_trend_report.rb +0 -10
- data/lib/pubid/iec/identifiers/systems_reference_document.rb +0 -10
- data/lib/pubid/iec/identifiers/technical_report.rb +0 -17
- data/lib/pubid/iec/identifiers/technical_specification.rb +0 -17
- data/lib/pubid/iec/identifiers/technology_report.rb +0 -10
- data/lib/pubid/iec/identifiers/test_report_form.rb +0 -11
- data/lib/pubid/iec/identifiers/white_paper.rb +0 -10
- data/lib/pubid/iec/identifiers/working_document.rb +24 -10
- data/lib/pubid/iec/parser.rb +2 -18
- data/lib/pubid/iec/renderer.rb +13 -10
- data/lib/pubid/iec/single_identifier.rb +33 -10
- data/lib/pubid/iec/urn_generator.rb +227 -61
- data/lib/pubid/iec/urn_parser.rb +42 -4
- data/lib/pubid/iec.rb +1 -0
- data/lib/pubid/ieee/aiee/identifier.rb +2 -2
- data/lib/pubid/ieee/aiee/parser.rb +1 -1
- data/lib/pubid/ieee/builder.rb +45 -1
- data/lib/pubid/ieee/identifiers/adopted_standard.rb +32 -0
- data/lib/pubid/ieee/identifiers/base.rb +42 -5
- data/lib/pubid/ieee/identifiers/csa_dual_published.rb +21 -0
- data/lib/pubid/ieee/identifiers/dual_published.rb +55 -0
- data/lib/pubid/ieee/identifiers/interpretation_identifier.rb +23 -0
- data/lib/pubid/ieee/identifiers/joint_development.rb +11 -7
- data/lib/pubid/ieee/identifiers/multi_numbered_identifier.rb +57 -5
- data/lib/pubid/ieee/identifiers/nesc/base.rb +2 -2
- data/lib/pubid/ieee/identifiers/nesc/draft.rb +2 -2
- data/lib/pubid/ieee/identifiers/nesc/handbook.rb +2 -2
- data/lib/pubid/ieee/identifiers/nesc/redline.rb +2 -2
- data/lib/pubid/ieee/identifiers/nesc/standard.rb +2 -2
- data/lib/pubid/ieee/ire/identifier.rb +2 -2
- data/lib/pubid/ieee/ire/parser.rb +1 -1
- data/lib/pubid/ieee/nesc/parser.rb +1 -1
- data/lib/pubid/ieee/parser.rb +1 -1
- data/lib/pubid/ieee/renderer.rb +5 -1
- data/lib/pubid/ieee/urn_generator.rb +32 -3
- data/lib/pubid/ieee.rb +7 -1
- data/lib/pubid/ieee_debug.rb +1 -0
- data/lib/pubid/ietf/builder.rb +24 -8
- data/lib/pubid/ietf/identifiers/base.rb +25 -28
- data/lib/pubid/ietf/identifiers/bcp.rb +11 -0
- data/lib/pubid/ietf/identifiers/fyi.rb +11 -0
- data/lib/pubid/ietf/identifiers/internet_draft.rb +18 -2
- data/lib/pubid/ietf/identifiers/rfc.rb +2 -0
- data/lib/pubid/ietf/identifiers/serialization.rb +51 -0
- data/lib/pubid/ietf/identifiers/std.rb +11 -0
- data/lib/pubid/ietf/identifiers.rb +1 -0
- data/lib/pubid/ietf/parser.rb +27 -9
- data/lib/pubid/ietf/renderer.rb +44 -6
- data/lib/pubid/ietf/urn_generator.rb +20 -6
- data/lib/pubid/ietf/urn_parser.rb +10 -2
- data/lib/pubid/ietf.rb +12 -2
- data/lib/pubid/iho/identifiers/base.rb +10 -3
- data/lib/pubid/iho/parser.rb +1 -1
- data/lib/pubid/iho.rb +1 -0
- data/lib/pubid/isbn/identifier.rb +25 -7
- data/lib/pubid/isbn/parser.rb +1 -1
- data/lib/pubid/isbn.rb +1 -0
- data/lib/pubid/iso/bundled_identifier.rb +5 -3
- data/lib/pubid/iso/combined_identifier.rb +5 -3
- data/lib/pubid/iso/identifier.rb +12 -7
- data/lib/pubid/iso/identifiers/directives_supplement.rb +4 -4
- data/lib/pubid/iso/parser.rb +1 -1
- data/lib/pubid/iso.rb +7 -1
- data/lib/pubid/itu/identifiers/addendum.rb +2 -2
- data/lib/pubid/itu/identifiers/amendment.rb +2 -2
- data/lib/pubid/itu/identifiers/base.rb +19 -5
- data/lib/pubid/itu/identifiers/corrigendum.rb +2 -2
- data/lib/pubid/itu/identifiers/errata.rb +2 -2
- data/lib/pubid/itu/identifiers/supplement.rb +2 -2
- data/lib/pubid/itu/parser.rb +1 -1
- data/lib/pubid/itu.rb +1 -0
- data/lib/pubid/jcgm/builder.rb +1 -1
- data/lib/pubid/jcgm/identifier.rb +10 -0
- data/lib/pubid/jcgm/identifiers/meeting.rb +1 -1
- data/lib/pubid/jcgm/parser.rb +10 -3
- data/lib/pubid/jcgm/renderer.rb +10 -3
- data/lib/pubid/jcgm/single_identifier.rb +24 -15
- data/lib/pubid/jcgm/urn_generator.rb +1 -1
- data/lib/pubid/jcgm/urn_parser.rb +156 -14
- data/lib/pubid/jcgm.rb +10 -0
- data/lib/pubid/jis/identifier.rb +10 -3
- data/lib/pubid/jis/parser.rb +1 -1
- data/lib/pubid/jis.rb +1 -0
- data/lib/pubid/nist/components/stage.rb +2 -2
- data/lib/pubid/nist/configuration.rb +6 -8
- data/lib/pubid/nist/identifiers/base.rb +12 -2
- data/lib/pubid/nist/identifiers/circular.rb +9 -2
- data/lib/pubid/nist/identifiers/circular_supplement.rb +14 -5
- data/lib/pubid/nist/identifiers/commercial_standards_monthly.rb +7 -1
- data/lib/pubid/nist/identifiers/crpl_report.rb +7 -1
- data/lib/pubid/nist/identifiers/handbook.rb +9 -2
- data/lib/pubid/nist/identifiers/internal_report.rb +12 -5
- data/lib/pubid/nist/identifiers/miscellaneous_publication.rb +14 -6
- data/lib/pubid/nist/identifiers/monograph.rb +14 -7
- data/lib/pubid/nist/identifiers/report.rb +14 -6
- data/lib/pubid/nist/parser.rb +1 -1
- data/lib/pubid/nist/supplement_identifier.rb +16 -1
- data/lib/pubid/nist.rb +7 -1
- data/lib/pubid/oasis/builder.rb +12 -10
- data/lib/pubid/oasis/identifier.rb +89 -11
- data/lib/pubid/oasis/parser.rb +1 -1
- data/lib/pubid/oasis.rb +7 -1
- data/lib/pubid/ogc/identifier.rb +9 -5
- data/lib/pubid/ogc/parser.rb +1 -1
- data/lib/pubid/ogc.rb +1 -0
- data/lib/pubid/oiml/builder.rb +5 -1
- data/lib/pubid/oiml/identifiers/basic_publication.rb +2 -0
- data/lib/pubid/oiml/identifiers/bulletin.rb +36 -0
- data/lib/pubid/oiml/identifiers/code_number.rb +90 -0
- data/lib/pubid/oiml/identifiers/document.rb +2 -0
- data/lib/pubid/oiml/identifiers/expert_report.rb +2 -0
- data/lib/pubid/oiml/identifiers/guide.rb +2 -0
- data/lib/pubid/oiml/identifiers/recommendation.rb +2 -0
- data/lib/pubid/oiml/identifiers/seminar_report.rb +2 -0
- data/lib/pubid/oiml/identifiers/vocabulary.rb +2 -0
- data/lib/pubid/oiml/identifiers.rb +1 -0
- data/lib/pubid/oiml/parser.rb +1 -1
- data/lib/pubid/oiml/single_identifier.rb +26 -42
- data/lib/pubid/oiml/supplement_identifier.rb +27 -0
- data/lib/pubid/oiml.rb +7 -1
- data/lib/pubid/omg/builder.rb +1 -0
- data/lib/pubid/omg/identifier.rb +20 -3
- data/lib/pubid/omg/parser.rb +64 -11
- data/lib/pubid/omg/renderer.rb +13 -1
- data/lib/pubid/omg.rb +2 -1
- data/lib/pubid/parser/grammar.rb +74 -0
- data/lib/pubid/parser.rb +2 -0
- data/lib/pubid/parsers/mr_string.rb +19 -0
- data/lib/pubid/plateau/parser.rb +1 -1
- data/lib/pubid/plateau.rb +10 -0
- data/lib/pubid/prefixes_support.rb +1 -0
- data/lib/pubid/renderers/annotator.rb +233 -0
- data/lib/pubid/renderers/base.rb +13 -0
- data/lib/pubid/renderers/directives_renderer.rb +3 -3
- data/lib/pubid/renderers/human_readable.rb +3 -3
- data/lib/pubid/renderers/mr_string.rb +15 -9
- data/lib/pubid/renderers.rb +1 -0
- data/lib/pubid/rendering/numbering.rb +25 -7
- data/lib/pubid/rendering.rb +1 -0
- data/lib/pubid/sae/identifiers/base.rb +9 -2
- data/lib/pubid/sae/parser.rb +1 -1
- data/lib/pubid/sae.rb +1 -0
- data/lib/pubid/schema/declaration.rb +33 -0
- data/lib/pubid/schema/error.rb +14 -0
- data/lib/pubid/schema/identifier_type.rb +23 -0
- data/lib/pubid/schema/loader.rb +117 -0
- data/lib/pubid/schema/typed_stage.rb +24 -0
- data/lib/pubid/schema.rb +25 -0
- data/lib/pubid/tgpp/builder.rb +1 -1
- data/lib/pubid/tgpp/identifier.rb +21 -5
- data/lib/pubid/tgpp/identifiers/technical_report.rb +2 -2
- data/lib/pubid/tgpp/identifiers/technical_specification.rb +2 -2
- data/lib/pubid/tgpp/parser.rb +22 -6
- data/lib/pubid/tgpp/renderer.rb +21 -5
- data/lib/pubid/tgpp/urn_generator.rb +27 -8
- data/lib/pubid/tgpp/urn_parser.rb +8 -6
- data/lib/pubid/tgpp.rb +7 -1
- data/lib/pubid/type_resolver.rb +16 -1
- data/lib/pubid/un/identifier.rb +6 -3
- data/lib/pubid/un/parser.rb +1 -1
- data/lib/pubid/un.rb +1 -0
- data/lib/pubid/urn_parser/errors.rb +8 -1
- data/lib/pubid/urn_parser.rb +1 -0
- data/lib/pubid/utils.rb +1 -0
- data/lib/pubid/version.rb +1 -1
- data/lib/pubid/w3c/builder.rb +5 -5
- data/lib/pubid/w3c/identifier.rb +38 -9
- data/lib/pubid/w3c/parser.rb +1 -1
- data/lib/pubid/w3c/renderer.rb +1 -1
- data/lib/pubid/w3c/urn_generator.rb +2 -2
- data/lib/pubid/w3c.rb +1 -0
- data/lib/pubid/xsf/identifier.rb +9 -5
- data/lib/pubid/xsf/parser.rb +17 -4
- data/lib/pubid/xsf.rb +7 -1
- data/lib/pubid.rb +399 -21
- data/lib/tasks/conformance.rake +34 -0
- data/lib/tasks/docs.rake +3 -3
- data/lib/tasks/schema.rake +88 -0
- data/schema/core/joint_prefixes.yaml +24 -0
- data/schema/iec.yaml +1017 -0
- data/schema/iso.yaml +1586 -0
- data/schema/schema.schema.yaml +96 -0
- metadata +38 -17
- data/archived-gems/pubid-ccsds/update_codes.yaml +0 -1
- data/archived-gems/pubid-iec/stages.yaml +0 -129
- data/archived-gems/pubid-iec/update_codes.yaml +0 -67
- data/archived-gems/pubid-ieee/update_codes.yaml +0 -104
- data/archived-gems/pubid-iso/stages.yaml +0 -106
- data/archived-gems/pubid-iso/update_codes.yaml +0 -4
- data/archived-gems/pubid-itu/i18n.yaml +0 -13
- data/archived-gems/pubid-itu/series.yaml +0 -42
- data/archived-gems/pubid-nist/publishers.yaml +0 -6
- data/archived-gems/pubid-nist/series.yaml +0 -121
- data/archived-gems/pubid-nist/update_codes.yaml +0 -93
- data/archived-gems/pubid-plateau/update_codes.yaml +0 -6
- data/lib/pubid/cen_cenelec/supplement_identifier.rb +0 -48
- data/lib/pubid/iec/components/code.rb +0 -36
- /data/{archived-gems/pubid-nist → data/nist}/stages.yaml +0 -0
|
@@ -44,20 +44,38 @@ module Pubid
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def self.parse(identifier)
|
|
47
|
+
unless identifier.is_a?(String)
|
|
48
|
+
raise Pubid::Errors::InvalidInputError,
|
|
49
|
+
Pubid::INPUT_NOT_A_STRING_MESSAGE
|
|
50
|
+
end
|
|
51
|
+
|
|
47
52
|
if identifier.length > Pubid::MAX_INPUT_LENGTH
|
|
48
|
-
raise
|
|
53
|
+
raise Pubid::Errors::InvalidInputError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
49
54
|
end
|
|
50
55
|
|
|
56
|
+
# The two guards above must stay OUTSIDE build_identifier: this method
|
|
57
|
+
# rescues ArgumentError to convert the Builder's check-digit and
|
|
58
|
+
# length validation into a parse failure, and that rescue used to
|
|
59
|
+
# swallow the guards' own ArgumentError and re-raise it as a
|
|
60
|
+
# RuntimeError - so ISBN was the one guarded flavor where an over-long
|
|
61
|
+
# input did not surface as ArgumentError.
|
|
62
|
+
build_identifier(identifier)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# @raise [Pubid::Errors::ParseError] if the string is not a valid ISBN
|
|
66
|
+
def self.build_identifier(identifier)
|
|
51
67
|
parsed = Parser.parse(identifier)
|
|
52
68
|
Builder.build(parsed)
|
|
53
|
-
rescue Parslet::ParseFailed => e
|
|
54
|
-
raise "Failed to parse ISBN '#{identifier}': #{e.message}"
|
|
55
69
|
rescue ArgumentError => e
|
|
56
|
-
# Builder validates length
|
|
57
|
-
#
|
|
58
|
-
#
|
|
59
|
-
raise
|
|
70
|
+
# The Builder validates length and check digit. Surface that as a parse
|
|
71
|
+
# failure, so every ISBN rejection reaches the caller as the same class
|
|
72
|
+
# a grammar rejection does.
|
|
73
|
+
raise Pubid::Errors::ParseError.new(
|
|
74
|
+
"invalid ISBN '#{identifier}': #{e.message}",
|
|
75
|
+
input: identifier, flavor: "isbn",
|
|
76
|
+
)
|
|
60
77
|
end
|
|
78
|
+
private_class_method :build_identifier
|
|
61
79
|
end
|
|
62
80
|
end
|
|
63
81
|
end
|
data/lib/pubid/isbn/parser.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Pubid
|
|
|
12
12
|
# ISBN-10 final digit may be "X" (check digit value 10). Hyphens are
|
|
13
13
|
# optional and may appear in any group position; they are preserved
|
|
14
14
|
# for round-trip rendering.
|
|
15
|
-
class Parser <
|
|
15
|
+
class Parser < ::Pubid::Parser::Grammar
|
|
16
16
|
rule(:space) { str(" ") }
|
|
17
17
|
rule(:colon) { str(":") }
|
|
18
18
|
rule(:hyphen) { str("-") }
|
data/lib/pubid/isbn.rb
CHANGED
|
@@ -86,15 +86,17 @@ module Pubid
|
|
|
86
86
|
base_document&.copublishers
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
+
# See the note on Pubid::BundledIdentifier#to_s: `**opts` carries flags
|
|
90
|
+
# this list does not name, `annotated:` above all.
|
|
89
91
|
def to_s(lang: :en, lang_single: false, with_edition: false, format: nil,
|
|
90
|
-
stage_format_long: nil, with_date: nil)
|
|
92
|
+
stage_format_long: nil, with_date: nil, **opts)
|
|
91
93
|
parts = [base_document.to_s(lang: lang, lang_single: lang_single,
|
|
92
|
-
with_edition: with_edition, format: format, stage_format_long: stage_format_long, with_date: with_date)]
|
|
94
|
+
with_edition: with_edition, format: format, stage_format_long: stage_format_long, with_date: with_date, **opts)]
|
|
93
95
|
|
|
94
96
|
# Add each supplement with "+" separator
|
|
95
97
|
supplements.each do |supplement|
|
|
96
98
|
supplement_str = supplement.to_supplement_s(lang: lang, lang_single: lang_single,
|
|
97
|
-
with_edition: with_edition, format: format, stage_format_long: stage_format_long, with_date: with_date)
|
|
99
|
+
with_edition: with_edition, format: format, stage_format_long: stage_format_long, with_date: with_date, **opts)
|
|
98
100
|
parts << "+ #{supplement_str}"
|
|
99
101
|
end
|
|
100
102
|
|
|
@@ -9,11 +9,13 @@ module Pubid
|
|
|
9
9
|
polymorphic: true, collection: true
|
|
10
10
|
attribute :type, :string, default: -> { "combined_identifier" }
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
# `**opts` carries render flags this list does not name (`annotated:`),
|
|
13
|
+
# which the closed signature used to reject outright.
|
|
14
|
+
def to_s(lang: :en, lang_single: false, **opts)
|
|
13
15
|
[
|
|
14
|
-
base.to_s(lang: lang, lang_single: lang_single),
|
|
16
|
+
base.to_s(lang: lang, lang_single: lang_single, **opts),
|
|
15
17
|
additional_identifiers.map do |id|
|
|
16
|
-
id.to_s(lang: lang, lang_single: lang_single)
|
|
18
|
+
id.to_s(lang: lang, lang_single: lang_single, **opts)
|
|
17
19
|
end,
|
|
18
20
|
].flatten.join(" | ")
|
|
19
21
|
end
|
data/lib/pubid/iso/identifier.rb
CHANGED
|
@@ -166,9 +166,14 @@ module Pubid
|
|
|
166
166
|
def stage_from_kv(model, value)
|
|
167
167
|
return if value.nil? || value.to_s.empty?
|
|
168
168
|
|
|
169
|
+
# The fallback consults the flavor-wide table. It used to call
|
|
170
|
+
# `Pubid::Iso::Scheme`, a class removed repo-wide in e3c19ea1 — so any
|
|
171
|
+
# code absent from the class's own TYPED_STAGES raised NameError
|
|
172
|
+
# instead of falling back. The IEC twin (iec/identifier.rb) was
|
|
173
|
+
# migrated at the time; ISO was missed.
|
|
169
174
|
ts = (model.class.const_defined?(:TYPED_STAGES) &&
|
|
170
175
|
model.class::TYPED_STAGES.find { |t| t.code.to_s == value.to_s }) ||
|
|
171
|
-
Pubid::Iso
|
|
176
|
+
Pubid::Iso.locate_stage_by_code(value)
|
|
172
177
|
return unless ts
|
|
173
178
|
|
|
174
179
|
# The renderer prefers `original_abbr` (the parsed surface form); without
|
|
@@ -283,8 +288,13 @@ module Pubid
|
|
|
283
288
|
end
|
|
284
289
|
|
|
285
290
|
def self.parse(string, format: :auto)
|
|
291
|
+
unless string.is_a?(String)
|
|
292
|
+
raise Pubid::Errors::InvalidInputError,
|
|
293
|
+
Pubid::INPUT_NOT_A_STRING_MESSAGE
|
|
294
|
+
end
|
|
295
|
+
|
|
286
296
|
if string.length > Pubid::MAX_INPUT_LENGTH
|
|
287
|
-
raise
|
|
297
|
+
raise Pubid::Errors::InvalidInputError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
288
298
|
end
|
|
289
299
|
|
|
290
300
|
format = Pubid::FormatDetector.detect(string) if format == :auto
|
|
@@ -296,11 +306,6 @@ module Pubid
|
|
|
296
306
|
Pubid::Parsers::MrString.parse(string)
|
|
297
307
|
else
|
|
298
308
|
parsed = Pubid::Iso::Parser.new.parse(string)
|
|
299
|
-
if parsed.nil? || parsed.empty?
|
|
300
|
-
raise Pubid::Iso::Parser::ParseError,
|
|
301
|
-
"Invalid identifier format"
|
|
302
|
-
end
|
|
303
|
-
|
|
304
309
|
Pubid::Iso::Builder.new.build(parsed)
|
|
305
310
|
end
|
|
306
311
|
end
|
|
@@ -68,12 +68,12 @@ module Pubid
|
|
|
68
68
|
# end
|
|
69
69
|
|
|
70
70
|
def to_s(lang: :en, lang_single: false, with_edition: false,
|
|
71
|
-
format: nil, stage_format_long: nil, with_date: nil)
|
|
71
|
+
format: nil, stage_format_long: nil, with_date: nil, **opts)
|
|
72
72
|
if base
|
|
73
73
|
# Full rendering with base identifier
|
|
74
74
|
[
|
|
75
75
|
base.to_s(lang: lang, lang_single: lang_single,
|
|
76
|
-
with_edition: with_edition, format: format, stage_format_long: stage_format_long, with_date: with_date),
|
|
76
|
+
with_edition: with_edition, format: format, stage_format_long: stage_format_long, with_date: with_date, **opts),
|
|
77
77
|
" #{supplement_publisher.render}",
|
|
78
78
|
" SUP", # Always render as "SUP" even though typed_stage.abbreviation is "DIR SUP"
|
|
79
79
|
(date ? ":#{date.render}" : ""),
|
|
@@ -81,13 +81,13 @@ format: nil, stage_format_long: nil, with_date: nil)
|
|
|
81
81
|
].join
|
|
82
82
|
else
|
|
83
83
|
# Simplified rendering for bundled identifiers (just the supplement part)
|
|
84
|
-
to_supplement_s(lang: lang, lang_single: lang_single)
|
|
84
|
+
to_supplement_s(lang: lang, lang_single: lang_single, **opts)
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
# Render just the supplement part (for use in bundled identifiers)
|
|
89
89
|
def to_supplement_s(lang: :en, lang_single: false, with_edition: false,
|
|
90
|
-
format: nil, stage_format_long: nil, with_date: nil)
|
|
90
|
+
format: nil, stage_format_long: nil, with_date: nil, **_opts)
|
|
91
91
|
date_str = if date
|
|
92
92
|
month_part = date.month ? "-#{date.month}" : ""
|
|
93
93
|
":#{date.render}#{month_part}"
|
data/lib/pubid/iso/parser.rb
CHANGED
data/lib/pubid/iso.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "pubid"
|
|
3
4
|
require "lutaml/model"
|
|
4
5
|
|
|
5
6
|
module Pubid
|
|
@@ -31,8 +32,13 @@ module Pubid
|
|
|
31
32
|
# @param format [Symbol] :auto, :human, :mr_string, or :urn
|
|
32
33
|
# @return [Identifier] the parsed identifier
|
|
33
34
|
def self.parse(identifier, format: :auto)
|
|
35
|
+
unless identifier.is_a?(String)
|
|
36
|
+
raise Pubid::Errors::InvalidInputError,
|
|
37
|
+
Pubid::INPUT_NOT_A_STRING_MESSAGE
|
|
38
|
+
end
|
|
39
|
+
|
|
34
40
|
if identifier.length > Pubid::MAX_INPUT_LENGTH
|
|
35
|
-
raise
|
|
41
|
+
raise Pubid::Errors::InvalidInputError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
36
42
|
end
|
|
37
43
|
|
|
38
44
|
format = Pubid::FormatDetector.detect(identifier) if format == :auto
|
|
@@ -6,8 +6,8 @@ module Pubid
|
|
|
6
6
|
# Addendum identifier (Add.)
|
|
7
7
|
# Pattern: "ITU-T I.363 (1993) Add. 1 (11/1993)"
|
|
8
8
|
class Addendum < Supplement
|
|
9
|
-
def to_s
|
|
10
|
-
render_supplement("Add.")
|
|
9
|
+
def to_s(**opts)
|
|
10
|
+
annotate_plain_render(render_supplement("Add."), **opts)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
end
|
|
@@ -10,8 +10,8 @@ module Pubid
|
|
|
10
10
|
# supplement types (Cor./Err./Suppl./Add.). The parser accepts both
|
|
11
11
|
# spellings (see Parser#supplement_type), so the period-less input form
|
|
12
12
|
# still round-trips through parse — it just normalizes here.
|
|
13
|
-
def to_s
|
|
14
|
-
render_supplement("Amd.")
|
|
13
|
+
def to_s(**opts)
|
|
14
|
+
annotate_plain_render(render_supplement("Amd."), **opts)
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
end
|
|
@@ -6,18 +6,29 @@ module Pubid
|
|
|
6
6
|
class Identifier < ::Pubid::Identifier
|
|
7
7
|
# Parse an ITU identifier string into an identifier object.
|
|
8
8
|
def self.parse(identifier)
|
|
9
|
+
unless identifier.is_a?(String)
|
|
10
|
+
raise Pubid::Errors::InvalidInputError,
|
|
11
|
+
Pubid::INPUT_NOT_A_STRING_MESSAGE
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
if identifier.length > Pubid::MAX_INPUT_LENGTH
|
|
15
|
+
raise Pubid::Errors::InvalidInputError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
16
|
+
end
|
|
17
|
+
|
|
9
18
|
parsed = Parser.parse(normalize_whitespace(identifier))
|
|
10
19
|
Builder.build(parsed)
|
|
11
|
-
rescue Parslet::ParseFailed => e
|
|
12
|
-
raise "Failed to parse ITU identifier '#{identifier}': #{e.message}"
|
|
13
20
|
end
|
|
14
21
|
|
|
15
22
|
# ITU's own listings occasionally carry a doubled space
|
|
16
23
|
# ("ITU-T D.271 (10/2016)"). Whitespace is never significant in an ITU
|
|
17
24
|
# identifier, so collapse runs of it rather than teaching every rule to
|
|
18
25
|
# tolerate them. Any string over the shared input-length guard is left
|
|
19
|
-
# untouched
|
|
20
|
-
# exists precisely to keep long inputs away from regexes.
|
|
26
|
+
# untouched: `self.parse` above rejects it before this point, and the
|
|
27
|
+
# guard exists precisely to keep long inputs away from regexes. (This
|
|
28
|
+
# note used to credit `Pubid.parse` with the rejection, which was wrong
|
|
29
|
+
# in both directions — `Pubid.parse` never routes a human-readable ITU
|
|
30
|
+
# string to a flavor, and ITU carried no raising guard of its own until
|
|
31
|
+
# one was added to `self.parse`, so an over-long string did reach here.)
|
|
21
32
|
def self.normalize_whitespace(identifier)
|
|
22
33
|
return identifier unless identifier.is_a?(String)
|
|
23
34
|
return identifier if identifier.length > ::Pubid::MAX_INPUT_LENGTH
|
|
@@ -184,10 +195,13 @@ module Pubid
|
|
|
184
195
|
# @param format [Symbol] :long for title-style rendering of supported
|
|
185
196
|
# identifiers, otherwise the default short form.
|
|
186
197
|
def to_s(**opts)
|
|
198
|
+
annotated = opts[:annotated]
|
|
187
199
|
opts = self.class.normalize_to_s_opts(opts)
|
|
188
200
|
result = render_base(**opts) + render_language_suffix
|
|
189
201
|
result += " | #{common_text_twin}" if common_text_twin
|
|
190
|
-
|
|
202
|
+
# ITU composes its own string rather than going through `render`, so it
|
|
203
|
+
# never reaches the shared annotation hook. Apply it here.
|
|
204
|
+
annotate_plain_render(result, annotated: annotated)
|
|
191
205
|
end
|
|
192
206
|
|
|
193
207
|
def render_base(**_opts)
|
|
@@ -19,8 +19,8 @@ module Pubid
|
|
|
19
19
|
map "technical", to: :technical
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def to_s
|
|
23
|
-
render_supplement(technical ? "Technical Cor." : "Cor.")
|
|
22
|
+
def to_s(**opts)
|
|
23
|
+
annotate_plain_render(render_supplement(technical ? "Technical Cor." : "Cor."), **opts)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
# `super` already enforces instance_of?(self.class), so this only has
|
|
@@ -6,8 +6,8 @@ module Pubid
|
|
|
6
6
|
# Errata identifier (Err.)
|
|
7
7
|
# Pattern: "ITU-T G.9701 (2014) Err. 1 (07/2016)"
|
|
8
8
|
class Errata < Supplement
|
|
9
|
-
def to_s
|
|
10
|
-
render_supplement("Err.")
|
|
9
|
+
def to_s(**opts)
|
|
10
|
+
annotate_plain_render(render_supplement("Err."), **opts)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
end
|
data/lib/pubid/itu/parser.rb
CHANGED
data/lib/pubid/itu.rb
CHANGED
data/lib/pubid/jcgm/builder.rb
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
module Pubid
|
|
4
4
|
module Jcgm
|
|
5
5
|
class Identifier < ::Pubid::Identifier
|
|
6
|
+
# `number`/`part`/`subpart` are declared here rather than inherited as a
|
|
7
|
+
# Components::Code: JCGM stores a bare string in `number` and uses neither
|
|
8
|
+
# of the other two. Declaring on this class is safe because its body lives
|
|
9
|
+
# in this one file and is never reopened, so every subclass body opens
|
|
10
|
+
# after it has run (lutaml deep-dups the parent attribute table at
|
|
11
|
+
# class-definition time).
|
|
12
|
+
attribute :number, :string
|
|
13
|
+
attribute :part, :string
|
|
14
|
+
attribute :subpart, :string
|
|
15
|
+
|
|
6
16
|
def self.parse(string)
|
|
7
17
|
Pubid::Jcgm.parse(string)
|
|
8
18
|
end
|
data/lib/pubid/jcgm/parser.rb
CHANGED
|
@@ -4,7 +4,7 @@ require "parslet"
|
|
|
4
4
|
|
|
5
5
|
module Pubid
|
|
6
6
|
module Jcgm
|
|
7
|
-
class Parser <
|
|
7
|
+
class Parser < ::Pubid::Parser::Grammar
|
|
8
8
|
include ::Pubid::Parser::CommonParseRules
|
|
9
9
|
include ::Pubid::Parser::CommonParseMethods
|
|
10
10
|
|
|
@@ -53,10 +53,17 @@ module Pubid
|
|
|
53
53
|
# wants the ordinal suffix), so ordered choice is unambiguous. Emits the
|
|
54
54
|
# same tokens as a guide plus type_with_stage "Meeting", so the generic
|
|
55
55
|
# builder path resolves it to Identifiers::Meeting (like "Amd").
|
|
56
|
+
#
|
|
57
|
+
# The trailing " (YYYY)" group is optional, so the partial reference
|
|
58
|
+
# "JCGM 11st Meeting" parses with `date` left nil. JCGM numbers its
|
|
59
|
+
# meetings in one sequence, so the ordinal alone names the event and the
|
|
60
|
+
# year is redundant detail. The whole group is `.maybe` (not the year
|
|
61
|
+
# inside it), so a dangling "(" or a truncated year still fails —
|
|
62
|
+
# the same shape as `date_portion.maybe` in `rule(:base)`.
|
|
56
63
|
rule(:meeting_identifier) do
|
|
57
64
|
publisher >> space >> digits.as(:number) >> ordinal_suffix >>
|
|
58
|
-
space >> str("Meeting").as(:type_with_stage) >>
|
|
59
|
-
str("(") >> year_digits.as(:date) >> str(")")
|
|
65
|
+
space >> str("Meeting").as(:type_with_stage) >>
|
|
66
|
+
(space >> str("(") >> year_digits.as(:date) >> str(")")).maybe
|
|
60
67
|
end
|
|
61
68
|
|
|
62
69
|
rule(:ordinal_suffix) do
|
data/lib/pubid/jcgm/renderer.rb
CHANGED
|
@@ -37,8 +37,15 @@ module Pubid
|
|
|
37
37
|
id.date ? ":#{id.date}" : ""
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
# Two surface forms:
|
|
41
|
+
# "JCGM 17th Meeting (2012)" — date present (published records)
|
|
42
|
+
# "JCGM 17th Meeting" — date absent (partial reference)
|
|
43
|
+
# The ordinal alone names the meeting, so the dateless form is a valid
|
|
44
|
+
# identifier and must stay re-parseable (the parser makes the " (YYYY)"
|
|
45
|
+
# group optional to match).
|
|
40
46
|
def render_meeting(id)
|
|
41
|
-
"JCGM #{id.ordinal} Meeting
|
|
47
|
+
base = "JCGM #{id.ordinal} Meeting"
|
|
48
|
+
id.date ? "#{base} (#{id.date.year})" : base
|
|
42
49
|
end
|
|
43
50
|
|
|
44
51
|
def render_single(id)
|
|
@@ -52,7 +59,7 @@ module Pubid
|
|
|
52
59
|
def render_amendment(id, context)
|
|
53
60
|
result = id.base.to_s if id.base
|
|
54
61
|
result += "/Amd"
|
|
55
|
-
result += " #{id.number
|
|
62
|
+
result += " #{id.number}" if id.number
|
|
56
63
|
result += ":#{id.date}" if id.date
|
|
57
64
|
result
|
|
58
65
|
end
|
|
@@ -60,7 +67,7 @@ module Pubid
|
|
|
60
67
|
def render_gum_guide(id, context)
|
|
61
68
|
parts = []
|
|
62
69
|
parts << id.publisher.publisher if id.publisher
|
|
63
|
-
parts << "GUM-#{id.number
|
|
70
|
+
parts << "GUM-#{id.number}" if id.number
|
|
64
71
|
|
|
65
72
|
result = parts.join(" ")
|
|
66
73
|
result += ":#{id.date}" if id.date
|
|
@@ -7,7 +7,6 @@ module Pubid
|
|
|
7
7
|
default: -> { self.class.default_publisher }
|
|
8
8
|
attribute :typed_stage, Pubid::Components::TypedStage,
|
|
9
9
|
default: -> { self.class.published_typed_stage }
|
|
10
|
-
attribute :number, Pubid::Components::Code
|
|
11
10
|
attribute :date, Pubid::Components::Date
|
|
12
11
|
attribute :languages, Pubid::Components::Language, collection: true
|
|
13
12
|
attribute :stage, Pubid::Components::Stage
|
|
@@ -18,7 +17,7 @@ module Pubid
|
|
|
18
17
|
# (fully determined by the class, i.e. `_type`) are intentionally NOT
|
|
19
18
|
# mapped — they are reconstructed from the class on load via the
|
|
20
19
|
# attribute defaults above. Components collapse to bare scalars:
|
|
21
|
-
# number
|
|
20
|
+
# number is already a bare :string; date -> year/month/day scalars.
|
|
22
21
|
# Mirrors ISO (lib/pubid/iso/identifier.rb) and OIML.
|
|
23
22
|
key_value do
|
|
24
23
|
map "_type", to: :_type
|
|
@@ -37,15 +36,29 @@ module Pubid
|
|
|
37
36
|
# The class's published typed_stage (canonical surface form). Each JCGM
|
|
38
37
|
# class registers exactly one, all :published; `_type` fixes the class,
|
|
39
38
|
# so an omitted typed_stage reconstructs deterministically on from_hash.
|
|
39
|
+
#
|
|
40
|
+
# `original_abbr` is deliberately LEFT NIL. It records the spelling the
|
|
41
|
+
# input used and is not serialized, so it cannot survive a round trip —
|
|
42
|
+
# and this method is one of the two paths that fill `typed_stage`. The
|
|
43
|
+
# other is the parse path (`Builder#locate_typed_stage` ->
|
|
44
|
+
# `Jcgm.locate_stage`), which returns the registry entry untouched.
|
|
45
|
+
# Setting it here made the two disagree, so `from_hash(to_hash) != parse`
|
|
46
|
+
# for every type the grammar tags (Meeting, Corrigendum, Amendment) —
|
|
47
|
+
# and because `#matches?` is `exclude(...) == other.exclude(...)`, a
|
|
48
|
+
# relaton index lookup then silently matched nothing. Nothing in JCGM
|
|
49
|
+
# reads the field: the renderer hardcodes its surface words, the URN
|
|
50
|
+
# generator reads only `type_code`, and `TypedStage#abbreviation` chooses
|
|
51
|
+
# among long_abbr/short_abbr/abbr.first. Recording the *matched* token
|
|
52
|
+
# instead would not work either — "/Cor 1" would store "Cor" where
|
|
53
|
+
# from_hash rebuilds "Corrigendum".
|
|
40
54
|
def self.published_typed_stage
|
|
41
55
|
return nil unless const_defined?(:TYPED_STAGES)
|
|
42
56
|
|
|
43
57
|
ts = self::TYPED_STAGES.find { |t| t.stage_code.to_s == "published" }
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
ts
|
|
48
|
-
ts
|
|
58
|
+
# dup: locate_stage hands out the shared object from the frozen
|
|
59
|
+
# TYPED_STAGES array (the array is frozen, its elements are not), so a
|
|
60
|
+
# future in-place mutation would otherwise leak globally.
|
|
61
|
+
ts&.dup
|
|
49
62
|
end
|
|
50
63
|
|
|
51
64
|
# type and stage are derived from typed_stage, never stored — so the
|
|
@@ -58,13 +71,9 @@ module Pubid
|
|
|
58
71
|
typed_stage&.to_stage
|
|
59
72
|
end
|
|
60
73
|
|
|
61
|
-
# --- number
|
|
62
|
-
def number_to_kv(model, doc) = emit_kv(doc, "number", model.number
|
|
63
|
-
def number_from_kv(model, value) = model.number =
|
|
64
|
-
|
|
65
|
-
def build_code(value)
|
|
66
|
-
Pubid::Components::Code.new(value: value.to_s)
|
|
67
|
-
end
|
|
74
|
+
# --- number ---
|
|
75
|
+
def number_to_kv(model, doc) = emit_kv(doc, "number", model.number)
|
|
76
|
+
def number_from_kv(model, value) = model.number = value.to_s
|
|
68
77
|
|
|
69
78
|
# --- date flattened to top-level year/month/day scalars ---
|
|
70
79
|
def year_to_kv(model, doc) = emit_kv(doc, "year", model.date&.year)
|
|
@@ -90,7 +99,7 @@ module Pubid
|
|
|
90
99
|
|
|
91
100
|
def number_portion
|
|
92
101
|
parts = []
|
|
93
|
-
parts << number
|
|
102
|
+
parts << number if number
|
|
94
103
|
parts << ":#{date.year}" if date
|
|
95
104
|
parts.join
|
|
96
105
|
end
|
|
@@ -18,7 +18,7 @@ module Pubid
|
|
|
18
18
|
# urn:jcgm:meeting:<number>:<year>, e.g. urn:jcgm:meeting:17:2012
|
|
19
19
|
def generate_meeting_urn
|
|
20
20
|
parts = ["urn", "jcgm", "meeting"]
|
|
21
|
-
parts << identifier.number
|
|
21
|
+
parts << identifier.number if identifier.number
|
|
22
22
|
parts << identifier.date.year if identifier.date
|
|
23
23
|
parts.join(":")
|
|
24
24
|
end
|