pubid 2.0.42 → 2.0.44

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/data/parg/arxiv.json +1 -0
  3. data/data/parg/bsi_pfs.json +1 -1
  4. data/data/parg/eu.json +1 -0
  5. data/lib/pubid/arxiv/CLAUDE.md +58 -0
  6. data/lib/pubid/arxiv/builder.rb +100 -0
  7. data/lib/pubid/arxiv/identifier.rb +111 -0
  8. data/lib/pubid/arxiv/identifiers/eprint.rb +20 -0
  9. data/lib/pubid/arxiv/identifiers.rb +9 -0
  10. data/lib/pubid/arxiv/parser.rb +18 -0
  11. data/lib/pubid/arxiv/pubid_urn_schema.rb +26 -0
  12. data/lib/pubid/arxiv/renderer.rb +30 -0
  13. data/lib/pubid/arxiv.rb +55 -0
  14. data/lib/pubid/bsi_pfs/adopted_base.rb +67 -14
  15. data/lib/pubid/bsi_pfs/builder.rb +37 -2
  16. data/lib/pubid/bsi_pfs/identifier.rb +9 -10
  17. data/lib/pubid/bsi_pfs/identifiers/adopted_european_norm.rb +21 -11
  18. data/lib/pubid/bsi_pfs/identifiers/adopted_international_standard.rb +21 -11
  19. data/lib/pubid/bsi_pfs/identifiers/consolidated_identifier.rb +25 -9
  20. data/lib/pubid/bsi_pfs/identifiers/draft_document.rb +6 -6
  21. data/lib/pubid/bsi_pfs/identifiers/publicly_available_specification.rb +6 -6
  22. data/lib/pubid/bsi_pfs/identifiers/published_document.rb +6 -6
  23. data/lib/pubid/bsi_pfs/identifiers/technical_specification.rb +6 -6
  24. data/lib/pubid/bsi_pfs/pubid_urn_schema.rb +17 -4
  25. data/lib/pubid/bsi_pfs/renderer.rb +18 -2
  26. data/lib/pubid/bsi_pfs/urn_generator.rb +31 -6
  27. data/lib/pubid/eu/CLAUDE.md +92 -0
  28. data/lib/pubid/eu/builder.rb +129 -0
  29. data/lib/pubid/eu/identifier.rb +117 -0
  30. data/lib/pubid/eu/identifiers/decision.rb +14 -0
  31. data/lib/pubid/eu/identifiers/directive.rb +14 -0
  32. data/lib/pubid/eu/identifiers/regulation.rb +14 -0
  33. data/lib/pubid/eu/identifiers.rb +11 -0
  34. data/lib/pubid/eu/parser.rb +10 -0
  35. data/lib/pubid/eu/pubid_urn_schema.rb +23 -0
  36. data/lib/pubid/eu/renderer.rb +38 -0
  37. data/lib/pubid/eu.rb +52 -0
  38. data/lib/pubid/version.rb +1 -1
  39. data/lib/pubid.rb +2 -0
  40. metadata +23 -1
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pubid"
4
+ module Pubid
5
+ # arXiv flavor — e-print identifiers per
6
+ # https://info.arxiv.org/help/arxiv_identifier_for_services.html
7
+ #
8
+ # Parses the new form (`2301.00001v1`, `0704.0001`) and the old form
9
+ # (`hep-th/9901001`, `math.GT/0309136`), each with an optional
10
+ # case-insensitive `arXiv:` or `arXiv ` prefix. A missing version is a
11
+ # wildcard under `===`, so `arXiv:2301.00001` matches every version.
12
+ module Arxiv
13
+ extend Pubid::PrefixesSupport
14
+
15
+ PREFIXES = ["arXiv"].freeze
16
+
17
+ autoload :Builder, "#{__dir__}/arxiv/builder"
18
+ autoload :Identifier, "#{__dir__}/arxiv/identifier"
19
+ autoload :Identifiers, "#{__dir__}/arxiv/identifiers"
20
+ autoload :Parser, "#{__dir__}/arxiv/parser"
21
+ autoload :Renderer, "#{__dir__}/arxiv/renderer"
22
+ autoload :PubidUrnSchema, "#{__dir__}/arxiv/pubid_urn_schema"
23
+
24
+ def self.parse(identifier)
25
+ Identifier.parse(identifier)
26
+ end
27
+
28
+ Identifier.format_registry = FormatRegistry.new(parent: Identifier.format_registry)
29
+ Identifier.format_registry.register(:human, renderer: Arxiv::Renderer)
30
+
31
+ def self.identifier_types
32
+ @identifier_types ||= Identifiers.constants
33
+ .filter_map { |c| begin; Identifiers.const_get(c); rescue NameError; nil; end }
34
+ .select { |c| c.is_a?(Class) && c.singleton_methods(false).include?(:type) }
35
+ .select { |c| c.type.is_a?(Hash) }
36
+ end
37
+
38
+ def self.all_typed_stages
39
+ @all_typed_stages ||= identifier_types.flat_map do |klass|
40
+ klass.const_defined?(:TYPED_STAGES) ? klass.const_get(:TYPED_STAGES) : []
41
+ end
42
+ end
43
+
44
+ def self.locate_type(code)
45
+ identifier_types.find { |t| t.type[:key].to_s == code.to_s }
46
+ end
47
+
48
+ def self.locate_stage(abbr)
49
+ abbr_str = abbr.to_s.upcase
50
+ all_typed_stages.find { |s| s.abbr.any? { |a| a.to_s.upcase == abbr_str } }
51
+ end
52
+ end
53
+ end
54
+
55
+ Pubid::Registry.register(:arxiv, Pubid::Arxiv)
@@ -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
 
@@ -17,19 +17,16 @@ module Pubid
17
17
  end
18
18
 
19
19
  attribute :publisher, ::Pubid::Components::Publisher, default: -> { self.class.default_publisher }
20
- attribute :type, ::Pubid::Components::Type, default: -> { self.class.default_type }
21
-
22
- def self.default_type
23
- ::Pubid::Components::Type.new(abbr: type[:short])
24
- end
25
20
 
26
21
  # The adopted document (feature 4): the whole identity lives
27
- # on the nested ISO/IEC identifier.
28
- attribute :adopted, ::Pubid::Identifier, polymorphic: true
22
+ # on the nested ISO/IEC identifier, under the declared
23
+ # model column (the uniform `base` renames the wrapper
24
+ # slot — the codec's root-first walk and the from_hash
25
+ # key read it).
26
+ attribute :base, ::Pubid::Identifier, polymorphic: true
29
27
 
30
- def root
31
- adopted ? adopted.root : self
32
- end
28
+ # The column IS the uniform parent accessor: #root and
29
+ # #base_document are the shared machinery's, walking it.
33
30
 
34
31
  # MR "cen.iso.ts.21003-7": the publisher group fused, then the
35
32
  # adopted document's own MR string in place of a number.
@@ -38,10 +35,23 @@ module Pubid
38
35
  .map { |p| p.to_s.downcase })
39
36
  end
40
37
 
38
+ # The wrapper carries no identity of its own: the MR slug
39
+ # reads the ROOT document (the coded RootIdentity shape),
40
+ # so an adoption slugs bs.1073-2.2002, not the adopted
41
+ # document's own MR string.
41
42
  def mr_number_with_part
42
- adopted ? adopted.to_mr_string : super
43
+ root.equal?(self) ? super : root.mr_number_with_part
43
44
  end
44
45
 
46
+ def mr_year
47
+ root.equal?(self) ? super : root.mr_year
48
+ end
49
+
50
+ # The wrapper's own edition face (the declared glued ED
51
+ # form): the hook lifts the trailing face+ordinal out of
52
+ # the adopted run onto this column.
53
+ attribute :edition, :string
54
+
45
55
  # The scheme-canonical wire tag declared in the definition:
46
56
  # to_hash stays byte-identical with the scheme's coded
47
57
  # flavor, and this flavor's own from_hash routes the tag
@@ -17,19 +17,16 @@ module Pubid
17
17
  end
18
18
 
19
19
  attribute :publisher, ::Pubid::Components::Publisher, default: -> { self.class.default_publisher }
20
- attribute :type, ::Pubid::Components::Type, default: -> { self.class.default_type }
21
-
22
- def self.default_type
23
- ::Pubid::Components::Type.new(abbr: type[:short])
24
- end
25
20
 
26
21
  # The adopted document (feature 4): the whole identity lives
27
- # on the nested ISO/IEC identifier.
28
- attribute :adopted, ::Pubid::Identifier, polymorphic: true
22
+ # on the nested ISO/IEC identifier, under the declared
23
+ # model column (the uniform `base` renames the wrapper
24
+ # slot — the codec's root-first walk and the from_hash
25
+ # key read it).
26
+ attribute :base, ::Pubid::Identifier, polymorphic: true
29
27
 
30
- def root
31
- adopted ? adopted.root : self
32
- end
28
+ # The column IS the uniform parent accessor: #root and
29
+ # #base_document are the shared machinery's, walking it.
33
30
 
34
31
  # MR "cen.iso.ts.21003-7": the publisher group fused, then the
35
32
  # adopted document's own MR string in place of a number.
@@ -38,10 +35,23 @@ module Pubid
38
35
  .map { |p| p.to_s.downcase })
39
36
  end
40
37
 
38
+ # The wrapper carries no identity of its own: the MR slug
39
+ # reads the ROOT document (the coded RootIdentity shape),
40
+ # so an adoption slugs bs.1073-2.2002, not the adopted
41
+ # document's own MR string.
41
42
  def mr_number_with_part
42
- adopted ? adopted.to_mr_string : super
43
+ root.equal?(self) ? super : root.mr_number_with_part
43
44
  end
44
45
 
46
+ def mr_year
47
+ root.equal?(self) ? super : root.mr_year
48
+ end
49
+
50
+ # The wrapper's own edition face (the declared glued ED
51
+ # form): the hook lifts the trailing face+ordinal out of
52
+ # the adopted run onto this column.
53
+ attribute :edition, :string
54
+
45
55
  # The scheme-canonical wire tag declared in the definition:
46
56
  # to_hash stays byte-identical with the scheme's coded
47
57
  # flavor, and this flavor's own from_hash routes the tag
@@ -2,7 +2,8 @@ module Pubid
2
2
  module BsiPfs
3
3
  module Identifiers
4
4
  # The consolidated (plus-run) bundle: the base document is
5
- # the first member; the supplements carry no base.
5
+ # the first member; each member amends it, so the members
6
+ # carry it as their base (the coded builder's shape).
6
7
  class ConsolidatedIdentifier < ::Pubid::BsiPfs::Identifier
7
8
  attribute :identifiers, ::Pubid::BsiPfs::Identifier,
8
9
  polymorphic: true, collection: true
@@ -21,15 +22,30 @@ module Pubid
21
22
  identifiers&.first || self
22
23
  end
23
24
 
24
- # The base document, then each member's own supplement
25
- # suffix behind the plus marker — the coded shape.
26
- def to_mr_string
27
- base, *supplements = identifiers
28
- return "" unless base
25
+ # The declared marker-less bundle (the coded-BSI shape): the
26
+ # wrapper reads the base document's identity and drops the
27
+ # member suffixes — the delegated publisher (off the wrapper's
28
+ # own wire entry, the coded compact-hash rule), the typed trio
29
+ # the base document carries, and the root-through MR hooks.
30
+ def type
31
+ member = identifiers&.first
32
+ member.respond_to?(:typed_stage) && member.typed_stage ? member.type : nil
33
+ end
34
+
35
+ def publisher
36
+ identifiers&.first&.publisher
37
+ end
38
+
39
+ def self.compact_hash(_model, hash)
40
+ hash.delete("publisher")
41
+ end
42
+
43
+ def mr_number_with_part
44
+ root.equal?(self) ? super : root.mr_number_with_part
45
+ end
29
46
 
30
- ([base.to_mr_string] +
31
- supplements.map { |s| "plus-#{s.mr_supplement_suffix}" })
32
- .join(::Pubid::Renderers::MrString::SEPARATOR_SUPPLEMENT)
47
+ def mr_year
48
+ root.equal?(self) ? super : root.mr_year
33
49
  end
34
50
 
35
51
  def self.polymorphic_name
@@ -4,6 +4,11 @@ module Pubid
4
4
  # Concrete Draft Document identifier type (PFS type `draft_document`).
5
5
  class DraftDocument < Identifier
6
6
  TYPED_STAGES = [
7
+ ::Pubid::Components::TypedStage.new(
8
+ code: :pubdd, stage_code: :published,
9
+ type_code: :dd, abbr: ["DD"],
10
+ name: "Draft Document", harmonized_stages: ["60.00", "60.60"],
11
+ ),
7
12
  ].freeze
8
13
 
9
14
  def self.type
@@ -13,15 +18,10 @@ module Pubid
13
18
  # The publisher default (feature 5): the type's own token
14
19
  # when the type is its designation, else the scheme default.
15
20
  def self.default_publisher
16
- ::Pubid::Components::Publisher.new(body: "DD")
21
+ ::Pubid::Components::Publisher.new(body: "BS")
17
22
  end
18
23
 
19
24
  attribute :publisher, ::Pubid::Components::Publisher, default: -> { self.class.default_publisher }
20
- attribute :type, ::Pubid::Components::Type, default: -> { self.class.default_type }
21
-
22
- def self.default_type
23
- ::Pubid::Components::Type.new(abbr: type[:short])
24
- end
25
25
 
26
26
  # The scheme-canonical wire tag declared in the definition:
27
27
  # to_hash stays byte-identical with the scheme's coded
@@ -4,6 +4,11 @@ module Pubid
4
4
  # Concrete Publicly Available Specification identifier type (PFS type `publicly_available_specification`).
5
5
  class PubliclyAvailableSpecification < Identifier
6
6
  TYPED_STAGES = [
7
+ ::Pubid::Components::TypedStage.new(
8
+ code: :pubpas, stage_code: :published,
9
+ type_code: :pas, abbr: ["PAS"],
10
+ name: "Publicly Available Specification", harmonized_stages: ["60.00", "60.60"],
11
+ ),
7
12
  ].freeze
8
13
 
9
14
  def self.type
@@ -13,15 +18,10 @@ module Pubid
13
18
  # The publisher default (feature 5): the type's own token
14
19
  # when the type is its designation, else the scheme default.
15
20
  def self.default_publisher
16
- ::Pubid::Components::Publisher.new(body: "PAS")
21
+ ::Pubid::Components::Publisher.new(body: "BS")
17
22
  end
18
23
 
19
24
  attribute :publisher, ::Pubid::Components::Publisher, default: -> { self.class.default_publisher }
20
- attribute :type, ::Pubid::Components::Type, default: -> { self.class.default_type }
21
-
22
- def self.default_type
23
- ::Pubid::Components::Type.new(abbr: type[:short])
24
- end
25
25
 
26
26
  # The scheme-canonical wire tag declared in the definition:
27
27
  # to_hash stays byte-identical with the scheme's coded
@@ -4,6 +4,11 @@ module Pubid
4
4
  # Concrete Published Document identifier type (PFS type `published_document`).
5
5
  class PublishedDocument < Identifier
6
6
  TYPED_STAGES = [
7
+ ::Pubid::Components::TypedStage.new(
8
+ code: :pubpd, stage_code: :published,
9
+ type_code: :pd, abbr: ["PD"],
10
+ name: "Published Document", harmonized_stages: ["60.00", "60.60"],
11
+ ),
7
12
  ].freeze
8
13
 
9
14
  def self.type
@@ -13,15 +18,10 @@ module Pubid
13
18
  # The publisher default (feature 5): the type's own token
14
19
  # when the type is its designation, else the scheme default.
15
20
  def self.default_publisher
16
- ::Pubid::Components::Publisher.new(body: "PD")
21
+ ::Pubid::Components::Publisher.new(body: "BS")
17
22
  end
18
23
 
19
24
  attribute :publisher, ::Pubid::Components::Publisher, default: -> { self.class.default_publisher }
20
- attribute :type, ::Pubid::Components::Type, default: -> { self.class.default_type }
21
-
22
- def self.default_type
23
- ::Pubid::Components::Type.new(abbr: type[:short])
24
- end
25
25
 
26
26
  # The scheme-canonical wire tag declared in the definition:
27
27
  # to_hash stays byte-identical with the scheme's coded
@@ -4,6 +4,11 @@ module Pubid
4
4
  # Concrete Technical Specification identifier type (PFS type `technical_specification`).
5
5
  class TechnicalSpecification < Identifier
6
6
  TYPED_STAGES = [
7
+ ::Pubid::Components::TypedStage.new(
8
+ code: :pubts, stage_code: :published,
9
+ type_code: :ts, abbr: ["TS"],
10
+ name: "Technical Specification", harmonized_stages: ["60.00", "60.60"],
11
+ ),
7
12
  ].freeze
8
13
 
9
14
  def self.type
@@ -13,15 +18,10 @@ module Pubid
13
18
  # The publisher default (feature 5): the type's own token
14
19
  # when the type is its designation, else the scheme default.
15
20
  def self.default_publisher
16
- ::Pubid::Components::Publisher.new(body: "TS")
21
+ ::Pubid::Components::Publisher.new(body: "BS")
17
22
  end
18
23
 
19
24
  attribute :publisher, ::Pubid::Components::Publisher, default: -> { self.class.default_publisher }
20
- attribute :type, ::Pubid::Components::Type, default: -> { self.class.default_type }
21
-
22
- def self.default_type
23
- ::Pubid::Components::Type.new(abbr: type[:short])
24
- end
25
25
 
26
26
  # The scheme-canonical wire tag declared in the definition:
27
27
  # to_hash stays byte-identical with the scheme's coded
@@ -6,17 +6,30 @@
6
6
  # namespace; identifiers carry the scheme's wire tag, so their
7
7
  # pubid URNs encode through the scheme's own schema.
8
8
  PubidUrnSchema = Pubid::PubidUrn.define("bsi_pfs") do
9
- atom "publisher", "pub"
9
+ atom "publisher.body", "pubbody"
10
10
  atom "part", "part"
11
11
  atom "year", "year"
12
- atom "adopted", "adopted", kind: :id
12
+ atom "edition", "ed"
13
+ atom "type.abbr", "typeabbr"
14
+ atom "type.name", "typename"
15
+ atom "type.type_code", "typetypecode"
16
+ atom "stage.abbr", "stageabbr"
17
+ atom "stage.name", "stagename"
18
+ atom "stage.stage_code", "stagecode"
19
+ atom "stage.harmonized_stages", "stagehs", kind: :list
20
+ atom "typed_stage.abbr", "tsabbr", kind: :list
21
+ atom "typed_stage.name", "tsname"
22
+ atom "typed_stage.code", "tscode"
23
+ atom "typed_stage.stage_code", "tsstagecode"
24
+ atom "typed_stage.type_code", "tstypecode"
25
+ atom "typed_stage.harmonized_stages", "tshs", kind: :list
13
26
  atom "identifiers", "ids", kind: :ids
14
27
  type "pubid:bsi:adopted-european-norm", "aen", core: []
15
28
  type "pubid:bsi:adopted-international-standard", "ais", core: []
16
- type "pubid:bsi:amendment", "amd", core: []
29
+ type "pubid:bsi:amendment", "amd", core: ["number"]
17
30
  type "pubid:bsi:british-standard", "bs", core: ["number"]
18
31
  type "pubid:bsi:consolidated-identifier", "consol", core: []
19
- type "pubid:bsi:corrigendum", "cor", core: []
32
+ type "pubid:bsi:corrigendum", "cor", core: ["number"]
20
33
  type "pubid:bsi:draft-document", "dd", core: ["number"]
21
34
  type "pubid:bsi:published-document", "pd", core: ["number"]
22
35
  type "pubid:bsi:publicly-available-specification", "pas", core: ["number"]
@@ -2,6 +2,11 @@ module Pubid
2
2
  module BsiPfs
3
3
  # Human renderer, generated from the canonical template.
4
4
  class Renderer < ::Pubid::Renderers::Base
5
+ # The designation faces (the typed trio): the token that
6
+ # selected the class prints where the face names the
7
+ # publisher — the column keeps the organization default.
8
+ DESIGNATION_FACES = ["PAS", "PD", "DD", "TS"].freeze
9
+
5
10
  def render(**_opts)
6
11
  f = render_fields(@id)
7
12
  "#{if f[:publisher] && f[:adopted]; "#{f[:publisher]} #{f[:adopted]}" elsif f[:publisher] && f[:number]; "#{f[:publisher]} #{f[:number]}#{("-#{f[:part]}") if f[:part]}#{(":#{f[:year]}") if f[:year]}"; end}#{("#{f[:supplements]}") if f[:supplements]}"
@@ -9,6 +14,17 @@ module Pubid
9
14
 
10
15
  private
11
16
 
17
+ # The adoption face: the adopted document, with the
18
+ # wrapper's own edition face after it (the declared glued
19
+ # ED form — the hook lifts the ordinal onto the wrapper).
20
+ def view_adopted(root)
21
+ adopted = root.respond_to?(:base) ? root.base : nil
22
+ return nil unless adopted
23
+
24
+ edition = root.edition
25
+ edition ? "#{adopted} ED#{edition}" : adopted.to_s
26
+ end
27
+
12
28
  # The field view: a wrapper reads through to the wrapped
13
29
  # standard and composes the printed run once — the standalone
14
30
  # chain behind its slash, the consolidated members behind the
@@ -31,11 +47,11 @@ module Pubid
31
47
  run << "+#{member.supplement_notation}"
32
48
  end
33
49
  view = {
34
- publisher: root.publisher&.respond_to?(:body) ? root.publisher.body : root.publisher,
50
+ publisher: (t = root.type&.abbr) && DESIGNATION_FACES.include?(t) ? t : (root.publisher&.respond_to?(:body) ? root.publisher.body : root.publisher),
35
51
  number: root.number,
36
52
  part: root.part,
37
53
  year: root.date&.year,
38
- adopted: root.respond_to?(:adopted) ? root.adopted : nil,
54
+ adopted: view_adopted(root),
39
55
  }
40
56
  view[:supplements] = run.empty? ? nil : run
41
57
  view