relaton-iso-bib 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad71b0b622c9135047f563a8408c72de0daaf015e6b51d4190cea7bdc31bd799
4
- data.tar.gz: d44e8d718863a37f4a14f942935798746b0fc0e760f4f252ff603e90feecb0e9
3
+ metadata.gz: 3b02914af398916111849f7377145375f05ce647e3ff02c6c2ca83013464b4d0
4
+ data.tar.gz: b32bddded529b02ae662959a692cf03e6a4df256751da54648fe9aca899845d3
5
5
  SHA512:
6
- metadata.gz: a2eb7356df7887db0e56622f0790edff531b3c52163f1fdb8a6bab592280e5d59a3b3008d21b1865abfe52968bf53d85760389d3e6fa9bb12c657b84da0230ea
7
- data.tar.gz: e6ddce5c5ebc885424582ba63ab3a313034acdf9d3c8f9c154a6c18fc7692f083d0667cf7fc9f0cf97a233bc9567a56c4b7f4af22ce4e4b7b4309c57be518896
6
+ metadata.gz: c5521cd8a693d3ba710aa6a3c1675033682ef390d882603398cdb15f2826182dd7b3bf8e5e00fcdd44f9e13d7b7676ea5aab357e9d76a94e639a4ae4c4179133
7
+ data.tar.gz: e92e7afbdead56a076456aba13be52f1484b191736787d3b4c3928daa6e77259ccaba67d6e2af1ebb59b4acf73277b984875c8caf96d3a4fa1a8021a4cade423
@@ -532,7 +532,7 @@
532
532
  </define>
533
533
  <define name="LocalityType">
534
534
  <data type="string">
535
- <param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|locality:[a-zA-Z0-9_]+</param>
535
+ <param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+</param>
536
536
  </data>
537
537
  </define>
538
538
  <define name="referenceFrom">
@@ -64,6 +64,85 @@
64
64
  <text/>
65
65
  </element>
66
66
  </define>
67
+ <define name="ul">
68
+ <element name="ul">
69
+ <attribute name="id">
70
+ <data type="ID"/>
71
+ </attribute>
72
+ <optional>
73
+ <attribute name="keep-with-next">
74
+ <data type="boolean"/>
75
+ </attribute>
76
+ </optional>
77
+ <optional>
78
+ <attribute name="keep-lines-together">
79
+ <data type="boolean"/>
80
+ </attribute>
81
+ </optional>
82
+ <oneOrMore>
83
+ <ref name="li"/>
84
+ </oneOrMore>
85
+ <zeroOrMore>
86
+ <ref name="note"/>
87
+ </zeroOrMore>
88
+ </element>
89
+ </define>
90
+ <define name="ol">
91
+ <element name="ol">
92
+ <attribute name="id">
93
+ <data type="ID"/>
94
+ </attribute>
95
+ <optional>
96
+ <attribute name="keep-with-next">
97
+ <data type="boolean"/>
98
+ </attribute>
99
+ </optional>
100
+ <optional>
101
+ <attribute name="keep-lines-together">
102
+ <data type="boolean"/>
103
+ </attribute>
104
+ </optional>
105
+ <attribute name="type">
106
+ <choice>
107
+ <value>roman</value>
108
+ <value>alphabet</value>
109
+ <value>arabic</value>
110
+ <value>roman_upper</value>
111
+ <value>alphabet_upper</value>
112
+ </choice>
113
+ </attribute>
114
+ <oneOrMore>
115
+ <ref name="li"/>
116
+ </oneOrMore>
117
+ <zeroOrMore>
118
+ <ref name="note"/>
119
+ </zeroOrMore>
120
+ </element>
121
+ </define>
122
+ <define name="dl">
123
+ <element name="dl">
124
+ <attribute name="id">
125
+ <data type="ID"/>
126
+ </attribute>
127
+ <optional>
128
+ <attribute name="keep-with-next">
129
+ <data type="boolean"/>
130
+ </attribute>
131
+ </optional>
132
+ <optional>
133
+ <attribute name="keep-lines-together">
134
+ <data type="boolean"/>
135
+ </attribute>
136
+ </optional>
137
+ <oneOrMore>
138
+ <ref name="dt"/>
139
+ <ref name="dd"/>
140
+ </oneOrMore>
141
+ <zeroOrMore>
142
+ <ref name="note"/>
143
+ </zeroOrMore>
144
+ </element>
145
+ </define>
67
146
  <define name="example">
68
147
  <element name="example">
69
148
  <attribute name="id">
@@ -77,6 +156,19 @@
77
156
  <optional>
78
157
  <attribute name="subsequence"/>
79
158
  </optional>
159
+ <optional>
160
+ <attribute name="number"/>
161
+ </optional>
162
+ <optional>
163
+ <attribute name="keep-with-next">
164
+ <data type="boolean"/>
165
+ </attribute>
166
+ </optional>
167
+ <optional>
168
+ <attribute name="keep-lines-together">
169
+ <data type="boolean"/>
170
+ </attribute>
171
+ </optional>
80
172
  <optional>
81
173
  <ref name="tname"/>
82
174
  </optional>
@@ -97,6 +189,296 @@
97
189
  </zeroOrMore>
98
190
  </element>
99
191
  </define>
192
+ <define name="table">
193
+ <element name="table">
194
+ <attribute name="id">
195
+ <data type="ID"/>
196
+ </attribute>
197
+ <optional>
198
+ <attribute name="unnumbered">
199
+ <data type="boolean"/>
200
+ </attribute>
201
+ </optional>
202
+ <optional>
203
+ <attribute name="number"/>
204
+ </optional>
205
+ <optional>
206
+ <attribute name="subsequence"/>
207
+ </optional>
208
+ <optional>
209
+ <attribute name="alt"/>
210
+ </optional>
211
+ <optional>
212
+ <attribute name="summary"/>
213
+ </optional>
214
+ <optional>
215
+ <attribute name="uri">
216
+ <data type="anyURI"/>
217
+ </attribute>
218
+ </optional>
219
+ <optional>
220
+ <attribute name="keep-with-next">
221
+ <data type="boolean"/>
222
+ </attribute>
223
+ </optional>
224
+ <optional>
225
+ <attribute name="keep-lines-together">
226
+ <data type="boolean"/>
227
+ </attribute>
228
+ </optional>
229
+ <optional>
230
+ <ref name="tname"/>
231
+ </optional>
232
+ <optional>
233
+ <ref name="thead"/>
234
+ </optional>
235
+ <ref name="tbody"/>
236
+ <optional>
237
+ <ref name="tfoot"/>
238
+ </optional>
239
+ <zeroOrMore>
240
+ <ref name="table-note"/>
241
+ </zeroOrMore>
242
+ <optional>
243
+ <ref name="dl"/>
244
+ </optional>
245
+ </element>
246
+ </define>
247
+ <define name="figure">
248
+ <element name="figure">
249
+ <attribute name="id">
250
+ <data type="ID"/>
251
+ </attribute>
252
+ <optional>
253
+ <attribute name="unnumbered">
254
+ <data type="boolean"/>
255
+ </attribute>
256
+ </optional>
257
+ <optional>
258
+ <attribute name="number"/>
259
+ </optional>
260
+ <optional>
261
+ <attribute name="subsequence"/>
262
+ </optional>
263
+ <optional>
264
+ <attribute name="keep-with-next">
265
+ <data type="boolean"/>
266
+ </attribute>
267
+ </optional>
268
+ <optional>
269
+ <attribute name="keep-lines-together">
270
+ <data type="boolean"/>
271
+ </attribute>
272
+ </optional>
273
+ <optional>
274
+ <attribute name="class"/>
275
+ </optional>
276
+ <optional>
277
+ <ref name="source"/>
278
+ </optional>
279
+ <optional>
280
+ <ref name="tname"/>
281
+ </optional>
282
+ <choice>
283
+ <ref name="image"/>
284
+ <ref name="video"/>
285
+ <ref name="audio"/>
286
+ <ref name="pre"/>
287
+ <oneOrMore>
288
+ <ref name="paragraph-with-footnote"/>
289
+ </oneOrMore>
290
+ <zeroOrMore>
291
+ <ref name="figure"/>
292
+ </zeroOrMore>
293
+ </choice>
294
+ <zeroOrMore>
295
+ <ref name="fn"/>
296
+ </zeroOrMore>
297
+ <optional>
298
+ <ref name="dl"/>
299
+ </optional>
300
+ <zeroOrMore>
301
+ <ref name="note"/>
302
+ </zeroOrMore>
303
+ </element>
304
+ </define>
305
+ <define name="sourcecode">
306
+ <element name="sourcecode">
307
+ <attribute name="id">
308
+ <data type="ID"/>
309
+ </attribute>
310
+ <optional>
311
+ <attribute name="unnumbered">
312
+ <data type="boolean"/>
313
+ </attribute>
314
+ </optional>
315
+ <optional>
316
+ <attribute name="number"/>
317
+ </optional>
318
+ <optional>
319
+ <attribute name="subsequence"/>
320
+ </optional>
321
+ <optional>
322
+ <attribute name="keep-with-next">
323
+ <data type="boolean"/>
324
+ </attribute>
325
+ </optional>
326
+ <optional>
327
+ <attribute name="keep-lines-together">
328
+ <data type="boolean"/>
329
+ </attribute>
330
+ </optional>
331
+ <optional>
332
+ <attribute name="lang"/>
333
+ </optional>
334
+ <optional>
335
+ <ref name="tname"/>
336
+ </optional>
337
+ <oneOrMore>
338
+ <choice>
339
+ <text/>
340
+ <ref name="callout"/>
341
+ </choice>
342
+ </oneOrMore>
343
+ <zeroOrMore>
344
+ <ref name="annotation"/>
345
+ </zeroOrMore>
346
+ <zeroOrMore>
347
+ <ref name="note"/>
348
+ </zeroOrMore>
349
+ </element>
350
+ </define>
351
+ <define name="formula">
352
+ <element name="formula">
353
+ <attribute name="id">
354
+ <data type="ID"/>
355
+ </attribute>
356
+ <optional>
357
+ <attribute name="unnumbered">
358
+ <data type="boolean"/>
359
+ </attribute>
360
+ </optional>
361
+ <optional>
362
+ <attribute name="number"/>
363
+ </optional>
364
+ <optional>
365
+ <attribute name="subsequence"/>
366
+ </optional>
367
+ <optional>
368
+ <attribute name="keep-with-next">
369
+ <data type="boolean"/>
370
+ </attribute>
371
+ </optional>
372
+ <optional>
373
+ <attribute name="keep-lines-together">
374
+ <data type="boolean"/>
375
+ </attribute>
376
+ </optional>
377
+ <optional>
378
+ <attribute name="inequality">
379
+ <data type="boolean"/>
380
+ </attribute>
381
+ </optional>
382
+ <ref name="stem"/>
383
+ <optional>
384
+ <ref name="dl"/>
385
+ </optional>
386
+ <zeroOrMore>
387
+ <ref name="note"/>
388
+ </zeroOrMore>
389
+ </element>
390
+ </define>
391
+ <define name="ParagraphType">
392
+ <attribute name="id">
393
+ <data type="ID"/>
394
+ </attribute>
395
+ <optional>
396
+ <attribute name="align">
397
+ <ref name="Alignments"/>
398
+ </attribute>
399
+ </optional>
400
+ <optional>
401
+ <attribute name="keep-with-next">
402
+ <data type="boolean"/>
403
+ </attribute>
404
+ </optional>
405
+ <optional>
406
+ <attribute name="keep-lines-together">
407
+ <data type="boolean"/>
408
+ </attribute>
409
+ </optional>
410
+ <zeroOrMore>
411
+ <ref name="TextElement"/>
412
+ </zeroOrMore>
413
+ <zeroOrMore>
414
+ <ref name="note"/>
415
+ </zeroOrMore>
416
+ </define>
417
+ <define name="paragraph-with-footnote">
418
+ <element name="p">
419
+ <attribute name="id">
420
+ <data type="ID"/>
421
+ </attribute>
422
+ <optional>
423
+ <attribute name="align">
424
+ <ref name="Alignments"/>
425
+ </attribute>
426
+ </optional>
427
+ <optional>
428
+ <attribute name="keep-with-next">
429
+ <data type="boolean"/>
430
+ </attribute>
431
+ </optional>
432
+ <optional>
433
+ <attribute name="keep-lines-together">
434
+ <data type="boolean"/>
435
+ </attribute>
436
+ </optional>
437
+ <zeroOrMore>
438
+ <choice>
439
+ <ref name="TextElement"/>
440
+ <ref name="fn"/>
441
+ </choice>
442
+ </zeroOrMore>
443
+ <zeroOrMore>
444
+ <ref name="note"/>
445
+ </zeroOrMore>
446
+ </element>
447
+ </define>
448
+ <define name="quote">
449
+ <element name="quote">
450
+ <attribute name="id">
451
+ <data type="ID"/>
452
+ </attribute>
453
+ <optional>
454
+ <attribute name="alignment">
455
+ <ref name="Alignments"/>
456
+ </attribute>
457
+ </optional>
458
+ <optional>
459
+ <attribute name="keep-with-next">
460
+ <data type="boolean"/>
461
+ </attribute>
462
+ </optional>
463
+ <optional>
464
+ <attribute name="keep-lines-together">
465
+ <data type="boolean"/>
466
+ </attribute>
467
+ </optional>
468
+ <optional>
469
+ <ref name="quote-source"/>
470
+ </optional>
471
+ <optional>
472
+ <ref name="quote-author"/>
473
+ </optional>
474
+ <oneOrMore>
475
+ <ref name="paragraph-with-footnote"/>
476
+ </oneOrMore>
477
+ <zeroOrMore>
478
+ <ref name="note"/>
479
+ </zeroOrMore>
480
+ </element>
481
+ </define>
100
482
  <define name="BibDataExtensionType">
101
483
  <ref name="doctype"/>
102
484
  <optional>
@@ -165,6 +547,30 @@
165
547
  <attribute name="id">
166
548
  <data type="ID"/>
167
549
  </attribute>
550
+ <optional>
551
+ <attribute name="unnumbered">
552
+ <data type="boolean"/>
553
+ </attribute>
554
+ </optional>
555
+ <optional>
556
+ <attribute name="number"/>
557
+ </optional>
558
+ <optional>
559
+ <attribute name="subsequence"/>
560
+ </optional>
561
+ <optional>
562
+ <attribute name="keep-with-next">
563
+ <data type="boolean"/>
564
+ </attribute>
565
+ </optional>
566
+ <optional>
567
+ <attribute name="keep-lines-together">
568
+ <data type="boolean"/>
569
+ </attribute>
570
+ </optional>
571
+ <optional>
572
+ <attribute name="type"/>
573
+ </optional>
168
574
  <oneOrMore>
169
575
  <choice>
170
576
  <ref name="paragraph"/>
@@ -910,6 +1316,27 @@
910
1316
  <attribute name="id">
911
1317
  <data type="ID"/>
912
1318
  </attribute>
1319
+ <optional>
1320
+ <attribute name="unnumbered">
1321
+ <data type="boolean"/>
1322
+ </attribute>
1323
+ </optional>
1324
+ <optional>
1325
+ <attribute name="number"/>
1326
+ </optional>
1327
+ <optional>
1328
+ <attribute name="subsequence"/>
1329
+ </optional>
1330
+ <optional>
1331
+ <attribute name="keep-with-next">
1332
+ <data type="boolean"/>
1333
+ </attribute>
1334
+ </optional>
1335
+ <optional>
1336
+ <attribute name="keep-lines-together">
1337
+ <data type="boolean"/>
1338
+ </attribute>
1339
+ </optional>
913
1340
  <oneOrMore>
914
1341
  <choice>
915
1342
  <ref name="paragraph"/>
@@ -362,6 +362,9 @@
362
362
  <data type="boolean"/>
363
363
  </attribute>
364
364
  </optional>
365
+ <optional>
366
+ <attribute name="number"/>
367
+ </optional>
365
368
  <optional>
366
369
  <attribute name="subsequence"/>
367
370
  </optional>
@@ -1,75 +1,8 @@
1
1
  module RelatonIsoBib
2
2
  class HashConverter < RelatonBib::HashConverter
3
3
  class << self
4
- # @override RelatonBib::HashConverter.hash_to_bib
5
- # @param args [Hash]
6
- # @param nested [TrueClass, FalseClass]
7
- # @return [Hash]
8
- def hash_to_bib(args, nested = false)
9
- ret = super
10
- return if ret.nil?
11
-
12
- editorialgroup_hash_to_bib(ret)
13
- ics_hash_to_bib(ret)
14
- structuredidentifier_hash_to_bib(ret)
15
- ret
16
- end
17
-
18
- def split_title(content, lang = "en", script = "Latn")
19
- titles = content&.split(/ (?:--|—|–) /)
20
- case titles&.size
21
- when nil, 0
22
- intro, main, part = nil, "", nil
23
- when 1
24
- intro, main, part = nil, titles[0], nil
25
- when 2
26
- if /^(Part|Partie) \d+:/ =~ titles[1]
27
- intro, main, part = nil, titles[0], titles[1]
28
- else
29
- intro, main, part = titles[0], titles[1], nil
30
- end
31
- when 3
32
- intro, main, part = titles[0], titles[1], titles[2]
33
- else
34
- intro, main, part = titles[0], titles[1], titles[2..-1]&.join(" -- ")
35
- end
36
- {
37
- title_intro: intro,
38
- title_main: main,
39
- title_part: part,
40
- language: lang,
41
- script: script,
42
- }
43
- end
44
-
45
4
  private
46
5
 
47
- #
48
- # Ovverides superclass's method
49
- #
50
- # @param ret [Hash]
51
- def title_hash_to_bib(ret)
52
- return unless ret[:title]
53
-
54
- ret[:title] = array(ret[:title])
55
- ret[:title] = ret[:title].reduce([]) do |a, t|
56
- if t.is_a?(String)
57
- a << split_title(t)
58
- elsif t.is_a?(Hash) && t[:type]
59
- idx = a.index { |i| i[:language] == t[:language] }
60
- title_key = t[:type].sub("-", "_").to_sym
61
- if idx
62
- a[idx][title_key] = t[:content]
63
- a
64
- else
65
- a << { title_key => t[:content], language: t[:language], script: t[:script] }
66
- end
67
- elsif t.is_a?(Hash) && t[:content]
68
- a << split_title(t[:content], t[:language], t[:script])
69
- end
70
- end
71
- end
72
-
73
6
  #
74
7
  # Ovverides superclass's method
75
8
  #
@@ -83,9 +16,9 @@ module RelatonIsoBib
83
16
  # Ovverides superclass's method
84
17
  #
85
18
  # @param title [Hash]
86
- # @return [RelatonIsoBib::TypedTitleString]
19
+ # @return [RelatonBib::TypedTitleString]
87
20
  def typed_title_strig(title)
88
- TypedTitleString.new title
21
+ RelatonBib::TypedTitleString.new title
89
22
  end
90
23
 
91
24
  # @param ret [Hash]
@@ -3,7 +3,7 @@
3
3
  require "nokogiri"
4
4
  require "isoics"
5
5
  require "relaton_bib"
6
- require "relaton_iso_bib/typed_title_string"
6
+ # require "relaton_iso_bib/typed_title_string"
7
7
  require "relaton_iso_bib/editorial_group"
8
8
  require "relaton_iso_bib/xml_parser"
9
9
  require "relaton_iso_bib/structured_identifier"
@@ -32,7 +32,7 @@ module RelatonIsoBib
32
32
  attr_reader :structuredidentifier
33
33
 
34
34
  # @!attribute [r] title
35
- # @return [Array<RelatonIsoBib::TypedTitleString>]
35
+ # @return [Array<RelatonBib::TypedTitleString>]
36
36
 
37
37
  # @return [String, NilClass]
38
38
  attr_reader :doctype, :stagename
@@ -43,9 +43,6 @@ module RelatonIsoBib
43
43
  # @return [Array<RelatonIsoBib::Ics>]
44
44
  attr_reader :ics
45
45
 
46
- # @return [TrueClass, FalseClass, NilClass]
47
- attr_accessor :all_parts
48
-
49
46
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
50
47
  # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity
51
48
 
@@ -76,7 +73,7 @@ module RelatonIsoBib
76
73
  # @option title [String] :language
77
74
  # @option title [String] :script
78
75
  #
79
- # @param editorialgroup [Hash, RelatonIsoBib::EditorialGroup, RelatonItu::EditorialGroup]
76
+ # @param editorialgroup [Hash, RelatonIsoBib::EditorialGroup]
80
77
  # @option workgrpup [String] :name
81
78
  # @option workgrpup [String] :abbreviation
82
79
  # @option workgrpup [String] :url
@@ -128,24 +125,23 @@ module RelatonIsoBib
128
125
  # @raise [ArgumentError]
129
126
  def initialize(**args)
130
127
  check_doctype args[:doctype]
131
- # check_language args.fetch(:language, [])
132
- # check_script args.fetch(:script, [])
133
128
 
134
129
  super_args = args.select do |k|
135
130
  %i[id docnumber language script docstatus date abstract contributor
136
131
  edition version relation biblionote series medium place copyright
137
132
  link fetched docid formattedref extent accesslocation classification
138
- validity keyword].include? k
133
+ validity doctype keyword].include? k
139
134
  end
140
135
  super super_args
141
136
 
142
137
  @type = args[:type] || "standard"
143
138
 
144
- @title = args.fetch(:title, []).reduce([]) do |a, t|
139
+ @title = args.fetch(:title, []).map do |t|
145
140
  if t.is_a? Hash
146
- a + typed_titles(t)
141
+ # a + typed_titles(t)
142
+ RelatonBib::TypedTitleString.new t
147
143
  else
148
- a << t
144
+ t
149
145
  end
150
146
  end
151
147
 
@@ -157,82 +153,11 @@ module RelatonIsoBib
157
153
  end
158
154
 
159
155
  @structuredidentifier = args[:structuredidentifier]
160
- @doctype ||= args[:doctype]
156
+ # @doctype = args[:doctype] || "international-standard"
161
157
  @ics = args.fetch(:ics, []).map { |i| i.is_a?(Hash) ? Ics.new(i) : i }
162
158
  @stagename = args[:stagename]
163
159
  @id_attribute = true
164
160
  end
165
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
166
- # rubocop:enable Metrics/MethodLength, Metrics/PerceivedComplexity
167
-
168
- def disable_id_attribute
169
- @id_attribute = false
170
- end
171
-
172
- # remove title part components and abstract
173
- def to_all_parts
174
- me = deep_clone
175
- me.disable_id_attribute
176
- me.relation << RelatonBib::DocumentRelation.new(
177
- type: "instance", bibitem: self,
178
- )
179
- me.language.each do |l|
180
- me.title.delete_if { |t| t.type == "title-part" }
181
- ttl = me.title.select { |t| t.type != "main" && t.title.language.include?(l) }
182
- tm_en = ttl.map { |t| t.title.content }.join " – "
183
- me.title.detect { |t| t.type == "main" && t.title.language.include?(l) }&.title&.content = tm_en
184
- end
185
- me.abstract = []
186
- me.docidentifier.each(&:remove_part)
187
- me.docidentifier.each(&:all_parts)
188
- me.structuredidentifier.remove_part
189
- me.structuredidentifier.all_parts
190
- me.docidentifier.each &:remove_date
191
- me.structuredidentifier&.remove_date
192
- me.all_parts = true
193
- me
194
- end
195
-
196
- def abstract=(value)
197
- @abstract = value
198
- end
199
-
200
- def deep_clone
201
- dump = Marshal.dump self
202
- Marshal.load dump
203
- end
204
-
205
- # convert ISO:yyyy reference to reference to most recent
206
- # instance of reference, removing date-specific infomration:
207
- # date of publication, abstracts. Make dated reference Instance relation
208
- # of the redacated document
209
- def to_most_recent_reference
210
- me = deep_clone
211
- self.disable_id_attribute
212
- me.relation << RelatonBib::DocumentRelation.new(type: "instance", bibitem: self)
213
- me.abstract = []
214
- me.date = []
215
- me.docidentifier.each &:remove_date
216
- me.structuredidentifier&.remove_date
217
- me.id&.sub! /-[12]\d\d\d/, ""
218
- me
219
- end
220
-
221
- # @param lang [String] language code Iso639
222
- # @return [Array<RelatonIsoBib::TypedTitleString>]
223
- def title(lang: nil)
224
- if lang
225
- @title.select { |t| t.title.language.include? lang }
226
- else
227
- @title
228
- end
229
- end
230
-
231
- # @param type [Symbol] type of url, can be :src/:obp/:rss
232
- # @return [String]
233
- def url(type = :src)
234
- @link.detect { |s| s.type == type.to_s }.content.to_s
235
- end
236
161
 
237
162
  # @return [String]
238
163
  def to_xml(builder = nil, **opts, &block)
@@ -265,37 +190,20 @@ module RelatonIsoBib
265
190
  end
266
191
  end
267
192
 
193
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
194
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
195
+
268
196
  # @return [Hash]
269
197
  def to_hash
270
198
  hash = super
271
199
  hash["editorialgroup"] = editorialgroup.to_hash if editorialgroup
272
200
  hash["ics"] = single_element_array(ics) if ics&.any?
273
- hash["structuredidentifier"] = structuredidentifier.to_hash if structuredidentifier
274
- hash["doctype"] = doctype if doctype
275
201
  hash["stagename"] = stagename if stagename
276
202
  hash
277
203
  end
278
204
 
279
205
  private
280
206
 
281
- # @param language [Array<String>]
282
- # @raise ArgumentError
283
- # def check_language(language)
284
- # language.each do |lang|
285
- # unless %w[en fr].include? lang
286
- # raise ArgumentError, "invalid language: #{lang}"
287
- # end
288
- # end
289
- # end
290
-
291
- # @param script [Array<String>]
292
- # @raise ArgumentError
293
- # def check_script(script)
294
- # script.each do |scr|
295
- # raise ArgumentError, "invalid script: #{scr}" unless scr == "Latn"
296
- # end
297
- # end
298
-
299
207
  # @param doctype [String]
300
208
  # @raise ArgumentError
301
209
  def check_doctype(doctype)
@@ -304,64 +212,17 @@ module RelatonIsoBib
304
212
  end
305
213
  end
306
214
 
307
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
308
-
309
- # @param title [Hash]
310
- # @option title [String] :title_intro
311
- # @option title [String] :title_main
312
- # @option title [String] :title_part
313
- # @option title [String] :language
314
- # @option title [String] :script
315
- # @return [Array<RelatonIsoBib::TypedTitleStrig>]
316
- def typed_titles(title)
317
- titles = []
318
- if title[:title_intro]
319
- titles << TypedTitleString.new(
320
- type: "title-intro", content: title[:title_intro],
321
- language: title[:language], script: title[:script], format: "text/plain",
322
- )
323
- end
324
-
325
- if title[:title_main]
326
- titles << TypedTitleString.new(
327
- type: "title-main", content: title[:title_main],
328
- language: title[:language], script: title[:script], format: "text/plain",
329
- )
330
- end
331
-
332
- if title[:title_part]
333
- titles << TypedTitleString.new(
334
- type: "title-part", content: title[:title_part],
335
- language: title[:language], script: title[:script], format: "text/plain",
336
- )
337
- end
338
-
339
- unless titles.empty?
340
- titles << TypedTitleString.new(
341
- type: "main", content: titles.map { |t| t.title.content }.join(" – "),
342
- language: title[:language], script: title[:script], format: "text/plain",
343
- )
344
- end
345
-
346
- titles
347
- end
348
-
349
215
  def makeid(id, attribute, _delim = "")
350
216
  return nil if attribute && !@id_attribute
351
217
 
352
218
  id ||= @docidentifier.reject { |i| i&.type == "DOI" }[0]
353
- # contribs = publishers.map { |p| p&.entity&.abbreviation }.join '/'
354
- # idstr = "#{contribs}#{delim}#{id.project_number}"
355
- # idstr = id.project_number.to_s
356
219
  if id
357
220
  idstr = id.id
358
221
  idstr = "IEV" if structuredidentifier&.project_number == "IEV"
359
222
  else
360
223
  idstr = formattedref&.content
361
224
  end
362
- # if id.part_number&.size&.positive? then idstr += "-#{id.part_number}"
363
225
  idstr&.gsub(/:/, "-")&.gsub(/\s/, "")&.strip
364
226
  end
365
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
366
227
  end
367
228
  end
@@ -26,7 +26,6 @@ module RelatonIsoBib
26
26
  @project_number = args[:project_number]
27
27
  @part = args[:part]
28
28
  @subpart = args[:subpart]
29
- # @prefix = args[:prefix]
30
29
  @type = args[:type]
31
30
  end
32
31
 
@@ -42,10 +41,10 @@ module RelatonIsoBib
42
41
  end
43
42
 
44
43
  def remove_date
45
- case @type
46
- when "Chinese Standard" then @project_number = @project_number.sub(/-[12]\d\d\d/, "")
44
+ if @type == "Chinese Standard"
45
+ @project_number.sub!(/-[12]\d\d\d/, "")
47
46
  else
48
- @project_number = @project_number.sub(/:[12]\d\d\d/, "")
47
+ @project_number.sub!(/:[12]\d\d\d/, "")
49
48
  end
50
49
  end
51
50
 
@@ -78,5 +77,9 @@ module RelatonIsoBib
78
77
  hash["type"] = type if type
79
78
  hash
80
79
  end
80
+
81
+ def presence?
82
+ true
83
+ end
81
84
  end
82
85
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIsoBib
2
- VERSION = "1.1.1".freeze
2
+ VERSION = "1.2.0".freeze
3
3
  end
@@ -15,7 +15,6 @@ module RelatonIsoBib
15
15
 
16
16
  data[:doctype] = ext.at("./doctype")&.text
17
17
  data[:editorialgroup] = fetch_editorialgroup ext
18
- data[:ics] = fetch_ics ext
19
18
  data[:structuredidentifier] = fetch_structuredidentifier ext
20
19
  data[:stagename] = ext.at("./stagename")&.text
21
20
  data
@@ -31,7 +30,7 @@ module RelatonIsoBib
31
30
  # @param ext [Nokogiri::XML::Element]
32
31
  # @return [RelatonIsoBib::StructuredIdentifier]
33
32
  def fetch_structuredidentifier(ext)
34
- sid = ext.at "./structuredidentifier"
33
+ sid = ext&.at "./structuredidentifier"
35
34
  return unless sid
36
35
 
37
36
  pn = sid.at "project-number"
@@ -44,27 +43,21 @@ module RelatonIsoBib
44
43
 
45
44
  # Override RelatonBib::XMLParser.ttitle method.
46
45
  # @param title [Nokogiri::XML::Element]
47
- # @return [RelatonIsoBib::TypedTitleString]
46
+ # @return [RelatonBib::TypedTitleString]
48
47
  def ttitle(title)
49
48
  return unless title
50
49
 
51
- TypedTitleString.new(
50
+ RelatonBib::TypedTitleString.new(
52
51
  type: title[:type], content: title.text, language: title[:language],
53
52
  script: title[:script], format: title[:format]
54
53
  )
55
54
  end
56
55
 
57
- # @param item [Nokogiri::XML::Element]
58
- # @return [Array<RelatonIsoBib::Ics>]
59
- def fetch_ics(ext)
60
- ext.xpath("./ics/code").map { |ics| Ics.new ics.text }
61
- end
62
-
63
56
  # @TODO Organization doesn't recreated
64
57
  # @param ext [Nokogiri::XML::Element]
65
58
  # @return [RelatonIsoBib::EditorialGroup]
66
59
  def fetch_editorialgroup(ext)
67
- eg = ext.at("./editorialgroup")
60
+ eg = ext&.at("./editorialgroup")
68
61
  return unless eg
69
62
 
70
63
  tc = eg&.xpath("technical-committee")&.map { |t| iso_subgroup(t) }
@@ -36,5 +36,5 @@ Gem::Specification.new do |spec|
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.1.0"
39
+ spec.add_dependency "relaton-bib", "~> 1.2.0"
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.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-18 00:00:00.000000000 Z
11
+ date: 2020-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.1.0
145
+ version: 1.2.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.1.0
152
+ version: 1.2.0
153
153
  description: 'RelatonIsoBib: Ruby ISOXMLDOC impementation.'
154
154
  email:
155
155
  - open.source@ribose.com
@@ -181,7 +181,6 @@ files:
181
181
  - lib/relaton_iso_bib/iso_bibliographic_item.rb
182
182
  - lib/relaton_iso_bib/iso_document_relation.rb
183
183
  - lib/relaton_iso_bib/structured_identifier.rb
184
- - lib/relaton_iso_bib/typed_title_string.rb
185
184
  - lib/relaton_iso_bib/version.rb
186
185
  - lib/relaton_iso_bib/xml_parser.rb
187
186
  - relaton_iso_bib.gemspec
@@ -1,32 +0,0 @@
1
- module RelatonIsoBib
2
- class TypedTitleString < RelatonBib::TypedTitleString
3
- # TITLE_TYPES = %w[title-main title-intro title-part main].freeze
4
-
5
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
6
-
7
- # @param type [String]
8
- # @param title [RelatonBib::FormattedString, Hash]
9
- # @param content [String]
10
- # @param language [String]
11
- # @param script [String]
12
- def initialize(**args)
13
- # if args[:type] && !TITLE_TYPES.include?(args[:type])
14
- # raise ArgumentError, %{The type #{args[:type]} is invalid.}
15
- # end
16
-
17
- unless args[:title] || args[:content]
18
- raise ArgumentError, %{Keyword "title" or "content" should be passed.}
19
- end
20
-
21
- @type = args[:type]
22
-
23
- if args[:title]
24
- @title = args[:title]
25
- else
26
- fsargs = args.select { |k, _v| %i[content language script format].include? k }
27
- @title = RelatonBib::FormattedString.new(fsargs)
28
- end
29
- end
30
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
31
- end
32
- end