pubid 2.0.0 → 2.0.1
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/adobe.json +1 -1
- data/data/parg/aiee.json +1 -1
- data/data/parg/amca.json +1 -1
- data/data/parg/ansi.json +1 -1
- data/data/parg/api.json +1 -1
- data/data/parg/ashrae.json +1 -1
- data/data/parg/asme.json +1 -1
- data/data/parg/astm.json +1 -1
- data/data/parg/bipm.json +1 -1
- data/data/parg/bsi.json +1 -1
- data/data/parg/calconnect.json +1 -1
- data/data/parg/ccsds.json +1 -1
- data/data/parg/cen_cenelec.json +1 -1
- data/data/parg/cie.json +1 -1
- data/data/parg/csa.json +1 -1
- data/data/parg/doi.json +1 -1
- data/data/parg/easc.json +1 -1
- data/data/parg/ecma.json +1 -1
- data/data/parg/etsi.json +1 -1
- data/data/parg/evs.json +1 -1
- data/data/parg/gb.json +1 -1
- data/data/parg/gost.json +1 -1
- data/data/parg/iala.json +1 -1
- data/data/parg/iana.json +1 -1
- data/data/parg/idf.json +1 -1
- data/data/parg/iec.json +1 -1
- data/data/parg/ieee.json +1 -29571
- data/data/parg/ietf.json +1 -1
- data/data/parg/ire.json +1 -1
- data/data/parg/isbn.json +1 -1
- data/data/parg/iso.json +1 -8510
- data/data/parg/itu.json +1 -1
- data/data/parg/jcgm.json +1 -1
- data/data/parg/jis.json +1 -1
- data/data/parg/nesc.json +1 -1
- data/data/parg/nist.json +1 -9588
- data/data/parg/oasis.json +1 -1
- data/data/parg/ogc.json +1 -1
- data/data/parg/oiml.json +1 -1
- data/data/parg/omg.json +1 -1
- data/data/parg/parg.json +1 -1
- data/data/parg/plateau.json +1 -1
- data/data/parg/sae.json +1 -1
- data/data/parg/tables/typed_stages.yaml +1 -0
- data/data/parg/tgpp.json +1 -1
- data/data/parg/un.json +1 -1
- data/data/parg/w3c.json +1 -1
- data/data/parg/xsf.json +1 -1
- data/lib/pubid/calconnect/identifier.rb +1 -1
- data/lib/pubid/doi/identifier.rb +1 -1
- data/lib/pubid/easc/identifier.rb +1 -1
- data/lib/pubid/gb/identifier.rb +1 -1
- data/lib/pubid/ietf/identifiers/base.rb +1 -1
- data/lib/pubid/iso/identifiers/international_standard.rb +3 -1
- data/lib/pubid/oasis/identifier.rb +1 -1
- data/lib/pubid/ogc/identifier.rb +1 -1
- data/lib/pubid/parg/artifact.rb +22 -3
- data/lib/pubid/parg/model.rb +98 -0
- data/lib/pubid/parg.rb +1 -0
- data/lib/pubid/sae/identifiers/base.rb +1 -1
- data/lib/pubid/version.rb +1 -1
- data/lib/pubid/w3c/identifier.rb +1 -1
- data/lib/pubid/xsf/identifier.rb +1 -1
- metadata +11 -4
data/data/parg/un.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"bindings":null,"version":"0.1.0","grammar":"PubidUn","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"UN "}},{"Repetition":{"atom":0,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":9}},{"Entity":{"atom":7}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Re":{"pattern":"[.]"}},{"Alternative":{"atoms":[4,5,6]}},{"Repetition":{"atom":3,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"token","atom":8}},{"Entity":{"atom":11}},{"Str":{"pattern":"/"}},{"Entity":{"atom":9}},{"Sequence":{"atoms":[10,12]}},{"Repetition":{"atom":13,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[1,2,14]}}],"root":15},"bindings":[]}},"preprocess":{},"tables":{},"lint":{"order_warnings":[]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"UN/CEFACT/TBG14","expect":{}},{"entry":"identifier","kind":"accept","input":"CEFACT/TBG14","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/un/parser.rb. `token` matches [A-Z0-9.] runs.\n\ngrammar PubidUn version \"0.1.0\" {\n token_char = %x41-5A / %x30-39 / %x2E\n token = (1*token_char) as token\n identifier = [\"UN \"] token 1*(slash token)\n slash = \"/\"\n entry identifier: identifier\n\n test {\n accept \"UN/CEFACT/TBG14\"\n accept \"CEFACT/TBG14\"\n reject \"nonsense\"\n }\n}\n","source_hash":"
|
|
1
|
+
{"bindings":null,"version":"0.1.0","grammar":"PubidUn","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"UN "}},{"Repetition":{"atom":0,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":9}},{"Entity":{"atom":7}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Re":{"pattern":"[.]"}},{"Alternative":{"atoms":[4,5,6]}},{"Repetition":{"atom":3,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"token","atom":8}},{"Entity":{"atom":11}},{"Str":{"pattern":"/"}},{"Entity":{"atom":9}},{"Sequence":{"atoms":[10,12]}},{"Repetition":{"atom":13,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[1,2,14]}}],"root":15},"bindings":[]}},"preprocess":{},"tables":{},"lint":{"order_warnings":[]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"UN/CEFACT/TBG14","expect":{}},{"entry":"identifier","kind":"accept","input":"CEFACT/TBG14","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/un/parser.rb. `token` matches [A-Z0-9.] runs.\n\ngrammar PubidUn version \"0.1.0\" mode \"v1\" {\n token_char = %x41-5A / %x30-39 / %x2E\n token = (1*token_char) as token\n identifier = [\"UN \"] token 1*(slash token)\n slash = \"/\"\n entry identifier: identifier\n\n test {\n accept \"UN/CEFACT/TBG14\"\n accept \"CEFACT/TBG14\"\n reject \"nonsense\"\n }\n}\n","source_hash":"8af25923f5616b2ebe0443dc994d305d8f4390efe46bb685d8aebf89c68c66e2","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.3.114","edition":1,"checksum":"sha256:634305272bf558b8cb9193a1af8e75b9cc799d75386dd4d4a53e42d4d66cce1b"}
|
data/data/parg/w3c.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"bindings":null,"version":"0.1.0","grammar":"PubidW3c","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"W3C "}},{"Entity":{"atom":16}},{"Entity":{"atom":13}},{"Str":{"pattern":"DNOTE"}},{"Str":{"pattern":"NOTE"}},{"Str":{"pattern":"WD"}},{"Str":{"pattern":"CRD"}},{"Str":{"pattern":"CR"}},{"Str":{"pattern":"REC"}},{"Str":{"pattern":"PER"}},{"Str":{"pattern":"PR"}},{"Str":{"pattern":"SPSD"}},{"Str":{"pattern":"OBSL"}},{"Alternative":{"atoms":[3,4,5,6,7,8,9,10,11,12]}},{"Named":{"name":"type","atom":2}},{"Str":{"pattern":"-"}},{"Sequence":{"atoms":[14,15]}},{"Repetition":{"atom":1,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":22}},{"Entity":{"atom":20}},{"Re":{"pattern":"[\\x01-\\u{10ffff}]"}},{"Repetition":{"atom":19,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"rest","atom":21}},{"Sequence":{"atoms":[0,17,18]}}],"root":23},"bindings":[]}},"preprocess":{},"tables":{},"lint":{"order_warnings":["rule type_token: branches 4 and 5 are order-dependent (shared first bytes; ordered choice is decisive)","rule type_token: branches 7 and 8 are order-dependent (shared first bytes; ordered choice is decisive)"]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"W3C REC-html40-19981224","expect":{}},{"entry":"identifier","kind":"accept","input":"W3C NOTE-datetime-19980827","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/w3c/parser.rb: split off the leading maturity token;\n# code/date boundary is builder-side by design. Token order matters for\n# shared prefixes (CRD before CR, PER before PR, DNOTE before NOTE).\n\ngrammar PubidW3c version \"0.1.0\" {\n any_char = %x01-10FFFF\n type_token = \"DNOTE\" / \"NOTE\" / \"WD\" / \"CRD\" / \"CR\" / \"REC\" / \"PER\" / \"PR\" / \"SPSD\" / \"OBSL\"\n type_part = type_token as type \"-\"\n rest = (1*any_char) as rest\n identifier = \"W3C \" [type_part] rest\n entry identifier: identifier\n\n test {\n accept \"W3C REC-html40-19981224\"\n accept \"W3C NOTE-datetime-19980827\"\n reject \"nonsense\"\n }\n}\n","source_hash":"
|
|
1
|
+
{"bindings":null,"version":"0.1.0","grammar":"PubidW3c","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"W3C "}},{"Entity":{"atom":16}},{"Entity":{"atom":13}},{"Str":{"pattern":"DNOTE"}},{"Str":{"pattern":"NOTE"}},{"Str":{"pattern":"WD"}},{"Str":{"pattern":"CRD"}},{"Str":{"pattern":"CR"}},{"Str":{"pattern":"REC"}},{"Str":{"pattern":"PER"}},{"Str":{"pattern":"PR"}},{"Str":{"pattern":"SPSD"}},{"Str":{"pattern":"OBSL"}},{"Alternative":{"atoms":[3,4,5,6,7,8,9,10,11,12]}},{"Named":{"name":"type","atom":2}},{"Str":{"pattern":"-"}},{"Sequence":{"atoms":[14,15]}},{"Repetition":{"atom":1,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":22}},{"Entity":{"atom":20}},{"Re":{"pattern":"[\\x01-\\u{10ffff}]"}},{"Repetition":{"atom":19,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"rest","atom":21}},{"Sequence":{"atoms":[0,17,18]}}],"root":23},"bindings":[{"capture":"type","path":"type","type":"string","card":null,"preprocess":null},{"capture":"rest","path":"rest","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":["rule type_token: branches 4 and 5 are order-dependent (shared first bytes; ordered choice is decisive)","rule type_token: branches 7 and 8 are order-dependent (shared first bytes; ordered choice is decisive)"]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"W3C REC-html40-19981224","expect":{}},{"entry":"identifier","kind":"accept","input":"W3C NOTE-datetime-19980827","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/w3c/parser.rb: split off the leading maturity token;\n# code/date boundary is builder-side by design. Token order matters for\n# shared prefixes (CRD before CR, PER before PR, DNOTE before NOTE).\n\ngrammar PubidW3c version \"0.1.0\" edition 2 {\n any_char = %x01-10FFFF\n type_token = \"DNOTE\" / \"NOTE\" / \"WD\" / \"CRD\" / \"CR\" / \"REC\" / \"PER\" / \"PR\" / \"SPSD\" / \"OBSL\"\n type_part = type_token as type \"-\"\n rest = (1*any_char) as rest\n identifier = \"W3C \" [type_part] rest\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 type -> type (string)\n rest -> rest (string)\n }\n\n\n test {\n accept \"W3C REC-html40-19981224\"\n accept \"W3C NOTE-datetime-19980827\"\n reject \"nonsense\"\n }\n}\n","source_hash":"f1c99f42c7492c18f63f735ee29f07b25aa24442d6d899308a7af8350b83a2d9","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.3.114","edition":2,"checksum":"sha256:7d7f51422516dea82179ab39580f4c8ca877471c100c8d1621c6b076273c56ba"}
|
data/data/parg/xsf.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"bindings":null,"version":"0.1.0","grammar":"PubidXsf","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"XEP "}},{"Entity":{"atom":10}},{"Entity":{"atom":3}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":2,"min":1,"max":null,"tag":"Repetition"}},{"Entity":{"atom":8}},{"Str":{"pattern":"README"}},{"Str":{"pattern":"xxxx"}},{"Alternative":{"atoms":[6,7]}},{"Alternative":{"atoms":[4,5]}},{"Named":{"name":"number","atom":9}},{"Sequence":{"atoms":[0,1]}}],"root":11},"bindings":[]}},"preprocess":{},"tables":{},"lint":{"order_warnings":[]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"XEP 0001","expect":{}},{"entry":"identifier","kind":"accept","input":"XEP README","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/xsf/parser.rb: \"XEP NNNN\" plus the two named\n# documents (README, xxxx) in SPECIAL_NUMBERS.\n grammar PubidXsf version \"0.1.0\" {\n digit = %x30-39\n special_number = \"README\" / \"xxxx\"\n number = (1*digit / special_number) as number\n identifier = \"XEP \" number\n entry identifier: identifier\n\n test {\n accept \"XEP 0001\"\n accept \"XEP README\"\n reject \"nonsense\"\n }\n}\n","source_hash":"
|
|
1
|
+
{"bindings":null,"version":"0.1.0","grammar":"PubidXsf","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"XEP "}},{"Entity":{"atom":10}},{"Entity":{"atom":3}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":2,"min":1,"max":null,"tag":"Repetition"}},{"Entity":{"atom":8}},{"Str":{"pattern":"README"}},{"Str":{"pattern":"xxxx"}},{"Alternative":{"atoms":[6,7]}},{"Alternative":{"atoms":[4,5]}},{"Named":{"name":"number","atom":9}},{"Sequence":{"atoms":[0,1]}}],"root":11},"bindings":[{"capture":"number","path":"number","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":[]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"XEP 0001","expect":{}},{"entry":"identifier","kind":"accept","input":"XEP README","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/xsf/parser.rb: \"XEP NNNN\" plus the two named\n# documents (README, xxxx) in SPECIAL_NUMBERS.\n grammar PubidXsf version \"0.1.0\" edition 2 {\n digit = %x30-39\n special_number = \"README\" / \"xxxx\"\n number = (1*digit / special_number) as number\n identifier = \"XEP \" number\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 number -> number (string)\n }\n\n\n test {\n accept \"XEP 0001\"\n accept \"XEP README\"\n reject \"nonsense\"\n }\n}\n","source_hash":"fdfa1a7c14e4430d5237cf1995240003797173c202dc8574d8c98c7f48f576d2","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.3.114","edition":2,"checksum":"sha256:8a983305c22e049b60a0c7c6ffdd06c36985eeb7efa4844ed6c4f3b96669ed16"}
|
|
@@ -118,7 +118,7 @@ module Pubid
|
|
|
118
118
|
raise Pubid::Errors::InvalidInputError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
119
119
|
end
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
Pubid::Parg::Model.parse(:calconnect, Identifiers::Standard, identifier)
|
|
122
122
|
end
|
|
123
123
|
end
|
|
124
124
|
end
|
data/lib/pubid/doi/identifier.rb
CHANGED
data/lib/pubid/gb/identifier.rb
CHANGED
|
@@ -54,7 +54,9 @@ module Pubid
|
|
|
54
54
|
code: :wds,
|
|
55
55
|
stage_code: :wds,
|
|
56
56
|
type_code: :is,
|
|
57
|
-
|
|
57
|
+
# ISO launched the "WD Study" WG consultation (stage 20.20/20.60,
|
|
58
|
+
# relaton-iso#125); its spelled-out form is an accepted input spelling.
|
|
59
|
+
abbr: ["WDS", "WD Study"],
|
|
58
60
|
name: "Working Draft Study",
|
|
59
61
|
harmonized_stages: %w[20.20 20.60],
|
|
60
62
|
),
|
|
@@ -146,7 +146,7 @@ module Pubid
|
|
|
146
146
|
raise Pubid::Errors::InvalidInputError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
147
147
|
end
|
|
148
148
|
|
|
149
|
-
parsed = Pubid::Parg::
|
|
149
|
+
parsed = Pubid::Parg::Model.bound(:oasis, identifier)
|
|
150
150
|
Builder.build(parsed)
|
|
151
151
|
end
|
|
152
152
|
|
data/lib/pubid/ogc/identifier.rb
CHANGED
data/lib/pubid/parg/artifact.rb
CHANGED
|
@@ -21,13 +21,19 @@ module Pubid
|
|
|
21
21
|
def for(flavor)
|
|
22
22
|
@artifacts[flavor] ||=
|
|
23
23
|
begin
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
new(Parsanol::PARG::Artifact.load(path_for(flavor),
|
|
25
|
+
tables_dir: TABLES_DIR))
|
|
26
26
|
rescue Parsanol::PARG::Error => e
|
|
27
27
|
raise Pubid::Errors::ParseError,
|
|
28
|
-
"PG artifact #{
|
|
28
|
+
"PG artifact #{path_for(flavor)} rejected: #{e.message}"
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
|
+
|
|
32
|
+
# The vendored artifact's path. PG::Lutaml.register loads the file
|
|
33
|
+
# itself, so model registration needs the path, not the wrapper.
|
|
34
|
+
def path_for(flavor)
|
|
35
|
+
File.join(DATA_DIR, "#{flavor}.json")
|
|
36
|
+
end
|
|
31
37
|
end
|
|
32
38
|
|
|
33
39
|
def initialize(artifact)
|
|
@@ -38,6 +44,19 @@ module Pubid
|
|
|
38
44
|
@artifact.parse(entry, input)
|
|
39
45
|
end
|
|
40
46
|
|
|
47
|
+
# The artifact tree with the entry's declared bindings applied —
|
|
48
|
+
# the builder-ready attribute hash the grammar's bindings block
|
|
49
|
+
# declares, types cast at the engine.
|
|
50
|
+
def parse_and_bind(entry, input)
|
|
51
|
+
@artifact.parse_and_bind(entry, input)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# The bindings the grammar declared for +entry+, empty when it
|
|
55
|
+
# declares none.
|
|
56
|
+
def bindings(entry)
|
|
57
|
+
@artifact.envelope.dig("entries", entry, "bindings") || []
|
|
58
|
+
end
|
|
59
|
+
|
|
41
60
|
def checksum
|
|
42
61
|
@artifact.envelope["checksum"]
|
|
43
62
|
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module Parg
|
|
5
|
+
# Typed model binding for one artifact entry point. The grammar declares
|
|
6
|
+
# which captures bind to which attributes (its `bindings` block); this
|
|
7
|
+
# module parses through those bindings — either straight into the
|
|
8
|
+
# flavor's model class (`parse`) or into the builder-ready hash its
|
|
9
|
+
# Builder consumes (`bound`) — so consumers never see the wire tree.
|
|
10
|
+
module Model
|
|
11
|
+
ALL_PARTS_SUFFIX = "(all parts)"
|
|
12
|
+
ALL_PARTS_PATTERN = /\s*\(all parts\)\s*\z/
|
|
13
|
+
|
|
14
|
+
@registered = {}
|
|
15
|
+
@mutex = Mutex.new
|
|
16
|
+
|
|
17
|
+
class << self
|
|
18
|
+
# Parse +input+ through the artifact's declared bindings into the
|
|
19
|
+
# builder-ready attribute hash, without materializing a model. For
|
|
20
|
+
# flavors whose Builder still owns type dispatch and component
|
|
21
|
+
# construction: the bindings replace tree normalization, not the
|
|
22
|
+
# builder. The "(all parts)" suffix keeps its contract — stripped
|
|
23
|
+
# before parsing, marked on the hash for the builder's AllPartsWrap.
|
|
24
|
+
def bound(flavor, input, entry: "identifier")
|
|
25
|
+
ensure_bindings!(flavor, entry)
|
|
26
|
+
all_parts = input.end_with?(ALL_PARTS_SUFFIX)
|
|
27
|
+
source = all_parts ? input.sub(ALL_PARTS_PATTERN, "") : input
|
|
28
|
+
hash = Artifact.for(flavor).parse_and_bind(entry, source)
|
|
29
|
+
all_parts ? Backend.mark_all_parts(hash) : hash
|
|
30
|
+
rescue Parsanol::ParseFailed => e
|
|
31
|
+
parse_error(e, input, flavor)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Parse +input+ into +model_class+ through the artifact's declared
|
|
35
|
+
# bindings. The "(all parts)" suffix is stripped before parsing and
|
|
36
|
+
# re-applied to the model, exactly as the tree backend does.
|
|
37
|
+
def parse(flavor, model_class, input, entry: "identifier")
|
|
38
|
+
register(flavor, model_class, entry)
|
|
39
|
+
model, all_parts = materialize(flavor, model_class, input)
|
|
40
|
+
all_parts ? model.to_all_parts : model
|
|
41
|
+
rescue Parsanol::ParseFailed => e
|
|
42
|
+
parse_error(e, input, flavor)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def parse_error(error, input, flavor)
|
|
48
|
+
raise Pubid::Errors::ParseError.new(
|
|
49
|
+
error.message,
|
|
50
|
+
nil,
|
|
51
|
+
input: input,
|
|
52
|
+
flavor: Backend.registered_name(flavor),
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def materialize(flavor, model_class, input)
|
|
57
|
+
all_parts = input.end_with?(ALL_PARTS_SUFFIX)
|
|
58
|
+
source = all_parts ? input.sub(ALL_PARTS_PATTERN, "") : input
|
|
59
|
+
[model_class.public_send(:"from_#{format_for(flavor)}", source),
|
|
60
|
+
all_parts]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def register(flavor, model_class, entry)
|
|
64
|
+
format = format_for(flavor)
|
|
65
|
+
@mutex.synchronize do
|
|
66
|
+
return if @registered[format] == model_class
|
|
67
|
+
|
|
68
|
+
ensure_bindings!(flavor, entry)
|
|
69
|
+
bind!(flavor, model_class, format, entry)
|
|
70
|
+
@registered[format] = model_class
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def bind!(flavor, model_class, format, entry)
|
|
75
|
+
Parsanol::PARG::Lutaml.register(
|
|
76
|
+
model_class,
|
|
77
|
+
format_name: format,
|
|
78
|
+
artifact: Artifact.path_for(flavor),
|
|
79
|
+
entry: entry,
|
|
80
|
+
tables_dir: Artifact::TABLES_DIR,
|
|
81
|
+
)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def ensure_bindings!(flavor, entry)
|
|
85
|
+
return unless Artifact.for(flavor).bindings(entry).empty?
|
|
86
|
+
|
|
87
|
+
raise Pubid::Errors::ParseError,
|
|
88
|
+
"PG artifact for #{flavor} declares no bindings " \
|
|
89
|
+
"for entry #{entry}"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def format_for(flavor)
|
|
93
|
+
:"pg_#{flavor}"
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
data/lib/pubid/parg.rb
CHANGED
data/lib/pubid/version.rb
CHANGED
data/lib/pubid/w3c/identifier.rb
CHANGED
|
@@ -122,7 +122,7 @@ module Pubid
|
|
|
122
122
|
raise Pubid::Errors::InvalidInputError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
123
123
|
end
|
|
124
124
|
|
|
125
|
-
parsed = Pubid::Parg::
|
|
125
|
+
parsed = Pubid::Parg::Model.bound(:w3c, identifier)
|
|
126
126
|
Builder.build(parsed)
|
|
127
127
|
end
|
|
128
128
|
end
|
data/lib/pubid/xsf/identifier.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lutaml-model
|
|
@@ -44,14 +44,20 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 1.3.
|
|
47
|
+
version: 1.3.114
|
|
48
|
+
- - "<"
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: '1.4'
|
|
48
51
|
type: :runtime
|
|
49
52
|
prerelease: false
|
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
54
|
requirements:
|
|
52
55
|
- - ">="
|
|
53
56
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 1.3.
|
|
57
|
+
version: 1.3.114
|
|
58
|
+
- - "<"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '1.4'
|
|
55
61
|
description: PubID is a Ruby library for parsing and generating international publication
|
|
56
62
|
identifiers (PubIDs). It provides a simple and flexible API for working with PubIDs,
|
|
57
63
|
allowing developers to easily create, manipulate, and validate PubIDs in their applications.
|
|
@@ -933,6 +939,7 @@ files:
|
|
|
933
939
|
- lib/pubid/parg.rb
|
|
934
940
|
- lib/pubid/parg/artifact.rb
|
|
935
941
|
- lib/pubid/parg/backend.rb
|
|
942
|
+
- lib/pubid/parg/model.rb
|
|
936
943
|
- lib/pubid/parser.rb
|
|
937
944
|
- lib/pubid/parser/common_parse_methods.rb
|
|
938
945
|
- lib/pubid/parser/common_parse_rules.rb
|