pubid 2.0.0.pre.alpha.16 → 2.0.0.pre.alpha.17

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.
@@ -868,6 +868,19 @@ module Pubid
868
868
  attributes[:lead_party] = attributes[:publishers]&.first || "ISO"
869
869
  attributes[:iso_stage] = extract_value(parsed[:iso_stage])
870
870
 
871
+ # A digit-suffixed stage word ("CD4", "DIS2") from a stage-FIRST
872
+ # spelling prints bare in the ISO face (every
873
+ # iso_stage_spellings_spec expectation: the iteration is draft
874
+ # machinery, not identity). The embedded/stage-last form keeps
875
+ # its "CD3" whole — its trailing token IS the identity the
876
+ # embedded corpus keys on (embedded_iso_stage_spec) — and
877
+ # serialized rows keep theirs verbatim (#477).
878
+ # the marker is a zero-length capture: presence is the signal
879
+ embedded = !parsed[:stage_embedded].nil?
880
+ if !embedded && attributes[:iso_stage]&.match?(/\A[A-Z]+\d+\z/)
881
+ attributes[:iso_stage] = attributes[:iso_stage][/\A[A-Z]+/]
882
+ end
883
+
871
884
  # Create typed_stage for ISO stage
872
885
  stage_abbr = attributes[:iso_stage]
873
886
  if stage_abbr
@@ -143,7 +143,12 @@ day: nil, iso_stage: nil, iso_iteration: nil)
143
143
  result = "/D#{version}"
144
144
  result += "=#{iso_stage}" if iso_stage
145
145
  result += ".#{iso_iteration}" if iso_stage && iso_iteration
146
- result += ".#{revision}" if revision
146
+ result += if revision.to_s.start_with?(".")
147
+ # a captured revision may carry its separator dot
148
+ revision.to_s
149
+ else
150
+ ".#{revision}"
151
+ end if revision
147
152
 
148
153
  if year
149
154
  # Use original month format to preserve abbreviated vs full names
@@ -79,10 +79,20 @@ module Pubid
79
79
  # Canonical format based on lead party
80
80
  # @return [Symbol] :ieee or :iso
81
81
  def canonical_format
82
- # A stage-tracked D= designator is IEEE draft notation — its
83
- # canonical face is the designator spelling (§1.3 spelling 7:
84
- # "JOINT PNUMBER/D=<STAGE>[:year]"), whatever the lead party.
85
- return :ieee if ieee_draft.to_s.start_with?("D=")
82
+ # A PARSED stage-tracked D= designator is IEEE draft notation —
83
+ # its canonical face is the designator spelling (§1.3 spelling 7:
84
+ # "JOINT PNUMBER/D=<STAGE>[:year]"). Rows that carry an ISO stage
85
+ # word (from_hash, or stage-led parses) keep the stage-word face
86
+ # no matter what the render derives: their published spelling is
87
+ # "IEEE FCD 15026.3:2010", not a designator (#477).
88
+ if ieee_draft.to_s.start_with?("D=") && iso_stage.to_s.empty?
89
+ return :ieee
90
+ end
91
+ # A stage-word row (parsed stage-led spelling, or a serialized
92
+ # row carrying iso_stage) prints the stage-word face whatever
93
+ # the lead party — the stage word is the printed identity
94
+ # ("IEEE FCD 15026.3:2010", #477).
95
+ return :iso unless iso_stage.to_s.empty?
86
96
 
87
97
  case lead_party
88
98
  when "IEEE", "AIEE"
@@ -143,12 +153,17 @@ module Pubid
143
153
  # onto the word only for the stages whose printed ISO spellings
144
154
  # carry it (CD2, DIS2 — the grammar's multi-digit families);
145
155
  # the P project stage is IEEE convention and never prints here.
146
- # The printed word is always the bare stage ("CD4" prints "CD",
147
- # "DIS3" prints "DIS" — every iso_stage_spellings_spec
148
- # expectation); the iteration is draft machinery, not ISO-face
149
- # identity.
150
- stage_word = iso_stage.to_s.sub(/\A([A-Z]+?)\d+\z/, '\1')
151
- stage_word = nil if stage_word.empty?
156
+ # The stage word prints verbatim: parsed digit-suffixed
157
+ # spellings ("CD4") are normalized to the bare word with the
158
+ # iteration carried separately at build time, while serialized
159
+ # rows keep the full "DIS2" — both must round-trip (#477).
160
+ stage_word = iso_stage
161
+ stage_word = nil if stage_word.to_s.empty?
162
+ # A serialized row's stage iteration is identity: re-attach it
163
+ # to the printed word ("DIS2 24748.4:2015", #477). The parse
164
+ # path never sets stage_iteration for digit-suffixed spellings.
165
+ iter = stage_iteration.respond_to?(:number) ? stage_iteration.number : stage_iteration
166
+ stage_word = "#{stage_word}#{iter}" if stage_word && iter.to_s.match?(/\A\d+\z/)
152
167
  draft_year = nil
153
168
  if stage_word.nil? &&
154
169
  ieee_draft.to_s.match(/\AD=([A-Z]+)(?:\.(\d+[a-z]?))?(?:[-:](\d{4}))?\z/)
@@ -174,6 +189,11 @@ module Pubid
174
189
  result += " (#{parenthetical_content})"
175
190
  end
176
191
 
192
+ # The revision narrative prints after the code: published joint
193
+ # rows carry it as identity spelling ("…:2012(E) Revision of
194
+ # IEEE Std C37.082-1982", #477).
195
+ result += " #{relationships.map(&:to_s).join(' ')}" if relationships && !relationships.empty?
196
+
177
197
  result
178
198
  end
179
199
 
@@ -210,11 +230,9 @@ module Pubid
210
230
  elsif ieee_draft
211
231
  code_str += "/#{ieee_draft}"
212
232
  elsif iso_stage
213
- # The ordinal-less stage draft: an iteration glued onto the
214
- # printed word ("CD2") renders in the doctrine's ".iter" slot
215
- # ("D=CD.2" — docs/IEEE-DRAFT-STAGES.md §1.3).
216
- stage = iso_stage.match(/\A([A-Z]+?)(\d+)\z/)
217
- code_str += stage ? "/D=#{stage[1]}.#{stage[2]}" : "/D=#{iso_stage}"
233
+ # A stage word never converts to a designator on the IEEE
234
+ # face: published stage rows print the stage-word face
235
+ # ("IEEE FCD 15026.3:2010", #477).
218
236
  elsif typed_stage&.ieee_draft_equivalent
219
237
  code_str += "/#{typed_stage.ieee_draft_equivalent}"
220
238
  end
data/lib/pubid/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pubid
4
- VERSION = "2.0.0.pre.alpha.16"
4
+ VERSION = "2.0.0.pre.alpha.17"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.alpha.16
4
+ version: 2.0.0.pre.alpha.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.