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
@@ -0,0 +1,365 @@
1
+ require 'forwardable'
2
+ require_relative "../renderer/urn"
3
+ require_relative "../renderer/urn-tc"
4
+
5
+ module Pubid::Iso
6
+ module Identifier
7
+ class Base < Pubid::Core::Identifier
8
+ extend Forwardable
9
+
10
+ attr_accessor :stage,
11
+ :iteration, :joint_document,
12
+ :tctype, :sctype, :wgtype, :tcnumber, :scnumber, :wgnumber,
13
+ :dirtype,
14
+ # supplement for DIR type identifiers
15
+ :supplement,
16
+ :base,
17
+ :typed_stage,
18
+ :supplements,
19
+ :addendum
20
+
21
+ # Creates new identifier from options provided, includes options from
22
+ # Pubid::Core::Identifier#initialize
23
+ #
24
+ # @param stage [Stage, Symbol, String] stage or typed stage, e.g. "PWI", "NP", "50.00", Stage.new(abbr: :WD), "DTR"
25
+ # @param iteration [Integer] document iteration, eg. "1", "2", "3"
26
+ # @param joint_document [Identifier] joint document
27
+ # @param supplement [Supplement] supplement
28
+ # @param tctype [String] Technical Committee type, eg. "TC", "JTC"
29
+ # @param sctype [String] TC subsommittee, eg. "SC"
30
+ # @param wgtype [String] TC working group type, eg. "AG", "AHG"
31
+ # @param tcnumber [Integer] Technical Committee number, eg. "1", "2"
32
+ # @param scnumber [Integer] Subsommittee number, eg. "1", "2"
33
+ # @param wgnumber [Integer] Working group number, eg. "1", "2"
34
+ # @param dirtype [String] Directives document type, eg. "JTC"
35
+ # @param base [Identifier] base document for supplement's identifier
36
+ # @param type [nil, :tr, :ts, :amd, :cor, :guide, :dir, :tc, Type] document's type, eg. :tr, :ts, :amd, :cor, Type.new(:tr)
37
+ # @raise [Errors::SupplementWithoutYearOrStageError] when trying to apply
38
+ # supplement to the document without edition year or stage
39
+ # @raise [Errors::IsStageIterationError] when trying to apply iteration
40
+ # to document with IS stage
41
+ # @raise [Errors::IterationWithoutStageError] when trying to applu iteration
42
+ # to document without stage
43
+ # @see Supplement
44
+ # @see Identifier
45
+ # @see Pubid::Core::Identifier
46
+ # @see Parser
47
+ def initialize(publisher: "ISO", number: nil, stage: nil, iteration: nil, supplement: nil,
48
+ joint_document: nil, tctype: nil, sctype: nil, wgtype: nil, tcnumber: nil,
49
+ scnumber: nil, wgnumber:nil,
50
+ dir: nil, dirtype: nil, year: nil, amendments: nil,
51
+ corrigendums: nil, type: nil, base: nil, supplements: nil,
52
+ part: nil, addendum: nil, **opts)
53
+ super(**opts.merge(number: number, publisher: publisher, year: year,
54
+ amendments: amendments, corrigendums: corrigendums))
55
+
56
+ if supplements
57
+ @supplements = supplements.map do |supplement|
58
+ if supplement.is_a?(Hash)
59
+ self.class.get_transformer_class.new.apply(:supplements => [supplement])[:supplements].first
60
+ else
61
+ supplement
62
+ end
63
+ end
64
+ end
65
+
66
+ if stage
67
+ if stage.is_a?(Stage)
68
+ @stage = stage
69
+ @typed_stage = resolve_typed_stage(@stage.harmonized_code) unless @stage.abbr
70
+ elsif self.class.has_typed_stage?(stage)
71
+ @typed_stage, @stage = find_typed_stage(stage)
72
+ else
73
+ @stage = Stage.parse(stage)
74
+ # resolve typed stage when harmonized code provided as stage
75
+ # or stage abbreviation was not resolved
76
+ if /\A[\d.]+\z/.match?(stage) || @stage.empty_abbr?(with_prf: true)
77
+ @typed_stage = resolve_typed_stage(@stage.harmonized_code)
78
+ end
79
+ end
80
+ elsif iteration && !is_a?(Supplement)
81
+ raise Errors::IterationWithoutStageError, "Document without stage cannot have iteration"
82
+ end
83
+
84
+ @iteration = iteration.to_i if iteration
85
+ @supplement = supplement if supplement
86
+ @joint_document = joint_document if joint_document
87
+ @tctype = tctype if tctype
88
+ @sctype = sctype.to_s if sctype
89
+ @wgtype = wgtype.to_s if wgtype
90
+ @tcnumber = tcnumber.to_s if tcnumber
91
+ @scnumber = scnumber.to_s if scnumber
92
+ @wgnumber = wgnumber.to_s if wgnumber
93
+ @dir = dir.to_s if dir
94
+ @dirtype = dirtype.to_s if dirtype
95
+ @base = base if base
96
+ @part = part if part
97
+ @addendum = addendum if addendum
98
+ end
99
+
100
+ # @param typed_stage [String, Symbol] eg. "DTR" or :dtr
101
+ # @return [[Symbol, Stage]] typed stage and stage with assigned harmonized codes
102
+ def find_typed_stage(typed_stage)
103
+ if typed_stage.is_a?(Symbol)
104
+ return [typed_stage,
105
+ Stage.new(
106
+ harmonized_code: HarmonizedStageCode.new(self.class::TYPED_STAGES[typed_stage][:harmonized_stages])),
107
+ ]
108
+ end
109
+
110
+ typed_stage = self.class::TYPED_STAGES.find do |_, v|
111
+ if v[:abbr].is_a?(Hash)
112
+ v[:abbr].value?(typed_stage)
113
+ else
114
+ if v.key?(:legacy_abbr)
115
+ v[:legacy_abbr].include?(typed_stage) || v[:abbr] == typed_stage
116
+ else
117
+ v[:abbr] == typed_stage
118
+ end
119
+ #
120
+ # v[:abbr] == typed_stage
121
+ end
122
+ end
123
+
124
+ [typed_stage.first,
125
+ Stage.new(harmonized_code: HarmonizedStageCode.new(typed_stage[1][:harmonized_stages]))]
126
+ end
127
+
128
+ # Resolve typed stage using stage harmonized stage code
129
+ # @param harmonized_code [HarmonizedStageCode]
130
+ # @return [Symbol, nil] typed stage or nil
131
+ def resolve_typed_stage(harmonized_code)
132
+ self.class::TYPED_STAGES.each do |k, v|
133
+ if (v[:harmonized_stages] & harmonized_code.stages) == harmonized_code.stages
134
+ return k
135
+ end
136
+ end
137
+ nil
138
+ end
139
+
140
+ class << self
141
+ def supplements_has_type?(supplements, type)
142
+ supplements.any? do |supplement|
143
+ supplement.type[:key] == type
144
+ end
145
+ end
146
+
147
+ def supplement_by_type(supplements, type)
148
+ supplements.select { |supplement| supplement.type[:key] == type }.first
149
+ end
150
+
151
+ def transform_supplements(supplements_params, base_params)
152
+ supplements = supplements_params.map do |supplement|
153
+ Identifier.create(number: supplement[:number], year: supplement[:year],
154
+ stage: supplement[:typed_stage], edition: supplement[:edition],
155
+ iteration: supplement[:iteration], type: (supplement[:type] || !supplement[:typed_stage] && :sup),
156
+ publisher: supplement[:publisher], base: Identifier.create(**base_params))
157
+ end
158
+
159
+ return supplements.first if supplements.count == 1
160
+
161
+ # update corrigendum base to amendment
162
+ if supplements_has_type?(supplements, :cor) &&
163
+ (supplements_has_type?(supplements, :amd) ||
164
+ supplements_has_type?(supplements, :sup)) && supplements.count == 2
165
+
166
+ supplement = supplement_by_type(supplements, :cor)
167
+ supplement.base = supplement_by_type(supplements, :amd) ||
168
+ supplement_by_type(supplements, :sup)
169
+ supplement
170
+ else
171
+ raise Errors::SupplementRenderingError, "don't know how to render provided supplements"
172
+ end
173
+ end
174
+
175
+ def transform(params)
176
+ identifier_params = params.map do |k, v|
177
+ get_transformer_class.new.apply(k => v)
178
+ end.inject({}, :merge)
179
+
180
+ # return supplement if supplements applied
181
+ if identifier_params[:supplements]
182
+ return transform_supplements(
183
+ identifier_params[:supplements],
184
+ identifier_params.dup.tap { |h| h.delete(:supplements) }
185
+ )
186
+ end
187
+
188
+ Identifier.create(**identifier_params)
189
+ end
190
+
191
+ def descendants
192
+ ObjectSpace.each_object(Class).select { |klass| klass < self }
193
+ end
194
+
195
+ # @param type [Symbol, String] eg. :tr, :ts, "TS"
196
+ # @return [Boolean] true if provided type matches with identifier's class type
197
+ def has_type?(type)
198
+ return type == self.type[:key] if type.is_a?(Symbol)
199
+
200
+ self.type.key?(:values) ? self.type[:values].include?(type) : type.to_s.downcase.to_sym == self.type[:key]
201
+ end
202
+
203
+ # @param typed_stage [String, Symbol] typed stage, eg. "DTR" or :dtr
204
+ # @return [Boolean] true when identifier has associated typed stage
205
+ def has_typed_stage?(typed_stage)
206
+ return self::TYPED_STAGES.key?(typed_stage) if typed_stage.is_a?(Symbol)
207
+
208
+ self::TYPED_STAGES.any? do |_, v|
209
+ if v[:abbr].is_a?(Hash)
210
+ v[:abbr].value?(typed_stage)
211
+ else
212
+ if v.key?(:legacy_abbr)
213
+ v[:legacy_abbr].include?(typed_stage) || v[:abbr] == typed_stage
214
+ else
215
+ v[:abbr] == typed_stage
216
+ end
217
+ end
218
+ end
219
+ end
220
+
221
+ def get_amendment_class
222
+ Pubid::Iso::Amendment
223
+ end
224
+
225
+ def get_corrigendum_class
226
+ Pubid::Iso::Corrigendum
227
+ end
228
+
229
+ def get_parser_class
230
+ Parser
231
+ end
232
+
233
+ def get_transformer_class
234
+ Transformer
235
+ end
236
+
237
+ def get_renderer_class
238
+ Renderer::Base
239
+ end
240
+
241
+ def get_update_codes
242
+ UPDATE_CODES
243
+ end
244
+ end
245
+
246
+ # Render URN identifier
247
+ # @return [String] URN identifier
248
+ def urn
249
+ ((@tctype && Renderer::UrnTc) || Pubid::Iso::Renderer::Urn).new(
250
+ get_params.merge({ type: type[:key] }),
251
+ ).render + (language ? ":#{language}" : "")
252
+ end
253
+
254
+ def get_params
255
+ instance_variables.map do |var|
256
+ if var.to_s == "@typed_stage" && @typed_stage
257
+ [:typed_stage, self.class::TYPED_STAGES[@typed_stage][:abbr]]
258
+ else
259
+ [var.to_s.gsub("@", "").to_sym, instance_variable_get(var)]
260
+ end
261
+ end.to_h
262
+ end
263
+
264
+ # @param format [:ref_num_short,:ref_num_long,:ref_dated,:ref_dated_long,:ref_undated,:ref_undated_long] create reference with specified format
265
+ # Format options are:
266
+ # :ref_num_short -- instance reference number: 1 letter language code + short form (DAM) + dated
267
+ # :ref_num_long -- instance reference number long: 2 letter language code + long form (DAmd) + dated
268
+ # :ref_dated -- reference dated: no language code + short form (DAM) + dated
269
+ # :ref_dated_long -- reference dated long: no language code + short form (DAM) + dated
270
+ # :ref_undated -- reference undated: no language code + short form (DAM) + undated
271
+ # :ref_undated_long -- reference undated long: 1 letter language code + long form (DAmd) + undated
272
+ def resolve_format(format = :ref_dated_long)
273
+ options = { with_date: true }
274
+ case format
275
+ when :ref_num_short
276
+ options[:with_language_code] = :single
277
+ options[:stage_format_long] = false
278
+ when :ref_num_long
279
+ options[:with_language_code] = :iso
280
+ options[:stage_format_long] = true
281
+ when :ref_dated
282
+ options[:with_language_code] = :none
283
+ options[:stage_format_long] = false
284
+ when :ref_dated_long
285
+ options[:with_language_code] = :none
286
+ options[:stage_format_long] = true
287
+ when :ref_undated
288
+ options[:with_language_code] = :none
289
+ options[:stage_format_long] = false
290
+ options[:with_date] = false
291
+ when :ref_undated_long
292
+ options[:with_language_code] = :none
293
+ options[:stage_format_long] = true
294
+ options[:with_date] = false
295
+ else
296
+ raise Errors::WrongFormat, "#{format} is not available"
297
+ end
298
+ options
299
+ end
300
+
301
+ # Renders pubid identifier
302
+ #
303
+ # @param lang [:french,:russian] use language specific renderer
304
+ # @param with_date [Boolean] render identifier with date
305
+ # @param with_edition [Boolean] render identifier with edition
306
+ # @param stage_format_long [Boolean] render with long or short stage format
307
+ # @param format [:ref_num_short,:ref_num_long,:ref_dated,:ref_dated_long,:ref_undated,:ref_undated_long] create reference with specified format
308
+ # @param with_prf [Boolean] include PRF stage in output
309
+ # Format options are:
310
+ # :ref_num_short -- instance reference number: 1 letter language code + short form (DAM) + dated
311
+ # :ref_num_long -- instance reference number long: 2 letter language code + long form (DAmd) + dated
312
+ # :ref_dated -- reference dated: no language code + short form (DAM) + dated
313
+ # :ref_dated_long -- reference dated long: no language code + short form (DAM) + dated
314
+ # :ref_undated -- reference undated: no language code + short form (DAM) + undated
315
+ # :ref_undated_long -- reference undated long: 1 letter language code + long form (DAmd) + undated
316
+ # @return [String] pubid identifier
317
+ def to_s(lang: nil, with_edition: false, with_prf: false,
318
+ format: :ref_dated_long)
319
+
320
+ options = resolve_format(format)
321
+ options[:with_edition] = with_edition
322
+ options[:with_prf] = with_prf
323
+ options[:language] = lang
324
+
325
+ self.class.get_renderer_class.new(get_params).render(**options) +
326
+ if @joint_document
327
+ render_joint_document(@joint_document)
328
+ end.to_s
329
+ end
330
+
331
+ def render_joint_document(joint_document)
332
+ "|#{@joint_document}"
333
+ end
334
+
335
+ # Return typed stage abbreviation, eg. "FDTR", "DIS", "TR"
336
+ def typed_stage_abbrev
337
+ if self.class::TYPED_STAGES.key?(typed_stage)
338
+ self.class::TYPED_STAGES[typed_stage][:abbr]
339
+ else
340
+ "#{stage.abbr} #{type[:key].to_s.upcase}"
341
+ end
342
+ end
343
+
344
+ # Return typed stage name, eg. "Final Draft Technical Report" for "FDTR"
345
+ def typed_stage_name
346
+ if self.class::TYPED_STAGES.key?(typed_stage)
347
+ self.class::TYPED_STAGES[typed_stage][:name]
348
+ else
349
+ "#{stage.name} #{type[:title]}"
350
+ end
351
+ end
352
+
353
+ def ==(other)
354
+ get_params == other.get_params
355
+ end
356
+
357
+ # returns root identifier
358
+ def root
359
+ return base.base if base&.base
360
+
361
+ base || self
362
+ end
363
+ end
364
+ end
365
+ end
@@ -0,0 +1,53 @@
1
+ require_relative "../renderer/corrigendum"
2
+ require_relative "../renderer/urn-corrigendum"
3
+
4
+ module Pubid::Iso
5
+ module Identifier
6
+ class Corrigendum < Supplement
7
+ def_delegators 'Pubid::Iso::Identifier::Corrigendum', :type
8
+
9
+ TYPED_STAGES = {
10
+ dcor: {
11
+ abbr: "DCOR",
12
+ legacy_abbr: %w[DCor],
13
+ name: "Draft Corrigendum",
14
+ harmonized_stages: %w[40.00 40.20 40.60 40.92 40.93 40.98 40.99],
15
+ },
16
+ fdcor: {
17
+ abbr: "FDCOR",
18
+ legacy_abbr: %w[FDCor FCOR],
19
+ name: "Final Draft Corrigendum",
20
+ harmonized_stages: %w[50.00 50.20 50.60 50.92 50.98 50.99],
21
+ },
22
+ }.freeze
23
+
24
+ def initialize(publisher: "ISO", number: nil, stage: nil, iteration: nil, supplement: nil,
25
+ joint_document: nil, tctype: nil, sctype: nil, wgtype: nil, tcnumber: nil,
26
+ scnumber: nil, wgnumber:nil,
27
+ dir: nil, dirtype: nil, year: nil, amendments: nil,
28
+ corrigendums: nil, type: nil, base: nil, supplements: nil, **opts)
29
+
30
+ if base.year.nil? && base.stage.nil?
31
+ raise Errors::SupplementWithoutYearOrStageError,
32
+ "Cannot apply supplement to document without base identifier edition year or stage"
33
+ end
34
+
35
+ super
36
+ end
37
+
38
+ def self.type
39
+ { key: :cor, title: "Corrigendum" }
40
+ end
41
+
42
+ def self.get_renderer_class
43
+ Renderer::Corrigendum
44
+ end
45
+
46
+ def urn
47
+ raise Errors::NoEditionError, "Base document must have edition" unless base_has_edition?
48
+
49
+ Renderer::UrnCorrigendum.new(get_params).render
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,29 @@
1
+ require_relative "../renderer/dir"
2
+ require_relative "../renderer/urn-dir"
3
+
4
+ module Pubid::Iso
5
+ module Identifier
6
+ class Directives < Base
7
+ def_delegators 'Pubid::Iso::Identifier::Directives', :type
8
+
9
+ TYPED_STAGES = {}.freeze
10
+
11
+ def self.type
12
+ { key: :dir, title: "Directives" }
13
+ end
14
+
15
+ def self.get_renderer_class
16
+ Renderer::Dir
17
+ end
18
+
19
+ def urn
20
+ Renderer::UrnDir.new(get_params).render
21
+ end
22
+
23
+ def render_joint_document(joint_document)
24
+ # remove "DIR" for short joint document format
25
+ "#{@joint_document}".sub(" DIR", "")
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,32 @@
1
+ require_relative "../renderer/guide"
2
+
3
+ module Pubid::Iso
4
+ module Identifier
5
+ class Guide < Base
6
+ def_delegators 'Pubid::Iso::Identifier::Guide', :type
7
+
8
+ TYPED_STAGES = {
9
+ dguide: {
10
+ abbr: "DGuide",
11
+ legacy_abbr: %w[DGUIDE],
12
+ name: "Draft Guide",
13
+ harmonized_stages: %w[40.00 40.20 40.60 40.92 40.93 40.98 40.99],
14
+ },
15
+ fdguide: {
16
+ abbr: "FDGuide",
17
+ legacy_abbr: ["FD GUIDE", "FD Guide"],
18
+ name: "Final Draft Guide",
19
+ harmonized_stages: %w[50.00 50.20 50.60 50.92 50.98 50.99],
20
+ },
21
+ }.freeze
22
+
23
+ def self.get_renderer_class
24
+ Renderer::Guide
25
+ end
26
+
27
+ def self.type
28
+ { key: :guide, title: "Guide" }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,45 @@
1
+ module Pubid::Iso
2
+ module Identifier
3
+ class InternationalStandard < Base
4
+ def_delegators 'Pubid::Iso::Identifier::InternationalStandard', :type
5
+
6
+ TYPED_STAGES = {
7
+ dis: {
8
+ abbr: "DIS",
9
+ name: "Draft International Standard",
10
+ harmonized_stages: %w[40.00 40.20 40.60 40.92 40.93 40.98 40.99],
11
+ },
12
+ fdis: {
13
+ abbr: "FDIS",
14
+ name: "Final Draft International Standard",
15
+ harmonized_stages: %w[50.00 50.20 50.60 50.92 50.98 50.99],
16
+ },
17
+ }.freeze
18
+
19
+ def initialize(publisher: "ISO", number: nil, stage: nil, iteration: nil, supplement: nil,
20
+ joint_document: nil, tctype: nil, sctype: nil, wgtype: nil, tcnumber: nil,
21
+ scnumber: nil, wgnumber:nil,
22
+ dir: nil, dirtype: nil, year: nil, amendments: nil,
23
+ corrigendums: nil, type: nil, base: nil, supplements: nil, **opts)
24
+
25
+ if iteration && stage.nil?
26
+ raise Errors::IsStageIterationError, "IS stage document cannot have iteration"
27
+ end
28
+
29
+ super
30
+ end
31
+
32
+ def typed_stage_abbrev
33
+ if self.class::TYPED_STAGES.key?(typed_stage)
34
+ super
35
+ else
36
+ stage.abbr
37
+ end
38
+ end
39
+
40
+ def self.type
41
+ { key: :is, title: "International Standard" }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,30 @@
1
+ require_relative "../renderer/international_standardized_profile"
2
+
3
+ module Pubid::Iso
4
+ module Identifier
5
+ class InternationalStandardizedProfile < Base
6
+ def_delegators 'Pubid::Iso::Identifier::InternationalStandardizedProfile', :type
7
+
8
+ TYPED_STAGES = {
9
+ dis: {
10
+ abbr: "DISP",
11
+ name: "Draft International Standardized Profile",
12
+ harmonized_stages: %w[40.00 40.20 40.60 40.92 40.93 40.98 40.99],
13
+ },
14
+ fdis: {
15
+ abbr: "FDISP",
16
+ name: "Final Draft International Standardized Profile",
17
+ harmonized_stages: %w[50.00 50.20 50.60 50.92],
18
+ },
19
+ }.freeze
20
+
21
+ def self.type
22
+ { key: :isp, title: "International Standardized Profile" }
23
+ end
24
+
25
+ def self.get_renderer_class
26
+ Renderer::InternationalStandardizedProfile
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ require_relative "../renderer/international_workshop_agreement"
2
+
3
+ module Pubid::Iso
4
+ module Identifier
5
+ class InternationalWorkshopAgreement < Base
6
+ def_delegators 'Pubid::Iso::Identifier::InternationalWorkshopAgreement', :type
7
+
8
+ TYPED_STAGES = {
9
+ dis: {
10
+ abbr: "DIWA",
11
+ name: "Draft International Workshop Agreement",
12
+ harmonized_stages: %w[40.00 40.20 40.60 40.92 40.93 40.98 40.99],
13
+ },
14
+ }.freeze
15
+
16
+ def self.type
17
+ { key: :iwa, title: "International Workshop Agreement" }
18
+ end
19
+
20
+ def self.get_renderer_class
21
+ Renderer::InternationalWorkshopAgreement
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,30 @@
1
+ require_relative "../renderer/publicly_available_specification"
2
+
3
+ module Pubid::Iso
4
+ module Identifier
5
+ class PubliclyAvailableSpecification < Base
6
+ def_delegators 'Pubid::Iso::Identifier::PubliclyAvailableSpecification', :type
7
+
8
+ TYPED_STAGES = {
9
+ dpas: {
10
+ abbr: "DPAS",
11
+ name: "Publicly Available Specification Draft",
12
+ harmonized_stages: %w[40.00 40.20 40.60 40.92 40.93 40.98 40.99],
13
+ },
14
+ fdpas: {
15
+ abbr: "FDPAS",
16
+ name: "Publicly Available Specification Final Draft",
17
+ harmonized_stages: %w[50.00 50.20 50.60 50.92 50.98 50.99],
18
+ },
19
+ }.freeze
20
+
21
+ def self.type
22
+ { key: :pas, title: "Publicly Available Specification" }
23
+ end
24
+
25
+ def self.get_renderer_class
26
+ Renderer::PubliclyAvailableSpecification
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,19 @@
1
+ require_relative "../renderer/recommendation"
2
+
3
+ module Pubid::Iso
4
+ module Identifier
5
+ class Recommendation < Base
6
+ def_delegators 'Pubid::Iso::Identifier::Recommendation', :type
7
+
8
+ TYPED_STAGES = {}.freeze
9
+
10
+ def self.type
11
+ { key: :r, title: "Recommendation" }
12
+ end
13
+
14
+ def self.get_renderer_class
15
+ Renderer::Recommendation
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,39 @@
1
+ require_relative "../renderer/supplement"
2
+ require_relative "../renderer/urn-supplement"
3
+
4
+ module Pubid::Iso
5
+ module Identifier
6
+ class Supplement < Base
7
+ def_delegators 'Pubid::Iso::Identifier::Supplement', :type
8
+
9
+ TYPED_STAGES = {
10
+ dsuppl: {
11
+ abbr: "DSuppl",
12
+ name: "Draft Supplement",
13
+ harmonized_stages: %w[40.00 40.20 40.60 40.92 40.93 40.98 40.99],
14
+ },
15
+ fdsuppl: {
16
+ abbr: "FDIS Suppl",
17
+ name: "Final Draft Supplement",
18
+ harmonized_stages: %w[50.00 50.20 50.60 50.92 50.98 50.99],
19
+ },
20
+ }.freeze
21
+
22
+ def base_has_edition?
23
+ @base.base.nil? && !@base.edition.nil? || (!@base.base.nil? && !@base.base.edition.nil?)
24
+ end
25
+
26
+ def self.type
27
+ { key: :sup, title: "Supplement", values: %w[Supplement Suppl SUP] }
28
+ end
29
+
30
+ def self.get_renderer_class
31
+ Renderer::Supplement
32
+ end
33
+
34
+ def urn
35
+ Renderer::UrnSupplement.new(get_params).render
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,19 @@
1
+ require_relative "../renderer/technical_committee"
2
+
3
+ module Pubid::Iso
4
+ module Identifier
5
+ class TechnicalCommittee < Base
6
+ def_delegators 'Pubid::Iso::Identifier::TechnicalCommittee', :type
7
+
8
+ TYPED_STAGES = {}.freeze
9
+
10
+ def self.type
11
+ { key: :tc, title: "Technical Committee" }
12
+ end
13
+
14
+ def self.get_renderer_class
15
+ Renderer::TechnicalCommittee
16
+ end
17
+ end
18
+ end
19
+ end