pubid 2.0.0.pre.alpha.59 → 2.0.0.pre.alpha.61

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f64146bcb3c4024625550d2628fd26b41532d75e47152bc4b75aae5cc106fd2b
4
- data.tar.gz: ecb7b76f593f90bfab3a4aa62b1fcbb16bbfa801d3063349269bab807e0e2a62
3
+ metadata.gz: c5afd984209314db5f3b13fa48ef4d24e3f90ffb08802b9362fa8e52b66f35af
4
+ data.tar.gz: 1fe21dc3bebe7cba7606d7b7df25ea2f2c0277b111193e6e260b2ceb922d3a30
5
5
  SHA512:
6
- metadata.gz: 5ef3dd986568cc780c61bfad05a4c57c9116ea0dfd946e914e92e8a0c3c59fc0ff8bb505bb500e072743dce6183603390528c17bfd6c3dd709aede61a5d78817
7
- data.tar.gz: 27cad2287fa638e2ff8b670a9c674d3a6225c8ca2344c4ad34e68dc32f3361c64591fc07cfebf367863e4e24e6e2fc0f4e076aa3a6cf8b1b752f54e7e7a0f86f
6
+ metadata.gz: 5d3f796d89995bdc9c994fffb5ac713b317c65e1b6ff46c102b4b72ce2ce7078e08ca3ee5471e00c6403b2d18a815df838b420fa124e4229dbe86daee42e9074
7
+ data.tar.gz: 5ed1785a22c19d5ffe47ca3733380d8e5bdfb37d66d57c0535866b71f4050a5a95c090ac35cc76403eab5aba4cab67568963f8643a4b414141a46d5160539d22
@@ -1987,11 +1987,16 @@ module Pubid
1987
1987
  end
1988
1988
  end
1989
1989
 
1990
- # The PARG capture carries its separator (".12", the #471
1991
- # convention); Draft#to_s prints the dot itself, so keep only
1992
- # the digits or "D2022.10.12" renders "D2022.10..12" (pubid#477).
1993
- if draft_data[:revision]
1994
- revision = extract_value(draft_data[:revision])&.delete_prefix(".")
1990
+ # The dotted ordinal stays part of the designator (the #601
1991
+ # convergence): the grammar splits it only on the joint
1992
+ # designation route, so a split field would make the parse and
1993
+ # from_hash paths build different Draft objects on
1994
+ # wire-identical rows ("DP62271-111_D6.1"). #to_s renders
1995
+ # version + revision identically, so the whole tail rides the
1996
+ # version on every route.
1997
+ if draft_data[:revision] && version
1998
+ tail = extract_value(draft_data[:revision])&.delete_prefix(".")
1999
+ version = "#{version}.#{tail}"
1995
2000
  end
1996
2001
 
1997
2002
  # The compound both-systems form (docs/IEEE-DRAFT-STAGES.md
@@ -8,13 +8,13 @@ module Pubid
8
8
  # IEEE draft version
9
9
  # Handles formats like:
10
10
  # /D5 - version only
11
- # /D3.4 - version with revision
11
+ # /D3.4 - dotted designator (the tail rides the version)
12
12
  # /D7, July 2019 - with date
13
13
  class Draft < Lutaml::Model::Serializable
14
14
  include ::Pubid::SubsetMatch
15
15
 
16
- attribute :version, :string # D5, D3, etc.
17
- attribute :revision, :string # .4, .2 in D3.4
16
+ attribute :version, :string # D5, D3.4, etc.
17
+ attribute :revision, :string # unused on construction paths (#601)
18
18
  attribute :year, :string
19
19
  attribute :month, :string
20
20
  attribute :day, :string
@@ -94,8 +94,10 @@ day: nil, iso_stage: nil, iso_iteration: nil)
94
94
  # The compound stage suffix (docs/IEEE-DRAFT-STAGES.md §1.3):
95
95
  # "=DIS.3" is canonical — D (draft) = DIS (the stage), iteration 3.
96
96
  # "=DDIS.3", "=DDIS3", "=DDIS-3" (the stage echoed with its own D)
97
- # are accepted aliases. Captures [stage, iteration].
98
- COMPOUND_SUFFIX = /=D?(PWI|NP|WD|CDV|FDIS|DIS|CD)(?:[.-]?(\d+))?\z/.freeze
97
+ # are accepted aliases. Captures [stage, iteration]. The
98
+ # iteration is SHORT — a long digit run is a glued date
99
+ # ("=CDV-201507", the designator face), not an ordinal.
100
+ COMPOUND_SUFFIX = /=D?(PWI|NP|WD|CDV|FDIS|DIS|CD)(?:[.-]?(\d{1,2}))?\z/.freeze
99
101
  private_constant :COMPOUND_SUFFIX
100
102
 
101
103
  # The D-echo aliases ("DDIS3" = D + DIS + iteration 3) normalize
@@ -103,7 +105,7 @@ day: nil, iso_stage: nil, iso_iteration: nil)
103
105
  # ("CD1", "FCD", "CDV1") restores verbatim -- the compound split
104
106
  # would degrade the glued iterations and drop the stages the
105
107
  # alias list never knew, so from_hash(row) != parse(row).
106
- ECHO_SUFFIX = /\AD(=?(PWI|NP|WD|CDV|FDIS|DIS|CD|FCD))(?:[.-]?\d+)?\z/.freeze
108
+ ECHO_SUFFIX = /\AD(=?(PWI|NP|WD|CDV|FDIS|DIS|CD|FCD))(?:[.-]?\d{1,2})?\z/.freeze
107
109
  private_constant :ECHO_SUFFIX
108
110
 
109
111
  def self.parse(value)
@@ -131,9 +133,19 @@ day: nil, iso_stage: nil, iso_iteration: nil)
131
133
  draft
132
134
  end
133
135
 
136
+ # The stage tokens #to_s renders verbatim (no D prepend). The
137
+ # strip_prefix must refuse them symmetrically: a wire form like
138
+ # "DIS2-1504" opens with the stage's own D, and stripping it
139
+ # corrupts the version ("IS2-1504") while still rendering alike.
140
+ STAGE_VERBATIM = /\A(ED\d|FDIS|FCD|CDV|DIS|CD|WD|PWI|NP)/
141
+ private_constant :STAGE_VERBATIM
142
+
134
143
  # Remove the leading "/D" (or a bare leading "D"/"/") that #to_s emits,
135
- # leaving the version and any trailing date.
144
+ # leaving the version and any trailing date. A stage-token version
145
+ # keeps its whole spelling: #to_s renders it with no designator
146
+ # prepend, so the leading D is the stage's own letter.
136
147
  def self.strip_prefix(str)
148
+ return str if str.match?(STAGE_VERBATIM)
137
149
  return str[2..] if str.start_with?("/D")
138
150
  return str[1..] if str.start_with?("/")
139
151
  return str[1..] if str.start_with?("D") && str.length > 1
@@ -174,7 +186,7 @@ day: nil, iso_stage: nil, iso_iteration: nil)
174
186
  # as "FDIS_March") renders verbatim — prepending D
175
187
  # concatenates a hallucinated token ("DED4", "DFDIS") that no
176
188
  # face spells. Every other version keeps the D designator.
177
- result = version&.match?(/\A(ED\d|(FDIS|FCD|CDV|DIS|CD|WD|PWI|NP))/) ? "/#{version}" : "/D#{version}"
189
+ result = version&.match?(STAGE_VERBATIM) ? "/#{version}" : "/D#{version}"
178
190
  result += "=#{iso_stage}" if iso_stage
179
191
  result += ".#{iso_iteration}" if iso_stage && iso_iteration
180
192
  result += if revision.to_s.start_with?(".")
@@ -1349,6 +1349,26 @@ module Pubid
1349
1349
  Regexp.last_match(0)
1350
1350
  end
1351
1351
  end
1352
+ # The crawl glues the month onto the stage after the code's slash
1353
+ # ("IEEE/IEC/ISO P80005-1/FDIS_March 2012", and its canonical
1354
+ # comma form "… Draft P80005-1/FDIS_March, 2012"): the stage is
1355
+ # the ISO/IEC token and the month belongs to the date (the
1356
+ # 2026-10-25 ruling) — decode onto the D= designator face. Scoped
1357
+ # to a real month name glued to a stage token; stage iteration
1358
+ # ("_CDV/V3", "_CDV July 2015") has its own routes.
1359
+ cleaned = cleaned.gsub(
1360
+ %r{\A((?:IEEE|ISO|IEC)(?:/(?:IEEE|ISO|IEC))*\s+(?:Draft\s+)?P?[A-Z0-9][A-Z0-9.-]*/)(FDIS|FCD|CDV|DIS|CD|WD|PWI|NP)_([A-Za-z]+),?\s+(\d{4})\z}
1361
+ ) do
1362
+ month = ::Pubid::Ieee::Builder::REV_MONTH_NUMBERS[
1363
+ Regexp.last_match(3).capitalize
1364
+ ]
1365
+ if month
1366
+ "#{Regexp.last_match(1)}D=#{Regexp.last_match(2)}-" \
1367
+ "#{Regexp.last_match(4)}#{month}"
1368
+ else
1369
+ Regexp.last_match(0)
1370
+ end
1371
+ end
1352
1372
  # The lettered REV spellings glue to the number ("P1310Rev3",
1353
1373
  # "P1722Rev1") or carry an after-word separator ("REV.ma",
1354
1374
  # "REV-ma"); the rev rules read a space or a bare word
@@ -89,6 +89,8 @@ module Pubid
89
89
  end
90
90
 
91
91
  def to_s(**opts)
92
+ return super if opts[:format] && opts[:format] != :human
93
+
92
94
  context = build_rendering_context(nil, format: :human, **opts)
93
95
  Pubid::Renderers::GuideRenderer.new(self).render(context:,
94
96
  **opts.slice(:with_edition))
@@ -54,6 +54,8 @@ module Pubid
54
54
  end
55
55
 
56
56
  def to_s(**opts)
57
+ return super if opts[:format] && opts[:format] != :human
58
+
57
59
  context = build_rendering_context(nil, format: :human, **opts)
58
60
  Pubid::Renderers::SupplementRenderer.new(self).render(context:,
59
61
  **opts.slice(:with_edition))
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.59"
4
+ VERSION = "2.0.0.pre.alpha.61"
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.59
4
+ version: 2.0.0.pre.alpha.61
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.