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.
- checksums.yaml +4 -4
- data/lib/pubid/amca/identifier.rb +4 -23
- data/lib/pubid/amca/identifiers/base.rb +67 -30
- data/lib/pubid/amca/identifiers/interpretation.rb +0 -4
- data/lib/pubid/amca/identifiers/publication.rb +0 -4
- data/lib/pubid/amca/identifiers/standard.rb +0 -4
- data/lib/pubid/amca/renderer.rb +1 -1
- data/lib/pubid/amca/urn_generator.rb +2 -1
- data/lib/pubid/api/builder.rb +4 -0
- data/lib/pubid/api/identifier.rb +5 -1
- data/lib/pubid/api/identifiers/base.rb +2 -12
- data/lib/pubid/api/identifiers/mpms.rb +0 -4
- data/lib/pubid/api/identifiers/typeless_standard.rb +0 -3
- data/lib/pubid/api/single_identifier.rb +5 -8
- data/lib/pubid/ashrae/identifier.rb +7 -22
- data/lib/pubid/ashrae/identifiers/base.rb +28 -17
- data/lib/pubid/ashrae/parser.rb +4 -0
- data/lib/pubid/ashrae.rb +4 -0
- data/lib/pubid/asme/single_identifier.rb +3 -1
- data/lib/pubid/astm/single_identifier.rb +3 -1
- data/lib/pubid/bsi/identifier.rb +5 -31
- data/lib/pubid/bsi/identifiers/addendum_document.rb +0 -4
- data/lib/pubid/bsi/identifiers/adopted_european_norm.rb +0 -4
- data/lib/pubid/bsi/identifiers/adopted_international_standard.rb +0 -4
- data/lib/pubid/bsi/identifiers/aerospace_standard.rb +0 -3
- data/lib/pubid/bsi/identifiers/amendment.rb +0 -4
- data/lib/pubid/bsi/identifiers/british_industrial_practice.rb +0 -3
- data/lib/pubid/bsi/identifiers/bundled_identifier.rb +2 -5
- data/lib/pubid/bsi/identifiers/committee_document.rb +0 -3
- data/lib/pubid/bsi/identifiers/consolidated_identifier.rb +2 -5
- data/lib/pubid/bsi/identifiers/corrigendum.rb +0 -4
- data/lib/pubid/bsi/identifiers/detailed_specification.rb +0 -3
- data/lib/pubid/bsi/identifiers/disc.rb +0 -3
- data/lib/pubid/bsi/identifiers/draft_document.rb +0 -3
- data/lib/pubid/bsi/identifiers/electronic_book.rb +0 -3
- data/lib/pubid/bsi/identifiers/expert_commentary.rb +0 -4
- data/lib/pubid/bsi/identifiers/explanatory_supplement.rb +0 -3
- data/lib/pubid/bsi/identifiers/flex.rb +0 -3
- data/lib/pubid/bsi/identifiers/handbook.rb +0 -3
- data/lib/pubid/bsi/identifiers/index.rb +0 -3
- data/lib/pubid/bsi/identifiers/method.rb +0 -3
- data/lib/pubid/bsi/identifiers/national_annex.rb +0 -3
- data/lib/pubid/bsi/identifiers/practice_guide.rb +0 -3
- data/lib/pubid/bsi/identifiers/publicly_available_specification.rb +0 -3
- data/lib/pubid/bsi/identifiers/published_document.rb +0 -3
- data/lib/pubid/bsi/identifiers/section.rb +0 -3
- data/lib/pubid/bsi/identifiers/set.rb +2 -5
- data/lib/pubid/bsi/identifiers/standalone_amendment.rb +0 -3
- data/lib/pubid/bsi/identifiers/supplement_document.rb +0 -4
- data/lib/pubid/bsi/identifiers/supplementary_index.rb +0 -3
- data/lib/pubid/bsi/identifiers/technical_specification.rb +0 -3
- data/lib/pubid/bsi/identifiers/test_method.rb +0 -3
- data/lib/pubid/bsi/identifiers/value_added_publication.rb +0 -4
- data/lib/pubid/bsi/single_identifier.rb +32 -13
- data/lib/pubid/bsi.rb +8 -1
- data/lib/pubid/ccsds/identifier.rb +2 -14
- data/lib/pubid/cen_cenelec/identifier.rb +10 -8
- data/lib/pubid/cen_cenelec/identifiers/adopted_european_norm.rb +0 -4
- data/lib/pubid/cen_cenelec/identifiers/amendment.rb +0 -4
- data/lib/pubid/cen_cenelec/identifiers/base.rb +2 -9
- data/lib/pubid/cen_cenelec/identifiers/consolidated_identifier.rb +0 -4
- data/lib/pubid/cen_cenelec/identifiers/corrigendum.rb +0 -4
- data/lib/pubid/cen_cenelec/identifiers/european_prestandard.rb +0 -3
- data/lib/pubid/cen_cenelec/identifiers/fragment.rb +0 -4
- data/lib/pubid/cen_cenelec/single_identifier.rb +4 -7
- data/lib/pubid/cen_cenelec.rb +4 -0
- data/lib/pubid/cie/identifier.rb +4 -0
- data/lib/pubid/cie/single_identifier.rb +4 -4
- data/lib/pubid/cie.rb +4 -0
- data/lib/pubid/csa/identifier.rb +10 -1
- data/lib/pubid/csa/identifiers/base.rb +0 -3
- data/lib/pubid/csa/identifiers/cec.rb +0 -4
- data/lib/pubid/csa/identifiers/series.rb +0 -4
- data/lib/pubid/csa/single_identifier.rb +1 -1
- data/lib/pubid/csa.rb +4 -0
- data/lib/pubid/etsi/components/code.rb +1 -7
- data/lib/pubid/etsi/components/version.rb +0 -5
- data/lib/pubid/etsi/identifier.rb +4 -12
- data/lib/pubid/etsi/identifiers/base.rb +31 -24
- data/lib/pubid/etsi/identifiers/supplement_identifier.rb +0 -3
- data/lib/pubid/etsi.rb +3 -1
- data/lib/pubid/identifier.rb +90 -1
- data/lib/pubid/idf/identifier.rb +4 -0
- data/lib/pubid/idf.rb +4 -0
- data/lib/pubid/iec/identifier.rb +14 -14
- data/lib/pubid/iec/identifiers/base.rb +0 -4
- data/lib/pubid/iec/identifiers/consolidated_identifier.rb +0 -4
- data/lib/pubid/iec/identifiers/fragment_identifier.rb +1 -5
- data/lib/pubid/iec/identifiers/sheet_identifier.rb +1 -5
- data/lib/pubid/iec/identifiers/test_report_form.rb +0 -3
- data/lib/pubid/iec/identifiers/vap_identifier.rb +1 -5
- data/lib/pubid/iec/identifiers/working_document.rb +0 -4
- data/lib/pubid/iec.rb +4 -0
- data/lib/pubid/ieee/identifier.rb +5 -17
- data/lib/pubid/ieee/identifiers/adopted_standard.rb +0 -4
- data/lib/pubid/ieee/identifiers/base.rb +223 -201
- data/lib/pubid/ieee/identifiers/conformance_identifier.rb +0 -4
- data/lib/pubid/ieee/identifiers/corrigendum.rb +0 -4
- data/lib/pubid/ieee/identifiers/csa_dual_published.rb +0 -4
- data/lib/pubid/ieee/identifiers/dual_identifier.rb +0 -4
- data/lib/pubid/ieee/identifiers/dual_published.rb +0 -4
- data/lib/pubid/ieee/identifiers/iec_ieee_copublished.rb +0 -4
- data/lib/pubid/ieee/identifiers/interpretation_identifier.rb +0 -4
- data/lib/pubid/ieee/identifiers/multi_numbered_identifier.rb +0 -4
- data/lib/pubid/ieee/identifiers/parenthetical_identifier.rb +0 -4
- data/lib/pubid/ieee/identifiers/redlined_standard.rb +0 -4
- data/lib/pubid/ieee/identifiers/si_standard.rb +0 -4
- data/lib/pubid/ieee.rb +4 -0
- data/lib/pubid/iho/identifier.rb +7 -25
- data/lib/pubid/iho/identifiers/base.rb +62 -68
- data/lib/pubid/iho.rb +3 -1
- data/lib/pubid/iso/identifier.rb +15 -14
- data/lib/pubid/iso/single_identifier.rb +0 -4
- data/lib/pubid/iso.rb +4 -0
- data/lib/pubid/itu/components/code.rb +1 -7
- data/lib/pubid/itu/components/sector.rb +15 -4
- data/lib/pubid/itu/components/series.rb +0 -4
- data/lib/pubid/itu/identifier.rb +4 -18
- data/lib/pubid/itu/identifiers/base.rb +124 -122
- data/lib/pubid/itu.rb +3 -1
- data/lib/pubid/jcgm/identifiers/amendment.rb +0 -4
- data/lib/pubid/jcgm/identifiers/gum_guide.rb +0 -4
- data/lib/pubid/jcgm/single_identifier.rb +0 -4
- data/lib/pubid/jis/identifier.rb +2 -14
- data/lib/pubid/nist/identifier.rb +8 -23
- data/lib/pubid/nist/identifiers/base.rb +553 -544
- data/lib/pubid/nist/preprocessor.rb +12 -0
- data/lib/pubid/nist.rb +4 -0
- data/lib/pubid/oiml/builder.rb +21 -3
- data/lib/pubid/oiml/components/code.rb +7 -0
- data/lib/pubid/oiml/identifier.rb +44 -0
- data/lib/pubid/oiml/identifiers/annex.rb +10 -1
- data/lib/pubid/oiml/identifiers/errata.rb +15 -0
- data/lib/pubid/oiml/identifiers.rb +1 -1
- data/lib/pubid/oiml/parser.rb +59 -12
- data/lib/pubid/oiml/renderer.rb +27 -17
- data/lib/pubid/oiml/single_identifier.rb +58 -0
- data/lib/pubid/oiml/supplement_identifier.rb +30 -1
- data/lib/pubid/plateau/identifier.rb +4 -21
- data/lib/pubid/plateau/identifiers/base.rb +45 -36
- data/lib/pubid/plateau/identifiers/handbook.rb +0 -4
- data/lib/pubid/plateau/identifiers/technical_report.rb +0 -4
- data/lib/pubid/plateau/supplement_identifier.rb +0 -4
- data/lib/pubid/sae/identifier.rb +4 -12
- data/lib/pubid/sae/identifiers/base.rb +26 -17
- data/lib/pubid/version.rb +1 -1
- data/lib/pubid.rb +18 -2
- data/lib/tasks/export.rake +6 -5
- metadata +3 -4
- data/lib/pubid/identifier_facade.rb +0 -114
- data/lib/pubid/oiml/identifiers/base.rb +0 -21
|
@@ -21,9 +21,6 @@ module Pubid
|
|
|
21
21
|
web: :publicly_available_specification, title: "Publicly Available Specification", short: "PAS" }
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
def to_s(lang: :en, lang_single: false)
|
|
25
|
-
render(format: :human, lang: lang, lang_single: lang_single)
|
|
26
|
-
end
|
|
27
24
|
end
|
|
28
25
|
end
|
|
29
26
|
end
|
|
@@ -13,13 +13,10 @@ module Pubid
|
|
|
13
13
|
# BS ISO 20400 + BS ISO 44001+BS ISO 44002
|
|
14
14
|
# BS ISO 9001+BS ISO 14001
|
|
15
15
|
class Set < SingleIdentifier
|
|
16
|
-
attribute :identifiers, ::Pubid::Identifier, collection: true,
|
|
16
|
+
attribute :identifiers, ::Pubid::Identifier, collection: true,
|
|
17
|
+
polymorphic: true
|
|
17
18
|
attribute :separators, :string, collection: true # Should all be " + "
|
|
18
19
|
|
|
19
|
-
def to_s(lang: :en, lang_single: false)
|
|
20
|
-
render(format: :human, lang: lang, lang_single: lang_single)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
20
|
def <=>(other)
|
|
24
21
|
return nil unless other.is_a?(Set)
|
|
25
22
|
|
|
@@ -15,10 +15,6 @@ module Pubid
|
|
|
15
15
|
attribute :base_identifier, ::Pubid::Identifier, polymorphic: true
|
|
16
16
|
attribute :format, :string, values: ["PDF", "TC", "BOOK"]
|
|
17
17
|
|
|
18
|
-
def to_s(lang: :en, lang_single: false)
|
|
19
|
-
render(format: :human, lang: lang, lang_single: lang_single)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
18
|
# Delegate common attributes to base_identifier
|
|
23
19
|
def publisher
|
|
24
20
|
base_identifier&.publisher
|
|
@@ -2,15 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
module Pubid
|
|
4
4
|
module Bsi
|
|
5
|
-
class
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
# BSI base class. Canonical name Pubid::Bsi::Identifier; SingleIdentifier is a
|
|
6
|
+
# back-compat alias (BSI's common ancestor — there is no Identifiers::Base).
|
|
7
|
+
# Every concrete BSI identifier descends from it, so they are all
|
|
8
|
+
# `is_a?(Pubid::Bsi::Identifier)` natively and get the shared polymorphic
|
|
9
|
+
# `from_hash` (no facade needed).
|
|
10
|
+
class Identifier < ::Pubid::Identifier
|
|
11
|
+
def self.parse(string)
|
|
12
|
+
if string.length > Pubid::MAX_INPUT_LENGTH
|
|
13
|
+
raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Delegate to IEC for bare IEC identifiers. This handles IEC-specific
|
|
17
|
+
# features like VAP suffixes (CSV, RLV, etc.) and consolidated
|
|
18
|
+
# supplements (+AMD1:2001).
|
|
19
|
+
if string.match?(/\bIEC\b/) &&
|
|
20
|
+
(string.match?(/\s+(CSV|CMV|RLV|SER|EXV|PAC|PRV)\b/) ||
|
|
21
|
+
string.match?(/\+AMD\d+:/) ||
|
|
22
|
+
string.match?(/\+COR\d+:/))
|
|
23
|
+
return Pubid::Iec.parse(string)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
parser = Parser.new
|
|
10
27
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
28
|
+
parsed = parser.parse(string)
|
|
29
|
+
Builder.build(parsed)
|
|
30
|
+
rescue Parslet::ParseFailed => e
|
|
31
|
+
raise StandardError, "Failed to parse '#{string}': #{e.message}"
|
|
32
|
+
end
|
|
14
33
|
|
|
15
34
|
attribute :publisher, Bsi::Components::Publisher, default: -> {
|
|
16
35
|
Bsi::Components::Publisher.new(body: "BS")
|
|
@@ -34,12 +53,8 @@ module Pubid
|
|
|
34
53
|
attribute :explicit_publisher, :boolean, default: -> { false }
|
|
35
54
|
attribute :space_separated_part, :boolean, default: -> { false }
|
|
36
55
|
|
|
37
|
-
def to_s(lang: :en, lang_single: false)
|
|
38
|
-
render(format: :human, lang: lang, lang_single: lang_single)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
56
|
def <=>(other)
|
|
42
|
-
return nil unless other.is_a?(
|
|
57
|
+
return nil unless other.is_a?(Pubid::Bsi::Identifier)
|
|
43
58
|
|
|
44
59
|
# Compare by number first
|
|
45
60
|
num_cmp = number.to_s <=> other.number.to_s
|
|
@@ -61,5 +76,9 @@ module Pubid
|
|
|
61
76
|
end
|
|
62
77
|
end
|
|
63
78
|
end
|
|
79
|
+
|
|
80
|
+
# Backward-compatible alias: BSI's base class is Pubid::Bsi::Identifier.
|
|
81
|
+
# Concrete types declared as `< SingleIdentifier` continue to work.
|
|
82
|
+
SingleIdentifier = Identifier
|
|
64
83
|
end
|
|
65
84
|
end
|
data/lib/pubid/bsi.rb
CHANGED
|
@@ -12,7 +12,10 @@ module Pubid
|
|
|
12
12
|
autoload :Builder, "#{__dir__}/bsi/builder"
|
|
13
13
|
autoload :Identifier, "#{__dir__}/bsi/identifier"
|
|
14
14
|
autoload :Identifiers, "#{__dir__}/bsi/identifiers"
|
|
15
|
-
|
|
15
|
+
# NOTE: bsi/model.rb is legacy/unused (nothing references Pubid::Bsi::Model)
|
|
16
|
+
# and defines a conflicting `class Identifier < Lutaml::Model::Serializable`.
|
|
17
|
+
# It is intentionally NOT autoloaded so it can never clash with the real
|
|
18
|
+
# Pubid::Bsi::Identifier (single_identifier.rb).
|
|
16
19
|
autoload :Parser, "#{__dir__}/bsi/parser"
|
|
17
20
|
autoload :Renderer, "#{__dir__}/bsi/renderer"
|
|
18
21
|
autoload :SingleIdentifier, "#{__dir__}/bsi/single_identifier"
|
|
@@ -203,6 +206,10 @@ module Pubid
|
|
|
203
206
|
].freeze
|
|
204
207
|
|
|
205
208
|
def self.parse(string)
|
|
209
|
+
if string.length > Pubid::MAX_INPUT_LENGTH
|
|
210
|
+
raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
211
|
+
end
|
|
212
|
+
|
|
206
213
|
Identifier.parse(string)
|
|
207
214
|
end
|
|
208
215
|
|
|
@@ -62,20 +62,8 @@ module Pubid
|
|
|
62
62
|
raise "Failed to parse CCSDS identifier '#{identifier}': #{e.message}"
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
# (lutaml resolves `_type` only for validation, not instantiation).
|
|
68
|
-
# Mirrors Pubid::Jis::Identifier.from_hash. The `klass == self` guard lets
|
|
69
|
-
# the matched subclass fall through to lutaml's inherited from_hash.
|
|
70
|
-
def self.from_hash(data, options = {})
|
|
71
|
-
type = data["_type"] || data[:_type]
|
|
72
|
-
klass_name = CCSDS_TYPE_MAP[type]
|
|
73
|
-
if klass_name
|
|
74
|
-
klass = Object.const_get(klass_name)
|
|
75
|
-
return klass.from_hash(data, options) unless klass == self
|
|
76
|
-
end
|
|
77
|
-
super
|
|
78
|
-
end
|
|
65
|
+
# from_hash is the shared polymorphic dispatch on Pubid::Identifier.
|
|
66
|
+
# CCSDS_TYPE_MAP remains as the key_value polymorphic_map.
|
|
79
67
|
end
|
|
80
68
|
end
|
|
81
69
|
end
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
module Pubid
|
|
5
4
|
module CenCenelec
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
# Common base class for all CEN/CENELEC identifiers. CEN/CENELEC has a split
|
|
6
|
+
# hierarchy — some concrete types descend from Identifiers::Base, others from
|
|
7
|
+
# SingleIdentifier — so this class is the shared parent of BOTH, making every
|
|
8
|
+
# CEN/CENELEC identifier `is_a?(Pubid::CenCenelec::Identifier)` natively (and
|
|
9
|
+
# giving them the shared polymorphic `from_hash`). No facade needed.
|
|
10
|
+
class Identifier < ::Pubid::Identifier
|
|
13
11
|
def self.parse(identifier)
|
|
12
|
+
if identifier.length > Pubid::MAX_INPUT_LENGTH
|
|
13
|
+
raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
14
|
+
end
|
|
15
|
+
|
|
14
16
|
parsed = Parser.parse(identifier)
|
|
15
17
|
Builder.new.build(parsed)
|
|
16
18
|
rescue Parslet::ParseFailed => e
|
|
@@ -3,12 +3,9 @@
|
|
|
3
3
|
module Pubid
|
|
4
4
|
module CenCenelec
|
|
5
5
|
module Identifiers
|
|
6
|
-
# Base CEN identifier
|
|
6
|
+
# Base CEN identifier (one of two roots; see Pubid::CenCenelec::Identifier).
|
|
7
7
|
# Format: {PUBLISHER} NUMBER[-PART]:YEAR
|
|
8
|
-
class Base < Pubid::Identifier
|
|
9
|
-
# Identity for the Pubid::CenCenelec::Identifier facade (see its comment).
|
|
10
|
-
include Pubid::CenCenelec::Identifier
|
|
11
|
-
|
|
8
|
+
class Base < Pubid::CenCenelec::Identifier
|
|
12
9
|
# Generate URN for this identifier
|
|
13
10
|
#
|
|
14
11
|
# @return [String] URN representation
|
|
@@ -23,10 +20,6 @@ module Pubid
|
|
|
23
20
|
attribute :adopted_identifier, Base, polymorphic: true # Nested identifier object (ISO, IEC, etc.)
|
|
24
21
|
attribute :edition, :string # Edition number
|
|
25
22
|
|
|
26
|
-
def to_s(**opts)
|
|
27
|
-
render(format: :human, **opts)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
23
|
def ==(other)
|
|
31
24
|
return false unless other.is_a?(Base)
|
|
32
25
|
|
|
@@ -8,10 +8,6 @@ module Pubid
|
|
|
8
8
|
class ConsolidatedIdentifier < Base
|
|
9
9
|
attribute :identifiers, Base, polymorphic: true, collection: true
|
|
10
10
|
|
|
11
|
-
def to_s(**opts)
|
|
12
|
-
render(format: :human, **opts)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
11
|
# Delegate to first identifier (base document)
|
|
16
12
|
def publisher
|
|
17
13
|
identifiers&.first&.publisher
|
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
module Pubid
|
|
4
4
|
module CenCenelec
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# facade module is included into each to cover every concrete type.
|
|
10
|
-
include Pubid::CenCenelec::Identifier
|
|
11
|
-
|
|
5
|
+
# The second of CEN/CENELEC's two identifier roots (the other is
|
|
6
|
+
# Identifiers::Base); both descend from Pubid::CenCenelec::Identifier so every
|
|
7
|
+
# concrete type is `is_a?` it.
|
|
8
|
+
class SingleIdentifier < Pubid::CenCenelec::Identifier
|
|
12
9
|
attribute :publisher, Components::Publisher, default: -> {
|
|
13
10
|
Components::Publisher.new(body: "EN")
|
|
14
11
|
}
|
data/lib/pubid/cen_cenelec.rb
CHANGED
data/lib/pubid/cie/identifier.rb
CHANGED
|
@@ -11,6 +11,10 @@ module Pubid
|
|
|
11
11
|
attribute :style, :string # "legacy" or "current"
|
|
12
12
|
|
|
13
13
|
def self.parse(input)
|
|
14
|
+
if input.length > Pubid::MAX_INPUT_LENGTH
|
|
15
|
+
raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
16
|
+
end
|
|
17
|
+
|
|
14
18
|
parsed = Parser.parse(input)
|
|
15
19
|
builder = Builder.new
|
|
16
20
|
builder.build(parsed, original_string: input)
|
|
@@ -18,10 +18,10 @@ module Pubid
|
|
|
18
18
|
# - Identical (identical to ISO publications)
|
|
19
19
|
# - TutorialBundle (tutorial bundles)
|
|
20
20
|
class SingleIdentifier < Identifier
|
|
21
|
-
#
|
|
22
|
-
def publisher
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
# Stored as a plain string (always "CIE") so it round-trips through
|
|
22
|
+
# to_hash/from_hash. Was a `def publisher` method, which made lutaml
|
|
23
|
+
# serialize a String against the Components::Publisher attribute and raise.
|
|
24
|
+
attribute :publisher, :string, default: -> { "CIE" }
|
|
25
25
|
|
|
26
26
|
attribute :year, :string
|
|
27
27
|
attribute :date_separator, :string # "dash" or "colon"
|
data/lib/pubid/cie.rb
CHANGED
|
@@ -19,6 +19,10 @@ module Pubid
|
|
|
19
19
|
# Main entry point for CIE identifiers
|
|
20
20
|
# Delegates to Identifier.parse
|
|
21
21
|
def self.parse(input)
|
|
22
|
+
if input.length > Pubid::MAX_INPUT_LENGTH
|
|
23
|
+
raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
24
|
+
end
|
|
25
|
+
|
|
22
26
|
Identifier.parse(input)
|
|
23
27
|
end
|
|
24
28
|
|
data/lib/pubid/csa/identifier.rb
CHANGED
|
@@ -2,8 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
module Pubid
|
|
4
4
|
module Csa
|
|
5
|
-
class
|
|
5
|
+
# Common base class for all CSA identifiers. SingleIdentifier (and the
|
|
6
|
+
# concrete Identifiers::* types through it) descends from it, so every CSA
|
|
7
|
+
# identifier is `is_a?(Pubid::Csa::Identifier)` natively and gets the shared
|
|
8
|
+
# polymorphic `from_hash`. (The Wrapper/Composite container models are
|
|
9
|
+
# separate Lutaml::Model types, not identifiers.)
|
|
10
|
+
class Identifier < ::Pubid::Identifier
|
|
6
11
|
def self.parse(input)
|
|
12
|
+
if input.length > Pubid::MAX_INPUT_LENGTH
|
|
13
|
+
raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
14
|
+
end
|
|
15
|
+
|
|
7
16
|
# Filter out comments
|
|
8
17
|
return nil if input.start_with?("#")
|
|
9
18
|
|
data/lib/pubid/csa.rb
CHANGED
|
@@ -15,6 +15,10 @@ module Pubid
|
|
|
15
15
|
autoload :Components, "#{__dir__}/csa/components"
|
|
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
|
Identifier.parse(identifier_string)
|
|
19
23
|
end
|
|
20
24
|
|
|
@@ -16,13 +16,7 @@ module Pubid
|
|
|
16
16
|
class Code < Lutaml::Model::Serializable
|
|
17
17
|
attribute :number, :string # Main number
|
|
18
18
|
attribute :minor, :string # Optional minor part
|
|
19
|
-
attribute :parts, :string, collection: true # Parts array
|
|
20
|
-
|
|
21
|
-
def initialize(number:, minor: nil, parts: nil)
|
|
22
|
-
@number = number
|
|
23
|
-
@minor = minor
|
|
24
|
-
@parts = parts || []
|
|
25
|
-
end
|
|
19
|
+
attribute :parts, :string, collection: true, default: [] # Parts array
|
|
26
20
|
|
|
27
21
|
# Render code with space for minor and dash-separated parts
|
|
28
22
|
def to_s
|