pubid 2.0.0.pre.alpha.3 → 2.0.0.pre.alpha.4

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 (151) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pubid/amca/identifier.rb +4 -23
  3. data/lib/pubid/amca/identifiers/base.rb +67 -30
  4. data/lib/pubid/amca/identifiers/interpretation.rb +0 -4
  5. data/lib/pubid/amca/identifiers/publication.rb +0 -4
  6. data/lib/pubid/amca/identifiers/standard.rb +0 -4
  7. data/lib/pubid/amca/renderer.rb +1 -1
  8. data/lib/pubid/amca/urn_generator.rb +2 -1
  9. data/lib/pubid/api/builder.rb +4 -0
  10. data/lib/pubid/api/identifier.rb +5 -1
  11. data/lib/pubid/api/identifiers/base.rb +2 -12
  12. data/lib/pubid/api/identifiers/mpms.rb +0 -4
  13. data/lib/pubid/api/identifiers/typeless_standard.rb +0 -3
  14. data/lib/pubid/api/single_identifier.rb +5 -8
  15. data/lib/pubid/ashrae/identifier.rb +7 -22
  16. data/lib/pubid/ashrae/identifiers/base.rb +28 -17
  17. data/lib/pubid/ashrae/parser.rb +4 -0
  18. data/lib/pubid/ashrae.rb +4 -0
  19. data/lib/pubid/asme/single_identifier.rb +3 -1
  20. data/lib/pubid/astm/single_identifier.rb +3 -1
  21. data/lib/pubid/bsi/identifier.rb +5 -31
  22. data/lib/pubid/bsi/identifiers/addendum_document.rb +0 -4
  23. data/lib/pubid/bsi/identifiers/adopted_european_norm.rb +0 -4
  24. data/lib/pubid/bsi/identifiers/adopted_international_standard.rb +0 -4
  25. data/lib/pubid/bsi/identifiers/aerospace_standard.rb +0 -3
  26. data/lib/pubid/bsi/identifiers/amendment.rb +0 -4
  27. data/lib/pubid/bsi/identifiers/british_industrial_practice.rb +0 -3
  28. data/lib/pubid/bsi/identifiers/bundled_identifier.rb +2 -5
  29. data/lib/pubid/bsi/identifiers/committee_document.rb +0 -3
  30. data/lib/pubid/bsi/identifiers/consolidated_identifier.rb +2 -5
  31. data/lib/pubid/bsi/identifiers/corrigendum.rb +0 -4
  32. data/lib/pubid/bsi/identifiers/detailed_specification.rb +0 -3
  33. data/lib/pubid/bsi/identifiers/disc.rb +0 -3
  34. data/lib/pubid/bsi/identifiers/draft_document.rb +0 -3
  35. data/lib/pubid/bsi/identifiers/electronic_book.rb +0 -3
  36. data/lib/pubid/bsi/identifiers/expert_commentary.rb +0 -4
  37. data/lib/pubid/bsi/identifiers/explanatory_supplement.rb +0 -3
  38. data/lib/pubid/bsi/identifiers/flex.rb +0 -3
  39. data/lib/pubid/bsi/identifiers/handbook.rb +0 -3
  40. data/lib/pubid/bsi/identifiers/index.rb +0 -3
  41. data/lib/pubid/bsi/identifiers/method.rb +0 -3
  42. data/lib/pubid/bsi/identifiers/national_annex.rb +0 -3
  43. data/lib/pubid/bsi/identifiers/practice_guide.rb +0 -3
  44. data/lib/pubid/bsi/identifiers/publicly_available_specification.rb +0 -3
  45. data/lib/pubid/bsi/identifiers/published_document.rb +0 -3
  46. data/lib/pubid/bsi/identifiers/section.rb +0 -3
  47. data/lib/pubid/bsi/identifiers/set.rb +2 -5
  48. data/lib/pubid/bsi/identifiers/standalone_amendment.rb +0 -3
  49. data/lib/pubid/bsi/identifiers/supplement_document.rb +0 -4
  50. data/lib/pubid/bsi/identifiers/supplementary_index.rb +0 -3
  51. data/lib/pubid/bsi/identifiers/technical_specification.rb +0 -3
  52. data/lib/pubid/bsi/identifiers/test_method.rb +0 -3
  53. data/lib/pubid/bsi/identifiers/value_added_publication.rb +0 -4
  54. data/lib/pubid/bsi/single_identifier.rb +32 -13
  55. data/lib/pubid/bsi.rb +8 -1
  56. data/lib/pubid/ccsds/identifier.rb +2 -14
  57. data/lib/pubid/cen_cenelec/identifier.rb +10 -8
  58. data/lib/pubid/cen_cenelec/identifiers/adopted_european_norm.rb +0 -4
  59. data/lib/pubid/cen_cenelec/identifiers/amendment.rb +0 -4
  60. data/lib/pubid/cen_cenelec/identifiers/base.rb +2 -9
  61. data/lib/pubid/cen_cenelec/identifiers/consolidated_identifier.rb +0 -4
  62. data/lib/pubid/cen_cenelec/identifiers/corrigendum.rb +0 -4
  63. data/lib/pubid/cen_cenelec/identifiers/european_prestandard.rb +0 -3
  64. data/lib/pubid/cen_cenelec/identifiers/fragment.rb +0 -4
  65. data/lib/pubid/cen_cenelec/single_identifier.rb +4 -7
  66. data/lib/pubid/cen_cenelec.rb +4 -0
  67. data/lib/pubid/cie/identifier.rb +4 -0
  68. data/lib/pubid/cie/single_identifier.rb +4 -4
  69. data/lib/pubid/cie.rb +4 -0
  70. data/lib/pubid/csa/identifier.rb +10 -1
  71. data/lib/pubid/csa/identifiers/base.rb +0 -3
  72. data/lib/pubid/csa/identifiers/cec.rb +0 -4
  73. data/lib/pubid/csa/identifiers/series.rb +0 -4
  74. data/lib/pubid/csa/single_identifier.rb +1 -1
  75. data/lib/pubid/csa.rb +4 -0
  76. data/lib/pubid/etsi/components/code.rb +1 -7
  77. data/lib/pubid/etsi/components/version.rb +0 -5
  78. data/lib/pubid/etsi/identifier.rb +4 -12
  79. data/lib/pubid/etsi/identifiers/base.rb +31 -24
  80. data/lib/pubid/etsi/identifiers/supplement_identifier.rb +0 -3
  81. data/lib/pubid/etsi.rb +3 -1
  82. data/lib/pubid/identifier.rb +90 -1
  83. data/lib/pubid/idf/identifier.rb +4 -0
  84. data/lib/pubid/idf.rb +4 -0
  85. data/lib/pubid/iec/identifier.rb +14 -14
  86. data/lib/pubid/iec/identifiers/base.rb +0 -4
  87. data/lib/pubid/iec/identifiers/consolidated_identifier.rb +0 -4
  88. data/lib/pubid/iec/identifiers/fragment_identifier.rb +1 -5
  89. data/lib/pubid/iec/identifiers/sheet_identifier.rb +1 -5
  90. data/lib/pubid/iec/identifiers/test_report_form.rb +0 -3
  91. data/lib/pubid/iec/identifiers/vap_identifier.rb +1 -5
  92. data/lib/pubid/iec/identifiers/working_document.rb +0 -4
  93. data/lib/pubid/iec.rb +4 -0
  94. data/lib/pubid/ieee/identifier.rb +5 -17
  95. data/lib/pubid/ieee/identifiers/adopted_standard.rb +0 -4
  96. data/lib/pubid/ieee/identifiers/base.rb +223 -201
  97. data/lib/pubid/ieee/identifiers/conformance_identifier.rb +0 -4
  98. data/lib/pubid/ieee/identifiers/corrigendum.rb +0 -4
  99. data/lib/pubid/ieee/identifiers/csa_dual_published.rb +0 -4
  100. data/lib/pubid/ieee/identifiers/dual_identifier.rb +0 -4
  101. data/lib/pubid/ieee/identifiers/dual_published.rb +0 -4
  102. data/lib/pubid/ieee/identifiers/iec_ieee_copublished.rb +0 -4
  103. data/lib/pubid/ieee/identifiers/interpretation_identifier.rb +0 -4
  104. data/lib/pubid/ieee/identifiers/multi_numbered_identifier.rb +0 -4
  105. data/lib/pubid/ieee/identifiers/parenthetical_identifier.rb +0 -4
  106. data/lib/pubid/ieee/identifiers/redlined_standard.rb +0 -4
  107. data/lib/pubid/ieee/identifiers/si_standard.rb +0 -4
  108. data/lib/pubid/ieee.rb +4 -0
  109. data/lib/pubid/iho/identifier.rb +7 -25
  110. data/lib/pubid/iho/identifiers/base.rb +62 -68
  111. data/lib/pubid/iho.rb +3 -1
  112. data/lib/pubid/iso/identifier.rb +15 -14
  113. data/lib/pubid/iso/single_identifier.rb +0 -4
  114. data/lib/pubid/iso.rb +4 -0
  115. data/lib/pubid/itu/components/code.rb +1 -7
  116. data/lib/pubid/itu/components/sector.rb +15 -4
  117. data/lib/pubid/itu/components/series.rb +0 -4
  118. data/lib/pubid/itu/identifier.rb +4 -18
  119. data/lib/pubid/itu/identifiers/base.rb +124 -122
  120. data/lib/pubid/itu.rb +3 -1
  121. data/lib/pubid/jcgm/identifiers/amendment.rb +0 -4
  122. data/lib/pubid/jcgm/identifiers/gum_guide.rb +0 -4
  123. data/lib/pubid/jcgm/single_identifier.rb +0 -4
  124. data/lib/pubid/jis/identifier.rb +2 -14
  125. data/lib/pubid/nist/identifier.rb +8 -23
  126. data/lib/pubid/nist/identifiers/base.rb +553 -544
  127. data/lib/pubid/nist/preprocessor.rb +12 -0
  128. data/lib/pubid/nist.rb +4 -0
  129. data/lib/pubid/oiml/builder.rb +21 -3
  130. data/lib/pubid/oiml/components/code.rb +7 -0
  131. data/lib/pubid/oiml/identifier.rb +44 -0
  132. data/lib/pubid/oiml/identifiers/annex.rb +10 -1
  133. data/lib/pubid/oiml/identifiers/errata.rb +15 -0
  134. data/lib/pubid/oiml/identifiers.rb +1 -1
  135. data/lib/pubid/oiml/parser.rb +59 -12
  136. data/lib/pubid/oiml/renderer.rb +27 -17
  137. data/lib/pubid/oiml/single_identifier.rb +58 -0
  138. data/lib/pubid/oiml/supplement_identifier.rb +30 -1
  139. data/lib/pubid/plateau/identifier.rb +4 -21
  140. data/lib/pubid/plateau/identifiers/base.rb +45 -36
  141. data/lib/pubid/plateau/identifiers/handbook.rb +0 -4
  142. data/lib/pubid/plateau/identifiers/technical_report.rb +0 -4
  143. data/lib/pubid/plateau/supplement_identifier.rb +0 -4
  144. data/lib/pubid/sae/identifier.rb +4 -12
  145. data/lib/pubid/sae/identifiers/base.rb +26 -17
  146. data/lib/pubid/version.rb +1 -1
  147. data/lib/pubid.rb +18 -2
  148. data/lib/tasks/export.rake +6 -5
  149. metadata +3 -4
  150. data/lib/pubid/identifier_facade.rb +0 -114
  151. data/lib/pubid/oiml/identifiers/base.rb +0 -21
@@ -1,14 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Pubid
4
- module Etsi
5
- class Identifier
6
- def self.parse(identifier)
7
- parsed = Parser.parse(identifier)
8
- Builder.build(parsed)
9
- rescue Parslet::ParseFailed => e
10
- raise "Failed to parse ETSI identifier '#{identifier}': #{e.message}"
11
- end
12
- end
13
- end
14
- end
3
+ # Pubid::Etsi::Identifier is the ETSI base class (a real Pubid::Identifier
4
+ # subclass); its body, `.parse`, and the Identifiers::Base back-compat alias
5
+ # live in identifiers/base.rb. This file just ensures it is loaded.
6
+ require_relative "identifiers/base"
@@ -2,34 +2,41 @@
2
2
 
3
3
  module Pubid
4
4
  module Etsi
5
- module Identifiers
6
- # Base class for all ETSI identifiers
7
- class Base < Pubid::Identifier
8
- # Generate URN for this identifier
9
- #
10
- # @return [String] URN representation
11
- attribute :type, :string
12
- attribute :code, Pubid::Etsi::Components::Code
13
- attribute :version, Pubid::Etsi::Components::Version
14
- attribute :date, Pubid::Components::Date
15
-
16
- def publisher
17
- "ETSI"
18
- end
5
+ # Base class for all ETSI identifiers. Canonical name Pubid::Etsi::Identifier
6
+ # (Identifiers::Base is a back-compat alias); every concrete ETSI identifier
7
+ # descends from it.
8
+ class Identifier < ::Pubid::Identifier
9
+ def self.parse(identifier)
10
+ parsed = Parser.parse(identifier)
11
+ Builder.build(parsed)
12
+ rescue Parslet::ParseFailed => e
13
+ raise "Failed to parse ETSI identifier '#{identifier}': #{e.message}"
14
+ end
19
15
 
20
- def to_s
21
- render(format: :human)
22
- end
16
+ attribute :type, :string
17
+ attribute :code, Pubid::Etsi::Components::Code
18
+ attribute :version, Pubid::Etsi::Components::Version
19
+ attribute :date, Pubid::Components::Date
20
+ # Stored as a plain string (always "ETSI") so it round-trips through
21
+ # to_hash/from_hash. Was previously a `def publisher` method, which made
22
+ # lutaml serialize a String against the Components::Publisher attribute and
23
+ # raise on to_hash.
24
+ attribute :publisher, :string, default: -> { "ETSI" }
23
25
 
24
- def ==(other)
25
- return false unless other.is_a?(Base)
26
+ def ==(other)
27
+ return false unless other.is_a?(Pubid::Etsi::Identifier)
26
28
 
27
- type == other.type &&
28
- code == other.code &&
29
- version == other.version &&
30
- date == other.date
31
- end
29
+ type == other.type &&
30
+ code == other.code &&
31
+ version == other.version &&
32
+ date == other.date
32
33
  end
33
34
  end
35
+
36
+ module Identifiers
37
+ # Backward-compatible alias: ETSI's base class used to be
38
+ # Pubid::Etsi::Identifiers::Base. It is now Pubid::Etsi::Identifier.
39
+ Base = Pubid::Etsi::Identifier
40
+ end
34
41
  end
35
42
  end
@@ -26,9 +26,6 @@ module Pubid
26
26
  end
27
27
 
28
28
  # Render via renderer
29
- def to_s
30
- render(format: :human)
31
- end
32
29
 
33
30
  # Recursively collect supplement notations from the supplement chain
34
31
  def collect_supplement_notations(current_supplement, notations)
data/lib/pubid/etsi.rb CHANGED
@@ -27,7 +27,9 @@ module Pubid
27
27
  @identifier_types ||= Identifiers.constants
28
28
  .filter_map { |c| begin; Identifiers.const_get(c); rescue NameError; nil; end }
29
29
  .select { |c| c.is_a?(Class) && c < Pubid::Identifier }
30
- .reject { |c| c.name&.split("::")&.last == "Base" }
30
+ # Exclude the flavor base itself by identity (Identifiers::Base is now an
31
+ # alias for Pubid::Etsi::Identifier, so name-based matching misses it).
32
+ .reject { |c| c == Identifiers::Base }
31
33
  end
32
34
 
33
35
  # Build typed stage index from identifier types
@@ -8,6 +8,96 @@ module Pubid
8
8
  end
9
9
 
10
10
  attr_writer :format_registry
11
+
12
+ # Polymorphic deserialization shared by every flavor base. lutaml's
13
+ # `key_value` polymorphic_map reads `_type` only to VALIDATE; it does not
14
+ # re-instantiate the concrete subclass. So a base-class `from_hash` would
15
+ # return a bare base object and drop subtype-specific attributes (e.g. a
16
+ # supplement's base_identifier). Route by `_type` to the concrete class
17
+ # named in `polymorphic_type_map`, then let its inherited from_hash (this
18
+ # method again, where klass == self) fall through to lutaml's real work.
19
+ #
20
+ # This generalizes the per-flavor `*_TYPE_MAP` dispatch that ISO, JIS,
21
+ # IEC, CCSDS and IHO each hand-rolled — one implementation, inherited by
22
+ # every flavor base.
23
+ def from_hash(data, options = {})
24
+ type = data && (data["_type"] || data[:_type])
25
+ klass = polymorphic_type_map[type]
26
+ return klass.from_hash(data, options) if klass && klass != self
27
+
28
+ super
29
+ end
30
+
31
+ # Map of polymorphic_name ("pubid:iso:corrigendum") => concrete class for
32
+ # the flavor this base belongs to. Built once by scanning the flavor's
33
+ # `Identifiers` namespace for Pubid::Identifier descendants and unioning
34
+ # the flavor's `identifier_types` registry (which may register classes
35
+ # living outside that namespace, e.g. ISO's BundledIdentifier). Memoized
36
+ # per class.
37
+ def polymorphic_type_map
38
+ @polymorphic_type_map ||=
39
+ identifier_registry_classes.each_with_object({}) do |klass, map|
40
+ poly = klass.polymorphic_name
41
+ map[poly] ||= klass if poly
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ # The flavor module namespacing this base, e.g. Pubid::Iso for
48
+ # Pubid::Iso::Identifier (and for the inherited Pubid::Iso::Identifiers::
49
+ # Corrigendum). Always the first two name components, so it is stable
50
+ # whether `self` is the base or a concrete subclass.
51
+ def flavor_module
52
+ @flavor_module ||= Object.const_get(name.split("::")[0, 2].join("::"))
53
+ end
54
+
55
+ def identifiers_namespace
56
+ @identifiers_namespace ||= flavor_module.const_get(:Identifiers)
57
+ end
58
+
59
+ def identifier_registry_classes
60
+ (scanned_identifier_classes +
61
+ registered_identifier_classes +
62
+ additional_identifier_classes).uniq
63
+ end
64
+
65
+ # Concrete identifier classes found directly in the flavor's `Identifiers`
66
+ # namespace. Empty for the abstract root (no flavor) or a flavor without
67
+ # that namespace. Only this namespace is scanned (never the flavor top
68
+ # level), to avoid force-autoloading unrelated flavor constants.
69
+ def scanned_identifier_classes
70
+ return [] unless flavor_identifiers_namespace?
71
+
72
+ identifiers_namespace.constants.filter_map do |const|
73
+ klass = identifiers_namespace.const_get(const)
74
+ klass if klass.is_a?(Class) && klass < ::Pubid::Identifier
75
+ rescue NameError
76
+ nil
77
+ end
78
+ end
79
+
80
+ # Classes the flavor explicitly registers via `identifier_types`, if any.
81
+ def registered_identifier_classes
82
+ return [] unless flavor_module.respond_to?(:identifier_types)
83
+
84
+ Array(flavor_module.identifier_types)
85
+ end
86
+
87
+ # Hook for identifier classes that carry a polymorphic `_type` but live
88
+ # OUTSIDE the flavor's `Identifiers` namespace (e.g. Pubid::Iso::
89
+ # BundledIdentifier, Pubid::Iec::SingleIdentifier). Flavors with such
90
+ # classes override this; the default is none. Replaces the hand-listing
91
+ # of these in the old static `*_TYPE_MAP`s.
92
+ def additional_identifier_classes
93
+ []
94
+ end
95
+
96
+ def flavor_identifiers_namespace?
97
+ flavor_module.const_defined?(:Identifiers)
98
+ rescue NameError
99
+ false
100
+ end
11
101
  end
12
102
 
13
103
  attribute :_type, :string, polymorphic_class: true
@@ -53,7 +143,6 @@ module Pubid
53
143
  "pubid:#{flavor}:#{type_kebab}"
54
144
  end
55
145
 
56
-
57
146
  def root
58
147
  return base_identifier.root if base_identifier
59
148
 
@@ -53,6 +53,10 @@ module Pubid
53
53
  end
54
54
 
55
55
  def self.parse(string)
56
+ if string.length > Pubid::MAX_INPUT_LENGTH
57
+ raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
58
+ end
59
+
56
60
  parsed = Pubid::Idf::Parser.new.parse(string)
57
61
  if parsed.nil? || parsed.empty?
58
62
  raise Pubid::Idf::Parser::ParseError,
data/lib/pubid/idf.rb CHANGED
@@ -13,6 +13,10 @@ module Pubid
13
13
  autoload :UrnParser, "#{__dir__}/idf/urn_parser"
14
14
 
15
15
  def self.parse(identifier)
16
+ if identifier.length > Pubid::MAX_INPUT_LENGTH
17
+ raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
18
+ end
19
+
16
20
  parser = Parser.new
17
21
  builder = Builder.new
18
22
 
@@ -98,6 +98,14 @@ module Pubid
98
98
  "pubid:iec:single-identifier" => "Pubid::Iec::SingleIdentifier",
99
99
  }.freeze
100
100
 
101
+ # SingleIdentifier lives outside Pubid::Iec::Identifiers but appears as a
102
+ # nested `_type`, so the shared polymorphic_type_map needs it explicitly
103
+ # (see Pubid::Identifier#additional_identifier_classes).
104
+ def self.additional_identifier_classes
105
+ [Pubid::Iec::SingleIdentifier]
106
+ end
107
+ private_class_method :additional_identifier_classes
108
+
101
109
  # Build the type map from the live class list, for the validation spec.
102
110
  def self.build_type_map
103
111
  types = Pubid::Iec.identifier_types
@@ -259,6 +267,10 @@ module Pubid
259
267
  end
260
268
 
261
269
  def self.parse(string)
270
+ if string.length > Pubid::MAX_INPUT_LENGTH
271
+ raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
272
+ end
273
+
262
274
  # Route URN strings to the URN parser (mirrors Iso::Identifier.parse)
263
275
  if Pubid::FormatDetector.detect(string) == :urn
264
276
  return Pubid::Iec::UrnParser.parse(string)
@@ -275,20 +287,8 @@ module Pubid
275
287
  Pubid::Iec::Builder.new.build(parsed)
276
288
  end
277
289
 
278
- # lutaml's polymorphic key_value mapping reads `_type` only to validate; it
279
- # does not re-instantiate the concrete subclass on root deserialization. So
280
- # `Identifier.from_hash(amendment_hash)` would return a bare Identifier and
281
- # drop base_identifier. Route by `_type` to the right subclass and let its
282
- # (inherited) from_hash do the real work, mirroring ISO/JIS.
283
- def self.from_hash(data, options = {})
284
- type = data["_type"] || data[:_type]
285
- klass_name = IEC_TYPE_MAP[type]
286
- if klass_name
287
- klass = Object.const_get(klass_name)
288
- return klass.from_hash(data, options) unless klass == self
289
- end
290
- super
291
- end
290
+ # from_hash is the shared polymorphic dispatch on Pubid::Identifier.
291
+ # IEC_TYPE_MAP remains as the key_value polymorphic_map.
292
292
  end
293
293
  end
294
294
  end
@@ -20,10 +20,6 @@ module Pubid
20
20
  map "database", to: :database, render_default: false
21
21
  end
22
22
 
23
- def to_s(**opts)
24
- render(format: :human, **opts)
25
- end
26
-
27
23
  def number_portion
28
24
  return "" unless number
29
25
 
@@ -35,10 +35,6 @@ module Pubid
35
35
  end
36
36
  end
37
37
 
38
- def to_s(**opts)
39
- render(format: :human, **opts)
40
- end
41
-
42
38
  # Delegate common attributes to first identifier (base document)
43
39
  def publisher
44
40
  identifiers&.first&.publisher
@@ -38,7 +38,7 @@ module Pubid
38
38
  return unless base
39
39
 
40
40
  doc.add_child(Lutaml::KeyValue::DataModel::Element.new("base",
41
- base.to_hash))
41
+ base.to_hash))
42
42
  end
43
43
 
44
44
  def base_from_kv(model, value)
@@ -118,10 +118,6 @@ module Pubid
118
118
  web: :fragment_identifier, title: "Fragment", short: "FRAG" }
119
119
  end
120
120
 
121
- def to_s(**opts)
122
- render(format: :human, **opts)
123
- end
124
-
125
121
  # Delegate common attributes to base_identifier
126
122
  def publisher
127
123
  base_identifier&.publisher
@@ -27,17 +27,13 @@ module Pubid
27
27
  return unless base
28
28
 
29
29
  doc.add_child(Lutaml::KeyValue::DataModel::Element.new("base",
30
- base.to_hash))
30
+ base.to_hash))
31
31
  end
32
32
 
33
33
  def base_from_kv(model, value)
34
34
  model.base_identifier = ::Pubid::Iec::Identifier.from_hash(value) if value
35
35
  end
36
36
 
37
- def to_s(**opts)
38
- render(format: :human, **opts)
39
- end
40
-
41
37
  # Delegate common attributes to base_identifier
42
38
  def publisher
43
39
  base_identifier&.publisher
@@ -40,9 +40,6 @@ module Pubid
40
40
  end
41
41
 
42
42
  # TRF uses special rendering via the Renderer
43
- def to_s(**opts)
44
- render(format: :human, **opts)
45
- end
46
43
  end
47
44
  end
48
45
  end
@@ -27,7 +27,7 @@ module Pubid
27
27
  return unless base
28
28
 
29
29
  doc.add_child(Lutaml::KeyValue::DataModel::Element.new("base",
30
- base.to_hash))
30
+ base.to_hash))
31
31
  end
32
32
 
33
33
  def base_from_kv(model, value)
@@ -42,10 +42,6 @@ module Pubid
42
42
  "SER" => "Serial version",
43
43
  }.freeze
44
44
 
45
- def to_s(**opts)
46
- render(format: :human, **opts)
47
- end
48
-
49
45
  # Delegate common attributes to base_identifier
50
46
  def publisher
51
47
  base_identifier&.publisher
@@ -42,10 +42,6 @@ module Pubid
42
42
 
43
43
  @stage ||= ::Pubid::Components::Stage.new(stage_code: stage_code)
44
44
  end
45
-
46
- def to_s(**opts)
47
- render(format: :human, **opts)
48
- end
49
45
  end
50
46
  end
51
47
  end
data/lib/pubid/iec.rb CHANGED
@@ -15,6 +15,10 @@ module Pubid
15
15
  autoload :Renderer, "#{__dir__}/iec/renderer"
16
16
 
17
17
  def self.parse(identifier_string)
18
+ if identifier_string.length > Pubid::MAX_INPUT_LENGTH
19
+ raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
20
+ end
21
+
18
22
  parsed = Parser.new.parse(identifier_string)
19
23
  Builder.new.build(parsed)
20
24
  end
@@ -1,19 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Pubid
4
- module Ieee
5
- # NOTE: intentionally does NOT `extend Pubid::IdentifierFacade`. IEEE's
6
- # `to_hash`/`from_hash` does not round-trip yet (e.g. `code`/`year` are
7
- # dropped on rebuild), so the facade would advertise a `from_hash` that
8
- # silently returns lossy objects — and a consumer's `instance_of?(module)`
9
- # validation can't catch it. Re-enable once IEEE serialization round-trips
10
- # cleanly. See identifier_facade.rb.
11
- module Identifier
12
- class << self
13
- def parse(input)
14
- Identifiers::Base.parse(input)
15
- end
16
- end
17
- end
18
- end
19
- end
3
+ # Pubid::Ieee::Identifier is the IEEE base class (a real Pubid::Identifier
4
+ # subclass); IEEE builds its identifiers as instances of it directly. Its body,
5
+ # `.parse`, and the Identifiers::Base back-compat alias live in
6
+ # identifiers/base.rb. This file just ensures it is loaded.
7
+ require_relative "identifiers/base"
@@ -15,10 +15,6 @@ module Pubid
15
15
  attribute :adopted_identifiers, Base, polymorphic: true,
16
16
  collection: true
17
17
 
18
- def to_s
19
- render(format: :human)
20
- end
21
-
22
18
  def publisher
23
19
  ieee_identifier&.publisher || "IEEE"
24
20
  end