pubid 2.0.36 → 2.0.38
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/data/parg/bsi_pfs.json +1 -0
- data/lib/pubid/bsi_pfs/adopted_base.rb +98 -0
- data/lib/pubid/bsi_pfs/builder.rb +154 -0
- data/lib/pubid/bsi_pfs/identifier.rb +121 -0
- data/lib/pubid/bsi_pfs/identifiers/adopted_european_norm.rb +55 -0
- data/lib/pubid/bsi_pfs/identifiers/adopted_international_standard.rb +55 -0
- data/lib/pubid/bsi_pfs/identifiers/amendment.rb +27 -0
- data/lib/pubid/bsi_pfs/identifiers/british_standard.rb +41 -0
- data/lib/pubid/bsi_pfs/identifiers/consolidated_identifier.rb +41 -0
- data/lib/pubid/bsi_pfs/identifiers/corrigendum.rb +27 -0
- data/lib/pubid/bsi_pfs/identifiers/draft_document.rb +36 -0
- data/lib/pubid/bsi_pfs/identifiers/publicly_available_specification.rb +36 -0
- data/lib/pubid/bsi_pfs/identifiers/published_document.rb +36 -0
- data/lib/pubid/bsi_pfs/identifiers/supplement.rb +31 -0
- data/lib/pubid/bsi_pfs/identifiers/technical_specification.rb +36 -0
- data/lib/pubid/bsi_pfs/identifiers.rb +17 -0
- data/lib/pubid/bsi_pfs/parser.rb +10 -0
- data/lib/pubid/bsi_pfs/pubid_urn_schema.rb +26 -0
- data/lib/pubid/bsi_pfs/renderer.rb +45 -0
- data/lib/pubid/bsi_pfs/urn_generator.rb +68 -0
- data/lib/pubid/bsi_pfs.rb +75 -0
- data/lib/pubid/version.rb +1 -1
- data/lib/pubid.rb +6 -0
- metadata +27 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d9b243273506e187c9540ddeabc5864a2a500f786b775cb4fe6b47f9a642ac50
|
|
4
|
+
data.tar.gz: 311bd464482432a7b574abf66e4f66ed3fcbdc13340f7805470ae8dde8c985f9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ca9e3937d4f016ba185608f48d9d9811920546f5c119b962dfe73ed1ecab0a7609a22b5f3f61f899b3610413728129ebe0f5177933a7e0bb319901e4000807a
|
|
7
|
+
data.tar.gz: 783f82bc0fbaf24c6808754c7e3b1b43dbbb983631fa2e081569167cc15be779a89846a6dab525d4a95f4ccd38d201a9995a1ae286fc0020d6b974c1062421f7
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"bindings":null,"version":"0.1.0","grammar":"PubidBsiPfs","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Entity":{"atom":7}},{"Str":{"pattern":"BS"}},{"Str":{"pattern":"PAS"}},{"Str":{"pattern":"PD"}},{"Str":{"pattern":"DD"}},{"Str":{"pattern":"TS"}},{"Alternative":{"atoms":[1,2,3,4,5]}},{"Named":{"name":"publisher","atom":6}},{"Str":{"pattern":" "}},{"Entity":{"atom":66}},{"Str":{"pattern":"EN"}},{"Str":{"pattern":"CEN"}},{"Str":{"pattern":"CLC"}},{"Str":{"pattern":"HD"}},{"Str":{"pattern":"ENV"}},{"Str":{"pattern":"ES"}},{"Str":{"pattern":"CR"}},{"Str":{"pattern":"CWA"}},{"Str":{"pattern":"ISO"}},{"Str":{"pattern":"IEC"}},{"Alternative":{"atoms":[10,11,12,13,14,15,16,17,18,19]}},{"Entity":{"atom":58}},{"Entity":{"atom":42}},{"Str":{"pattern":"/"}},{"Named":{"name":"supplements_slash","atom":23}},{"Str":{"pattern":"+"}},{"Named":{"name":"supplements_plus","atom":25}},{"Alternative":{"atoms":[24,26]}},{"Str":{"pattern":"A"}},{"Named":{"name":"supplement_kind","atom":28}},{"Entity":{"atom":34}},{"Entity":{"atom":32}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":31,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"supplement_number","atom":33}},{"Str":{"pattern":":"}},{"Entity":{"atom":39}},{"Entity":{"atom":32}},{"Repetition":{"atom":37,"min":4,"max":4,"tag":"Repetition"}},{"Named":{"name":"supplements_year","atom":38}},{"Sequence":{"atoms":[35,36]}},{"Repetition":{"atom":40,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[27,29,30,41]}},{"Entity":{"atom":56}},{"Str":{"pattern":"/"}},{"Named":{"name":"supplements_slash","atom":44}},{"Str":{"pattern":"+"}},{"Named":{"name":"supplements_plus","atom":46}},{"Alternative":{"atoms":[45,47]}},{"Str":{"pattern":"C"}},{"Named":{"name":"supplement_kind","atom":49}},{"Entity":{"atom":34}},{"Str":{"pattern":":"}},{"Entity":{"atom":39}},{"Sequence":{"atoms":[52,53]}},{"Repetition":{"atom":54,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[48,50,51,55]}},{"Alternative":{"atoms":[22,43]}},{"Named":{"name":"supplement","atom":57}},{"Lookahead":{"atom":21,"positive":false}},{"Re":{"pattern":"[\\x01-\\x09]"}},{"Re":{"pattern":"[\\x0b-\\u{10ffff}]"}},{"Alternative":{"atoms":[60,61]}},{"Sequence":{"atoms":[59,62]}},{"Repetition":{"atom":63,"min":0,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[20,64]}},{"Named":{"name":"adopted","atom":65}},{"Sequence":{"atoms":[0,8,9]}},{"Entity":{"atom":7}},{"Str":{"pattern":" "}},{"Entity":{"atom":76}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":71,"min":1,"max":null,"tag":"Repetition"}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Repetition":{"atom":73,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[72,74]}},{"Named":{"name":"number","atom":75}},{"Str":{"pattern":"-"}},{"Entity":{"atom":96}},{"Entity":{"atom":32}},{"Entity":{"atom":83}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Alternative":{"atoms":[81,82]}},{"Alternative":{"atoms":[79,80]}},{"Repetition":{"atom":84,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"."}},{"Str":{"pattern":"-"}},{"Alternative":{"atoms":[86,87]}},{"Entity":{"atom":32}},{"Entity":{"atom":83}},{"Alternative":{"atoms":[89,90]}},{"Repetition":{"atom":91,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[88,92]}},{"Repetition":{"atom":93,"min":0,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[85,94]}},{"Named":{"name":"part","atom":95}},{"Sequence":{"atoms":[77,78]}},{"Repetition":{"atom":97,"min":0,"max":1,"tag":"Maybe"}},{"Str":{"pattern":":"}},{"Entity":{"atom":103}},{"Entity":{"atom":32}},{"Repetition":{"atom":101,"min":4,"max":4,"tag":"Repetition"}},{"Named":{"name":"year","atom":102}},{"Sequence":{"atoms":[99,100]}},{"Repetition":{"atom":104,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[68,69,70,98,105]}},{"Alternative":{"atoms":[67,106]}},{"Entity":{"atom":111}},{"Entity":{"atom":58}},{"Repetition":{"atom":109,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"supplements","atom":110}},{"Repetition":{"atom":108,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[107,112]}}],"root":113},"bindings":[{"capture":"publisher","path":"publisher","type":"string","card":null,"preprocess":null},{"capture":"number","path":"number","type":"string","card":null,"preprocess":null},{"capture":"part","path":"part","type":"string","card":null,"preprocess":null},{"capture":"year","path":"year","type":"string","card":null,"preprocess":null},{"capture":"adopted","path":"adopted","type":"string","card":null,"preprocess":null},{"capture":"supplement","path":"supplements[].supplement","type":"raw","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":[]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"BS 10005:1995","expect":{}},{"entry":"identifier","kind":"accept","input":"BS 1016-107.2:1991","expect":{}},{"entry":"identifier","kind":"accept","input":"BS 1344-A1:1960","expect":{}},{"entry":"identifier","kind":"accept","input":"PD 5730","expect":{}},{"entry":"identifier","kind":"accept","input":"PAS 003:1994","expect":{}},{"entry":"identifier","kind":"accept","input":"DD 136-2:1986","expect":{}},{"entry":"identifier","kind":"accept","input":"TS 1:1995","expect":{}},{"entry":"identifier","kind":"accept","input":"BS EN 1073-2:2002","expect":{}},{"entry":"identifier","kind":"accept","input":"BS EN ISO 105-B06:2020","expect":{}},{"entry":"identifier","kind":"accept","input":"BS EN IEC 61851-1:2019","expect":{}},{"entry":"identifier","kind":"accept","input":"BS ISO 8601:2019","expect":{}},{"entry":"identifier","kind":"accept","input":"BS IEC 60747-8:2000","expect":{}},{"entry":"identifier","kind":"accept","input":"BS HD 60269-3","expect":{}},{"entry":"identifier","kind":"accept","input":"DD CEN ISO/TS 12180-1:2007","expect":{}},{"entry":"identifier","kind":"accept","input":"DD CLC/TS 50131-2-2:2004","expect":{}},{"entry":"identifier","kind":"accept","input":"BS EN IEC 60601-1/FRAG1","expect":{}},{"entry":"identifier","kind":"accept","input":"BS EN IEC 61535/AMD1/FRAG1","expect":{}},{"entry":"identifier","kind":"accept","input":"BS 10125:2014+A1:2016","expect":{}},{"entry":"identifier","kind":"accept","input":"BS EN 1005-1:2001+A1:2008","expect":{}},{"entry":"identifier","kind":"accept","input":"BS 646:1958+A2:2013","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}},{"entry":"identifier","kind":"reject","input":"BS","expect":{}},{"entry":"identifier","kind":"reject","input":"EN 1325","expect":{}},{"entry":"identifier","kind":"reject","input":"ISO 9001:2015","expect":{}},{"entry":"identifier","kind":"reject","input":"BS 2X 26:2001","expect":{}},{"entry":"identifier","kind":"reject","input":"DISC PD 0005:1995","expect":{}},{"entry":"identifier","kind":"reject","input":"BS A 103:2025","expect":{}},{"entry":"identifier","kind":"reject","input":"BSI Flex 1886 v2.0:2024-09","expect":{}},{"entry":"identifier","kind":"reject","input":"BS 7671 AMD2","expect":{}},{"entry":"identifier","kind":"reject","input":"BS 1000[9]:1971","expect":{}},{"entry":"identifier","kind":"reject","input":"BS 1580:Parts 1 and 2:1962","expect":{}},{"entry":"identifier","kind":"reject","input":"BS CISPR 12:1997","expect":{}},{"entry":"identifier","kind":"reject","input":"14/30300822 DC","expect":{}},{"entry":"identifier","kind":"reject","input":"NA to BS EN 1996-1-2:2005","expect":{}},{"entry":"identifier","kind":"reject","input":"BS 7722:2006 BOOK","expect":{}},{"entry":"identifier","kind":"reject","input":"BS 31100:2021 ExComm","expect":{}},{"entry":"identifier","kind":"reject","input":"AMD 11015","expect":{}},{"entry":"identifier","kind":"reject","input":"BS 1425:Supplement No. 1:1966","expect":{}},{"entry":"identifier","kind":"reject","input":"BS 185 Index:1962","expect":{}},{"entry":"identifier","kind":"reject","input":"BS 2782-10:Method 1006:1978","expect":{}},{"entry":"identifier","kind":"reject","input":"BS 1902-2.3:Addendum No. 1:1976","expect":{}},{"entry":"identifier","kind":"example","input":"BS 10005:1995","expect":{"publisher":"BS","number":"10005","year":"1995"}},{"entry":"identifier","kind":"example","input":"BS 1016-107.2:1991","expect":{"publisher":"BS","number":"1016","part":"107.2","year":"1991"}},{"entry":"identifier","kind":"example","input":"BS 1344-A1:1960","expect":{"publisher":"BS","number":"1344","part":"A1","year":"1960"}},{"entry":"identifier","kind":"example","input":"PD 5730","expect":{"publisher":"PD","number":"5730"}},{"entry":"identifier","kind":"example","input":"PAS 003:1994","expect":{"publisher":"PAS","number":"003","year":"1994"}},{"entry":"identifier","kind":"example","input":"DD 136-2:1986","expect":{"publisher":"DD","number":"136","part":"2","year":"1986"}},{"entry":"identifier","kind":"example","input":"TS 1:1995","expect":{"publisher":"TS","number":"1","year":"1995"}},{"entry":"identifier","kind":"example","input":"BS EN 1073-2:2002","expect":{"publisher":"BS","adopted":"EN 1073-2:2002"}},{"entry":"identifier","kind":"example","input":"BS EN ISO 105-B06:2020","expect":{"publisher":"BS","adopted":"EN ISO 105-B06:2020"}},{"entry":"identifier","kind":"example","input":"BS EN IEC 61851-1:2019","expect":{"publisher":"BS","adopted":"EN IEC 61851-1:2019"}},{"entry":"identifier","kind":"example","input":"BS ISO 8601:2019","expect":{"publisher":"BS","adopted":"ISO 8601:2019"}},{"entry":"identifier","kind":"example","input":"BS IEC 60747-8:2000","expect":{"publisher":"BS","adopted":"IEC 60747-8:2000"}},{"entry":"identifier","kind":"example","input":"BS HD 60269-3","expect":{"publisher":"BS","adopted":"HD 60269-3"}},{"entry":"identifier","kind":"example","input":"DD CEN ISO/TS 12180-1:2007","expect":{"publisher":"DD","adopted":"CEN ISO/TS 12180-1:2007"}},{"entry":"identifier","kind":"example","input":"DD CLC/TS 50131-2-2:2004","expect":{"publisher":"DD","adopted":"CLC/TS 50131-2-2:2004"}},{"entry":"identifier","kind":"example","input":"BS EN IEC 60601-1/FRAG1","expect":{"publisher":"BS","adopted":"EN IEC 60601-1/FRAG1"}},{"entry":"identifier","kind":"example","input":"BS EN IEC 61535/AMD1/FRAG1","expect":{"publisher":"BS","adopted":"EN IEC 61535/AMD1/FRAG1"}},{"entry":"identifier","kind":"example","input":"BS 10125:2014+A1:2016","expect":{"publisher":"BS","number":"10125","year":"2014"}},{"entry":"identifier","kind":"example","input":"BS EN 1005-1:2001+A1:2008","expect":{"publisher":"BS","adopted":"EN 1005-1:2001"}},{"entry":"identifier","kind":"example","input":"BS 646:1958+A2:2013","expect":{"publisher":"BS","number":"646","year":"1958"}}],"docs":{},"source":"# PFS-generated grammar — DO NOT EDIT BY HAND.\n# Source: definitions/bsi.pfs (pfs:1) sha256:acb28ac064cf70b7dcaf8ec199cd535f95c201ca348746f9124ce7d080473585\n# Compiler: pubid/grammar/pfs 0.1.0\n# Flavor key: bsi_pfs (grammar PubidBsiPfs)\n# Regenerate: ruby scripts/pfs compile definitions/bsi.pfs --as bsi_pfs\n# Module: iso.inner v1 (sha256:7a088d2a7814...)\n# Module: iec.inner v1 (sha256:b9002f5d106b...)\n# Module: en.overlay v1 (sha256:b92ac2b27544...)\n# Module: national.prefix v1 (sha256:c7aa2f2442e8...)\n# Module: supplements.core v1 (sha256:9fa9656375c7...)\n\ngrammar PubidBsiPfs version \"0.1.0\" edition 2 {\n\n # Grammar fragments: named lexical terms declared under `grammar:`.\n iso_space = \" \"\n iso_colon = \":\"\n iso_dash = \"-\"\n iso_year = 4*digit\n iso_part = 1*digit [\"-\" 1*digit]\n iso_number = 1*(\"0\" %x31-39) as iso_zero_lead *digit [iso_dash iso_part]\n iso_document = \"ISO\" iso_space iso_number [iso_colon iso_year]\n iec_space = \" \"\n iec_colon = \":\"\n iec_dash = \"-\"\n iec_year = 4*digit\n iec_part = 1*digit\n iec_number = ((\"6\" 4*digit / 5*digit / 1*digit)) as iec_number_core [iec_dash iec_part]\n iec_document = \"IEC\" iec_space iec_number [iec_colon iec_year]\n en_space = \" \"\n en_draft = (\"pr\" / \"Fpr\") as en_draft_kind\n en_face = [en_draft] \"EN\"\n en_adoption = en_face en_space iso_document\n supplement_number = 1*digit\n supplement_year = 4*digit\n supplement_month = 2*digit\n digit = %x30-39\n alpha = %x41-5A / %x61-7A\n\n # Fields: one capture rule per declared field; the whole pattern\n # is the capture.\n bsi_publisher = ((\"BS\" / \"PAS\" / \"PD\" / \"DD\" / \"TS\")) as publisher\n bsi_number = (1*(%x30-39) [%x41-5A]) as number\n bsi_part = (1*(digit / alpha) *((\".\" / \"-\") 1*(digit / alpha))) as part\n bsi_year = (4digit) as year\n bsi_adopted = (( ( \"EN\" / \"CEN\" / \"CLC\" / \"HD\" / \"ENV\" / \"ES\" / \"CR\" / \"CWA\" / \"ISO\" / \"IEC\" ) ( *( !(bsi_supplement) ( %x01-09 / %x0B-10FFFF ) ) ) )) as adopted\n\n # Supplement run (compiled from the supplements declaration):\n # each item binds its separator, kind face, ordinal and date\n # columns; the builder folds the run into the declared wrapper\n # classes (the slash run standalone, the plus run consolidated).\n bsi_supplement_number = (1*digit) as supplement_number\n bsi_supplements_year = (4digit) as supplements_year\n bsi_supplement_amendment = {\n (\"/\" as supplements_slash / \"+\" as supplements_plus)\n \"A\" as supplement_kind bsi_supplement_number [\":\" bsi_supplements_year]\n }\n bsi_supplement_corrigendum = {\n (\"/\" as supplements_slash / \"+\" as supplements_plus)\n \"C\" as supplement_kind bsi_supplement_number [\":\" bsi_supplements_year]\n }\n bsi_supplement = ( bsi_supplement_amendment / bsi_supplement_corrigendum ) as supplement\n bsi_supplements = (1*bsi_supplement) as supplements\n\n # Identifier rule: the canonical template first, then the\n # declared alternates (parse-in spellings; they normalize to the\n # canonical render face).\n identifier = ( bsi_publisher \" \" bsi_adopted / bsi_publisher \" \" bsi_number [\"-\" bsi_part] [\":\" bsi_year] ) [bsi_supplements]\n entry identifier: identifier\n\n # Typed model bindings: every bound capture lands on the\n # consumer model's field of the same name.\n bindings identifier {\n publisher -> publisher (string)\n number -> number (string)\n part -> part (string)\n year -> year (string)\n adopted -> adopted (string)\n supplement -> supplements[].supplement (raw)\n }\n\n # REQUIRED examples from the definition — accepts, rejects, and\n # the capture expectations the compiler replayed at compile time.\n test {\n accept \"BS 10005:1995\"\n accept \"BS 1016-107.2:1991\"\n accept \"BS 1344-A1:1960\"\n accept \"PD 5730\"\n accept \"PAS 003:1994\"\n accept \"DD 136-2:1986\"\n accept \"TS 1:1995\"\n accept \"BS EN 1073-2:2002\"\n accept \"BS EN ISO 105-B06:2020\"\n accept \"BS EN IEC 61851-1:2019\"\n accept \"BS ISO 8601:2019\"\n accept \"BS IEC 60747-8:2000\"\n accept \"BS HD 60269-3\"\n accept \"DD CEN ISO/TS 12180-1:2007\"\n accept \"DD CLC/TS 50131-2-2:2004\"\n accept \"BS EN IEC 60601-1/FRAG1\"\n accept \"BS EN IEC 61535/AMD1/FRAG1\"\n accept \"BS 10125:2014+A1:2016\"\n accept \"BS EN 1005-1:2001+A1:2008\"\n accept \"BS 646:1958+A2:2013\"\n reject \"nonsense\"\n reject \"BS\"\n reject \"EN 1325\"\n reject \"ISO 9001:2015\"\n reject \"BS 2X 26:2001\"\n reject \"DISC PD 0005:1995\"\n reject \"BS A 103:2025\"\n reject \"BSI Flex 1886 v2.0:2024-09\"\n reject \"BS 7671 AMD2\"\n reject \"BS 1000[9]:1971\"\n reject \"BS 1580:Parts 1 and 2:1962\"\n reject \"BS CISPR 12:1997\"\n reject \"14/30300822 DC\"\n reject \"NA to BS EN 1996-1-2:2005\"\n reject \"BS 7722:2006 BOOK\"\n reject \"BS 31100:2021 ExComm\"\n reject \"AMD 11015\"\n reject \"BS 1425:Supplement No. 1:1966\"\n reject \"BS 185 Index:1962\"\n reject \"BS 2782-10:Method 1006:1978\"\n reject \"BS 1902-2.3:Addendum No. 1:1976\"\n example \"BS 10005:1995\" { publisher: \"BS\" number: \"10005\" year: \"1995\" }\n example \"BS 1016-107.2:1991\" { publisher: \"BS\" number: \"1016\" part: \"107.2\" year: \"1991\" }\n example \"BS 1344-A1:1960\" { publisher: \"BS\" number: \"1344\" part: \"A1\" year: \"1960\" }\n example \"PD 5730\" { publisher: \"PD\" number: \"5730\" }\n example \"PAS 003:1994\" { publisher: \"PAS\" number: \"003\" year: \"1994\" }\n example \"DD 136-2:1986\" { publisher: \"DD\" number: \"136\" part: \"2\" year: \"1986\" }\n example \"TS 1:1995\" { publisher: \"TS\" number: \"1\" year: \"1995\" }\n example \"BS EN 1073-2:2002\" { publisher: \"BS\" adopted: \"EN 1073-2:2002\" }\n example \"BS EN ISO 105-B06:2020\" { publisher: \"BS\" adopted: \"EN ISO 105-B06:2020\" }\n example \"BS EN IEC 61851-1:2019\" { publisher: \"BS\" adopted: \"EN IEC 61851-1:2019\" }\n example \"BS ISO 8601:2019\" { publisher: \"BS\" adopted: \"ISO 8601:2019\" }\n example \"BS IEC 60747-8:2000\" { publisher: \"BS\" adopted: \"IEC 60747-8:2000\" }\n example \"BS HD 60269-3\" { publisher: \"BS\" adopted: \"HD 60269-3\" }\n example \"DD CEN ISO/TS 12180-1:2007\" { publisher: \"DD\" adopted: \"CEN ISO/TS 12180-1:2007\" }\n example \"DD CLC/TS 50131-2-2:2004\" { publisher: \"DD\" adopted: \"CLC/TS 50131-2-2:2004\" }\n example \"BS EN IEC 60601-1/FRAG1\" { publisher: \"BS\" adopted: \"EN IEC 60601-1/FRAG1\" }\n example \"BS EN IEC 61535/AMD1/FRAG1\" { publisher: \"BS\" adopted: \"EN IEC 61535/AMD1/FRAG1\" }\n example \"BS 10125:2014+A1:2016\" { publisher: \"BS\" number: \"10125\" year: \"2014\" }\n example \"BS EN 1005-1:2001+A1:2008\" { publisher: \"BS\" adopted: \"EN 1005-1:2001\" }\n example \"BS 646:1958+A2:2013\" { publisher: \"BS\" number: \"646\" year: \"1958\" }\n }\n}\n","source_hash":"5a9bd671fb9193d1b1b5b8df1284fe1ecf5fdf40ea2514b5fc10d5c4da3473a3","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.3.126","edition":2,"semantics_hash":"sha256:ff4f7c71d1477155a9534c68abb01b36917ce6f7473818342999488a85af2eb5","checksum":"sha256:0d7c2d530133e507bcc1254029a9d35b3e439ce596ff3994c584def3642667c2"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module BsiPfs
|
|
5
|
+
# The adopted-base dispatch hook (pubid#706 §4, the coded escape
|
|
6
|
+
# hatch — pubid-grammar#121 feature 4). The generated builder calls
|
|
7
|
+
# this module at the captured adopted run; this module owns the
|
|
8
|
+
# value-dependent dispatch the declaration cannot carry:
|
|
9
|
+
#
|
|
10
|
+
# * the adopted string parses with the OWNING scheme's flavor —
|
|
11
|
+
# the en.overlay routing the module library declares: EN, CEN,
|
|
12
|
+
# CLC, HD, ENV, ES, CR and CWA leads through Pubid::CenCenelec
|
|
13
|
+
# (the cen inner), ISO leads through Pubid::Iso, IEC and CISPR
|
|
14
|
+
# leads through Pubid::Iec;
|
|
15
|
+
# * the wrapper class follows what came back: a CEN identifier is
|
|
16
|
+
# the adopted European norm (BS EN …, including the multi-level
|
|
17
|
+
# chains — "BS EN ISO 105-B06:2020" is this wrapper over a CEN
|
|
18
|
+
# adoption over the ISO document); anything else is the adopted
|
|
19
|
+
# international standard (BS ISO …, BS IEC …);
|
|
20
|
+
# * a run no flavor owns, or a run the owning flavor rejects, is a
|
|
21
|
+
# REJECTION (Pubid::Errors::ParseError) — never a silently empty
|
|
22
|
+
# wrapper (the parse-failure contract's nil/raise rule).
|
|
23
|
+
module AdoptedBase
|
|
24
|
+
CEN_LEADS = %w[EN CEN CLC HD ENV ES CR CWA].freeze
|
|
25
|
+
ISO_LEADS = %w[ISO].freeze
|
|
26
|
+
IEC_LEADS = %w[IEC CISPR].freeze
|
|
27
|
+
|
|
28
|
+
class << self
|
|
29
|
+
# The adoption identifier the captured run builds. Raises when the
|
|
30
|
+
# run names no known flavor or the owning flavor rejects it.
|
|
31
|
+
def build(builder, data)
|
|
32
|
+
adopted_str = builder.unwrap(data[:adopted])&.to_s&.strip
|
|
33
|
+
if adopted_str.nil? || adopted_str.empty?
|
|
34
|
+
raise ::Pubid::Errors::ParseError,
|
|
35
|
+
"an adopted run captured no document (#{builder.flavor_name})"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
adopted_id = parse_adopted(adopted_str)
|
|
39
|
+
publisher = builder.unwrap(data[:publisher])&.to_s
|
|
40
|
+
|
|
41
|
+
attrs = { adopted: adopted_id }
|
|
42
|
+
attrs[:publisher] =
|
|
43
|
+
::Pubid::Components::Publisher.new(body: publisher) if publisher
|
|
44
|
+
|
|
45
|
+
wrapper_class(adopted_id).new(**attrs)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# The implicit probe: BSI carries none — the coded builder's
|
|
49
|
+
# adoptions are all printed ("BS EN …", "BS ISO …"); there is no
|
|
50
|
+
# number-range adoption to probe. Always nil, so the generated
|
|
51
|
+
# builder's probe point stays explicit and inert.
|
|
52
|
+
def implicit(_builder, _data)
|
|
53
|
+
nil
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
# The wrapper class by what the owning flavor came back with: a
|
|
59
|
+
# CEN identifier (including a CEN adoption of an ISO/IEC document)
|
|
60
|
+
# is the adopted European norm; an ISO/IEC identifier is the
|
|
61
|
+
# adopted international standard.
|
|
62
|
+
def wrapper_class(adopted_id)
|
|
63
|
+
if adopted_id.class.name.start_with?("Pubid::CenCenelec::")
|
|
64
|
+
Identifiers::AdoptedEuropeanNorm
|
|
65
|
+
else
|
|
66
|
+
Identifiers::AdoptedInternationalStandard
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# The en.overlay routing: the lead token names the owning flavor.
|
|
71
|
+
# An unknown lead is a rejection citing the run; a run the owning
|
|
72
|
+
# flavor rejects propagates THAT flavor's Pubid::Errors::ParseError
|
|
73
|
+
# (the delegation route the coded builder keeps — the owning
|
|
74
|
+
# flavor's parse failure is the honest attribution).
|
|
75
|
+
def parse_adopted(adopted_str)
|
|
76
|
+
lead = adopted_str.split(/\s|\//, 2).first.to_s
|
|
77
|
+
klass = dispatch(lead)
|
|
78
|
+
if klass.nil?
|
|
79
|
+
raise ::Pubid::Errors::ParseError,
|
|
80
|
+
"no owning flavor parses the adopted run #{adopted_str.inspect}"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
klass.parse(adopted_str)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def dispatch(lead)
|
|
87
|
+
if CEN_LEADS.include?(lead)
|
|
88
|
+
::Pubid::CenCenelec
|
|
89
|
+
elsif ISO_LEADS.include?(lead)
|
|
90
|
+
::Pubid::Iso
|
|
91
|
+
elsif IEC_LEADS.include?(lead)
|
|
92
|
+
::Pubid::Iec
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
class Builder
|
|
4
|
+
# The type each declared token selects (feature 1); the
|
|
5
|
+
# token-free type is the default class.
|
|
6
|
+
TYPE_TOKENS = {
|
|
7
|
+
"PAS" => "PubliclyAvailableSpecification",
|
|
8
|
+
"PD" => "PublishedDocument",
|
|
9
|
+
"DD" => "DraftDocument",
|
|
10
|
+
"TS" => "TechnicalSpecification",
|
|
11
|
+
}.freeze
|
|
12
|
+
|
|
13
|
+
DEFAULT_TYPE = "BritishStandard"
|
|
14
|
+
|
|
15
|
+
# The declared draft stages (feature 2): code → the
|
|
16
|
+
# typed-stage row the trio builds from.
|
|
17
|
+
STAGES = {
|
|
18
|
+
|
|
19
|
+
}.freeze
|
|
20
|
+
|
|
21
|
+
# The captured spelling → the serialized stage code.
|
|
22
|
+
STAGE_MAP = {
|
|
23
|
+
|
|
24
|
+
}.freeze
|
|
25
|
+
|
|
26
|
+
def self.build(parsed_data)
|
|
27
|
+
new.build(parsed_data)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.stage_by_code(code)
|
|
31
|
+
row = STAGES[code.to_s]
|
|
32
|
+
return nil unless row
|
|
33
|
+
|
|
34
|
+
::Pubid::Components::TypedStage.new(
|
|
35
|
+
code: row[:code], stage_code: row[:stage_code],
|
|
36
|
+
type_code: row[:type_code], abbr: row[:abbr],
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def build(data)
|
|
41
|
+
base = build_base_document(data)
|
|
42
|
+
wrapped = wrap_supplements(base, data)
|
|
43
|
+
wrapped
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# The document the supplements apply to. The adopted-base
|
|
47
|
+
# dispatch (feature 4) calls the vendored hook at two explicit
|
|
48
|
+
# points: the captured adopted run, and the hook's own implicit
|
|
49
|
+
# probe — never implicitly.
|
|
50
|
+
def build_base_document(data)
|
|
51
|
+
return AdoptedBase.build(self, data) if data[:adopted]
|
|
52
|
+
|
|
53
|
+
implicit = AdoptedBase.implicit(self, data)
|
|
54
|
+
return implicit if implicit
|
|
55
|
+
|
|
56
|
+
identifier = locate_identifier_klass(data).new
|
|
57
|
+
assign_attributes(identifier, data)
|
|
58
|
+
identifier
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# The class each reference selects: the type-position token
|
|
62
|
+
# first, then the publisher-position token (the publisher-type
|
|
63
|
+
# faces CR/CWA/…), then the token-free default class.
|
|
64
|
+
def locate_identifier_klass(data)
|
|
65
|
+
token = data[:guide] || data[:type]
|
|
66
|
+
token ||= data[:publisher] if TYPE_TOKENS.key?(data[:publisher].to_s)
|
|
67
|
+
name = token ? TYPE_TOKENS.fetch(token.to_s, DEFAULT_TYPE) : DEFAULT_TYPE
|
|
68
|
+
Identifiers.const_get(name)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# The columns, as the coded builder's cast writes them.
|
|
72
|
+
def assign_attributes(identifier, data)
|
|
73
|
+
if data[:year]
|
|
74
|
+
identifier.date = ::Pubid::Components::Date.new(
|
|
75
|
+
year: data[:year]&.to_s,
|
|
76
|
+
)
|
|
77
|
+
end
|
|
78
|
+
identifier.number = data[:number]&.to_s
|
|
79
|
+
identifier.part = data[:part]&.to_s
|
|
80
|
+
identifier.version = present_string(data[:version])
|
|
81
|
+
if data[:publisher]
|
|
82
|
+
identifier.publisher = ::Pubid::Components::Publisher.new(body: data[:publisher].to_s)
|
|
83
|
+
end
|
|
84
|
+
copubs = Array(data[:copublishers]).map do |row|
|
|
85
|
+
value = row[:copublisher] || row["copublisher"]
|
|
86
|
+
::Pubid::Components::Publisher.new(body: unwrap(value).to_s)
|
|
87
|
+
end
|
|
88
|
+
identifier.copublishers = copubs unless copubs.empty?
|
|
89
|
+
type_token = data[:guide] || data[:type]
|
|
90
|
+
identifier.type = ::Pubid::Components::Type.new(abbr: type_token.to_s) if type_token
|
|
91
|
+
captured = data[:stage]
|
|
92
|
+
return unless captured
|
|
93
|
+
|
|
94
|
+
typed_stage = Builder.stage_by_code(STAGE_MAP.fetch(captured.to_s))
|
|
95
|
+
identifier.typed_stage = typed_stage
|
|
96
|
+
identifier.type = typed_stage.to_type
|
|
97
|
+
identifier.stage = typed_stage.to_stage
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# A capture the grammar bound as an empty string stores as nil:
|
|
101
|
+
# to_hash drops the empty string, so from_hash would give nil and
|
|
102
|
+
# the two identifiers would not be ==.
|
|
103
|
+
def present_string(value)
|
|
104
|
+
str = unwrap(value)&.to_s
|
|
105
|
+
str unless str.nil? || str.empty?
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# The run's internal captures bind only through the item row, so
|
|
109
|
+
# unbound ones arrive as raw leaves — a Parsanol::Slice or a
|
|
110
|
+
# {value:, offset: ...} span. Unwrap the captured value.
|
|
111
|
+
def unwrap(capture)
|
|
112
|
+
return capture.content if capture.is_a?(Parsanol::Slice)
|
|
113
|
+
return capture[:value] if capture.is_a?(Hash) && capture.key?(:value)
|
|
114
|
+
|
|
115
|
+
capture
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# The wrapper classes by kind face: the run's dispatch.
|
|
119
|
+
SUPPLEMENT_WRAPPERS = {
|
|
120
|
+
"A" => Identifiers::Amendment,
|
|
121
|
+
"C" => Identifiers::Corrigendum,
|
|
122
|
+
}.freeze
|
|
123
|
+
|
|
124
|
+
def wrap_supplements(base, data)
|
|
125
|
+
rows = Array(data[:supplements])
|
|
126
|
+
return base if rows.empty?
|
|
127
|
+
|
|
128
|
+
items = rows.map do |row|
|
|
129
|
+
inner = row[:supplement] || row["supplement"] || {}
|
|
130
|
+
inner = inner.values.first if inner.values.all?(Hash)
|
|
131
|
+
inner
|
|
132
|
+
end
|
|
133
|
+
if items.any? { |item| item[:supplements_plus] || item["supplements_plus"] }
|
|
134
|
+
members = items.map { |item| supplement_from(item) }
|
|
135
|
+
Identifiers::ConsolidatedIdentifier.new(identifiers: [base] + members)
|
|
136
|
+
else
|
|
137
|
+
supplement_from(items.first, base: base)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def supplement_from(item, base: nil)
|
|
142
|
+
kind = unwrap(item[:supplement_kind] || item["supplement_kind"])
|
|
143
|
+
number = unwrap(item[:supplement_number] || item["supplement_number"])
|
|
144
|
+
attrs = {}
|
|
145
|
+
attrs[:base] = base if base
|
|
146
|
+
attrs[:number] = present_string(number)
|
|
147
|
+
attrs[:year] = present_string(unwrap(item[:supplements_year] || item["supplements_year"]))
|
|
148
|
+
SUPPLEMENT_WRAPPERS.fetch(kind.to_s).new(**attrs)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
Pubid::BsiPfs::Builder.prepend(Pubid::Builder::AllPartsWrap)
|
|
154
|
+
end
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
# The shared base of every concrete BsiPfs class. The
|
|
4
|
+
# serialization is the shared ::Pubid::Identifier's (the coded
|
|
5
|
+
# flavor's own shape): flat publisher/copublishers scalars, the
|
|
6
|
+
# date flattened to its fields, and the draft stage compacted
|
|
7
|
+
# to its code by the class hooks below.
|
|
8
|
+
class Identifier < ::Pubid::Identifier
|
|
9
|
+
# The ETSI-style version suffix ("EN 302 326-2 V2.2.1").
|
|
10
|
+
attribute :version, :string
|
|
11
|
+
|
|
12
|
+
# A published document holds no type, stage or typed stage, so
|
|
13
|
+
# a nil one means "published", not "any stage": `EN 1325` is
|
|
14
|
+
# not `prEN 1325`. The three components repeat one entry of
|
|
15
|
+
# the stage registry, so they move together.
|
|
16
|
+
subset_strict :type, :stage, :typed_stage
|
|
17
|
+
|
|
18
|
+
# The bodies that print as a publisher prefix. The publisher
|
|
19
|
+
# attribute also holds the deliverable types that ARE the
|
|
20
|
+
# designation ("CR 954"); those stay under
|
|
21
|
+
# with_publisher: false, as `BS` does for BSI.
|
|
22
|
+
PUBLISHER_PREFIXES = ["BS", "PAS", "PD", "DD", "TS"].freeze
|
|
23
|
+
|
|
24
|
+
def publisher_prefixes
|
|
25
|
+
super.select do |prefix|
|
|
26
|
+
PUBLISHER_PREFIXES.include?(prefix.split("/").first)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# The publisher serializes as a bare string, the copublishers
|
|
31
|
+
# as a list of strings (the coded flavor's flat-scalar table).
|
|
32
|
+
def self.flat_scalar_components
|
|
33
|
+
super.merge(publisher: "publisher", copublishers: "copublishers")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.flat_scalar_fields
|
|
37
|
+
super.merge(publisher: :body, copublishers: :body)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# The declared draft stages: the serialized code is the key,
|
|
41
|
+
# the official-URN code the declared `urn:` value.
|
|
42
|
+
STAGE_CODES = {
|
|
43
|
+
|
|
44
|
+
}.freeze
|
|
45
|
+
|
|
46
|
+
# A draft stage serializes as its typed-stage code
|
|
47
|
+
# ("stage" => "pren"); #inflate_scalar_components rebuilds
|
|
48
|
+
# the three components from it (the coded compact-hash shape).
|
|
49
|
+
def self.compact_hash(model, hash)
|
|
50
|
+
stage = model.typed_stage
|
|
51
|
+
return unless stage && hash.key?("typed_stage")
|
|
52
|
+
return unless model.type == stage.to_type &&
|
|
53
|
+
model.stage == stage.to_stage
|
|
54
|
+
|
|
55
|
+
hash.delete("type")
|
|
56
|
+
hash.delete("typed_stage")
|
|
57
|
+
hash["stage"] = stage.code.to_s
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Reads the short stage form back; the nested form still
|
|
61
|
+
# reads as before.
|
|
62
|
+
def self.inflate_scalar_components(data)
|
|
63
|
+
data = super
|
|
64
|
+
return data unless data.is_a?(::Hash) && component_attribute?(:stage)
|
|
65
|
+
|
|
66
|
+
key = data.key?("stage") ? "stage" : :stage
|
|
67
|
+
value = data[key]
|
|
68
|
+
return data unless value.is_a?(::String) || value.is_a?(::Symbol)
|
|
69
|
+
|
|
70
|
+
stage = locate_stage_by_code(value)
|
|
71
|
+
return data unless stage
|
|
72
|
+
|
|
73
|
+
data = data.dup
|
|
74
|
+
data.delete(key)
|
|
75
|
+
data["type"] = stage.to_type.to_hash
|
|
76
|
+
data["stage"] = stage.to_stage.to_hash
|
|
77
|
+
data["typed_stage"] = stage.to_hash
|
|
78
|
+
data
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# The stage entry by serialized code, or nil.
|
|
82
|
+
def self.locate_stage_by_code(code)
|
|
83
|
+
Builder.stage_by_code(code.to_s)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# The draft stage's own code is the MR type segment
|
|
87
|
+
# ("en.pren.10160"); a published identifier has no typed
|
|
88
|
+
# stage, so the shared hook answers nil.
|
|
89
|
+
def mr_type
|
|
90
|
+
stage = typed_stage
|
|
91
|
+
return super unless stage && stage.stage_code.to_s != "published"
|
|
92
|
+
|
|
93
|
+
stage.code.to_s.downcase
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def self.parse(identifier)
|
|
97
|
+
unless identifier.is_a?(String)
|
|
98
|
+
raise Pubid::Errors::InvalidInputError,
|
|
99
|
+
Pubid::INPUT_NOT_A_STRING_MESSAGE
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
if identifier.length > Pubid::MAX_INPUT_LENGTH
|
|
103
|
+
raise Pubid::Errors::InvalidInputError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
identifier = ::Pubid.utf8_input(identifier)
|
|
107
|
+
|
|
108
|
+
parsed = Pubid::Parg::Model.bound(:bsi_pfs, identifier)
|
|
109
|
+
Builder.build(parsed)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
private
|
|
113
|
+
|
|
114
|
+
# "amd.1.2005" from ("amd", "1", 2005). A nil or blank
|
|
115
|
+
# segment is left out.
|
|
116
|
+
def mr_join_segments(*segments)
|
|
117
|
+
segments.map(&:to_s).reject(&:empty?).join(".").downcase
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
module Identifiers
|
|
4
|
+
# Concrete Adopted European Norm identifier type (PFS type `adopted_european_norm`).
|
|
5
|
+
class AdoptedEuropeanNorm < Identifier
|
|
6
|
+
TYPED_STAGES = [
|
|
7
|
+
].freeze
|
|
8
|
+
|
|
9
|
+
def self.type
|
|
10
|
+
{ key: :aen, web: :adopted_european_norm, title: "Adopted European Norm", short: "EN" }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# The publisher default (feature 5): the type's own token
|
|
14
|
+
# when the type is its designation, else the scheme default.
|
|
15
|
+
def self.default_publisher
|
|
16
|
+
::Pubid::Components::Publisher.new(body: "BS")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
attribute :publisher, ::Pubid::Components::Publisher, default: -> { self.class.default_publisher }
|
|
20
|
+
attribute :type, ::Pubid::Components::Type, default: -> { self.class.default_type }
|
|
21
|
+
|
|
22
|
+
def self.default_type
|
|
23
|
+
::Pubid::Components::Type.new(abbr: type[:short])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# The adopted document (feature 4): the whole identity lives
|
|
27
|
+
# on the nested ISO/IEC identifier.
|
|
28
|
+
attribute :adopted, ::Pubid::Identifier, polymorphic: true
|
|
29
|
+
|
|
30
|
+
def root
|
|
31
|
+
adopted ? adopted.root : self
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# MR "cen.iso.ts.21003-7": the publisher group fused, then the
|
|
35
|
+
# adopted document's own MR string in place of a number.
|
|
36
|
+
def mr_publisher
|
|
37
|
+
mr_join(*([publisher] + Array(copublishers)).compact
|
|
38
|
+
.map { |p| p.to_s.downcase })
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def mr_number_with_part
|
|
42
|
+
adopted ? adopted.to_mr_string : super
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# The scheme-canonical wire tag declared in the definition:
|
|
46
|
+
# to_hash stays byte-identical with the scheme's coded
|
|
47
|
+
# flavor, and this flavor's own from_hash routes the tag
|
|
48
|
+
# to this class.
|
|
49
|
+
def self.polymorphic_name
|
|
50
|
+
"pubid:bsi:adopted-european-norm"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
module Identifiers
|
|
4
|
+
# Concrete Adopted International Standard identifier type (PFS type `adopted_international_standard`).
|
|
5
|
+
class AdoptedInternationalStandard < Identifier
|
|
6
|
+
TYPED_STAGES = [
|
|
7
|
+
].freeze
|
|
8
|
+
|
|
9
|
+
def self.type
|
|
10
|
+
{ key: :ais, web: :adopted_international_standard, title: "Adopted International Standard", short: "BS" }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# The publisher default (feature 5): the type's own token
|
|
14
|
+
# when the type is its designation, else the scheme default.
|
|
15
|
+
def self.default_publisher
|
|
16
|
+
::Pubid::Components::Publisher.new(body: "BS")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
attribute :publisher, ::Pubid::Components::Publisher, default: -> { self.class.default_publisher }
|
|
20
|
+
attribute :type, ::Pubid::Components::Type, default: -> { self.class.default_type }
|
|
21
|
+
|
|
22
|
+
def self.default_type
|
|
23
|
+
::Pubid::Components::Type.new(abbr: type[:short])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# The adopted document (feature 4): the whole identity lives
|
|
27
|
+
# on the nested ISO/IEC identifier.
|
|
28
|
+
attribute :adopted, ::Pubid::Identifier, polymorphic: true
|
|
29
|
+
|
|
30
|
+
def root
|
|
31
|
+
adopted ? adopted.root : self
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# MR "cen.iso.ts.21003-7": the publisher group fused, then the
|
|
35
|
+
# adopted document's own MR string in place of a number.
|
|
36
|
+
def mr_publisher
|
|
37
|
+
mr_join(*([publisher] + Array(copublishers)).compact
|
|
38
|
+
.map { |p| p.to_s.downcase })
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def mr_number_with_part
|
|
42
|
+
adopted ? adopted.to_mr_string : super
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# The scheme-canonical wire tag declared in the definition:
|
|
46
|
+
# to_hash stays byte-identical with the scheme's coded
|
|
47
|
+
# flavor, and this flavor's own from_hash routes the tag
|
|
48
|
+
# to this class.
|
|
49
|
+
def self.polymorphic_name
|
|
50
|
+
"pubid:bsi:adopted-international-standard"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
module Identifiers
|
|
4
|
+
# The synthesized Amendment wrapper (PFS supplements
|
|
5
|
+
# declaration, issue #121 feature 3): the kind face
|
|
6
|
+
# "A" is the run's dispatch token and the
|
|
7
|
+
# printed notation's face.
|
|
8
|
+
class Amendment < Supplement
|
|
9
|
+
FACE = "A".freeze
|
|
10
|
+
|
|
11
|
+
def self.face
|
|
12
|
+
FACE
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.polymorphic_name
|
|
16
|
+
"pubid:bsi:amendment"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# The MR slug's supplement suffix: the shared MrString
|
|
20
|
+
# recurses into base and appends this.
|
|
21
|
+
def mr_supplement_suffix
|
|
22
|
+
mr_join_segments("amd", number, year)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
module Identifiers
|
|
4
|
+
# Concrete British Standard identifier type (PFS type `british_standard`).
|
|
5
|
+
class BritishStandard < Identifier
|
|
6
|
+
TYPED_STAGES = [
|
|
7
|
+
::Pubid::Components::TypedStage.new(
|
|
8
|
+
code: :pubbs, stage_code: :published,
|
|
9
|
+
type_code: :bs, abbr: ["BS"],
|
|
10
|
+
name: "British Standard", harmonized_stages: [],
|
|
11
|
+
),
|
|
12
|
+
].freeze
|
|
13
|
+
|
|
14
|
+
def self.type
|
|
15
|
+
{ key: :bs, web: :british_standard, title: "British Standard", short: "BS" }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# The publisher default (feature 5): the type's own token
|
|
19
|
+
# when the type is its designation, else the scheme default.
|
|
20
|
+
def self.default_publisher
|
|
21
|
+
::Pubid::Components::Publisher.new(body: "BS")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
attribute :publisher, ::Pubid::Components::Publisher, default: -> { self.class.default_publisher }
|
|
25
|
+
attribute :type, ::Pubid::Components::Type, default: -> { self.class.default_type }
|
|
26
|
+
|
|
27
|
+
def self.default_type
|
|
28
|
+
::Pubid::Components::Type.new(abbr: type[:short])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# The scheme-canonical wire tag declared in the definition:
|
|
32
|
+
# to_hash stays byte-identical with the scheme's coded
|
|
33
|
+
# flavor, and this flavor's own from_hash routes the tag
|
|
34
|
+
# to this class.
|
|
35
|
+
def self.polymorphic_name
|
|
36
|
+
"pubid:bsi:british-standard"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
module Identifiers
|
|
4
|
+
# The consolidated (plus-run) bundle: the base document is
|
|
5
|
+
# the first member; the supplements carry no base.
|
|
6
|
+
class ConsolidatedIdentifier < ::Pubid::BsiPfs::Identifier
|
|
7
|
+
attribute :identifiers, ::Pubid::BsiPfs::Identifier,
|
|
8
|
+
polymorphic: true, collection: true
|
|
9
|
+
|
|
10
|
+
# The origin document. Members live in `identifiers`, so
|
|
11
|
+
# walk the first member to its root.
|
|
12
|
+
def root
|
|
13
|
+
identifiers&.first&.root || self
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def base_document
|
|
17
|
+
identifiers&.first&.base_document || self
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def drop_supplements
|
|
21
|
+
identifiers&.first || self
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# The base document, then each member's own supplement
|
|
25
|
+
# suffix behind the plus marker — the coded shape.
|
|
26
|
+
def to_mr_string
|
|
27
|
+
base, *supplements = identifiers
|
|
28
|
+
return "" unless base
|
|
29
|
+
|
|
30
|
+
([base.to_mr_string] +
|
|
31
|
+
supplements.map { |s| "plus-#{s.mr_supplement_suffix}" })
|
|
32
|
+
.join(::Pubid::Renderers::MrString::SEPARATOR_SUPPLEMENT)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.polymorphic_name
|
|
36
|
+
"pubid:bsi:consolidated-identifier"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
module Identifiers
|
|
4
|
+
# The synthesized Corrigendum wrapper (PFS supplements
|
|
5
|
+
# declaration, issue #121 feature 3): the kind face
|
|
6
|
+
# "C" is the run's dispatch token and the
|
|
7
|
+
# printed notation's face.
|
|
8
|
+
class Corrigendum < Supplement
|
|
9
|
+
FACE = "C".freeze
|
|
10
|
+
|
|
11
|
+
def self.face
|
|
12
|
+
FACE
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.polymorphic_name
|
|
16
|
+
"pubid:bsi:corrigendum"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# The MR slug's supplement suffix: the shared MrString
|
|
20
|
+
# recurses into base and appends this.
|
|
21
|
+
def mr_supplement_suffix
|
|
22
|
+
mr_join_segments("cor", number, year)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
module Identifiers
|
|
4
|
+
# Concrete Draft Document identifier type (PFS type `draft_document`).
|
|
5
|
+
class DraftDocument < Identifier
|
|
6
|
+
TYPED_STAGES = [
|
|
7
|
+
].freeze
|
|
8
|
+
|
|
9
|
+
def self.type
|
|
10
|
+
{ key: :dd, web: :draft_document, title: "Draft Document", short: "DD" }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# The publisher default (feature 5): the type's own token
|
|
14
|
+
# when the type is its designation, else the scheme default.
|
|
15
|
+
def self.default_publisher
|
|
16
|
+
::Pubid::Components::Publisher.new(body: "DD")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
attribute :publisher, ::Pubid::Components::Publisher, default: -> { self.class.default_publisher }
|
|
20
|
+
attribute :type, ::Pubid::Components::Type, default: -> { self.class.default_type }
|
|
21
|
+
|
|
22
|
+
def self.default_type
|
|
23
|
+
::Pubid::Components::Type.new(abbr: type[:short])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# The scheme-canonical wire tag declared in the definition:
|
|
27
|
+
# to_hash stays byte-identical with the scheme's coded
|
|
28
|
+
# flavor, and this flavor's own from_hash routes the tag
|
|
29
|
+
# to this class.
|
|
30
|
+
def self.polymorphic_name
|
|
31
|
+
"pubid:bsi:draft-document"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
module Identifiers
|
|
4
|
+
# Concrete Publicly Available Specification identifier type (PFS type `publicly_available_specification`).
|
|
5
|
+
class PubliclyAvailableSpecification < Identifier
|
|
6
|
+
TYPED_STAGES = [
|
|
7
|
+
].freeze
|
|
8
|
+
|
|
9
|
+
def self.type
|
|
10
|
+
{ key: :pas, web: :publicly_available_specification, title: "Publicly Available Specification", short: "PAS" }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# The publisher default (feature 5): the type's own token
|
|
14
|
+
# when the type is its designation, else the scheme default.
|
|
15
|
+
def self.default_publisher
|
|
16
|
+
::Pubid::Components::Publisher.new(body: "PAS")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
attribute :publisher, ::Pubid::Components::Publisher, default: -> { self.class.default_publisher }
|
|
20
|
+
attribute :type, ::Pubid::Components::Type, default: -> { self.class.default_type }
|
|
21
|
+
|
|
22
|
+
def self.default_type
|
|
23
|
+
::Pubid::Components::Type.new(abbr: type[:short])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# The scheme-canonical wire tag declared in the definition:
|
|
27
|
+
# to_hash stays byte-identical with the scheme's coded
|
|
28
|
+
# flavor, and this flavor's own from_hash routes the tag
|
|
29
|
+
# to this class.
|
|
30
|
+
def self.polymorphic_name
|
|
31
|
+
"pubid:bsi:publicly-available-specification"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
module Identifiers
|
|
4
|
+
# Concrete Published Document identifier type (PFS type `published_document`).
|
|
5
|
+
class PublishedDocument < Identifier
|
|
6
|
+
TYPED_STAGES = [
|
|
7
|
+
].freeze
|
|
8
|
+
|
|
9
|
+
def self.type
|
|
10
|
+
{ key: :pd, web: :published_document, title: "Published Document", short: "PD" }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# The publisher default (feature 5): the type's own token
|
|
14
|
+
# when the type is its designation, else the scheme default.
|
|
15
|
+
def self.default_publisher
|
|
16
|
+
::Pubid::Components::Publisher.new(body: "PD")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
attribute :publisher, ::Pubid::Components::Publisher, default: -> { self.class.default_publisher }
|
|
20
|
+
attribute :type, ::Pubid::Components::Type, default: -> { self.class.default_type }
|
|
21
|
+
|
|
22
|
+
def self.default_type
|
|
23
|
+
::Pubid::Components::Type.new(abbr: type[:short])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# The scheme-canonical wire tag declared in the definition:
|
|
27
|
+
# to_hash stays byte-identical with the scheme's coded
|
|
28
|
+
# flavor, and this flavor's own from_hash routes the tag
|
|
29
|
+
# to this class.
|
|
30
|
+
def self.polymorphic_name
|
|
31
|
+
"pubid:bsi:published-document"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
module Identifiers
|
|
4
|
+
# The supplement wrapper base: the wrapper owns its ordinal
|
|
5
|
+
# and the base identifier; every delegated attribute reads
|
|
6
|
+
# through (the coded SupplementIdentifier shape).
|
|
7
|
+
class Supplement < ::Pubid::BsiPfs::Identifier
|
|
8
|
+
attribute :base, ::Pubid::BsiPfs::Identifier
|
|
9
|
+
attribute :number, :string
|
|
10
|
+
attribute :year, :string
|
|
11
|
+
|
|
12
|
+
def base_document
|
|
13
|
+
base&.base_document || self
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def drop_supplements
|
|
17
|
+
base || self
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# The printed notation: the kind face, the ordinal (absent
|
|
21
|
+
# for an unnumbered corrigendum) and the declared date tail.
|
|
22
|
+
# The bare notation; the renderer's walkers add the
|
|
23
|
+
# standalone slash and the consolidated plus themselves.
|
|
24
|
+
def supplement_notation
|
|
25
|
+
"#{self.class.face}#{number}#{year ? ":#{year}" : ''}"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
module Identifiers
|
|
4
|
+
# Concrete Technical Specification identifier type (PFS type `technical_specification`).
|
|
5
|
+
class TechnicalSpecification < Identifier
|
|
6
|
+
TYPED_STAGES = [
|
|
7
|
+
].freeze
|
|
8
|
+
|
|
9
|
+
def self.type
|
|
10
|
+
{ key: :ts, web: :technical_specification, title: "Technical Specification", short: "TS" }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# The publisher default (feature 5): the type's own token
|
|
14
|
+
# when the type is its designation, else the scheme default.
|
|
15
|
+
def self.default_publisher
|
|
16
|
+
::Pubid::Components::Publisher.new(body: "TS")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
attribute :publisher, ::Pubid::Components::Publisher, default: -> { self.class.default_publisher }
|
|
20
|
+
attribute :type, ::Pubid::Components::Type, default: -> { self.class.default_type }
|
|
21
|
+
|
|
22
|
+
def self.default_type
|
|
23
|
+
::Pubid::Components::Type.new(abbr: type[:short])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# The scheme-canonical wire tag declared in the definition:
|
|
27
|
+
# to_hash stays byte-identical with the scheme's coded
|
|
28
|
+
# flavor, and this flavor's own from_hash routes the tag
|
|
29
|
+
# to this class.
|
|
30
|
+
def self.polymorphic_name
|
|
31
|
+
"pubid:bsi:technical-specification"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
module Identifiers
|
|
4
|
+
autoload :BritishStandard, "#{__dir__}/identifiers/british_standard"
|
|
5
|
+
autoload :AdoptedEuropeanNorm, "#{__dir__}/identifiers/adopted_european_norm"
|
|
6
|
+
autoload :AdoptedInternationalStandard, "#{__dir__}/identifiers/adopted_international_standard"
|
|
7
|
+
autoload :PubliclyAvailableSpecification, "#{__dir__}/identifiers/publicly_available_specification"
|
|
8
|
+
autoload :PublishedDocument, "#{__dir__}/identifiers/published_document"
|
|
9
|
+
autoload :DraftDocument, "#{__dir__}/identifiers/draft_document"
|
|
10
|
+
autoload :TechnicalSpecification, "#{__dir__}/identifiers/technical_specification"
|
|
11
|
+
autoload :Supplement, "#{__dir__}/identifiers/supplement"
|
|
12
|
+
autoload :Amendment, "#{__dir__}/identifiers/amendment"
|
|
13
|
+
autoload :Corrigendum, "#{__dir__}/identifiers/corrigendum"
|
|
14
|
+
autoload :ConsolidatedIdentifier, "#{__dir__}/identifiers/consolidated_identifier"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
# PFS-generated parser shell. Parsing runs through the baked
|
|
4
|
+
# PARG artifact (data/parg/bsi_pfs.json) via Pubid::Parg::Model.bound;
|
|
5
|
+
# the grammar source lives in pubid-grammar
|
|
6
|
+
# (grammars/bsi_pfs.parg, compiled from definitions/bsi.pfs).
|
|
7
|
+
class Parser
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
# The pubid-scheme URN schema, registered under the compiled
|
|
4
|
+
# flavor key. The definition's declared namespace
|
|
5
|
+
# ("bsi") is the scheme's canonical
|
|
6
|
+
# namespace; identifiers carry the scheme's wire tag, so their
|
|
7
|
+
# pubid URNs encode through the scheme's own schema.
|
|
8
|
+
PubidUrnSchema = Pubid::PubidUrn.define("bsi_pfs") do
|
|
9
|
+
atom "publisher", "pub"
|
|
10
|
+
atom "part", "part"
|
|
11
|
+
atom "year", "year"
|
|
12
|
+
atom "adopted", "adopted", kind: :id
|
|
13
|
+
atom "identifiers", "ids", kind: :ids
|
|
14
|
+
type "pubid:bsi:adopted-european-norm", "aen", core: []
|
|
15
|
+
type "pubid:bsi:adopted-international-standard", "ais", core: []
|
|
16
|
+
type "pubid:bsi:amendment", "amd", core: []
|
|
17
|
+
type "pubid:bsi:british-standard", "bs", core: ["number"]
|
|
18
|
+
type "pubid:bsi:consolidated-identifier", "consol", core: []
|
|
19
|
+
type "pubid:bsi:corrigendum", "cor", core: []
|
|
20
|
+
type "pubid:bsi:draft-document", "dd", core: ["number"]
|
|
21
|
+
type "pubid:bsi:published-document", "pd", core: ["number"]
|
|
22
|
+
type "pubid:bsi:publicly-available-specification", "pas", core: ["number"]
|
|
23
|
+
type "pubid:bsi:technical-specification", "ts", core: ["number"]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
# Human renderer, generated from the canonical template.
|
|
4
|
+
class Renderer < ::Pubid::Renderers::Base
|
|
5
|
+
def render(**_opts)
|
|
6
|
+
f = render_fields(@id)
|
|
7
|
+
"#{if f[:publisher] && f[:adopted]; "#{f[:publisher]} #{f[:adopted]}" elsif f[:publisher] && f[:number]; "#{f[:publisher]} #{f[:number]}#{("-#{f[:part]}") if f[:part]}#{(":#{f[:year]}") if f[:year]}"; end}#{("#{f[:supplements]}") if f[:supplements]}"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
# The field view: a wrapper reads through to the wrapped
|
|
13
|
+
# standard and composes the printed run once — the standalone
|
|
14
|
+
# chain behind its slash, the consolidated members behind the
|
|
15
|
+
# plus — and the fragment face follows its base.
|
|
16
|
+
def render_fields(id)
|
|
17
|
+
root = id
|
|
18
|
+
run = +""
|
|
19
|
+
members = nil
|
|
20
|
+
frag = nil
|
|
21
|
+
if root.is_a?(Identifiers::ConsolidatedIdentifier)
|
|
22
|
+
base, *consolidated = root.identifiers
|
|
23
|
+
members = consolidated
|
|
24
|
+
root = base
|
|
25
|
+
end
|
|
26
|
+
while root.is_a?(Identifiers::Supplement)
|
|
27
|
+
run.prepend("/#{root.supplement_notation}")
|
|
28
|
+
root = root.base
|
|
29
|
+
end
|
|
30
|
+
members&.each do |member|
|
|
31
|
+
run << "+#{member.supplement_notation}"
|
|
32
|
+
end
|
|
33
|
+
view = {
|
|
34
|
+
publisher: root.publisher&.respond_to?(:body) ? root.publisher.body : root.publisher,
|
|
35
|
+
number: root.number,
|
|
36
|
+
part: root.part,
|
|
37
|
+
year: root.date&.year,
|
|
38
|
+
adopted: root.respond_to?(:adopted) ? root.adopted : nil,
|
|
39
|
+
}
|
|
40
|
+
view[:supplements] = run.empty? ? nil : run
|
|
41
|
+
view
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
module Pubid
|
|
2
|
+
module BsiPfs
|
|
3
|
+
# The official URN generator: the scheme's declared namespace
|
|
4
|
+
# ("bsi") and the ordered fused segments
|
|
5
|
+
# (feature 6) — the publisher group, the adopted document's
|
|
6
|
+
# fused MR string, the composed code, the year, the draft
|
|
7
|
+
# stage. A wrapper reads through to its subject and appends
|
|
8
|
+
# its declared chain; the consolidated bundle marks each
|
|
9
|
+
# member with the plus marker.
|
|
10
|
+
class UrnGenerator < ::Pubid::UrnGenerator::Base
|
|
11
|
+
def urn_namespace
|
|
12
|
+
"bsi"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def generate
|
|
16
|
+
id = @identifier
|
|
17
|
+
members = nil
|
|
18
|
+
frag_segments = []
|
|
19
|
+
wrapper = []
|
|
20
|
+
if id.is_a?(Identifiers::ConsolidatedIdentifier)
|
|
21
|
+
base, *consolidated = id.identifiers
|
|
22
|
+
members = consolidated
|
|
23
|
+
id = base
|
|
24
|
+
end
|
|
25
|
+
while id.is_a?(Identifiers::Supplement)
|
|
26
|
+
wrapper.prepend(*wrapper_segments(id))
|
|
27
|
+
id = id.base
|
|
28
|
+
end
|
|
29
|
+
@identifier = id
|
|
30
|
+
parts = ["urn", urn_namespace]
|
|
31
|
+
parts.concat(official_segments)
|
|
32
|
+
parts.concat(wrapper)
|
|
33
|
+
members&.each do |member|
|
|
34
|
+
parts << "plus"
|
|
35
|
+
parts.concat(wrapper_segments(member))
|
|
36
|
+
end
|
|
37
|
+
parts.concat(frag_segments)
|
|
38
|
+
parts.join(":")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def official_segments
|
|
44
|
+
segments = []
|
|
45
|
+
segments << @identifier.publisher.to_s.downcase if @identifier.publisher
|
|
46
|
+
segments << @identifier.number if @identifier.number
|
|
47
|
+
segments << "-" + @identifier.part.to_s if @identifier.part
|
|
48
|
+
date = [@identifier.date&.year].compact
|
|
49
|
+
segments << date.join("-") unless date.empty?
|
|
50
|
+
segments
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# One wrapper's declared URN chain: the kind word, then the
|
|
54
|
+
# wrapper's columns (the ordinal, the year-month date).
|
|
55
|
+
def wrapper_segments(id)
|
|
56
|
+
segments = case id
|
|
57
|
+
when Identifiers::Amendment
|
|
58
|
+
["amd", id.number, id.year]
|
|
59
|
+
when Identifiers::Corrigendum
|
|
60
|
+
["cor", id.number, id.year]
|
|
61
|
+
else
|
|
62
|
+
[]
|
|
63
|
+
end
|
|
64
|
+
segments.map(&:to_s).reject(&:empty?)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
#
|
|
3
|
+
# PFS-generated flavor — DO NOT EDIT BY HAND.
|
|
4
|
+
# Source: definitions/bsi.pfs (pfs:1) sha256:acb28ac064cf70b7dcaf8ec199cd535f95c201ca348746f9124ce7d080473585
|
|
5
|
+
# Compiler: pubid/grammar/pfs 0.1.0 (baked with parsanol 1.3.126)
|
|
6
|
+
# Regenerate: ruby scripts/pfs compile definitions/bsi.pfs --as bsi_pfs --ruby-out <dir>
|
|
7
|
+
|
|
8
|
+
require "pubid"
|
|
9
|
+
|
|
10
|
+
module Pubid
|
|
11
|
+
# BSI (module composition) flavor, compiled from its PFS definition
|
|
12
|
+
# (pubid/pubid#706). A compiled flavor is a peer of the coded
|
|
13
|
+
# flavors: same registry, same input guards, same error
|
|
14
|
+
# namespace, same URN contracts.
|
|
15
|
+
module BsiPfs
|
|
16
|
+
extend Pubid::PrefixesSupport
|
|
17
|
+
|
|
18
|
+
PREFIXES = ["BS", "PAS", "PD", "DD", "TS"].freeze
|
|
19
|
+
# The module composition the definition binds (issue #706 §4):
|
|
20
|
+
# each entry names the library module, the version it was bound
|
|
21
|
+
# at, and — where the module declares one — its IDENTITY
|
|
22
|
+
# composition (wrapper-with-adopted: the adopted document is
|
|
23
|
+
# the base). Carried so consumers and the wizard can
|
|
24
|
+
# introspect what the flavor is composed of.
|
|
25
|
+
MODULES = [
|
|
26
|
+
{ name: "iso.inner", version: 1, identity: { composition: "wrapper-with-adopted", base_module: "iso.inner", adopted_field: :adopted } },
|
|
27
|
+
{ name: "iec.inner", version: 1, identity: { composition: "wrapper-with-adopted", base_module: "iec.inner", adopted_field: :adopted } },
|
|
28
|
+
{ name: "en.overlay", version: 1, identity: { composition: "wrapper-with-adopted", base_module: "iso.inner", adopted_field: :adopted } },
|
|
29
|
+
{ name: "national.prefix", version: 1, identity: { composition: "wrapper-with-adopted", base_module: "iso.inner", adopted_field: :adopted } },
|
|
30
|
+
{ name: "supplements.core", version: 1, identity: { composition: "wrapper-with-adopted", adopted_field: :base } },
|
|
31
|
+
].freeze
|
|
32
|
+
# The adopted-base dispatch hook (the §4 coded escape hatch):
|
|
33
|
+
# vendored beside the generated classes — a missing hook file
|
|
34
|
+
# fails loudly on the first adoption, never silently.
|
|
35
|
+
autoload :AdoptedBase, "#{__dir__}/bsi_pfs/adopted_base"
|
|
36
|
+
autoload :Builder, "#{__dir__}/bsi_pfs/builder"
|
|
37
|
+
autoload :Identifier, "#{__dir__}/bsi_pfs/identifier"
|
|
38
|
+
autoload :Identifiers, "#{__dir__}/bsi_pfs/identifiers"
|
|
39
|
+
autoload :Parser, "#{__dir__}/bsi_pfs/parser"
|
|
40
|
+
autoload :Renderer, "#{__dir__}/bsi_pfs/renderer"
|
|
41
|
+
autoload :PubidUrnSchema, "#{__dir__}/bsi_pfs/pubid_urn_schema"
|
|
42
|
+
autoload :UrnGenerator, "#{__dir__}/bsi_pfs/urn_generator"
|
|
43
|
+
|
|
44
|
+
def self.parse(identifier)
|
|
45
|
+
Identifier.parse(identifier)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
Identifier.format_registry = FormatRegistry.new(parent: Identifier.format_registry)
|
|
49
|
+
Identifier.format_registry.register(:human, renderer: BsiPfs::Renderer)
|
|
50
|
+
|
|
51
|
+
def self.identifier_types
|
|
52
|
+
@identifier_types ||= Identifiers.constants
|
|
53
|
+
.filter_map { |c| begin; Identifiers.const_get(c); rescue NameError; nil; end }
|
|
54
|
+
.select { |c| c.is_a?(Class) && c.singleton_methods(false).include?(:type) }
|
|
55
|
+
.select { |c| c.type.is_a?(Hash) }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self.all_typed_stages
|
|
59
|
+
@all_typed_stages ||= identifier_types.flat_map do |klass|
|
|
60
|
+
klass.const_defined?(:TYPED_STAGES) ? klass.const_get(:TYPED_STAGES) : []
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def self.locate_type(code)
|
|
65
|
+
identifier_types.find { |t| t.type[:key].to_s == code.to_s }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def self.locate_stage(abbr)
|
|
69
|
+
abbr_str = abbr.to_s.upcase
|
|
70
|
+
all_typed_stages.find { |s| s.abbr.any? { |a| a.to_s.upcase == abbr_str } }
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
Pubid::Registry.register(:bsi_pfs, Pubid::BsiPfs)
|
data/lib/pubid/version.rb
CHANGED
data/lib/pubid.rb
CHANGED
|
@@ -232,6 +232,12 @@ module Pubid
|
|
|
232
232
|
autoload :Astm, "pubid/astm"
|
|
233
233
|
autoload :Bipm, "pubid/bipm"
|
|
234
234
|
autoload :Bsi, "pubid/bsi"
|
|
235
|
+
# The PFS-compiled module-composition surface of bsi (pubid/pubid#706
|
|
236
|
+
# §4): the first module-composition proof flavor — the BS face composed
|
|
237
|
+
# from the module library (national.prefix + en.overlay over the
|
|
238
|
+
# adopted ISO/IEC inners), measured against the coded flavor over the
|
|
239
|
+
# bsi corpus (spec/pubid/bsi_pfs/parity_spec.rb's ledger).
|
|
240
|
+
autoload :BsiPfs, "pubid/bsi_pfs"
|
|
235
241
|
autoload :Calconnect, "pubid/calconnect"
|
|
236
242
|
# The PFS-compiled dev alias of calconnect (pubid/pubid#706 §8): the
|
|
237
243
|
# acceptance port, registered beside the coded flavor, never routed by
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pubid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.38
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: lutaml-model
|
|
@@ -30,14 +29,14 @@ dependencies:
|
|
|
30
29
|
requirements:
|
|
31
30
|
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.
|
|
32
|
+
version: 1.5.0
|
|
34
33
|
type: :runtime
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
37
|
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.
|
|
39
|
+
version: 1.5.0
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
41
|
name: benchmark
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -60,8 +59,8 @@ email:
|
|
|
60
59
|
executables: []
|
|
61
60
|
extensions: []
|
|
62
61
|
extra_rdoc_files:
|
|
63
|
-
- README.adoc
|
|
64
62
|
- LICENSE.txt
|
|
63
|
+
- README.adoc
|
|
65
64
|
files:
|
|
66
65
|
- LICENSE.txt
|
|
67
66
|
- README.adoc
|
|
@@ -90,6 +89,7 @@ files:
|
|
|
90
89
|
- data/parg/bipm.json
|
|
91
90
|
- data/parg/bipm.parg
|
|
92
91
|
- data/parg/bsi.json
|
|
92
|
+
- data/parg/bsi_pfs.json
|
|
93
93
|
- data/parg/calconnect.json
|
|
94
94
|
- data/parg/calconnect_pfs.json
|
|
95
95
|
- data/parg/ccsds.json
|
|
@@ -343,6 +343,26 @@ files:
|
|
|
343
343
|
- lib/pubid/bsi/single_identifier.rb
|
|
344
344
|
- lib/pubid/bsi/urn_generator.rb
|
|
345
345
|
- lib/pubid/bsi/urn_parser.rb
|
|
346
|
+
- lib/pubid/bsi_pfs.rb
|
|
347
|
+
- lib/pubid/bsi_pfs/adopted_base.rb
|
|
348
|
+
- lib/pubid/bsi_pfs/builder.rb
|
|
349
|
+
- lib/pubid/bsi_pfs/identifier.rb
|
|
350
|
+
- lib/pubid/bsi_pfs/identifiers.rb
|
|
351
|
+
- lib/pubid/bsi_pfs/identifiers/adopted_european_norm.rb
|
|
352
|
+
- lib/pubid/bsi_pfs/identifiers/adopted_international_standard.rb
|
|
353
|
+
- lib/pubid/bsi_pfs/identifiers/amendment.rb
|
|
354
|
+
- lib/pubid/bsi_pfs/identifiers/british_standard.rb
|
|
355
|
+
- lib/pubid/bsi_pfs/identifiers/consolidated_identifier.rb
|
|
356
|
+
- lib/pubid/bsi_pfs/identifiers/corrigendum.rb
|
|
357
|
+
- lib/pubid/bsi_pfs/identifiers/draft_document.rb
|
|
358
|
+
- lib/pubid/bsi_pfs/identifiers/publicly_available_specification.rb
|
|
359
|
+
- lib/pubid/bsi_pfs/identifiers/published_document.rb
|
|
360
|
+
- lib/pubid/bsi_pfs/identifiers/supplement.rb
|
|
361
|
+
- lib/pubid/bsi_pfs/identifiers/technical_specification.rb
|
|
362
|
+
- lib/pubid/bsi_pfs/parser.rb
|
|
363
|
+
- lib/pubid/bsi_pfs/pubid_urn_schema.rb
|
|
364
|
+
- lib/pubid/bsi_pfs/renderer.rb
|
|
365
|
+
- lib/pubid/bsi_pfs/urn_generator.rb
|
|
346
366
|
- lib/pubid/builder/base.rb
|
|
347
367
|
- lib/pubid/bundled_identifier.rb
|
|
348
368
|
- lib/pubid/calconnect.rb
|
|
@@ -1191,7 +1211,6 @@ metadata:
|
|
|
1191
1211
|
changelog_uri: https://github.com/pubid/pubid/releases
|
|
1192
1212
|
documentation_uri: https://rubydoc.info/gems/pubid
|
|
1193
1213
|
rubygems_mfa_required: 'true'
|
|
1194
|
-
post_install_message:
|
|
1195
1214
|
rdoc_options: []
|
|
1196
1215
|
require_paths:
|
|
1197
1216
|
- lib
|
|
@@ -1206,8 +1225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1206
1225
|
- !ruby/object:Gem::Version
|
|
1207
1226
|
version: '0'
|
|
1208
1227
|
requirements: []
|
|
1209
|
-
rubygems_version:
|
|
1210
|
-
signing_key:
|
|
1228
|
+
rubygems_version: 4.0.23
|
|
1211
1229
|
specification_version: 4
|
|
1212
1230
|
summary: The international publication identifier (PubID) library for Ruby.
|
|
1213
1231
|
test_files: []
|