pubid 2.0.41 → 2.0.43

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.
data/data/parg/iso.parg CHANGED
@@ -190,13 +190,17 @@ grammar PubidIso version "0.5.0" edition 2 {
190
190
  jcgm_identifier = "JCGM" as publisher space second_part third_part
191
191
 
192
192
  # ---- NSB stage prefixes: "FprISO 105-A03", "WD/ISO 10360-5:2000" ----
193
+ ## #118: the stage-to-publisher join differs per branch — the Fpr form
194
+ ## glues onto the publisher, the WD form carries a slash. The slash
195
+ ## captures as nsb_stage_slash so the render emits the join per shape
196
+ ## (the Fpr branch binds nothing to join with).
193
197
  nsb_iso_identifier = {
194
198
  (
195
199
  ("Fpr" as nsb_stage) prefix_sole_publisher [space] [copublishers] [space] [type_with_stage] [space] second_part third_part
196
200
  )
197
201
  /
198
202
  (
199
- ("WD" as nsb_stage) slash prefix_sole_publisher [space] [copublishers] [space] [type_with_stage] [space] second_part third_part
203
+ ("WD" as nsb_stage) (slash as nsb_stage_slash) prefix_sole_publisher [space] [copublishers] [space] [type_with_stage] [space] second_part third_part
200
204
  )
201
205
  }
202
206
 
@@ -213,7 +217,11 @@ grammar PubidIso version "0.5.0" edition 2 {
213
217
  slash sc_type space (1*digit) as sc_number
214
218
  )
215
219
  }
216
- tc_document = prefix_sole_publisher (slash / space) tc_type space (1*digit) as tc_number [tc_subcommittee_part] space "N" [space] (1*digit) as number [(colon (("19" / "20") 2*digit !digit) as year)]
220
+ ## #118: the publisher-to-type join is "/" or a space per the input's
221
+ ## own spelling; it captures as tc_join so the render emits the
222
+ ## captured join back (a canonical slash would re-bind a space-joined
223
+ ## input to the other alternative's value).
224
+ tc_document = prefix_sole_publisher ((slash / space) as tc_join) tc_type space (1*digit) as tc_number [tc_subcommittee_part] space "N" [space] (1*digit) as number [(colon (("19" / "20") 2*digit !digit) as year)]
217
225
  bare_tc_document = {
218
226
  (1*digit) as tc_number
219
227
  slash sc_type space (1*digit) as sc_number
@@ -723,6 +731,7 @@ grammar PubidIso version "0.5.0" edition 2 {
723
731
  type_with_stage_fr -> type_with_stage_fr (string)
724
732
  base_edition -> base_edition (string)
725
733
  nsb_stage -> nsb_stage (string)
734
+ nsb_stage_slash -> nsb_stage_slash (string)
726
735
  iso_r_prefix -> iso_r_prefix (string)
727
736
  number_with_part -> number_with_part (string)
728
737
  stage_iteration -> stage_iteration (string)
@@ -733,6 +742,7 @@ grammar PubidIso version "0.5.0" edition 2 {
733
742
  all_parts -> all_parts (string)
734
743
  year -> year (string)
735
744
  tc_type -> tc_type (string)
745
+ tc_join -> tc_join (string)
736
746
  tc_number -> tc_number (string)
737
747
  sc_type -> sc_type (string)
738
748
  sc_number -> sc_number (string)
@@ -871,6 +881,49 @@ bs3_undated_marker -> bs3_undated_marker (string)
871
881
  ballot_stamp_number: "1"
872
882
  ballot_stamp_date: "2006"
873
883
  }
884
+ # #118: the nsb_stage face — the Fpr branch glues onto the publisher,
885
+ # the WD branch carries the captured slash (nsb_stage_slash).
886
+ accept "FprISO 10140-4"
887
+ accept "FprISO 13679"
888
+ accept "FprISO/IEC 17029"
889
+ accept "WD/ISO 10360-2"
890
+ example "FprISO 105-A03" {
891
+ nsb_stage: "Fpr"
892
+ publisher: "ISO"
893
+ number_with_part: "105-A03"
894
+ }
895
+ example "WD/ISO 10360-5:2000" {
896
+ nsb_stage: "WD"
897
+ nsb_stage_slash: "/"
898
+ date: "2000"
899
+ }
900
+ # #118: the publisher-bearing tc_document face — the join captures as
901
+ # tc_join, the type as tc_type (the bare-TC face binds neither).
902
+ accept "ISO/TC 184/SC 4 N 789"
903
+ accept "ISO/TC 184/SC/QC 4 N246"
904
+ accept "ISO/TC 184 N 100"
905
+ accept "ISO/TC 184 N 100:2024"
906
+ accept "ISO TC 46 N 3064"
907
+ example "ISO/TC 184/SC 4/WG 3 N 123" {
908
+ tc_join: "/"
909
+ tc_type: "TC"
910
+ tc_number: "184"
911
+ sc_number: "4"
912
+ wg_number: "3"
913
+ number: "123"
914
+ }
915
+ example "ISO TC 46 N 3064" {
916
+ tc_join: " "
917
+ tc_type: "TC"
918
+ tc_number: "46"
919
+ number: "3064"
920
+ }
921
+ example "ISO/JTC 1 N 456" {
922
+ tc_join: "/"
923
+ tc_type: "JTC"
924
+ tc_number: "1"
925
+ number: "456"
926
+ }
874
927
  }
875
928
  }
876
929
 
@@ -880,12 +933,360 @@ preprocess publisher_names {
880
933
 
881
934
  derive urn "urn:iso:std:{number_with_part}:{date}"
882
935
 
936
+ # F6 render spec, #116: every bound field, in a join order that re-parses
937
+ # to the same bound map (the rs#459 round-trip oracle). The rules the
938
+ # segments obey, checked line-by-line against the identifier rules above:
939
+ #
940
+ # - The publisher joins the number with a SPACE (`prefix_sole_publisher =
941
+ # publisher [space] ...`); the dash the old spec emitted is never
942
+ # grammar-valid there. Shapes with no publisher at all (bare TC
943
+ # documents, the ISO/R forms) render no prefix and no separator.
944
+ # - `copublishers` captures WITH its leading slash, so `publisher`
945
+ # + `copublishers` needs no separator between them.
946
+ # - A typed stage after the prefix is joined with a space: the copublisher
947
+ # spine accepts `[space] [slash] [type_with_stage]`, and the space form
948
+ # re-parses to the same map for every stage-bearing shape ("ISO/WD Study
949
+ # 42010" renders as "ISO WD Study 42010" — the bound map is identical).
950
+ # - A ballot stage always renders slash-prefixed: the TYPE-first ballot
951
+ # branch takes `[space] [slash] ballot_type_with_stage` after the
952
+ # prefix, so "ISO/IEC PDAM 2 10646:2012" renders as
953
+ # "ISO/IEC/PDAM 2 10646:2012" and re-parses through the same branch to
954
+ # the same map; the space-attached ballot face re-parses through the
955
+ # same branch too.
956
+ # - The ballot stamp's abbrev token is decode-away (matched uncaptured),
957
+ # so the stamp renders the canonical "/Amd" spelling: the re-parse binds
958
+ # stamp number/date only, and the abbrev spelling is not identity. The
959
+ # dot-number stamp alternative is a different bound field
960
+ # (ballot_stamp_dot_number), so the number renders in the spaced form.
961
+ # - Supplements join with "/" + the bound abbrev; the ISO/R supplement
962
+ # layer takes the slash separator alternative of
963
+ # iso_r_supplement_separator.
964
+ # - The joint renders " | " (the `[space] "|" [space]` join, house form).
965
+ # - The undated marker renders after its colon (`date = (colon / dash)
966
+ # [date_core]`), and bare-TC documents keep the glued `N<number>` the
967
+ # bare_tc_document rule accepts.
968
+ # - The NSB stage renders BEFORE the publisher, with the join its own
969
+ # branch bound (#118): the Fpr branch binds no join face, so "FprISO
970
+ # 105-A03" renders glued ("FprISO 105-A03"); the WD branch captures the
971
+ # slash as nsb_stage_slash, so "WD/ISO 10360-5:2000" renders
972
+ # "WD/ISO 10360-5:2000". (The coded flavor decodes the NSB stage onto
973
+ # the modern stage face — "ISO/PRF 105-A03" — which would re-bind a
974
+ # different map; the render keeps the bound faces instead.)
975
+ # - The publisher-bearing tc_document face renders the join AS CAPTURED
976
+ # (#118): a canonical slash would re-bind a space-joined input to the
977
+ # other alternative, so `field tc_join` emits "/" or " " per the input.
978
+ # The type follows space-joined (the rule's own `tc_type space`), then
979
+ # the shared bare-TC cluster — "ISO/TC 184/SC 4/WG 3 N 123" renders as
980
+ # "ISO/TC 184/SC 4/WG 3 N123", the glued N the cluster already uses
981
+ # (spelling, not identity; the re-parse binds the identical map).
883
982
  render default {
884
- field publisher
885
- literal "-"
886
- field number_with_part
983
+ cond nsb_stage {
984
+ field nsb_stage
985
+ cond nsb_stage_slash {
986
+ field nsb_stage_slash
987
+ }
988
+ }
989
+ cond type_with_stage_fr {
990
+ field type_with_stage_fr
991
+ literal " "
992
+ }
993
+ cond iso_r_prefix {
994
+ field iso_r_prefix
995
+ }
996
+ cond publisher {
997
+ field publisher
998
+ }
999
+ # #118: the tc_document face — the join renders as captured, the type
1000
+ # space-joined per the rule's own `tc_type space`. Neither face is
1001
+ # bound by any other spine, so the segments are inert everywhere else.
1002
+ cond tc_join {
1003
+ field tc_join
1004
+ }
1005
+ cond tc_type {
1006
+ field tc_type
1007
+ literal " "
1008
+ }
1009
+ cond copublishers {
1010
+ field copublishers
1011
+ }
1012
+ cond subgroup {
1013
+ literal " "
1014
+ field subgroup
1015
+ }
1016
+ cond tc_number {
1017
+ field tc_number
1018
+ # #118: the subcommittee tail is OPTIONAL on the publisher-bearing
1019
+ # tc_document face (the bare face always carries it), so the slash
1020
+ # rides on the SC's presence — "ISO/TC 184 N 100" renders without a
1021
+ # dangling "/".
1022
+ cond sc_type {
1023
+ literal "/"
1024
+ field sc_type
1025
+ literal " "
1026
+ field sc_number
1027
+ cond wg_type {
1028
+ literal "/"
1029
+ field wg_type
1030
+ literal " "
1031
+ field wg_number
1032
+ }
1033
+ }
1034
+ literal " N"
1035
+ field number
1036
+ cond year {
1037
+ literal ":"
1038
+ field year
1039
+ }
1040
+ }
1041
+ cond ballot_type_with_stage {
1042
+ literal "/"
1043
+ field ballot_type_with_stage
1044
+ cond ballot_number {
1045
+ literal " "
1046
+ field ballot_number
1047
+ }
1048
+ }
1049
+ cond type_with_stage {
1050
+ literal " "
1051
+ field type_with_stage
1052
+ }
1053
+ cond number_with_part {
1054
+ literal " "
1055
+ field number_with_part
1056
+ }
1057
+ cond stage_iteration {
1058
+ literal "."
1059
+ field stage_iteration
1060
+ }
887
1061
  cond date {
888
1062
  literal ":"
889
1063
  field date
890
1064
  }
1065
+ cond undated_marker {
1066
+ literal ":"
1067
+ field undated_marker
1068
+ }
1069
+ cond base_edition {
1070
+ literal " "
1071
+ field base_edition
1072
+ }
1073
+ cond ballot_stamp_number {
1074
+ literal "/Amd "
1075
+ field ballot_stamp_number
1076
+ cond ballot_stamp_date {
1077
+ literal ":"
1078
+ field ballot_stamp_date
1079
+ }
1080
+ cond ballot_stamp_undated_marker {
1081
+ literal ":"
1082
+ field ballot_stamp_undated_marker
1083
+ }
1084
+ }
1085
+ cond ballot_stamp_dot_number {
1086
+ literal "/Amd."
1087
+ field ballot_stamp_dot_number
1088
+ }
1089
+ cond supp_type_with_stage {
1090
+ literal "/"
1091
+ field supp_type_with_stage
1092
+ cond supp_number_with_part {
1093
+ literal " "
1094
+ field supp_number_with_part
1095
+ }
1096
+ cond supp_stage_iteration {
1097
+ literal "."
1098
+ field supp_stage_iteration
1099
+ }
1100
+ cond supp_number {
1101
+ literal "."
1102
+ field supp_number
1103
+ }
1104
+ cond supp_date {
1105
+ literal ":"
1106
+ field supp_date
1107
+ }
1108
+ cond supp_undated_marker {
1109
+ literal ":"
1110
+ field supp_undated_marker
1111
+ }
1112
+ }
1113
+ cond supp2_type_with_stage {
1114
+ literal "/"
1115
+ field supp2_type_with_stage
1116
+ cond supp2_number_with_part {
1117
+ literal " "
1118
+ field supp2_number_with_part
1119
+ }
1120
+ cond supp2_stage_iteration {
1121
+ literal "."
1122
+ field supp2_stage_iteration
1123
+ }
1124
+ cond supp2_number {
1125
+ literal "."
1126
+ field supp2_number
1127
+ }
1128
+ cond supp2_date {
1129
+ literal ":"
1130
+ field supp2_date
1131
+ }
1132
+ cond supp2_undated_marker {
1133
+ literal ":"
1134
+ field supp2_undated_marker
1135
+ }
1136
+ }
1137
+ cond supp3_type_with_stage {
1138
+ literal "/"
1139
+ field supp3_type_with_stage
1140
+ cond supp3_number_with_part {
1141
+ literal " "
1142
+ field supp3_number_with_part
1143
+ }
1144
+ cond supp3_stage_iteration {
1145
+ literal "."
1146
+ field supp3_stage_iteration
1147
+ }
1148
+ cond supp3_number {
1149
+ literal "."
1150
+ field supp3_number
1151
+ }
1152
+ cond supp3_date {
1153
+ literal ":"
1154
+ field supp3_date
1155
+ }
1156
+ cond supp3_undated_marker {
1157
+ literal ":"
1158
+ field supp3_undated_marker
1159
+ }
1160
+ }
1161
+ cond isor_supp_type_with_stage {
1162
+ literal "/"
1163
+ field isor_supp_type_with_stage
1164
+ cond isor_supp_number_with_part {
1165
+ literal " "
1166
+ field isor_supp_number_with_part
1167
+ }
1168
+ cond isor_supp_stage_iteration {
1169
+ literal "."
1170
+ field isor_supp_stage_iteration
1171
+ }
1172
+ cond isor_supp_date {
1173
+ literal ":"
1174
+ field isor_supp_date
1175
+ }
1176
+ cond isor_supp_undated_marker {
1177
+ literal ":"
1178
+ field isor_supp_undated_marker
1179
+ }
1180
+ }
1181
+ cond idf_publisher {
1182
+ literal " | "
1183
+ field idf_publisher
1184
+ cond idf_type_with_stage {
1185
+ literal "/"
1186
+ field idf_type_with_stage
1187
+ }
1188
+ cond idf_stage_iteration {
1189
+ literal "."
1190
+ field idf_stage_iteration
1191
+ }
1192
+ cond idf_number_with_part {
1193
+ literal " "
1194
+ field idf_number_with_part
1195
+ }
1196
+ cond idf_date {
1197
+ literal ":"
1198
+ field idf_date
1199
+ }
1200
+ cond idf_languages {
1201
+ literal "("
1202
+ field idf_languages
1203
+ literal ")"
1204
+ }
1205
+ cond idf_all_parts {
1206
+ literal " "
1207
+ field idf_all_parts
1208
+ }
1209
+ }
1210
+ cond edition {
1211
+ literal " "
1212
+ field edition
1213
+ }
1214
+ cond languages {
1215
+ literal "("
1216
+ field languages
1217
+ literal ")"
1218
+ }
1219
+ cond all_parts {
1220
+ literal " "
1221
+ field all_parts
1222
+ }
1223
+ cond dsupp_publisher {
1224
+ literal " "
1225
+ field dsupp_publisher
1226
+ literal " "
1227
+ field dsupp_type_with_stage
1228
+ cond dsupp_date {
1229
+ literal ":"
1230
+ field dsupp_date
1231
+ }
1232
+ cond dsupp_undated_marker {
1233
+ literal ":"
1234
+ field dsupp_undated_marker
1235
+ }
1236
+ cond dsupp_edition {
1237
+ literal " "
1238
+ field dsupp_edition
1239
+ }
1240
+ cond dsupp_languages {
1241
+ literal "("
1242
+ field dsupp_languages
1243
+ literal ")"
1244
+ }
1245
+ cond dsupp_all_parts {
1246
+ literal " "
1247
+ field dsupp_all_parts
1248
+ }
1249
+ }
1250
+ cond bs1_publisher {
1251
+ literal " + "
1252
+ field bs1_publisher
1253
+ literal " "
1254
+ field bs1_type_with_stage
1255
+ cond bs1_date {
1256
+ literal ":"
1257
+ field bs1_date
1258
+ }
1259
+ cond bs1_undated_marker {
1260
+ literal ":"
1261
+ field bs1_undated_marker
1262
+ }
1263
+ }
1264
+ cond bs2_publisher {
1265
+ literal " + "
1266
+ field bs2_publisher
1267
+ literal " "
1268
+ field bs2_type_with_stage
1269
+ cond bs2_date {
1270
+ literal ":"
1271
+ field bs2_date
1272
+ }
1273
+ cond bs2_undated_marker {
1274
+ literal ":"
1275
+ field bs2_undated_marker
1276
+ }
1277
+ }
1278
+ cond bs3_publisher {
1279
+ literal " + "
1280
+ field bs3_publisher
1281
+ literal " "
1282
+ field bs3_type_with_stage
1283
+ cond bs3_date {
1284
+ literal ":"
1285
+ field bs3_date
1286
+ }
1287
+ cond bs3_undated_marker {
1288
+ literal ":"
1289
+ field bs3_undated_marker
1290
+ }
1291
+ }
891
1292
  }
@@ -17,6 +17,13 @@ module Pubid
17
17
  # chains — "BS EN ISO 105-B06:2020" is this wrapper over a CEN
18
18
  # adoption over the ISO document); anything else is the adopted
19
19
  # international standard (BS ISO …, BS IEC …);
20
+ # * the adopted document lands on the builder's declared
21
+ # ADOPTED_ATTRIBUTE — the uniform `base` (the codec's root-first
22
+ # walk, the from_hash key and the MR join read it);
23
+ # * the wrapper's own glued edition face (the declared
24
+ # ADOPTED_EDITION_FACE, "BS HD IEC 60364-8-81 ED1") lifts out of
25
+ # the run BEFORE the delegation — the owning flavor drops it, the
26
+ # wrapper column carries it (the coded builder's own extraction);
20
27
  # * a run no flavor owns, or a run the owning flavor rejects, is a
21
28
  # REJECTION (Pubid::Errors::ParseError) — never a silently empty
22
29
  # wrapper (the parse-failure contract's nil/raise rule).
@@ -29,20 +36,12 @@ module Pubid
29
36
  # The adoption identifier the captured run builds. Raises when the
30
37
  # run names no known flavor or the owning flavor rejects it.
31
38
  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
39
+ adopted_str = captured_run(builder, data)
40
+ run, edition = extract_edition(builder, adopted_str)
41
+ adopted_id = parse_adopted(run)
44
42
 
45
- wrapper_class(adopted_id).new(**attrs)
43
+ wrapper_class(adopted_id).new(**wrapper_attrs(builder, data,
44
+ adopted_id, edition))
46
45
  end
47
46
 
48
47
  # The implicit probe: BSI carries none — the coded builder's
@@ -55,6 +54,60 @@ module Pubid
55
54
 
56
55
  private
57
56
 
57
+ # The captured run, stripped — or the rejection (the parse-failure
58
+ # contract's nil/raise rule: an adopted run that captured no
59
+ # document never builds a silently empty wrapper).
60
+ def captured_run(builder, data)
61
+ adopted_str = builder.unwrap(data[:adopted])&.to_s&.strip
62
+ if adopted_str.nil? || adopted_str.empty?
63
+ raise ::Pubid::Errors::ParseError,
64
+ "an adopted run captured no document (#{builder.flavor_name})"
65
+ end
66
+
67
+ adopted_str
68
+ end
69
+
70
+ # The wrapper's attributes: the adopted document under the
71
+ # builder's declared model column, the captured head token as the
72
+ # publisher, and the lifted edition face when the run carried one.
73
+ def wrapper_attrs(builder, data, adopted_id, edition)
74
+ attrs = { adopted_attribute(builder) => adopted_id }
75
+ publisher = builder.unwrap(data[:publisher])&.to_s
76
+ if publisher
77
+ attrs[:publisher] =
78
+ ::Pubid::Components::Publisher.new(body: publisher)
79
+ end
80
+ attrs[:edition] = edition if edition
81
+ attrs
82
+ end
83
+
84
+ # The wrapper's model column for the adopted document, from the
85
+ # generated builder's declaration (the capture name when it
86
+ # declares none — the legacy slot).
87
+ def adopted_attribute(builder)
88
+ if builder.class.const_defined?(:ADOPTED_ATTRIBUTE)
89
+ builder.class::ADOPTED_ATTRIBUTE.to_sym
90
+ else
91
+ :adopted
92
+ end
93
+ end
94
+
95
+ # The declared glued edition face, lifted from the run's tail
96
+ # ("BS HD IEC 60364-8-81 ED1" — the ordinal glues to the face,
97
+ # there is no edition_space). Returns the cleaned run and the
98
+ # ordinal; a run with no face passes through untouched.
99
+ def extract_edition(builder, adopted_str)
100
+ unless builder.class.const_defined?(:ADOPTED_EDITION_FACE)
101
+ return [adopted_str, nil]
102
+ end
103
+
104
+ face = builder.class::ADOPTED_EDITION_FACE
105
+ match = adopted_str.match(/\s+#{face}(\d+)\s*\z/)
106
+ return [adopted_str, nil] unless match
107
+
108
+ [adopted_str.sub(/\s+#{face}#{match[1]}\s*\z/, ""), match[1]]
109
+ end
110
+
58
111
  # The wrapper class by what the owning flavor came back with: a
59
112
  # CEN identifier (including a CEN adoption of an ISO/IEC document)
60
113
  # is the adopted European norm; an ISO/IEC identifier is the
@@ -77,7 +130,7 @@ module Pubid
77
130
  klass = dispatch(lead)
78
131
  if klass.nil?
79
132
  raise ::Pubid::Errors::ParseError,
80
- "no owning flavor parses the adopted run #{adopted_str.inspect}"
133
+ "no owning flavor parses the run #{adopted_str.inspect}"
81
134
  end
82
135
 
83
136
  klass.parse(adopted_str)
@@ -23,6 +23,23 @@ module Pubid
23
23
 
24
24
  }.freeze
25
25
 
26
+ # The designation trios (the typed trio's declaration): the
27
+ # token that selected the class is the designation face, not
28
+ # a publisher — the column keeps the class default and the
29
+ # identifier carries the stage entry's type/stage/typed_stage
30
+ # (the coded builder's cast).
31
+ DESIGNATION_STAGES = {
32
+ "PAS" => { code: "pubpas", stage_code: "published", type_code: "pas", abbr: ["PAS"], name: "Publicly Available Specification", harmonized_stages: ["60.00", "60.60"] },
33
+ "PD" => { code: "pubpd", stage_code: "published", type_code: "pd", abbr: ["PD"], name: "Published Document", harmonized_stages: ["60.00", "60.60"] },
34
+ "DD" => { code: "pubdd", stage_code: "published", type_code: "dd", abbr: ["DD"], name: "Draft Document", harmonized_stages: ["60.00", "60.60"] },
35
+ "TS" => { code: "pubts", stage_code: "published", type_code: "ts", abbr: ["TS"], name: "Technical Specification", harmonized_stages: ["60.00", "60.60"] },
36
+ }.freeze
37
+
38
+ # The model column the adopted document lands on (the vendored
39
+ # hook's wrapper slot) and the declared edition face, if any.
40
+ ADOPTED_ATTRIBUTE = "base"
41
+ ADOPTED_EDITION_FACE = "ED"
42
+
26
43
  def self.build(parsed_data)
27
44
  new.build(parsed_data)
28
45
  end
@@ -78,7 +95,9 @@ module Pubid
78
95
  identifier.number = data[:number]&.to_s
79
96
  identifier.part = data[:part]&.to_s
80
97
  identifier.version = present_string(data[:version])
81
- if data[:publisher]
98
+ # A designation token selects the class but is not a publisher:
99
+ # the column keeps the class default (the organization's).
100
+ if data[:publisher] && !DESIGNATION_STAGES.key?(data[:publisher].to_s)
82
101
  identifier.publisher = ::Pubid::Components::Publisher.new(body: data[:publisher].to_s)
83
102
  end
84
103
  copubs = Array(data[:copublishers]).map do |row|
@@ -88,6 +107,19 @@ module Pubid
88
107
  identifier.copublishers = copubs unless copubs.empty?
89
108
  type_token = data[:guide] || data[:type]
90
109
  identifier.type = ::Pubid::Components::Type.new(abbr: type_token.to_s) if type_token
110
+ # The typed trio (the designation's stage entry): type, stage
111
+ # and typed_stage carry the registry row — the wire keys the
112
+ # coded flavor serializes.
113
+ if (row = DESIGNATION_STAGES[data[:publisher].to_s])
114
+ typed_stage = ::Pubid::Components::TypedStage.new(
115
+ code: row[:code], stage_code: row[:stage_code],
116
+ type_code: row[:type_code], abbr: row[:abbr],
117
+ name: row[:name], harmonized_stages: row[:harmonized_stages],
118
+ )
119
+ identifier.typed_stage = typed_stage
120
+ identifier.type = typed_stage.to_type
121
+ identifier.stage = typed_stage.to_stage
122
+ end
91
123
  captured = data[:stage]
92
124
  return unless captured
93
125
 
@@ -131,7 +163,10 @@ module Pubid
131
163
  inner
132
164
  end
133
165
  if items.any? { |item| item[:supplements_plus] || item["supplements_plus"] }
134
- members = items.map { |item| supplement_from(item) }
166
+ # The declared marker-less bundle (the coded-BSI shape): each
167
+ # member amends THE bundle's base document, so the members
168
+ # carry it (the coded builder's wrap_with_consolidated).
169
+ members = items.map { |item| supplement_from(item, base: base) }
135
170
  Identifiers::ConsolidatedIdentifier.new(identifiers: [base] + members)
136
171
  else
137
172
  supplement_from(items.first, base: base)
@@ -27,16 +27,11 @@ module Pubid
27
27
  end
28
28
  end
29
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
-
30
+ # The publisher and copublishers keep the lutaml
31
+ # component shapes ({"body" => "DD"} — the coded
32
+ # flavor's own wire form): the definition's
33
+ # serialization declaration declines the flat-scalar
34
+ # table.
40
35
  # The declared draft stages: the serialized code is the key,
41
36
  # the official-URN code the declared `urn:` value.
42
37
  STAGE_CODES = {
@@ -46,9 +41,13 @@ module Pubid
46
41
  # A draft stage serializes as its typed-stage code
47
42
  # ("stage" => "pren"); #inflate_scalar_components rebuilds
48
43
  # the three components from it (the coded compact-hash shape).
44
+ # A PUBLISHED trio stays nested: the coded flavors that
45
+ # carry one (the designations) serialize type/stage/
46
+ # typed_stage in full — only a draft stage compacts.
49
47
  def self.compact_hash(model, hash)
50
48
  stage = model.typed_stage
51
49
  return unless stage && hash.key?("typed_stage")
50
+ return if stage.stage_code.to_s == "published"
52
51
  return unless model.type == stage.to_type &&
53
52
  model.stage == stage.to_stage
54
53