relaton-iso-bib 1.8.0 → 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,6 +38,9 @@
38
38
  </define>
39
39
  <define name="BibDataExtensionType">
40
40
  <ref name="doctype"/>
41
+ <optional>
42
+ <ref name="docsubtype"/>
43
+ </optional>
41
44
  <optional>
42
45
  <ref name="horizontal"/>
43
46
  </optional>
@@ -98,7 +101,11 @@
98
101
  <ref name="definitions"/>
99
102
  </optional>
100
103
  <oneOrMore>
101
- <ref name="clause"/>
104
+ <choice>
105
+ <ref name="clause"/>
106
+ <ref name="term-clause"/>
107
+ <ref name="terms"/>
108
+ </choice>
102
109
  </oneOrMore>
103
110
  </element>
104
111
  </define>
@@ -133,22 +140,17 @@
133
140
  <optional>
134
141
  <ref name="section-title"/>
135
142
  </optional>
136
- <group>
143
+ <choice>
137
144
  <choice>
138
- <group>
139
- <oneOrMore>
140
- <ref name="BasicBlock"/>
141
- </oneOrMore>
142
- <zeroOrMore>
143
- <ref name="note"/>
144
- </zeroOrMore>
145
- </group>
145
+ <oneOrMore>
146
+ <ref name="BasicBlock"/>
147
+ </oneOrMore>
146
148
  <ref name="amend"/>
147
149
  </choice>
148
150
  <oneOrMore>
149
151
  <ref name="clause-subsection"/>
150
152
  </oneOrMore>
151
- </group>
153
+ </choice>
152
154
  </define>
153
155
  <define name="term">
154
156
  <element name="term">
@@ -157,6 +159,20 @@
157
159
  <data type="ID"/>
158
160
  </attribute>
159
161
  </optional>
162
+ <optional>
163
+ <attribute name="language"/>
164
+ </optional>
165
+ <optional>
166
+ <attribute name="script"/>
167
+ </optional>
168
+ <optional>
169
+ <attribute name="tag"/>
170
+ </optional>
171
+ <optional>
172
+ <attribute name="multilingual-rendering">
173
+ <ref name="MultilingualRenderingType"/>
174
+ </attribute>
175
+ </optional>
160
176
  <ref name="preferred"/>
161
177
  <zeroOrMore>
162
178
  <ref name="admitted"/>
@@ -167,7 +183,7 @@
167
183
  <optional>
168
184
  <ref name="termdomain"/>
169
185
  </optional>
170
- <ref name="definition"/>
186
+ <ref name="termdefinition"/>
171
187
  <zeroOrMore>
172
188
  <ref name="termnote"/>
173
189
  </zeroOrMore>
@@ -177,6 +193,9 @@
177
193
  <zeroOrMore>
178
194
  <ref name="termsource"/>
179
195
  </zeroOrMore>
196
+ <zeroOrMore>
197
+ <ref name="term"/>
198
+ </zeroOrMore>
180
199
  </element>
181
200
  </define>
182
201
  <define name="annex">
@@ -215,9 +234,6 @@
215
234
  -->
216
235
  <ref name="BasicBlock"/>
217
236
  </zeroOrMore>
218
- <zeroOrMore>
219
- <ref name="note"/>
220
- </zeroOrMore>
221
237
  <zeroOrMore>
222
238
  <ref name="clause-hanging-paragraph-with-footnote"/>
223
239
  </zeroOrMore>
@@ -259,6 +275,14 @@
259
275
  <value>directive</value>
260
276
  </choice>
261
277
  </define>
278
+ <define name="DocumentSubtype">
279
+ <choice>
280
+ <value>specification</value>
281
+ <value>method-of-test</value>
282
+ <value>vocabulary</value>
283
+ <value>code-of-practice</value>
284
+ </choice>
285
+ </define>
262
286
  <define name="structuredidentifier">
263
287
  <element name="structuredidentifier">
264
288
  <optional>
@@ -333,14 +357,9 @@
333
357
  <ref name="section-title"/>
334
358
  </optional>
335
359
  <choice>
336
- <group>
337
- <zeroOrMore>
338
- <ref name="BasicBlock"/>
339
- </zeroOrMore>
340
- <zeroOrMore>
341
- <ref name="note"/>
342
- </zeroOrMore>
343
- </group>
360
+ <zeroOrMore>
361
+ <ref name="BasicBlock"/>
362
+ </zeroOrMore>
344
363
  <oneOrMore>
345
364
  <ref name="content-subsection"/>
346
365
  </oneOrMore>
@@ -457,9 +476,6 @@
457
476
  <!-- allow hanging paragraphs in annexes: they introduce lists -->
458
477
  <ref name="BasicBlock"/>
459
478
  </zeroOrMore>
460
- <zeroOrMore>
461
- <ref name="note"/>
462
- </zeroOrMore>
463
479
  <zeroOrMore>
464
480
  <ref name="clause-hanging-paragraph-with-footnote"/>
465
481
  </zeroOrMore>
data/grammars/reqt.rng CHANGED
@@ -58,15 +58,23 @@
58
58
  <optional>
59
59
  <attribute name="type"/>
60
60
  </optional>
61
+ <optional>
62
+ <attribute name="tag"/>
63
+ </optional>
64
+ <optional>
65
+ <attribute name="multilingual-rendering">
66
+ <ref name="MultilingualRenderingType"/>
67
+ </attribute>
68
+ </optional>
61
69
  <optional>
62
70
  <ref name="reqtitle"/>
63
71
  </optional>
64
72
  <optional>
65
73
  <ref name="label"/>
66
74
  </optional>
67
- <optional>
75
+ <zeroOrMore>
68
76
  <ref name="subject"/>
69
- </optional>
77
+ </zeroOrMore>
70
78
  <zeroOrMore>
71
79
  <ref name="reqinherit"/>
72
80
  </zeroOrMore>
@@ -80,6 +88,7 @@
80
88
  <ref name="verification"/>
81
89
  <ref name="import"/>
82
90
  <ref name="description"/>
91
+ <ref name="component"/>
83
92
  </choice>
84
93
  </zeroOrMore>
85
94
  <optional>
@@ -100,17 +109,23 @@
100
109
  </define>
101
110
  <define name="label">
102
111
  <element name="label">
103
- <text/>
112
+ <oneOrMore>
113
+ <ref name="TextElement"/>
114
+ </oneOrMore>
104
115
  </element>
105
116
  </define>
106
117
  <define name="subject">
107
118
  <element name="subject">
108
- <text/>
119
+ <oneOrMore>
120
+ <ref name="TextElement"/>
121
+ </oneOrMore>
109
122
  </element>
110
123
  </define>
111
124
  <define name="reqinherit">
112
125
  <element name="inherit">
113
- <text/>
126
+ <oneOrMore>
127
+ <ref name="TextElement"/>
128
+ </oneOrMore>
114
129
  </element>
115
130
  </define>
116
131
  <define name="measurementtarget">
@@ -138,6 +153,12 @@
138
153
  <ref name="RequirementSubpart"/>
139
154
  </element>
140
155
  </define>
156
+ <define name="component">
157
+ <element name="component">
158
+ <attribute name="class"/>
159
+ <ref name="RequirementSubpart"/>
160
+ </element>
161
+ </define>
141
162
  <define name="reqt_references">
142
163
  <element name="references">
143
164
  <oneOrMore>
@@ -164,6 +185,14 @@
164
185
  <data type="boolean"/>
165
186
  </attribute>
166
187
  </optional>
188
+ <optional>
189
+ <attribute name="tag"/>
190
+ </optional>
191
+ <optional>
192
+ <attribute name="multilingual-rendering">
193
+ <ref name="MultilingualRenderingType"/>
194
+ </attribute>
195
+ </optional>
167
196
  <oneOrMore>
168
197
  <ref name="BasicBlock"/>
169
198
  </oneOrMore>
@@ -35,13 +35,13 @@ module RelatonIsoBib
35
35
  # @param secretariat [String, NilClass]
36
36
  def initialize(technical_committee:, **args) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/AbcSize
37
37
  @technical_committee = technical_committee.map do |tc|
38
- tc.is_a?(Hash) ? IsoSubgroup.new(**tc) : tc
38
+ tc.is_a?(Hash) ? RelatonBib::WorkGroup.new(**tc) : tc
39
39
  end
40
40
  @subcommittee = args.fetch(:subcommittee, []).map do |sc|
41
- sc.is_a?(Hash) ? IsoSubgroup.new(**sc) : sc
41
+ sc.is_a?(Hash) ? RelatonBib::WorkGroup.new(**sc) : sc
42
42
  end
43
43
  @workgroup = args.fetch(:workgroup, []).map do |wg|
44
- wg.is_a?(Hash) ? IsoSubgroup.new(**wg) : wg
44
+ wg.is_a?(Hash) ? RelatonBib::WorkGroup.new(**wg) : wg
45
45
  end
46
46
  @secretariat = args[:secretariat]
47
47
  end
@@ -86,7 +86,7 @@ module RelatonIsoBib
86
86
  # @param prefix [String]
87
87
  # @return [String]
88
88
  def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
89
- pref = prefix.empty? ? prefix : prefix + "."
89
+ pref = prefix.empty? ? prefix : "#{prefix}."
90
90
  pref += "editorialgroup"
91
91
  out = ""
92
92
  technical_committee.each do |tc|
@@ -105,48 +105,48 @@ module RelatonIsoBib
105
105
  end
106
106
 
107
107
  # ISO subgroup.
108
- class IsoSubgroup
109
- # @return [String, NilClass]
110
- attr_reader :type
111
-
112
- # @return [Integer, NilClass]
113
- attr_reader :number
114
-
115
- # @return [String]
116
- attr_reader :name
117
-
118
- # @param name [String]
119
- # @param type [String, NilClass]
120
- # @param number [Integer, NilClass]
121
- def initialize(name:, type: nil, number: nil)
122
- @name = name
123
- @type = type
124
- @number = number
125
- end
126
-
127
- # @param builder [Nokogiri::XML::Builder]
128
- def to_xml(builder)
129
- builder.parent[:number] = number if number
130
- builder.parent[:type] = type if type
131
- builder.text name
132
- end
133
-
134
- # @return [Hash]
135
- def to_hash
136
- hash = { "name" => name }
137
- hash["type"] = type if type
138
- hash["number"] = number if number
139
- hash
140
- end
141
-
142
- # @param prefix [String]
143
- # @param count [Integer] number of the elements
144
- def to_asciibib(prefix, count = 1)
145
- out = count > 1 ? "#{prefix}::\n" : ""
146
- out += "#{prefix}.type:: #{type}\n" if type
147
- out += "#{prefix}.number:: #{number}\n" if number
148
- out += "#{prefix}.name:: #{name}\n"
149
- out
150
- end
151
- end
108
+ # class IsoSubgroup
109
+ # # @return [String, NilClass]
110
+ # attr_reader :type
111
+
112
+ # # @return [Integer, NilClass]
113
+ # attr_reader :number
114
+
115
+ # # @return [String]
116
+ # attr_reader :name
117
+
118
+ # # @param name [String]
119
+ # # @param type [String, NilClass]
120
+ # # @param number [Integer, NilClass]
121
+ # def initialize(name:, type: nil, number: nil)
122
+ # @name = name
123
+ # @type = type
124
+ # @number = number
125
+ # end
126
+
127
+ # # @param builder [Nokogiri::XML::Builder]
128
+ # def to_xml(builder)
129
+ # builder.parent[:number] = number if number
130
+ # builder.parent[:type] = type if type
131
+ # builder.text name
132
+ # end
133
+
134
+ # # @return [Hash]
135
+ # def to_hash
136
+ # hash = { "name" => name }
137
+ # hash["type"] = type if type
138
+ # hash["number"] = number if number
139
+ # hash
140
+ # end
141
+
142
+ # # @param prefix [String]
143
+ # # @param count [Integer] number of the elements
144
+ # def to_asciibib(prefix, count = 1)
145
+ # out = count > 1 ? "#{prefix}::\n" : ""
146
+ # out += "#{prefix}.type:: #{type}\n" if type
147
+ # out += "#{prefix}.number:: #{number}\n" if number
148
+ # out += "#{prefix}.name:: #{name}\n"
149
+ # out
150
+ # end
151
+ # end
152
152
  end
@@ -18,7 +18,7 @@ module RelatonIsoBib
18
18
  # @param title [Hash]
19
19
  # @return [RelatonBib::TypedTitleString]
20
20
  def typed_title_strig(title)
21
- RelatonBib::TypedTitleString.new **title
21
+ RelatonBib::TypedTitleString.new(**title)
22
22
  end
23
23
 
24
24
  # @param ret [Hash]
@@ -27,6 +27,7 @@ module RelatonIsoBib
27
27
  def to_hash
28
28
  hash = {}
29
29
  hash["code"] = code if code
30
+ hash["text"] = description if description
30
31
  hash
31
32
  end
32
33
 
@@ -27,6 +27,8 @@ module RelatonIsoBib
27
27
  amendment technical-corrigendum directive
28
28
  ].freeze
29
29
 
30
+ SUBDOCTYPES = %w[specification method-of-test vocabulary code-of-practice].freeze
31
+
30
32
  # @return [RelatonIsoBib::StructuredIdentifier]
31
33
  attr_reader :structuredidentifier
32
34
 
@@ -66,6 +68,7 @@ module RelatonIsoBib
66
68
  # @param validity [RelatonBib:Validity, NilClass]
67
69
  # @param docid [Array<RelatonBib::DocumentIdentifier>]
68
70
  # @param doctype [String, nil]
71
+ # @param subdoctype [String, nil]
69
72
  # @param horizontal [Boolean, nil]
70
73
  # @param structuredidentifier [RelatonIsoBib::StructuredIdentifier]
71
74
  # @param stagename [String, NilClass]
@@ -130,13 +133,14 @@ module RelatonIsoBib
130
133
  def initialize(**args)
131
134
  check_doctype args[:doctype]
132
135
 
133
- super_args = args.select do |k|
134
- %i[id title docnumber language script docstatus date abstract
135
- contributor edition version relation biblionote series medium place
136
- copyright link fetched docid formattedref extent accesslocation
137
- classification validity doctype keyword].include? k
138
- end
139
- super **super_args
136
+ arg_names = %i[
137
+ id title docnumber language script docstatus date abstract contributor
138
+ edition version relation biblionote series medium place copyright link
139
+ fetched docid formattedref extent accesslocation classification validity
140
+ editorialgroup doctype keyword
141
+ ]
142
+ super_args = args.select { |k| arg_names.include? k }
143
+ super(**super_args)
140
144
 
141
145
  @type = args[:type] || "standard"
142
146
 
@@ -147,6 +151,10 @@ module RelatonIsoBib
147
151
  end
148
152
  end
149
153
 
154
+ if args[:subdoctype] && !SUBDOCTYPES.include?(args[:subdoctype])
155
+ warn "Invald subdoctype '#{args[:subdoctype]}'. Allowed values are: #{SUBDOCTYPES.join(', ')}"
156
+ end
157
+ @subdoctype = args[:subdoctype]
150
158
  @structuredidentifier = args[:structuredidentifier]
151
159
  @horizontal = args[:horizontal]
152
160
  @ics = args.fetch(:ics, []).map { |i| i.is_a?(Hash) ? Ics.new(**i) : i }
@@ -160,23 +168,17 @@ module RelatonIsoBib
160
168
  # @option opts [String] :lang language
161
169
  # @return [String] XML
162
170
  def to_xml(**opts)
163
- super **opts do |b|
171
+ super(**opts) do |b|
164
172
  if block_given? then yield b
165
173
  elsif opts[:bibdata] && has_ext_attrs?
166
174
  b.ext do
167
175
  b.doctype doctype if doctype
176
+ b.subdoctype subdoctype if subdoctype
168
177
  b.horizontal horizontal unless horizontal.nil?
169
- # b.docsubtype docsubtype if respond_to?(:docsubtype) && docsubtype
170
- # GB renders gbcommittee elements istead of an editorialgroup
171
- # if respond_to? :committee
172
- # committee&.to_xml b
173
- # else
174
178
  editorialgroup&.to_xml b
175
- # end
176
179
  ics.each { |i| i.to_xml b }
177
180
  structuredidentifier&.to_xml b
178
181
  b.stagename stagename if stagename
179
- # yield b if block_given?
180
182
  end
181
183
  end
182
184
  end
@@ -208,7 +210,8 @@ module RelatonIsoBib
208
210
  # @raise ArgumentError
209
211
  def check_doctype(doctype)
210
212
  if doctype && !self.class::TYPES.include?(doctype)
211
- warn "[relaton-iso-bib] invalid doctype: #{doctype}"
213
+ warn "[relaton-iso-bib] WARNING: invalid doctype: #{doctype}"
214
+ warn "[relaton-iso-bib] Allowed doctypes are: #{self.class::TYPES.join(', ')}"
212
215
  end
213
216
  end
214
217
 
@@ -31,8 +31,8 @@ module RelatonIsoBib
31
31
 
32
32
  # in docid manipulations, assume ISO as the default: id-part:year
33
33
  def remove_part
34
- @part_number = nil
35
- @subpart_number = nil
34
+ @part = nil
35
+ @subpart = nil
36
36
  @project_number = case @type
37
37
  when "Chinese Standard"
38
38
  @project_number.sub(/\.\d+/, "")
@@ -1,3 +1,3 @@
1
1
  module RelatonIsoBib
2
- VERSION = "1.8.0".freeze
2
+ VERSION = "1.10.1".freeze
3
3
  end
@@ -23,7 +23,7 @@ module RelatonIsoBib
23
23
  # @param item_hash [Hash]
24
24
  # @return [RelatonIsoBib::IsoBibliographicItem]
25
25
  def bib_item(item_hash)
26
- IsoBibliographicItem.new **item_hash
26
+ IsoBibliographicItem.new(**item_hash)
27
27
  end
28
28
 
29
29
  # @param ext [Nokogiri::XML::Element]
@@ -60,8 +60,8 @@ module RelatonIsoBib
60
60
  def iso_subgroup(com)
61
61
  return nil if com.nil?
62
62
 
63
- IsoSubgroup.new(name: com.text, type: com[:type],
64
- number: com[:number]&.to_i)
63
+ RelatonBib::WorkGroup.new(name: com.text, type: com[:type],
64
+ number: com[:number]&.to_i)
65
65
  end
66
66
  end
67
67
  end
@@ -24,17 +24,17 @@ Gem::Specification.new do |spec|
24
24
  spec.bindir = "exe"
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
27
- spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
27
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
28
28
 
29
29
  # spec.add_development_dependency "debase"
30
30
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
31
31
  spec.add_development_dependency "pry-byebug"
32
- spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rake", "~> 13.0"
33
33
  spec.add_development_dependency "rspec", "~> 3.0"
34
34
  # spec.add_development_dependency "ruby-debug-ide"
35
35
  spec.add_development_dependency "ruby-jing"
36
36
  spec.add_development_dependency "simplecov"
37
37
 
38
38
  spec.add_dependency "isoics", "~> 0.1.6"
39
- spec.add_dependency "relaton-bib", "~> 1.8.0"
39
+ spec.add_dependency "relaton-bib", "~> 1.10.1"
40
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iso-bib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-17 00:00:00.000000000 Z
11
+ date: 2022-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.8.0
117
+ version: 1.10.1
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.8.0
124
+ version: 1.10.1
125
125
  description: 'RelatonIsoBib: Ruby ISOXMLDOC impementation.'
126
126
  email:
127
127
  - open.source@ribose.com
@@ -138,6 +138,7 @@ files:
138
138
  - README.adoc
139
139
  - Rakefile
140
140
  - bin/console
141
+ - bin/rspec
141
142
  - bin/setup
142
143
  - grammars/basicdoc.rng
143
144
  - grammars/biblio.rng
@@ -166,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
167
  requirements:
167
168
  - - ">="
168
169
  - !ruby/object:Gem::Version
169
- version: 2.4.0
170
+ version: 2.5.0
170
171
  required_rubygems_version: !ruby/object:Gem::Requirement
171
172
  requirements:
172
173
  - - ">="