pubid-iso 0.3.0 → 0.4.0

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +118 -39
  3. data/lib/pubid/iso/errors.rb +0 -3
  4. data/lib/pubid/iso/harmonized_stage_code.rb +1 -145
  5. data/lib/pubid/iso/identifier/amendment.rb +52 -0
  6. data/lib/pubid/iso/identifier/base.rb +365 -0
  7. data/lib/pubid/iso/identifier/corrigendum.rb +53 -0
  8. data/lib/pubid/iso/identifier/directives.rb +29 -0
  9. data/lib/pubid/iso/identifier/guide.rb +32 -0
  10. data/lib/pubid/iso/identifier/international_standard.rb +45 -0
  11. data/lib/pubid/iso/identifier/international_standardized_profile.rb +30 -0
  12. data/lib/pubid/iso/identifier/international_workshop_agreement.rb +25 -0
  13. data/lib/pubid/iso/identifier/publicly_available_specification.rb +30 -0
  14. data/lib/pubid/iso/identifier/recommendation.rb +19 -0
  15. data/lib/pubid/iso/identifier/supplement.rb +39 -0
  16. data/lib/pubid/iso/identifier/technical_committee.rb +19 -0
  17. data/lib/pubid/iso/identifier/technical_report.rb +30 -0
  18. data/lib/pubid/iso/identifier/technical_specification.rb +30 -0
  19. data/lib/pubid/iso/identifier/technology_trends_assessments.rb +30 -0
  20. data/lib/pubid/iso/identifier.rb +39 -264
  21. data/lib/pubid/iso/parser.rb +56 -20
  22. data/lib/pubid/iso/renderer/amendment.rb +7 -0
  23. data/lib/pubid/iso/renderer/base.rb +129 -98
  24. data/lib/pubid/iso/renderer/corrigendum.rb +7 -0
  25. data/lib/pubid/iso/renderer/dir.rb +5 -3
  26. data/lib/pubid/iso/renderer/guide.rb +19 -0
  27. data/lib/pubid/iso/renderer/international_standard.rb +11 -0
  28. data/lib/pubid/iso/renderer/international_standardized_profile.rb +13 -0
  29. data/lib/pubid/iso/renderer/international_workshop_agreement.rb +17 -0
  30. data/lib/pubid/iso/renderer/publicly_available_specification.rb +12 -0
  31. data/lib/pubid/iso/renderer/recommendation.rb +13 -0
  32. data/lib/pubid/iso/renderer/supplement.rb +63 -0
  33. data/lib/pubid/iso/renderer/technical_committee.rb +47 -0
  34. data/lib/pubid/iso/renderer/technical_report.rb +13 -0
  35. data/lib/pubid/iso/renderer/technical_specification.rb +13 -0
  36. data/lib/pubid/iso/renderer/technology_trends_assessments.rb +13 -0
  37. data/lib/pubid/iso/renderer/urn-amendment.rb +12 -0
  38. data/lib/pubid/iso/renderer/urn-corrigendum.rb +12 -0
  39. data/lib/pubid/iso/renderer/urn-dir.rb +11 -3
  40. data/lib/pubid/iso/renderer/urn-supplement.rb +31 -0
  41. data/lib/pubid/iso/renderer/urn-tc.rb +2 -0
  42. data/lib/pubid/iso/renderer/urn.rb +25 -13
  43. data/lib/pubid/iso/stage.rb +1 -99
  44. data/lib/pubid/iso/transformer.rb +91 -107
  45. data/lib/pubid/iso/type.rb +9 -1
  46. data/lib/pubid/iso/version.rb +1 -1
  47. data/lib/pubid/iso.rb +20 -14
  48. data/stages.yaml +93 -0
  49. data/update_codes.yaml +1 -0
  50. metadata +37 -11
  51. data/lib/pubid/iso/amendment.rb +0 -15
  52. data/lib/pubid/iso/corrigendum.rb +0 -31
  53. data/lib/pubid/iso/renderer/french.rb +0 -29
  54. data/lib/pubid/iso/renderer/russian.rb +0 -64
  55. data/lib/pubid/iso/renderer/tc.rb +0 -30
  56. data/lib/pubid/iso/supplement.rb +0 -56
  57. data/lib/pubid/iso/typed_stage.rb +0 -204
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 418f8b225027cf9b50cb2ec43aad7d043b3bfd0db87733366c6021df8f92f940
4
- data.tar.gz: fd9a028a0cb2721b4422b2f515aa46263c7d713da57e02c8fc1ed4c54c22f737
3
+ metadata.gz: 0d4663e5dcbd65463c62e3fd2d204cf0ad3bac87dd8b8c20f2812a4b2e28f82e
4
+ data.tar.gz: 074d079407abe61c365984f5d945054383f2cca91007cea95e6e4e3cacd9006a
5
5
  SHA512:
6
- metadata.gz: bf1f97bde499237e29b24b793d7e9fe115e03e42a92471a549f90aea9c416ddc357fcfd95079a97bff4b200b4fe8c93f786fc8e3c8256ad3275f2365f9c946e8
7
- data.tar.gz: d4b53365fc22d587b204a7c38fcaf362e7f85b5cc5a07767ecb4f97fe5c7a3b8c70c3e24c8c30b63166321bd4f757f7d6658df154a4ccab4715ae94c62e8f17e
6
+ metadata.gz: 6363362daf26cf5c8e4f32bfe3cdea4b577340f3231a4f377df5f4ed6f95f0a04ace24e165569a7fa2e6a4f2b13783b3d8e7011c7c1c0569f730ae7bd06a7dd3
7
+ data.tar.gz: d8da3197efd8947f4b33b98e4cc9983a3e27dccb644d853bf70ea69883467bbc605dc8e025cf49f40fbd92341516f5e3f4ed95ad350248e31ef432ec0c4d475e
data/README.adoc CHANGED
@@ -12,108 +12,140 @@ identifiers.
12
12
  . generate language specific PubID
13
13
  . generate dated vs undated PubIDs
14
14
 
15
- === Usage samples
15
+ == Usage
16
+
17
+ === Identifier creation
18
+
19
+ Basic usage of the pubid-iso gem starts with the `Identifier#create` method.
16
20
 
17
21
  [source,ruby]
18
22
  ----
19
23
  require "pubid-iso"
20
24
 
21
- pubid = Pubid::Iso::Identifier.new(publisher: "ISO", number: 123)
25
+ pubid = Pubid::Iso::Identifier.create(publisher: "ISO", number: 123)
22
26
  pubid.to_s
23
27
 
24
28
  => "ISO 1234"
25
29
  ----
26
30
 
27
- ==== With coopublisher
31
+
32
+ === With co-publisher
28
33
 
29
34
  [source,ruby]
30
35
  ----
31
- pubid = Pubid::Iso::Identifier.new(publisher: "ISO", copublisher: "IEC", number: 123)
36
+ pubid = Pubid::Iso::Identifier.create(publisher: "ISO", copublisher: "IEC", number: 123)
32
37
  pubid.to_s
33
38
 
34
39
  => "ISO/IEC 1234"
35
40
  ----
36
41
 
37
- ==== With document type
42
+ === With document type
38
43
 
39
44
  [source,ruby]
40
45
  ----
41
- pubid = Pubid::Iso::Identifier.new(publisher: "ISO", type: "TR", number: 123)
46
+ pubid = Pubid::Iso::Identifier.create(publisher: "ISO", type: "TR", number: 123)
42
47
  pubid.to_s
43
48
 
44
49
  => "ISO/TR 1234"
45
50
  ----
46
51
 
47
- ==== With stage
52
+ === With stage
48
53
 
49
54
  [source,ruby]
50
55
  ----
51
- pubid = Pubid::Iso::Identifier.new(publisher: "ISO", stage: :WD, number: 123)
56
+ pubid = Pubid::Iso::Identifier.create(publisher: "ISO", stage: :WD, number: 123)
52
57
  pubid.to_s
53
58
 
54
59
  => "ISO/WD 1234"
55
60
  ----
56
61
 
57
- ==== With part number
62
+ === With part number
58
63
 
59
64
  [source,ruby]
60
65
  ----
61
- pubid = Pubid::Iso::Identifier.new(publisher: "ISO", number: 123, part: 1)
66
+ pubid = Pubid::Iso::Identifier.create(publisher: "ISO", number: 123, part: 1)
62
67
  pubid.to_s
63
68
 
64
69
  => "ISO 1234-1"
65
70
  ----
66
71
 
67
- ==== Iteration
72
+ === Iteration
73
+
74
+ An iteration is a version within a stage. A stage must be provided to set
75
+ an iteration.
76
+
77
+ If an iteration exists but a stage is not set, an error will be raised.
68
78
 
69
79
  [source,ruby]
70
80
  ----
71
- pubid = Pubid::Iso::Identifier.new(publisher: "ISO", number: 123, part: 1, stage: :DIS, iteration: 1)
81
+ pubid = Pubid::Iso::Identifier.create(publisher: "ISO", number: 123, part: 1, stage: "DIS", iteration: 1)
72
82
  pubid.to_s
73
83
 
74
84
  => "ISO/DIS 1234-1.1"
75
85
  ----
76
- To apply iteration to document stage should be provided as well.
77
- Without stage error will be raised.
78
86
 
79
- ==== Amendment and Corrigendum
87
+
88
+ === Supplement identifiers
89
+
90
+ A supplement identifier represents a supplement on top of a base document.
91
+
92
+ A supplement can be of the following types:
93
+
94
+ * Amendment `:amd`
95
+ * Addendum `:add` (superseded by Amendment)
96
+ * Technical Corrigendum `:cor`
97
+ * Supplement `:supp`
98
+
99
+ The general construction of a supplement identifier requires a base identifier.
100
+
101
+ NOTE: See documentation on
102
+ https://rubydoc.info/gems/pubid-iso/Pubid%2FIso%2FSupplement:initialize[PubId::Iso::Supplement#initialize]
103
+ and
104
+ https://rubydoc.info/gems/pubid-core/Pubid%2FCore%2FSupplement:initialize[Pubid::Core::Supplement#initialize]
105
+ to see all available options.
106
+
107
+ === Amendment
108
+
80
109
  [source,ruby]
81
110
  ----
82
- > pubid = Pubid::Iso::Identifier.new(publisher: "ISO", number: 123, part: 1, year: 2019, amendments: [{ number: "1", year: "2021", stage: :WD }])
111
+ > base = Pubid::Iso::Identifier.create(publisher: "ISO", number: 123, part: 1, year: 2019)
112
+ > pubid = Pubid::Iso::Identifier.create(type: :amd, number: 1, year: "2021", stage: "WD", base: base)
83
113
  > pubid.to_s
84
114
  => "ISO 1234-1:2019/WD Amd 1:2021"
115
+ ----
116
+
117
+ === Corrigendum
85
118
 
86
- > pubid = Pubid::Iso::Identifier.new(publisher: "ISO", number: 123, part: 1, year: 2019, corrigendums: [{ number: "1", year: "2021", stage: :WD }])
119
+ [source,ruby]
120
+ ----
121
+ > base = Pubid::Iso::Identifier.create(publisher: "ISO", number: 123, part: 1, year: 2019)
122
+ > pubid = Pubid::Iso::Identifier.create(type: :cor, number: "1", year: "2021", stage: :WD, base: base)
87
123
  > pubid.to_s
88
124
  => "ISO 1234-1:2019/WD Cor 1:2021"
89
125
  ----
90
- See documentation on https://rubydoc.info/gems/pubid-iso/Pubid%2FIso%2FSupplement:initialize[PubId::Iso::Supplement#initialize] and https://rubydoc.info/gems/pubid-core/Pubid%2FCore%2FSupplement:initialize[Pubid::Core::Supplement#initialize] to see all available options.
91
126
 
92
- ==== Using format options
127
+
128
+ === Using format options
129
+
93
130
  [source,ruby]
94
131
  ----
95
- > pubid = Pubid::Iso::Identifier.new(
132
+ > base = Pubid::Iso::Identifier.create(
96
133
  number: "8601",
97
134
  part: "1",
98
135
  year: 2019,
99
136
  edition: 1,
100
- amendment: {number: "1", year: "2021", stage: "DIS"}
137
+ language: "en"
101
138
  )
139
+ > pubid = Pubid::Iso::Identifier.create(type: :amd, number: "1", year: "2021", stage: "DAM", base: base)
102
140
  > pubid.to_s(:ref_num_short)
103
141
  => "ISO 8601-1:2019/DAM 1:2021(E)"
104
- > pubid.to_s(:ref_num_long)
105
- => "ISO 8601-1:2019/DAmd 1:2021(en)"
106
142
  > pubid.to_s(:ref_dated)
107
143
  => "ISO 8601-1:2019/DAM 1:2021"
108
- > pubid.to_s(:ref_dated_long)
109
- => "ISO 8601-1:2019/DAmd 1:2021"
110
144
  > pubid.to_s(:ref_undated)
111
145
  => "ISO 8601-1:2019/DAM 1"
112
- > pubid.to_s(:ref_undated_long)
113
- => "ISO 8601-1:2019/DAmd 1"
114
146
  ----
115
147
 
116
- ==== Using language specific rendering
148
+ === Using language specific rendering
117
149
  [source,ruby]
118
150
  ----
119
151
  > pubid = Pubid::Iso::Identifier.parse("ISO/FDIS 26000:2010(ru)")
@@ -124,28 +156,30 @@ See documentation on https://rubydoc.info/gems/pubid-iso/Pubid%2FIso%2FSupplemen
124
156
  => "Guide ISO/CEI 71:2001(fr)"
125
157
  ----
126
158
 
127
- ==== Rendering URN identifier
159
+ === Rendering URN identifier
160
+
128
161
  [source,ruby]
129
162
  ----
130
- > pubid = Pubid::Iso::Identifier.new(
163
+ > base = Pubid::Iso::Identifier.create(
131
164
  number: "8601",
132
165
  part: "1",
133
166
  year: 2019,
134
167
  edition: 1,
135
- amendments: {number: "1", year: "2021", stage: "DIS"}
136
168
  )
169
+ > pubid = Pubid::Iso::Identifier.create(type: :amd, number: "1", year: "2021", stage: "DAM", base: base)
137
170
  > pubid.urn
138
- => "urn:iso:std:iso:8601:-1:ed-1:amd:2021:v1"
171
+ => "urn:iso:std:iso:8601:-1:ed-1:stage-draft:amd:2021:v1"
139
172
  ----
140
173
 
141
- ==== Typed stage abbreviation
174
+ === Typed stage abbreviation
175
+
142
176
  [source,ruby]
143
177
  ----
144
178
  > pubid = Pubid::Iso::Identifier.parse("ISO/FDIS 26000:2010")
145
179
  > pubid.typed_stage_abbrev
146
180
  => "FDIS"
147
181
  > pubid.typed_stage_name
148
- => "Final Draft"
182
+ => "Final Draft International Standard"
149
183
 
150
184
  > pubid = Pubid::Iso::Identifier.parse("ISO/FDTR 26000:2010")
151
185
  > pubid.typed_stage_abbrev
@@ -160,13 +194,58 @@ See documentation on https://rubydoc.info/gems/pubid-iso/Pubid%2FIso%2FSupplemen
160
194
  => "Working Draft Technical Report"
161
195
  ----
162
196
 
163
- See documentation (https://www.rubydoc.info/gems/pubid-iso/Pubid/Iso/Identifier#initialize-instance_method[Pubid::Iso::Identifier] and https://www.rubydoc.info/gems/pubid-core/Pubid/Core/Identifier#initialize-instance_method[Pubid::Core::Identifier]) for all available attributes and options.
197
+ === Identifier's class and type
198
+
199
+ `Identifier#parse` resolves a parsed identifier to the correct class and type.
200
+
201
+ [source,ruby]
202
+ ----
203
+ Pubid::Iso::Identifier.parse("ISO/TC 184/SC 4 N1000").class
204
+ # => Pubid::Iso::Identifier::TechnicalCommittee
205
+ Pubid::Iso::Identifier.parse("ISO/TC 184/SC 4 N1000").type
206
+ # => {:key=>:tc, :title=>"Technical Committee"}
207
+ Pubid::Iso::Identifier.parse("ISO 10001").class
208
+ # => Pubid::Iso::Identifier::InternationalStandard
209
+ Pubid::Iso::Identifier.parse("ISO 10001").type
210
+ # => {:key=>:is, :title=>"International Standard"}
211
+ ----
212
+
213
+
214
+
215
+ === Root identifier
216
+
217
+ `Identifier#root` points to the root identifier.
218
+
219
+ The root identifier is defined as:
220
+
221
+ * for supplement identifiers, the root identifier is the base identifier;
222
+
223
+ * for other identifiers, the root identifier is the identifier itself.
224
+
225
+ [source,ruby]
226
+ ----
227
+ > pubid = Pubid::Iso::Identifier.parse("ISO/WD TR 26000:2010")
228
+ > pubid.root.to_s
229
+ => "ISO/WD TR 26000:2010"
230
+ > pubid = Pubid::Iso::Identifier.parse("ISO 10231:2003/Amd 1:2015")
231
+ > pubid.root.to_s
232
+ => "ISO 10231:2003"
233
+ > pubid = Pubid::Iso::Identifier.parse("ISO/IEC 13818-1:2015/Amd 3:2016/Cor 1:2017")
234
+ > pubid.root.to_s
235
+ => "ISO/IEC 13818-1:2015"
236
+ ----
237
+
238
+ See documentation
239
+ (https://www.rubydoc.info/gems/pubid-iso/Pubid/Iso/Identifier#initialize-instance_method[Pubid::Iso::Identifier]
240
+ and
241
+ https://www.rubydoc.info/gems/pubid-core/Pubid/Core/Identifier#initialize-instance_method[Pubid::Core::Identifier])
242
+ for all available attributes and options.
164
243
 
165
244
  == Elements of the PubID
166
245
 
167
246
  === Document identifier
168
247
 
169
- ==== General
248
+ === General
170
249
 
171
250
  The ISO document identifier is assembled out of these metadata elements:
172
251
 
@@ -178,7 +257,7 @@ document type:: type of ISO deliverable
178
257
  copyright year:: year of publication of document
179
258
  language:: language of document
180
259
 
181
- ==== Publisher
260
+ === Publisher
182
261
 
183
262
  This is the abbreviation of the publishing organization, typically `ISO`.
184
263
 
@@ -194,7 +273,7 @@ An International Workshop Agreement document has publisher abbreviation of
194
273
  ====
195
274
 
196
275
 
197
- ==== Document type and stage
276
+ === Document type and stage
198
277
 
199
278
  ISO document stages in document identifiers are mapped as follows.
200
279
 
@@ -281,7 +360,7 @@ Once the document is published (stage 60 substage 60), no status abbreviation is
281
360
  given.
282
361
 
283
362
 
284
- ==== Full PubID patterns
363
+ === Full PubID patterns
285
364
 
286
365
  The patterns are as follows:
287
366
 
@@ -2,9 +2,6 @@ module Pubid::Iso
2
2
  module Errors
3
3
  class ParseError < StandardError; end
4
4
  class PublishedIterationError < StandardError; end
5
- class HarmonizedStageCodeInvalidError < StandardError; end
6
- class HarmonizedStageRenderingError < StandardError; end
7
- class StageInvalidError < StandardError; end
8
5
  class IsStageIterationError < StandardError; end
9
6
  class IterationWithoutStageError < StandardError; end
10
7
  class WrongFormat < StandardError; end
@@ -1,149 +1,5 @@
1
1
  module Pubid::Iso
2
- class HarmonizedStageCode
3
- include Comparable
4
- # attr_accessor :stage, :substage
5
- attr_accessor :stages
2
+ class HarmonizedStageCode < Pubid::Core::HarmonizedStageCode
6
3
 
7
- DESCRIPTIONS = {
8
- "00.00" => "Proposal for new project received",
9
- "00.20" => "Proposal for new project under review",
10
- "00.60" => "Close of review",
11
- "00.98" => "Proposal for new project abandoned",
12
- "00.99" => "Approval to ballot proposal for new project",
13
- "10.00" => "Proposal for new project registered",
14
- "10.20" => "New project ballot initiated",
15
- "10.60" => "Close of voting",
16
- "10.92" => "Proposal returned to submitter for further definition",
17
- "10.98" => "New project rejected",
18
- "10.99" => "New project approved",
19
- "20.00" => "New project registered in TC/SC work programme",
20
- "20.20" => "Working draft (WD) study initiated",
21
- "20.60" => "Close of comment period",
22
- "20.98" => "Project deleted",
23
- "20.99" => "WD approved for registration as CD",
24
- "30.00" => "Committee draft (CD) registered",
25
- "30.20" => "CD study/ballot initiated",
26
- "30.60" => "Close of voting/ comment period",
27
- "30.92" => "CD referred back to Working Group",
28
- "30.98" => "Project deleted",
29
- "30.99" => "CD approved for registration as DIS",
30
- "40.00" => "DIS registered",
31
- "40.20" => "DIS ballot initiated: 12 weeks",
32
- "40.60" => "Close of voting",
33
- "40.92" => "Full report circulated: DIS referred back to TC or SC",
34
- "40.93" => "Full report circulated: decision for new DIS ballot",
35
- "40.98" => "Project deleted",
36
- "40.99" => "Full report circulated: DIS approved for registration as FDIS",
37
- "50.00" => "Final text received or FDIS registered for formal approval",
38
- "50.20" => "Proof sent to secretariat or FDIS ballot initiated: 8 weeks",
39
- "50.60" => "Close of voting. Proof returned by secretariat",
40
- "50.92" => "FDIS or proof referred back to TC or SC",
41
- "50.98" => "Project deleted",
42
- "50.99" => "FDIS or proof approved for publication",
43
- "60.00" => "International Standard under publication",
44
- "60.60" => "International Standard published",
45
- "90.20" => "International Standard under systematic review",
46
- "90.60" => "Close of review",
47
- "90.92" => "International Standard to be revised",
48
- "90.93" => "International Standard confirmed",
49
- "90.99" => "Withdrawal of International Standard proposed by TC or SC",
50
- "95.20" => "Withdrawal ballot initiated",
51
- "95.60" => "Close of voting",
52
- "95.92" => "Decision not to withdraw International Standard",
53
- "95.99" => "Withdrawal of International Standard"
54
- }.freeze
55
-
56
- DRAFT_STAGES = %w[00.00 00.20 00.60 00.99 10.00 10.20 10.60 10.92 10.99 20.00 20.20 20.60 20.99 30.00
57
- 30.20 30.60 30.92 30.99 40.00 40.20 40.60 40.92 40.93 40.99 50.00 50.20 50.60
58
- 50.92 50.99].freeze
59
-
60
- CANCELED_STAGES = %w[00.98 10.98 20.98 30.98 40.98 50.98 95.99].freeze
61
-
62
- PUBLISHED_STAGES = %w[60.00 60.60 90.20 90.60 90.92 90.93 90.99 95.20 95.60 95.92].freeze
63
-
64
- STAGES_NAMES = {
65
- preliminary: "00",
66
- proposal: "10",
67
- preparatory: "20",
68
- committee: "30",
69
- enquiry: "40",
70
- approval: "50",
71
- publication: "60",
72
- review: "90",
73
- withdrawal: "95",
74
- }.freeze
75
-
76
- SUBSTAGES_NAMES = {
77
- registration: "00",
78
- start_of_main_action: "20",
79
- completion_of_main_action: "60",
80
- repeat_an_earlier_phase: "92",
81
- repeat_current_phase: "93",
82
- abandon: "98",
83
- proceed: "99",
84
- }.freeze
85
-
86
- # @param stage_or_code [String,Array<String>] stage number or whole harmonized code with substage
87
- # or list or stages for fuzzy stages eg. "10", 10, "20.20", ["10.20", "20.20"]
88
- # @param substage [Integer, String] eg. "00", 0
89
- def initialize(stage_or_code, substage = "00")
90
- @stages = if stage_or_code.is_a?(Array)
91
- stage_or_code
92
- elsif stage_or_code.is_a?(String) && DESCRIPTIONS.key?(stage_or_code)
93
- [stage_or_code]
94
- # when stage is stage name
95
- elsif STAGES_NAMES.key?(stage_or_code)
96
- ["#{STAGES_NAMES[stage_or_code]}.#{SUBSTAGES_NAMES[substage]}"]
97
- else
98
- # stage is number
99
- ["#{stage_or_code}.#{substage}"]
100
- end
101
- validate_stages
102
- end
103
-
104
- def validate_stages
105
- @stages.each do |stage|
106
- # raise an error when stage is wrong
107
- raise Errors::HarmonizedStageCodeInvalidError unless DESCRIPTIONS.key?(stage)
108
- end
109
- end
110
-
111
- def to_s
112
- if fuzzy?
113
- return "draft" if @stages.all? { |s| DRAFT_STAGES.include?(s) || CANCELED_STAGES.include?(s) }
114
-
115
- return "published" if @stages.all? { |s| PUBLISHED_STAGES.include?(s) }
116
-
117
- raise Errors::HarmonizedStageRenderingError, "cannot render fuzzy stages"
118
- else
119
- @stages.first
120
- end
121
- end
122
-
123
- def ==(other)
124
- (stages & other.stages) == other.stages
125
- end
126
-
127
- def fuzzy?
128
- @stages.length > 1
129
- end
130
-
131
- def stage
132
- raise Errors::HarmonizedStageRenderingError, "cannot render stage for fuzzy stages" if fuzzy?
133
-
134
- return nil if @stages.empty?
135
-
136
- @stages.first.split(".").first
137
- end
138
-
139
- def substage
140
- raise Errors::HarmonizedStageRenderingError, "cannot render substage for fuzzy stages" if fuzzy?
141
-
142
- @stages.first.split(".").last
143
- end
144
-
145
- def description
146
- DESCRIPTIONS[to_s]
147
- end
148
4
  end
149
5
  end
@@ -0,0 +1,52 @@
1
+ require_relative "../renderer/amendment"
2
+ require_relative "../renderer/urn-amendment"
3
+
4
+ module Pubid::Iso
5
+ module Identifier
6
+ class Amendment < Supplement
7
+ def_delegators 'Pubid::Iso::Identifier::Amendment', :type
8
+
9
+ TYPED_STAGES = {
10
+ damd: {
11
+ abbr: "DAM",
12
+ legacy_abbr: %w[DAmd FPDAM],
13
+ name: "Draft Amendment",
14
+ harmonized_stages: %w[40.00 40.20 40.60 40.92 40.93 40.98 40.99],
15
+ },
16
+ fdamd: {
17
+ abbr: "FDAM",
18
+ legacy_abbr: %w[FDAmd],
19
+ name: "Final Draft Amendment",
20
+ harmonized_stages: %w[50.00 50.20 50.60 50.92 50.98 50.99],
21
+ },
22
+ }.freeze
23
+ def initialize(publisher: "ISO", number: nil, stage: nil, iteration: nil, supplement: nil,
24
+ joint_document: nil, tctype: nil, sctype: nil, wgtype: nil, tcnumber: nil,
25
+ scnumber: nil, wgnumber:nil,
26
+ dir: nil, dirtype: nil, year: nil, amendments: nil,
27
+ corrigendums: nil, type: nil, base: nil, supplements: nil, **opts)
28
+
29
+ if base.year.nil? && base.stage.nil?
30
+ raise Errors::SupplementWithoutYearOrStageError,
31
+ "Cannot apply supplement to document without base identifier edition year or stage"
32
+ end
33
+
34
+ super
35
+ end
36
+
37
+ def self.type
38
+ { key: :amd, title: "Amendment" }
39
+ end
40
+
41
+ def self.get_renderer_class
42
+ Renderer::Amendment
43
+ end
44
+
45
+ def urn
46
+ raise Errors::NoEditionError, "Base document must have edition" unless base_has_edition?
47
+
48
+ Renderer::UrnAmendment.new(get_params).render
49
+ end
50
+ end
51
+ end
52
+ end