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.
- checksums.yaml +4 -4
- data/README.adoc +118 -39
- data/lib/pubid/iso/errors.rb +0 -3
- data/lib/pubid/iso/harmonized_stage_code.rb +1 -145
- data/lib/pubid/iso/identifier/amendment.rb +52 -0
- data/lib/pubid/iso/identifier/base.rb +365 -0
- data/lib/pubid/iso/identifier/corrigendum.rb +53 -0
- data/lib/pubid/iso/identifier/directives.rb +29 -0
- data/lib/pubid/iso/identifier/guide.rb +32 -0
- data/lib/pubid/iso/identifier/international_standard.rb +45 -0
- data/lib/pubid/iso/identifier/international_standardized_profile.rb +30 -0
- data/lib/pubid/iso/identifier/international_workshop_agreement.rb +25 -0
- data/lib/pubid/iso/identifier/publicly_available_specification.rb +30 -0
- data/lib/pubid/iso/identifier/recommendation.rb +19 -0
- data/lib/pubid/iso/identifier/supplement.rb +39 -0
- data/lib/pubid/iso/identifier/technical_committee.rb +19 -0
- data/lib/pubid/iso/identifier/technical_report.rb +30 -0
- data/lib/pubid/iso/identifier/technical_specification.rb +30 -0
- data/lib/pubid/iso/identifier/technology_trends_assessments.rb +30 -0
- data/lib/pubid/iso/identifier.rb +39 -264
- data/lib/pubid/iso/parser.rb +56 -20
- data/lib/pubid/iso/renderer/amendment.rb +7 -0
- data/lib/pubid/iso/renderer/base.rb +129 -98
- data/lib/pubid/iso/renderer/corrigendum.rb +7 -0
- data/lib/pubid/iso/renderer/dir.rb +5 -3
- data/lib/pubid/iso/renderer/guide.rb +19 -0
- data/lib/pubid/iso/renderer/international_standard.rb +11 -0
- data/lib/pubid/iso/renderer/international_standardized_profile.rb +13 -0
- data/lib/pubid/iso/renderer/international_workshop_agreement.rb +17 -0
- data/lib/pubid/iso/renderer/publicly_available_specification.rb +12 -0
- data/lib/pubid/iso/renderer/recommendation.rb +13 -0
- data/lib/pubid/iso/renderer/supplement.rb +63 -0
- data/lib/pubid/iso/renderer/technical_committee.rb +47 -0
- data/lib/pubid/iso/renderer/technical_report.rb +13 -0
- data/lib/pubid/iso/renderer/technical_specification.rb +13 -0
- data/lib/pubid/iso/renderer/technology_trends_assessments.rb +13 -0
- data/lib/pubid/iso/renderer/urn-amendment.rb +12 -0
- data/lib/pubid/iso/renderer/urn-corrigendum.rb +12 -0
- data/lib/pubid/iso/renderer/urn-dir.rb +11 -3
- data/lib/pubid/iso/renderer/urn-supplement.rb +31 -0
- data/lib/pubid/iso/renderer/urn-tc.rb +2 -0
- data/lib/pubid/iso/renderer/urn.rb +25 -13
- data/lib/pubid/iso/stage.rb +1 -99
- data/lib/pubid/iso/transformer.rb +91 -107
- data/lib/pubid/iso/type.rb +9 -1
- data/lib/pubid/iso/version.rb +1 -1
- data/lib/pubid/iso.rb +20 -14
- data/stages.yaml +93 -0
- data/update_codes.yaml +1 -0
- metadata +37 -11
- data/lib/pubid/iso/amendment.rb +0 -15
- data/lib/pubid/iso/corrigendum.rb +0 -31
- data/lib/pubid/iso/renderer/french.rb +0 -29
- data/lib/pubid/iso/renderer/russian.rb +0 -64
- data/lib/pubid/iso/renderer/tc.rb +0 -30
- data/lib/pubid/iso/supplement.rb +0 -56
- data/lib/pubid/iso/typed_stage.rb +0 -204
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative "../renderer/technical_report"
|
2
|
+
|
3
|
+
module Pubid::Iso
|
4
|
+
module Identifier
|
5
|
+
class TechnicalReport < Base
|
6
|
+
def_delegators 'Pubid::Iso::Identifier::TechnicalReport', :type
|
7
|
+
|
8
|
+
TYPED_STAGES = {
|
9
|
+
dtr: {
|
10
|
+
abbr: "DTR",
|
11
|
+
name: "Draft Technical Report",
|
12
|
+
harmonized_stages: %w[40.00 40.20 40.60 40.92 40.93 40.98 40.99],
|
13
|
+
},
|
14
|
+
fdtr: {
|
15
|
+
abbr: "FDTR",
|
16
|
+
name: "Final Draft Technical Report",
|
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: :tr, title: "Technical Report" }
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.get_renderer_class
|
26
|
+
Renderer::TechnicalReport
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative "../renderer/technical_specification"
|
2
|
+
|
3
|
+
module Pubid::Iso
|
4
|
+
module Identifier
|
5
|
+
class TechnicalSpecification < Base
|
6
|
+
def_delegators 'Pubid::Iso::Identifier::TechnicalSpecification', :type
|
7
|
+
|
8
|
+
TYPED_STAGES = {
|
9
|
+
dts: {
|
10
|
+
abbr: "DTS",
|
11
|
+
name: "Draft Technical Specification",
|
12
|
+
harmonized_stages: %w[40.00 40.20 40.60 40.92 40.93 40.98 40.99],
|
13
|
+
},
|
14
|
+
fdts: {
|
15
|
+
abbr: "FDTS",
|
16
|
+
name: "Final Draft Technical Specification",
|
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: :ts, title: "Technical Specification" }
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.get_renderer_class
|
26
|
+
Renderer::TechnicalSpecification
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative "../renderer/technology_trends_assessments"
|
2
|
+
|
3
|
+
module Pubid::Iso
|
4
|
+
module Identifier
|
5
|
+
class TechnologyTrendsAssessments < Base
|
6
|
+
def_delegators 'Pubid::Iso::Identifier::TechnologyTrendsAssessments', :type
|
7
|
+
|
8
|
+
TYPED_STAGES = {
|
9
|
+
dtta: {
|
10
|
+
abbr: "DTTA",
|
11
|
+
name: "Technology Trends Assessments Draft",
|
12
|
+
harmonized_stages: %w[40.00 40.20 40.60 40.92 40.93 40.98 40.99],
|
13
|
+
},
|
14
|
+
fdtta: {
|
15
|
+
abbr: "FDTTA",
|
16
|
+
name: "Technology Trends Assessments 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: :tta, title: "Technology Trends Assessments" }
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.get_renderer_class
|
26
|
+
Renderer::TechnologyTrendsAssessments
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/pubid/iso/identifier.rb
CHANGED
@@ -1,281 +1,56 @@
|
|
1
1
|
module Pubid::Iso
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
# @param wgnumber [Integer] Working group number, eg. "1", "2"
|
26
|
-
# @param dirtype [String] Directives document type, eg. "JTC"
|
27
|
-
# @param base [Identifier] base document for supplement's identifier
|
28
|
-
# @param type [nil, :tr, :ts, :amd, :cor, :guide, :dir, :tc, Type] document's type, eg. :tr, :ts, :amd, :cor, Type.new(:tr)
|
29
|
-
# @raise [Errors::SupplementWithoutYearOrStageError] when trying to apply
|
30
|
-
# supplement to the document without edition year or stage
|
31
|
-
# @raise [Errors::IsStageIterationError] when trying to apply iteration
|
32
|
-
# to document with IS stage
|
33
|
-
# @raise [Errors::IterationWithoutStageError] when trying to applu iteration
|
34
|
-
# to document without stage
|
35
|
-
# @see Supplement
|
36
|
-
# @see Identifier
|
37
|
-
# @see Pubid::Core::Identifier
|
38
|
-
# @see Parser
|
39
|
-
#
|
40
|
-
def initialize(publisher: "ISO", number: nil, stage: nil, iteration: nil, supplement: nil,
|
41
|
-
joint_document: nil, tctype: nil, sctype: nil, wgtype: nil, tcnumber: nil,
|
42
|
-
scnumber: nil, wgnumber:nil,
|
43
|
-
dir: nil, dirtype: nil, year: nil, amendments: nil,
|
44
|
-
corrigendums: nil, type: nil, base: nil, supplements: nil, **opts)
|
45
|
-
super(**opts.merge(number: number, publisher: publisher, year: year,
|
46
|
-
amendments: amendments, corrigendums: corrigendums))
|
47
|
-
|
48
|
-
if supplements
|
49
|
-
@supplements = supplements.map do |supplement|
|
50
|
-
if supplement.is_a?(Hash)
|
51
|
-
self.class.get_transformer_class.new.apply(:supplements => [supplement])[:supplements].first
|
52
|
-
else
|
53
|
-
supplement
|
2
|
+
module Identifier
|
3
|
+
class << self
|
4
|
+
# Resolve identifier's class and create new identifier
|
5
|
+
# @see Pubid::Identifier::Base.initialize for available options
|
6
|
+
def create(**opts)
|
7
|
+
resolve_identifier(
|
8
|
+
opts[:type],
|
9
|
+
opts[:stage],
|
10
|
+
opts.reject { |k, _v| [:type, :stage].include?(k) })
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param typed_stage_or_stage [String] typed stage or stage
|
14
|
+
# @return identifier's class
|
15
|
+
def resolve_identifier(type, typed_stage_or_stage, parameters = {})
|
16
|
+
return Identifier::InternationalStandard.new(**parameters) if type.nil? && typed_stage_or_stage.nil?
|
17
|
+
|
18
|
+
Base.descendants.each do |identifier_type|
|
19
|
+
if type
|
20
|
+
return identifier_type.new(stage: typed_stage_or_stage, **parameters) if identifier_type.has_type?(type)
|
21
|
+
|
22
|
+
next
|
23
|
+
elsif identifier_type.has_typed_stage?(typed_stage_or_stage)
|
24
|
+
return identifier_type.new(stage: typed_stage_or_stage, **parameters)
|
54
25
|
end
|
55
26
|
end
|
56
|
-
end
|
57
|
-
|
58
|
-
if %i(amd cor).include?(type) && (base.year.nil? && base.stage.nil?)
|
59
|
-
raise Errors::SupplementWithoutYearOrStageError,
|
60
|
-
"Cannot apply supplement to document without base identifieredition year or stage"
|
61
|
-
end
|
62
|
-
|
63
|
-
if stage.is_a?(TypedStage)
|
64
|
-
@typed_stage = stage
|
65
|
-
# add type to typed stage when missing (case for amendment with stage, eg. "CD Amd")
|
66
|
-
@typed_stage.type = Type.new(type) if @typed_stage.type.nil? && type
|
67
|
-
elsif stage || type
|
68
|
-
@typed_stage = if type
|
69
|
-
TypedStage.new(type: type.is_a?(Type) ? type : Type.new(type))
|
70
|
-
else
|
71
|
-
TypedStage.new
|
72
|
-
end
|
73
27
|
|
74
|
-
|
75
|
-
|
28
|
+
# When stage is not typed stage and type is not defined
|
29
|
+
if type.nil? && (typed_stage_or_stage.is_a?(Stage) || Stage.has_stage?(typed_stage_or_stage))
|
30
|
+
return Identifier::InternationalStandard.new(stage: typed_stage_or_stage, **parameters)
|
76
31
|
end
|
77
32
|
|
78
|
-
if
|
79
|
-
provided_type = @typed_stage.type
|
33
|
+
raise Errors::TypeStageParseError, "cannot parse typed stage or stage '#{typed_stage_or_stage}'" if type.nil?
|
80
34
|
|
81
|
-
|
82
|
-
if !provided_type.nil? && @typed_stage.type != provided_type
|
83
|
-
raise Errors::StageInvalidError,
|
84
|
-
"cannot assign typed stage for document with different type (#{provided_type} vs #{@typed_stage.type})"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
elsif iteration
|
88
|
-
raise Errors::IterationWithoutStageError, "Document without stage cannot have iteration"
|
35
|
+
raise Errors::ParseTypeError, "cannot parse type #{type}"
|
89
36
|
end
|
90
37
|
|
91
|
-
@
|
92
|
-
|
93
|
-
|
94
|
-
@tctype = tctype if tctype
|
95
|
-
@sctype = sctype.to_s if sctype
|
96
|
-
@wgtype = wgtype.to_s if wgtype
|
97
|
-
@tcnumber = tcnumber.to_s if tcnumber
|
98
|
-
@scnumber = scnumber.to_s if scnumber
|
99
|
-
@wgnumber = wgnumber.to_s if wgnumber
|
100
|
-
@dir = dir.to_s if dir
|
101
|
-
@dirtype = dirtype.to_s if dirtype
|
102
|
-
@base = base if base
|
103
|
-
end
|
104
|
-
|
105
|
-
def self.parse_from_title(title)
|
106
|
-
title.split.reverse.inject(title) do |acc, part|
|
107
|
-
return parse(acc)
|
108
|
-
rescue Pubid::Core::Errors::ParseError
|
109
|
-
# delete parts from the title until it's parseable
|
110
|
-
acc.reverse.sub(part.reverse, "").reverse.strip
|
38
|
+
# @see Pubid::Identifier::Base.parse
|
39
|
+
def parse(*args)
|
40
|
+
Base.parse(*args)
|
111
41
|
end
|
112
|
-
end
|
113
42
|
|
114
|
-
|
115
|
-
def
|
116
|
-
|
117
|
-
|
43
|
+
# Parse identifier from title
|
44
|
+
def parse_from_title(title)
|
45
|
+
title.split.reverse.inject(title) do |acc, part|
|
46
|
+
return Base.parse(acc)
|
47
|
+
rescue Pubid::Core::Errors::ParseError
|
48
|
+
# delete parts from the title until it's parseable
|
49
|
+
acc.reverse.sub(part.reverse, "").reverse.strip
|
118
50
|
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def supplement_by_type(supplements, type)
|
122
|
-
supplements.select { |supplement| supplement.type == type }.first
|
123
|
-
end
|
124
|
-
|
125
|
-
def transform_supplements(supplements_params, base_params)
|
126
|
-
supplements = supplements_params.map do |supplement|
|
127
|
-
new(number: supplement[:number], year: supplement[:year],
|
128
|
-
stage: supplement[:typed_stage], edition: supplement[:edition],
|
129
|
-
iteration: supplement[:iteration],
|
130
|
-
base: new(**base_params))
|
131
|
-
end
|
132
|
-
|
133
|
-
return supplements.first if supplements.count == 1
|
134
|
-
|
135
|
-
# update corrigendum base to amendment
|
136
|
-
if supplements_has_type?(supplements, :cor) &&
|
137
|
-
supplements_has_type?(supplements, :amd) && supplements.count == 2
|
138
|
-
|
139
|
-
supplement = supplement_by_type(supplements, :cor)
|
140
|
-
supplement.base = supplement_by_type(supplements, :amd)
|
141
|
-
supplement
|
142
|
-
else
|
143
|
-
raise Errors::SupplementRenderingError, "don't know how to render provided supplements"
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
def transform(params)
|
148
|
-
identifier_params = params.map do |k, v|
|
149
|
-
get_transformer_class.new.apply(k => v).to_a.first
|
150
|
-
end.to_h
|
151
|
-
|
152
|
-
# return supplement if supplements applied
|
153
|
-
if identifier_params[:supplements]
|
154
|
-
return transform_supplements(
|
155
|
-
identifier_params[:supplements],
|
156
|
-
identifier_params.dup.tap { |h| h.delete(:supplements) })
|
157
|
-
end
|
158
|
-
|
159
|
-
new(**identifier_params)
|
160
|
-
end
|
161
|
-
|
162
|
-
def get_amendment_class
|
163
|
-
Pubid::Iso::Amendment
|
164
|
-
end
|
165
|
-
|
166
|
-
def get_corrigendum_class
|
167
|
-
Pubid::Iso::Corrigendum
|
168
|
-
end
|
169
|
-
|
170
|
-
def get_parser_class
|
171
|
-
Parser
|
172
|
-
end
|
173
51
|
|
174
|
-
|
175
|
-
Transformer
|
52
|
+
raise Errors::ParseError, "cannot parse #{title}"
|
176
53
|
end
|
177
|
-
|
178
|
-
def get_renderer_class
|
179
|
-
Renderer::Base
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
# Render URN identifier
|
184
|
-
# @return [String] URN identifier
|
185
|
-
def urn
|
186
|
-
if %i(amd cor).include?(type&.type) && (@base.base.nil? && !@base.edition || (!@base.base.nil? && !@base.base.edition))
|
187
|
-
raise Errors::NoEditionError, "Base document must have edition"
|
188
|
-
end
|
189
|
-
(@tctype && Renderer::UrnTc || type == :dir && Renderer::UrnDir || Pubid::Iso::Renderer::Urn).new(get_params).render
|
190
|
-
end
|
191
|
-
|
192
|
-
# Renders pubid identifier
|
193
|
-
#
|
194
|
-
# @param lang [:french,:russian] use language specific renderer
|
195
|
-
# @param with_date [Boolean] render identifier with date
|
196
|
-
# @param with_edition [Boolean] render identifier with edition
|
197
|
-
# @param stage_format_long [Boolean] render with long or short stage format
|
198
|
-
# @param format [:ref_num_short,:ref_num_long,:ref_dated,:ref_dated_long,:ref_undated,:ref_undated_long] create reference with specified format
|
199
|
-
# @param with_prf [Boolean] include PRF stage in output
|
200
|
-
# Format options are:
|
201
|
-
# :ref_num_short -- instance reference number: 1 letter language code + short form (DAM) + dated
|
202
|
-
# :ref_num_long -- instance reference number long: 2 letter language code + long form (DAmd) + dated
|
203
|
-
# :ref_dated -- reference dated: no language code + short form (DAM) + dated
|
204
|
-
# :ref_dated_long -- reference dated long: no language code + short form (DAM) + dated
|
205
|
-
# :ref_undated -- reference undated: no language code + short form (DAM) + undated
|
206
|
-
# :ref_undated_long -- reference undated long: 1 letter language code + long form (DAmd) + undated
|
207
|
-
# @return [String] pubid identifier
|
208
|
-
def to_s(lang: nil, with_date: true,
|
209
|
-
with_edition: false, with_prf: false,
|
210
|
-
format: :ref_dated_long)
|
211
|
-
with_language_code = nil
|
212
|
-
stage_format_long = nil
|
213
|
-
if format
|
214
|
-
case format
|
215
|
-
when :ref_num_short
|
216
|
-
with_language_code = :single
|
217
|
-
stage_format_long = false
|
218
|
-
when :ref_num_long
|
219
|
-
with_language_code = :iso
|
220
|
-
stage_format_long = true
|
221
|
-
when :ref_dated
|
222
|
-
with_language_code = :none
|
223
|
-
stage_format_long = false
|
224
|
-
when :ref_dated_long
|
225
|
-
with_language_code = :none
|
226
|
-
stage_format_long = true
|
227
|
-
when :ref_undated
|
228
|
-
with_language_code = :none
|
229
|
-
stage_format_long = false
|
230
|
-
with_date = false
|
231
|
-
when :ref_undated_long
|
232
|
-
with_language_code = :none
|
233
|
-
stage_format_long = true
|
234
|
-
with_date = false
|
235
|
-
else
|
236
|
-
raise Errors::WrongFormat, "#{format} is not available"
|
237
|
-
end
|
238
|
-
end
|
239
|
-
case lang
|
240
|
-
when :french
|
241
|
-
Renderer::French.new(get_params)
|
242
|
-
when :russian
|
243
|
-
Renderer::Russian.new(get_params)
|
244
|
-
else
|
245
|
-
if @tctype
|
246
|
-
Renderer::Tc.new(get_params)
|
247
|
-
elsif @typed_stage&.type == :dir
|
248
|
-
Renderer::Dir.new(get_params)
|
249
|
-
else
|
250
|
-
self.class.get_renderer_class.new(get_params)
|
251
|
-
end
|
252
|
-
end.render(with_date: with_date, with_language_code: with_language_code, with_edition: with_edition,
|
253
|
-
stage_format_long: stage_format_long, with_prf: with_prf) +
|
254
|
-
if @joint_document && @typed_stage&.type != :dir
|
255
|
-
"|#{@joint_document}"
|
256
|
-
end.to_s
|
257
|
-
end
|
258
|
-
|
259
|
-
def stage
|
260
|
-
typed_stage&.stage
|
261
|
-
end
|
262
|
-
|
263
|
-
def type
|
264
|
-
typed_stage&.type
|
265
|
-
end
|
266
|
-
|
267
|
-
# Return typed stage abbreviation, eg. "FDTR", "DIS", "TR"
|
268
|
-
def typed_stage_abbrev
|
269
|
-
typed_stage.to_s
|
270
|
-
end
|
271
|
-
|
272
|
-
# Return typed stage name, eg. "Final Draft Technical Report" for "FDTR"
|
273
|
-
def typed_stage_name
|
274
|
-
typed_stage.name
|
275
|
-
end
|
276
|
-
|
277
|
-
def ==(other)
|
278
|
-
get_params == other.get_params
|
279
54
|
end
|
280
55
|
end
|
281
56
|
end
|
data/lib/pubid/iso/parser.rb
CHANGED
@@ -1,10 +1,30 @@
|
|
1
|
+
require_relative "identifier/base"
|
2
|
+
require_relative "renderer/base"
|
3
|
+
|
1
4
|
module Pubid::Iso
|
2
5
|
class Parser < Pubid::Core::Parser
|
3
6
|
STAGES = %w[NP NWIP WD CD PRF AWI PWI FPD].freeze
|
4
7
|
TYPES = %w[DATA ISP IWA R TTA TS TR IS PAS Guide GUIDE DIR].freeze
|
5
|
-
TYPED_STAGES = %w[DIS FDIS DPAS FDTR FDTS DTS DTR PDTR PDTS].freeze
|
6
|
-
SUPPLEMENTS = %w[Amd Cor AMD COR]
|
7
|
-
STAGED_SUPPLEMENTS =
|
8
|
+
# TYPED_STAGES = %w[DIS FDIS DPAS FDTR FDTS DTS DTR PDTR PDTS].freeze
|
9
|
+
SUPPLEMENTS = %w[Amd Cor AMD COR Suppl].freeze
|
10
|
+
STAGED_SUPPLEMENTS = Pubid::Iso::Identifier::Amendment::TYPED_STAGES.map do |_, v|
|
11
|
+
v[:legacy_abbr] + [v[:abbr]]
|
12
|
+
end.flatten +
|
13
|
+
Pubid::Iso::Identifier::Corrigendum::TYPED_STAGES.map do |_, v|
|
14
|
+
v[:legacy_abbr] + [v[:abbr]]
|
15
|
+
end.flatten +
|
16
|
+
Pubid::Iso::Identifier::Supplement::TYPED_STAGES.map do |_, v|
|
17
|
+
v[:abbr]
|
18
|
+
end.flatten +
|
19
|
+
%w[pDCOR PDAM]
|
20
|
+
|
21
|
+
DIR_SUPPLEMENTS = %w[Supplement SUP].freeze
|
22
|
+
|
23
|
+
TYPED_STAGES = Pubid::Iso::Identifier::Base.descendants.map do |type|
|
24
|
+
type::TYPED_STAGES.map do |_, v|
|
25
|
+
v.key?(:legacy_abbr) ? (v[:legacy_abbr] + [v[:abbr]]) : v[:abbr]
|
26
|
+
end
|
27
|
+
end.flatten - STAGED_SUPPLEMENTS + %w[PDTR PDTS]
|
8
28
|
|
9
29
|
TCTYPES = ["TC", "JTC", "PC", "IT", "CAB", "CASCO", "COPOLCO",
|
10
30
|
"COUNCIL", "CPSG", "CS", "DEVCO", "GA", "GAAB", "INFCO",
|
@@ -13,15 +33,15 @@ module Pubid::Iso
|
|
13
33
|
"JSAG", "JSCTF-TF", "JTCG", "JTCG-TF", "SAG_Acc", "SAG_CRMI",
|
14
34
|
"SAG_CRMI_CG", "SAG_ESG", "SAG_ESG_CG", "SAG_MRS", "SAG SF", "SAG SF_CG",
|
15
35
|
"SMCC", "STMG", "MENA STAR"].freeze
|
16
|
-
|
36
|
+
|
17
37
|
WGTYPES = ["AG", "AHG", "AhG", "WG", "JWG", "QC", "TF",
|
18
38
|
"PPC", "CAG", "WG SGDG", "WG SR", "STAR", "STTF", "TIG",
|
19
39
|
"CPAG", "CSC", "ITSAG", "CSC/FIN", "CSC/NOM", "CSC/OVE",
|
20
40
|
"CSC/SP", "CSC/FIN", "JAG"].freeze
|
21
41
|
|
22
|
-
ORGANIZATIONS = %w[IEC IEEE CIW SAE CIE ASME ASTM OECD ISO
|
42
|
+
ORGANIZATIONS = %w[IEC IEEE CIW SAE CIE ASME ASTM OECD ISO HL7 CEI].freeze
|
23
43
|
rule(:stage) do
|
24
|
-
array_to_str(Renderer::
|
44
|
+
array_to_str(Pubid::Iso::Renderer::Base::TRANSLATION[:russian][:stage].values) | array_to_str(STAGES)
|
25
45
|
end
|
26
46
|
|
27
47
|
rule(:typed_stage) do
|
@@ -37,7 +57,7 @@ module Pubid::Iso
|
|
37
57
|
end
|
38
58
|
|
39
59
|
rule(:type) do
|
40
|
-
(array_to_str(Renderer::
|
60
|
+
(array_to_str(Pubid::Iso::Renderer::Base::TRANSLATION[:russian][:type].values) | array_to_str(TYPES)).as(:type)
|
41
61
|
end
|
42
62
|
|
43
63
|
rule(:tctype) do
|
@@ -53,13 +73,24 @@ module Pubid::Iso
|
|
53
73
|
array_to_str(WGTYPES)
|
54
74
|
end
|
55
75
|
|
76
|
+
rule(:roman_numerals) do
|
77
|
+
array_to_str(%w[I V X L C D M]).repeat(1).as(:roman_numerals)
|
78
|
+
end
|
79
|
+
|
80
|
+
rule(:year_digits) { (str("19") | str("20")) >> match('\d').repeat(2, 2) >> digits.absent? }
|
81
|
+
|
82
|
+
|
83
|
+
rule(:part_matcher) do
|
84
|
+
year_digits.absent? >>
|
85
|
+
(str("Amd") | str("Cor")).absent? >> ((roman_numerals >> digits.absent?) | match['[\dA-Z]'].repeat(1)).as(:part)
|
86
|
+
end
|
87
|
+
|
56
88
|
rule(:part) do
|
57
|
-
(str("
|
58
|
-
(str("Amd") | str("Cor")).absent? >> (match['[\dA-Z]'] | str("-")).repeat(1).as(:part)
|
89
|
+
(str("/") | str("-")) >> space? >> part_matcher >> (str("-") >> part_matcher).repeat
|
59
90
|
end
|
60
91
|
|
61
92
|
rule(:organization) do
|
62
|
-
array_to_str(Renderer::
|
93
|
+
array_to_str(Pubid::Iso::Renderer::Base::TRANSLATION[:russian][:publisher].values) | array_to_str(ORGANIZATIONS)
|
63
94
|
end
|
64
95
|
|
65
96
|
rule(:edition) do
|
@@ -73,13 +104,20 @@ module Pubid::Iso
|
|
73
104
|
|
74
105
|
rule(:supplement) do
|
75
106
|
((str("/") | space).maybe >>
|
76
|
-
(
|
107
|
+
(((stage.as(:typed_stage) >> space).maybe >> supplements.as(:type)) |
|
108
|
+
(staged_supplement).as(:typed_stage)) >>
|
77
109
|
(space | str(".")).repeat(1).maybe >>
|
78
|
-
digits.as(:number) >>
|
110
|
+
digits.as(:number).maybe >>
|
79
111
|
(str(".") >> digits.as(:iteration)).maybe >>
|
80
112
|
((str(":") | str("-")) >> digits.as(:year)).maybe).repeat(1).as(:supplements)
|
81
113
|
end
|
82
114
|
|
115
|
+
rule(:addendum) do
|
116
|
+
(
|
117
|
+
((str("/") >> (str("Add") | str("ADD"))) | (str(" — Addendum"))) >> space >> digits.as(:number) >> ((str(":")) >> digits.as(:year)).maybe
|
118
|
+
).as(:addendum)
|
119
|
+
end
|
120
|
+
|
83
121
|
rule(:language) do
|
84
122
|
str("(") >> (
|
85
123
|
( # parse ru,en,fr
|
@@ -114,8 +152,8 @@ module Pubid::Iso
|
|
114
152
|
(str("JTC").as(:dirtype) >> space).maybe >>
|
115
153
|
(digits.as(:number) >> (str(":") >> year).maybe).maybe >>
|
116
154
|
(str(" -- Consolidated").maybe >> (space? >> (organization.as(:publisher) >> space).maybe >>
|
117
|
-
(
|
118
|
-
dir_supplement_edition.maybe).as(:
|
155
|
+
(array_to_str(DIR_SUPPLEMENTS)) >> (str(":") >> year).maybe >>
|
156
|
+
dir_supplement_edition.maybe).repeat(1).as(:supplements)).maybe
|
119
157
|
end
|
120
158
|
|
121
159
|
rule(:std_document_body) do
|
@@ -127,10 +165,8 @@ module Pubid::Iso
|
|
127
165
|
(str("|") >> (str("IDF").as(:publisher) >> space >> digits.as(:number)).as(:joint_document)).maybe >>
|
128
166
|
part.maybe >> iteration.maybe >>
|
129
167
|
(space? >> (str(":") | str("-")) >> year).maybe >>
|
130
|
-
|
131
|
-
|
132
|
-
# stage before corrigendum
|
133
|
-
(supplement).maybe) >>
|
168
|
+
supplement.maybe >>
|
169
|
+
addendum.maybe >>
|
134
170
|
edition.maybe >>
|
135
171
|
language.maybe
|
136
172
|
end
|
@@ -143,9 +179,9 @@ module Pubid::Iso
|
|
143
179
|
(guide_prefix.as(:type) >> space).maybe >>
|
144
180
|
(stage.as(:stage) >> space).maybe >>
|
145
181
|
(typed_stage.as(:stage) >> space).maybe >>
|
146
|
-
originator >> (space | str("/")) >>
|
182
|
+
(originator >> (space | str("/"))).maybe >>
|
147
183
|
(tc_document_body | std_document_body | (dir_document_body >>
|
148
|
-
(str(" + ") >> (originator >> space >> dir_document_body).as(:
|
184
|
+
(str(" + ") >> (originator >> space >> dir_document_body).as(:dir_joint_document)).maybe))
|
149
185
|
end
|
150
186
|
|
151
187
|
rule(:root) { identifier }
|