pubid 2.0.0.pre.alpha.18 → 2.0.0.pre.alpha.20

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.
@@ -347,6 +347,37 @@ module Pubid
347
347
  end
348
348
 
349
349
  # Route to appropriate identifier class based on content
350
+ # The bare-IEEE fdraft clause (pubid#203): a slash-led stage word
351
+ # after the code ("IEEE P15026.2/FDIS, August 2010") captures the
352
+ # stage and its date; route them onto the identifier exactly like
353
+ # the joint stage-first spelling so the lossless stage-word face
354
+ # renders them instead of silently dropping them (the drop was the
355
+ # deferred residue noted in Parser.normalize_input).
356
+ if parsed[:fdraft].is_a?(Hash)
357
+ fd = parsed[:fdraft]
358
+ fd_stage = extract_value(fd[:fdraft_stage])
359
+ if fd_stage
360
+ # An IEEE identifier carrying an ISO stage renders the IEEE
361
+ # designator face with the IEEE date convention:
362
+ # "IEEE P15026.2/D=FDIS-201008" (pubid#203 ruling). The
363
+ # stage and date ride the designator; the ISO face is not
364
+ # elected.
365
+ year = extract_value(fd[:year])
366
+ month = extract_value(fd[:month])
367
+ date = ""
368
+ if year
369
+ date = "-#{year}"
370
+ date += format("%02d", Date.parse(month.to_s).month) if month
371
+ end
372
+ # The date rides inside the designator ("-201008"); a bare
373
+ # year attribute would print a second, colon-joined date on
374
+ # the code ("P15026.2:2010/D=…").
375
+ attributes[:publishers] ||= [attributes[:publisher] || "IEEE"].compact
376
+ attributes[:ieee_draft] = "D=#{fd_stage}#{date}"
377
+ attributes[:typed_stage] = Pubid::Ieee.locate_stage(fd_stage)
378
+ end
379
+ end
380
+
350
381
  identifier_class = determine_identifier_class(attributes)
351
382
  rename_supplement_keys(attributes)
352
383
  identifier_class.new(**attributes)
@@ -786,12 +817,11 @@ module Pubid
786
817
  iter = extract_value(parsed[:draft_iso_iteration]).to_s.sub(/\A\./, "")
787
818
  joint_draft += ".#{iter}" unless iter.empty?
788
819
  end
789
- # The date rides inside the designator colon-joined
790
- # ("D=CDV:2020" — the standing joint_stage_draft_spec contract;
791
- # the dash spelling the grammar newly accepts is an alias that
792
- # normalizes to the colon face).
820
+ # The designator date joins verbatim: the grammar captures the
821
+ # separator with the value (":2020", "-2017", "-201008" — the
822
+ # IEEE date convention for an ISO-staged draft, pubid#203).
793
823
  if parsed[:draft_stage_year]
794
- joint_draft += ":#{extract_value(parsed[:draft_stage_year])}"
824
+ joint_draft += extract_value(parsed[:draft_stage_year]).to_s
795
825
  end
796
826
  attributes[:ieee_draft] = joint_draft
797
827
  end
@@ -859,26 +889,80 @@ module Pubid
859
889
  return Identifiers::Standard.new(**printed_attrs.compact)
860
890
  end
861
891
 
892
+ # The re-parse of the pubid#203 designator render ("IEEE
893
+ # P15026.2/D=FDIS-201008") captures the stage and the verbatim
894
+ # date token (":2020", "-201008") with no publisher slot; the
895
+ # designator is the IEEE face, so IEEE is the sole publisher.
896
+ if parsed[:iso_stage] && parsed[:draft_stage_year]
897
+ stage_word = extract_value(parsed[:iso_stage])
898
+ attributes[:publishers] ||= ["IEEE"]
899
+ attributes[:publisher] ||= "IEEE"
900
+ attributes[:copublisher] ||= []
901
+ attributes[:ieee_draft] =
902
+ "D=#{stage_word}#{extract_value(parsed[:draft_stage_year])}"
903
+ attributes[:typed_stage] = Pubid::Ieee.locate_stage(stage_word)
904
+ attributes[:lead_party] = "IEEE"
905
+ attributes.delete(:year)
906
+ attributes.delete(:month)
907
+ end
908
+
862
909
  # Detect lead party based on pattern
863
910
  if parsed[:iso_stage]
864
- # ISO stage word present: the reference is printed in the ISO
865
- # position ("IEEE FCD 15026.3:2010"), so it parses as printed
866
- # (pubid#469) - lead ISO, ISO face, whatever the publisher
867
- # order. The printed first publisher is not the arrangement, and
868
- # the published relaton-data-ieee rows carry lead ISO (pubid#477).
869
- attributes[:lead_party] = "ISO"
870
- attributes[:iso_stage] = extract_value(parsed[:iso_stage])
871
-
872
- # Create typed_stage for ISO stage
873
- stage_abbr = attributes[:iso_stage]
874
- if stage_abbr
875
- attributes[:typed_stage] =
876
- Pubid::Ieee.locate_stage(stage_abbr)
911
+ stage_abbr = extract_value(parsed[:iso_stage])
912
+ bare_ieee_project = parsed[:project_marker] &&
913
+ attributes[:publisher] == "IEEE" &&
914
+ attributes[:copublisher] == []
915
+ if bare_ieee_project && parsed[:draft_stage_year].nil?
916
+ # pubid#203: a bare-IEEE project row carrying an ISO stage is
917
+ # an IEEE draft of joint ISO/IEC work ("IEEE FDIS P15026.2,
918
+ # August 2010"). The stage rides the IEEE designator with the
919
+ # IEEE date convention and the date rides inside the
920
+ # designator; the ISO stage-word face is not elected.
921
+ date = ""
922
+ if attributes[:year]
923
+ date = "-#{attributes[:year]}"
924
+ m = attributes[:month].to_s
925
+ unless m.empty?
926
+ month_num = m.match?(/\A\d+\z/) ? m.to_i : Date.parse(m).month
927
+ date += format("%02d", month_num)
928
+ end
929
+ end
930
+ attributes[:ieee_draft] = "D=#{stage_abbr}#{date}"
931
+ attributes[:typed_stage] = Pubid::Ieee.locate_stage(stage_abbr)
932
+ attributes[:lead_party] = "IEEE"
933
+ attributes.delete(:year)
934
+ attributes.delete(:month)
935
+ elsif !bare_ieee_project
936
+ # ISO stage word present: the reference is printed in the ISO
937
+ # position ("IEEE FCD 15026.3:2010"), so it parses as printed
938
+ # (pubid#469) - lead ISO, ISO face, whatever the publisher
939
+ # order. The printed first publisher is not the arrangement,
940
+ # and the published relaton-data-ieee rows carry lead ISO
941
+ # (pubid#477).
942
+ attributes[:lead_party] = "ISO"
943
+ attributes[:iso_stage] = stage_abbr
944
+
945
+ # Create typed_stage for ISO stage
946
+ if stage_abbr
947
+ attributes[:typed_stage] =
948
+ Pubid::Ieee.locate_stage(stage_abbr)
949
+ end
877
950
  end
951
+ # bare_ieee_project with a designator date token: the block
952
+ # above already composed the D= designator (lead IEEE).
878
953
  elsif parsed[:iso_published]
879
- # Stage-less PUBLISHED joint form (pubid#317): ISO-led spelling,
880
- # no project marker, no typed stage - renders as printed.
881
- attributes[:lead_party] = "ISO"
954
+ if parsed[:draft_iso_stage] && attributes[:publisher] == "IEEE" &&
955
+ attributes[:copublisher] == []
956
+ # The re-parse of the pubid#203 designator render ("IEEE
957
+ # P15026.2/D=FDIS-201008") lands here: bare IEEE publishers,
958
+ # the stage on the D= designator - lead IEEE, not ISO.
959
+ attributes[:lead_party] = "IEEE"
960
+ else
961
+ # Stage-less PUBLISHED joint form (pubid#317): ISO-led
962
+ # spelling, no project marker, no typed stage - renders as
963
+ # printed.
964
+ attributes[:lead_party] = "ISO"
965
+ end
882
966
  else
883
967
  # IEEE format - lead party is IEEE
884
968
  attributes[:lead_party] = "IEEE"
@@ -1012,6 +1096,15 @@ module Pubid
1012
1096
  return Ieee::Aiee::Identifier
1013
1097
  end
1014
1098
 
1099
+ # A stage-bearing row is a joint development whatever its type
1100
+ # code: the stage is the printed identity ("IEEE P15026.2/FDIS",
1101
+ # pubid#203) and only JointDevelopment carries iso_stage and the
1102
+ # D= designator.
1103
+ if attributes[:iso_stage] ||
1104
+ attributes[:ieee_draft].to_s.start_with?("D=")
1105
+ return Identifiers::JointDevelopment
1106
+ end
1107
+
1015
1108
  # Get type from attributes and use flavor module to locate class
1016
1109
  type_code = attributes[:type]
1017
1110
 
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.18"
4
+ VERSION = "2.0.0.pre.alpha.20"
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.18
4
+ version: 2.0.0.pre.alpha.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.3.57
47
+ version: 1.3.62
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 1.3.57
54
+ version: 1.3.62
55
55
  description: PubID is a Ruby library for parsing and generating international publication
56
56
  identifiers (PubIDs). It provides a simple and flexible API for working with PubIDs,
57
57
  allowing developers to easily create, manipulate, and validate PubIDs in their applications.