relaton-bib 1.3.0 → 1.5.pre1

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: 2d2e73e228a1e3d0b56ec177f3fa39a721dbd76ff99fd3f18e38c331672aca43
4
- data.tar.gz: c9dab886bcffafd638735157419c904b88da2363048178fb8c458399d9a74909
3
+ metadata.gz: 1c135ae20e6dedad964161c4688f955bc1f6ff9945e36dcfbb4aaed73bf6d6bf
4
+ data.tar.gz: 7e1775460d12c0c2b8e4014cced56a7dbd84abf215c0882e34a11c198977d28c
5
5
  SHA512:
6
- metadata.gz: 62292ca68783b8f5817807ca4b014ec0c782a81c3724ff7860562f7d4529cd3eac9e1f1dccddae7149d6bb56dbb114dd1bcd7393cbc797cb91b7beb02a3de953
7
- data.tar.gz: ff58d4ed2c0bb448bca70e62e8a6d9252ffa02865bfcbbc31f0bf360e009f372e8bc292c59ee7c970f891e0ab496cf4e81df3241f967dbbde1968cebdccf8952
6
+ metadata.gz: f6ca89938617badf59e7e92503e1b08a87428ea0cadca42af71e93c9e528a5d2f9fd1a2f7c1a90893233db16cad05c46295561f42962c3fcdb8402cbf331e723
7
+ data.tar.gz: 82204e17e4ce3dc1df5555eea3f7817b1cbfa4d1f1bd2de22ef3499ea84539dbce1ef114e651a303367ae35b1a78823b043dc954d907f1717b3305662d692312
@@ -136,10 +136,13 @@ item = RelatonBib::BibliographicItem.new(
136
136
  },
137
137
  { entity: { name: "Institution" }, role: [type: "sponsor"] }
138
138
  ],
139
- copyright: { owner: {
140
- name: "International Organization for Standardization",
141
- abbreviation: "ISO", url: "www.iso.org"
142
- }, from: "2014", to: "2020" },
139
+ copyright: [{
140
+ owner: [{
141
+ name: "International Organization for Standardization",
142
+ abbreviation: "ISO", url: "www.iso.org"
143
+ }],
144
+ from: "2014", to: "2020"
145
+ }],
143
146
  link: [
144
147
  { type: "src", content: "https://www.iso.org/standard/53798.html" },
145
148
  { type: "obp",
@@ -232,6 +235,10 @@ item = RelatonBib::BibliographicItem.new(
232
235
  revision: Time.new(2011, 3, 4, 9, 0),
233
236
  )
234
237
  )
238
+
239
+ => #<RelatonBib::BibliographicItem:0x007fc8b6c796c0
240
+ @abstract=
241
+ [#<RelatonBib::FormattedString:0x007fc8b6c726b8 @content="ISO 19115-1:2014 defines the schema required for ...", @format="text/plain", @language=["en"], @script=["Latn"]>,
235
242
  ----
236
243
 
237
244
  === BibliographicItem Typed Title Strings
@@ -245,6 +252,11 @@ item.title
245
252
  #<RelatonBib::TypedTitleString:0x007fa49a35bf38
246
253
  @title=#<RelatonBib::FormattedString:0x007fa49a35bdd0 @content="Information géographique", @format=nil, @language=["fr"], @script=["Latn"]>,
247
254
  @type=nil>]
255
+
256
+ item.title lang: "fr"
257
+ => [#<RelatonBib::TypedTitleString:0x007fa49a35bf38
258
+ @title=#<RelatonBib::FormattedString:0x007fa49a35bdd0 @content="Information géographique", @format=nil, @language=["fr"], @script=["Latn"]>,
259
+ @type=nil>]
248
260
  ----
249
261
 
250
262
  === BibliographicItem Formatted Strings
@@ -252,8 +264,8 @@ item.title
252
264
  [source,ruby]
253
265
  ----
254
266
  item.abstract
255
- => [#<RelatonBib::FormattedString:0x007fa49a35aed0 @content="ISO 19115-1:2014 defines the schema required for ...", @format="text/plain", @language=["en"], @script=["Latn"]>,
256
- #<RelatonBib::FormattedString:0x007fa49a35ae08 @content="L'ISO 19115-1:2014 définit le schéma requis pour ...", @format="text/plain", @language=["fr"], @script=["Latn"]>]
267
+ => [#<RelatonBib::FormattedString:0x007fc8b6c726b8 @content="ISO 19115-1:2014 defines the schema required for ...", @format="text/plain", @language=["en"], @script=["Latn"]>,
268
+ #<RelatonBib::FormattedString:0x007fc8b6c725f0 @content="L'ISO 19115-1:2014 définit le schéma requis pour ...", @format="text/plain", @language=["fr"], @script=["Latn"]>]
257
269
 
258
270
  item.abstract(lang: "en").to_s
259
271
  => "ISO 19115-1:2014 defines the schema required for ..."
@@ -263,8 +275,8 @@ item.abstract(lang: "en").to_s
263
275
 
264
276
  [source,ruby]
265
277
  ----
266
- item.shortref item
267
- => "ISO/TC211:2014"
278
+ item.shortref item.docidentifier.first
279
+ => "TC211:2014"
268
280
  ----
269
281
 
270
282
  === XML serialization
@@ -272,10 +284,10 @@ item.shortref item
272
284
  [source,ruby]
273
285
  ----
274
286
  item.to_xml
275
- => "<bibitem id=\"ISO/TC211\" type=\"standard\">
287
+ => "<bibitem id="ISO/TC211" type="standard">
276
288
  <fetched>2019-04-30</fetched>
277
- <title type=\"main\" language=\"en\" script=\"Latn\">Geographic information</title>
278
- <title language=\"fr\" script=\"Latn\">Information géographique</title>
289
+ <title type="main" language="en" script="Latn">Geographic information</title>
290
+ <title language="fr" script="Latn">Information géographique</title>
279
291
  ...
280
292
  </bibitem>"
281
293
  ----
@@ -285,9 +297,9 @@ Default root element is `bibitem`. With argument `bibdata: true` the XML wrapped
285
297
  [source,ruby]
286
298
  ----
287
299
  item.to_xml bibdata: true
288
- => "<bibdata type=\"standard\">
300
+ => "<bibdata type="standard">
289
301
  <fetched>2019-04-30</fetched>
290
- <title type=\"main\" language=\"en\" script=\"Latn\">Geographic information</title>
302
+ <title type="main" language="en" script="Latn">Geographic information</title>
291
303
  ...
292
304
  </bibdata>"
293
305
  ----
@@ -296,12 +308,12 @@ item.to_xml bibdata: true
296
308
 
297
309
  By default date elements are formatted as year (yyyy). Option `:date_format` allows to output date elements in `:short` (yyyy-mm) and `:full` (yyyy-mm-dd) additiona formats.
298
310
 
299
- [surce,ruby]
311
+ [source,ruby]
300
312
  ----
301
313
  item.to_xml date_format: :short
302
- => "<bibitem id=\"ISO/TC211\" type=\"standard\">
314
+ => "<bibitem id="ISO/TC211" type="standard">
303
315
  <fetched>2019-04-30</fetched>
304
- <title type=\"main\" language=\"en\" script=\"Latn\">Geographic information</title>
316
+ <title type="main" language="en" script="Latn">Geographic information</title>
305
317
  ...
306
318
  <date type="issued">
307
319
  <on>2014-01</on>
@@ -313,9 +325,10 @@ item.to_xml date_format: :short
313
325
  <on>2015-05</on>
314
326
  </date>
315
327
  ...
328
+ </bibitem>"
316
329
 
317
330
  item.to_xml date_format: :full
318
- => "<bibitem id=\"ISO/TC211\" type=\"standard\">
331
+ => "<bibitem id="ISO/TC211" type="standard">
319
332
  ...
320
333
  <date type="issued">
321
334
  <on>2014-01-01</on>
@@ -327,6 +340,19 @@ item.to_xml date_format: :full
327
340
  <on>2015-05-20</on>
328
341
  </date>
329
342
  ...
343
+ </bibitem>"
344
+ ----
345
+
346
+ ==== Adding notes
347
+
348
+ [source,ruby]
349
+ ----
350
+ item.to_xml note: [{ text: "Note", type: "note" }]
351
+ =>"<bibitem id="ISO19115-1-2014">
352
+ ...
353
+ <note format="text/plain" type="note">Note</note>
354
+ ...
355
+ </bibitem>"
330
356
  ----
331
357
 
332
358
  === Create bibliographic item form YAML
@@ -362,7 +388,7 @@ item.to_hash
362
388
 
363
389
  [source,ruby]
364
390
  ----
365
- RelatonBib::BibtexParser.from_bibtex File.read('spec/examples/bibitem.bib')
391
+ RelatonBib::BibtexParser.from_bibtex File.read('spec/examples/techreport.bib')
366
392
  => {"ISOTC211"=>
367
393
  #<RelatonBib::BibliographicItem:0x007fedee0a2ab0
368
394
  ...
@@ -42,8 +42,11 @@
42
42
  </define>
43
43
  <define name="xref">
44
44
  <element name="xref">
45
+ <!-- attribute target { xsd:IDREF }, -->
45
46
  <attribute name="target">
46
- <data type="IDREF"/>
47
+ <data type="string">
48
+ <param name="pattern">\i\c*|\c+#\c+</param>
49
+ </data>
47
50
  </attribute>
48
51
  <optional>
49
52
  <attribute name="type">
@@ -61,6 +64,11 @@
61
64
  </choice>
62
65
  </attribute>
63
66
  </optional>
67
+ <optional>
68
+ <attribute name="droploc">
69
+ <data type="boolean"/>
70
+ </attribute>
71
+ </optional>
64
72
  <text/>
65
73
  </element>
66
74
  </define>
@@ -578,6 +586,8 @@
578
586
  <ref name="ol"/>
579
587
  <ref name="dl"/>
580
588
  <ref name="formula"/>
589
+ <ref name="quote"/>
590
+ <ref name="sourcecode"/>
581
591
  </choice>
582
592
  </oneOrMore>
583
593
  </element>
@@ -661,6 +671,16 @@
661
671
  </choice>
662
672
  </attribute>
663
673
  </optional>
674
+ <optional>
675
+ <attribute name="valign">
676
+ <choice>
677
+ <value>top</value>
678
+ <value>middle</value>
679
+ <value>bottom</value>
680
+ <value>baseline</value>
681
+ </choice>
682
+ </attribute>
683
+ </optional>
664
684
  <choice>
665
685
  <zeroOrMore>
666
686
  <choice>
@@ -697,6 +717,16 @@
697
717
  </choice>
698
718
  </attribute>
699
719
  </optional>
720
+ <optional>
721
+ <attribute name="valign">
722
+ <choice>
723
+ <value>top</value>
724
+ <value>middle</value>
725
+ <value>bottom</value>
726
+ <value>baseline</value>
727
+ </choice>
728
+ </attribute>
729
+ </optional>
700
730
  <choice>
701
731
  <zeroOrMore>
702
732
  <choice>
@@ -855,7 +885,7 @@
855
885
  <oneOrMore>
856
886
  <choice>
857
887
  <ref name="content"/>
858
- <ref name="preface_abstract"/>
888
+ <ref name="abstract"/>
859
889
  <ref name="foreword"/>
860
890
  <ref name="introduction"/>
861
891
  <ref name="acknowledgements"/>
@@ -922,6 +952,9 @@
922
952
  <optional>
923
953
  <attribute name="script"/>
924
954
  </optional>
955
+ <optional>
956
+ <attribute name="type"/>
957
+ </optional>
925
958
  <optional>
926
959
  <attribute name="obligation">
927
960
  <choice>
@@ -961,9 +994,6 @@
961
994
  </define>
962
995
  <define name="content-subsection">
963
996
  <element name="clause">
964
- <optional>
965
- <attribute name="type"/>
966
- </optional>
967
997
  <ref name="Content-Section"/>
968
998
  </element>
969
999
  </define>
@@ -992,6 +1022,9 @@
992
1022
  </choice>
993
1023
  </attribute>
994
1024
  </optional>
1025
+ <optional>
1026
+ <attribute name="type"/>
1027
+ </optional>
995
1028
  <optional>
996
1029
  <ref name="section-title"/>
997
1030
  </optional>
@@ -1011,9 +1044,6 @@
1011
1044
  </define>
1012
1045
  <define name="clause">
1013
1046
  <element name="clause">
1014
- <optional>
1015
- <attribute name="type"/>
1016
- </optional>
1017
1047
  <ref name="Clause-Section"/>
1018
1048
  </element>
1019
1049
  </define>
@@ -1042,18 +1072,24 @@
1042
1072
  </choice>
1043
1073
  </attribute>
1044
1074
  </optional>
1075
+ <optional>
1076
+ <attribute name="type"/>
1077
+ </optional>
1045
1078
  <optional>
1046
1079
  <ref name="section-title"/>
1047
1080
  </optional>
1048
1081
  <group>
1049
- <group>
1050
- <zeroOrMore>
1051
- <ref name="BasicBlock"/>
1052
- </zeroOrMore>
1053
- <zeroOrMore>
1054
- <ref name="note"/>
1055
- </zeroOrMore>
1056
- </group>
1082
+ <choice>
1083
+ <group>
1084
+ <zeroOrMore>
1085
+ <ref name="BasicBlock"/>
1086
+ </zeroOrMore>
1087
+ <zeroOrMore>
1088
+ <ref name="note"/>
1089
+ </zeroOrMore>
1090
+ </group>
1091
+ <ref name="amend"/>
1092
+ </choice>
1057
1093
  <zeroOrMore>
1058
1094
  <choice>
1059
1095
  <ref name="clause-subsection"/>
@@ -1180,6 +1216,9 @@
1180
1216
  <optional>
1181
1217
  <attribute name="script"/>
1182
1218
  </optional>
1219
+ <optional>
1220
+ <attribute name="type"/>
1221
+ </optional>
1183
1222
  <optional>
1184
1223
  <attribute name="obligation">
1185
1224
  <choice>
@@ -1447,11 +1486,6 @@
1447
1486
  </optional>
1448
1487
  </element>
1449
1488
  </define>
1450
- <define name="preface_abstract">
1451
- <element name="abstract">
1452
- <ref name="Basic-Section"/>
1453
- </element>
1454
- </define>
1455
1489
  <define name="term-clause">
1456
1490
  <element name="clause">
1457
1491
  <optional>
@@ -1501,4 +1535,79 @@
1501
1535
  <ref name="CitationType"/>
1502
1536
  </element>
1503
1537
  </define>
1538
+ <define name="amend">
1539
+ <element name="amend">
1540
+ <optional>
1541
+ <attribute name="id">
1542
+ <data type="ID"/>
1543
+ </attribute>
1544
+ </optional>
1545
+ <attribute name="change">
1546
+ <choice>
1547
+ <value>add</value>
1548
+ <value>modify</value>
1549
+ <value>delete</value>
1550
+ </choice>
1551
+ </attribute>
1552
+ <optional>
1553
+ <attribute name="path"/>
1554
+ </optional>
1555
+ <optional>
1556
+ <attribute name="path_end"/>
1557
+ </optional>
1558
+ <optional>
1559
+ <attribute name="title"/>
1560
+ </optional>
1561
+ <optional>
1562
+ <element name="location">
1563
+ <zeroOrMore>
1564
+ <ref name="locality"/>
1565
+ </zeroOrMore>
1566
+ </element>
1567
+ </optional>
1568
+ <zeroOrMore>
1569
+ <ref name="autonumber"/>
1570
+ </zeroOrMore>
1571
+ <optional>
1572
+ <element name="description">
1573
+ <zeroOrMore>
1574
+ <ref name="BasicBlock"/>
1575
+ </zeroOrMore>
1576
+ </element>
1577
+ </optional>
1578
+ <optional>
1579
+ <element name="newcontent">
1580
+ <zeroOrMore>
1581
+ <ref name="BasicBlock"/>
1582
+ </zeroOrMore>
1583
+ </element>
1584
+ </optional>
1585
+ <optional>
1586
+ <element name="description">
1587
+ <zeroOrMore>
1588
+ <ref name="BasicBlock"/>
1589
+ </zeroOrMore>
1590
+ </element>
1591
+ </optional>
1592
+ </element>
1593
+ </define>
1594
+ <define name="autonumber">
1595
+ <element name="autonumber">
1596
+ <attribute name="type">
1597
+ <choice>
1598
+ <value>requirement</value>
1599
+ <value>recommendation</value>
1600
+ <value>permission</value>
1601
+ <value>table</value>
1602
+ <value>figure</value>
1603
+ <value>admonition</value>
1604
+ <value>formula</value>
1605
+ <value>sourcecode</value>
1606
+ <value>example</value>
1607
+ <value>note</value>
1608
+ </choice>
1609
+ </attribute>
1610
+ <text/>
1611
+ </element>
1612
+ </define>
1504
1613
  </grammar>
@@ -39,12 +39,6 @@
39
39
  <optional>
40
40
  <attribute name="filename"/>
41
41
  </optional>
42
- <optional>
43
- <attribute name="model"/>
44
- </optional>
45
- <optional>
46
- <attribute name="type"/>
47
- </optional>
48
42
  <optional>
49
43
  <ref name="reqtitle"/>
50
44
  </optional>
@@ -54,9 +48,9 @@
54
48
  <optional>
55
49
  <ref name="subject"/>
56
50
  </optional>
57
- <zeroOrMore>
51
+ <optional>
58
52
  <ref name="reqinherit"/>
59
- </zeroOrMore>
53
+ </optional>
60
54
  <zeroOrMore>
61
55
  <ref name="classification"/>
62
56
  </zeroOrMore>
@@ -1,5 +1,7 @@
1
+ require "forwardable"
1
2
  require "relaton_bib/version"
2
3
  require "relaton_bib/deep_dup"
4
+ require "relaton_bib/localized_string"
3
5
  require "relaton_bib/bibliographic_item"
4
6
  require "relaton_bib/hit_collection"
5
7
  require "relaton_bib/hit"
@@ -34,7 +36,7 @@ module RelatonBib
34
36
 
35
37
  # @param array [Array]
36
38
  # @return [Array<String>, String]
37
- def single_element_array(array) # rubocop:disable Metrics/CyclomaticComplexity
39
+ def single_element_array(array) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
38
40
  if array.size > 1
39
41
  array.map { |e| e.is_a?(String) ? e : e.to_hash }
40
42
  else
@@ -1,4 +1,31 @@
1
1
  module RelatonBib
2
+ class BiblioNoteCollection
3
+ extend Forwardable
4
+
5
+ def_delegators :@array, :[], :first, :last, :empty?, :any?, :size,
6
+ :each, :map, :detect, :length
7
+
8
+ def initialize(notes)
9
+ @array = notes
10
+ end
11
+
12
+ # @param bibnote [RelatonBib::BiblioNote]
13
+ # @return [self]
14
+ def <<(bibnote)
15
+ @array << bibnote
16
+ self
17
+ end
18
+
19
+ # @param opts [Hash]
20
+ # @option opts [Nokogiri::XML::Builder] XML builder
21
+ # @option opts [String] :lang language
22
+ def to_xml(**opts)
23
+ bnc = @array.select { |bn| bn.language&.include? opts[:lang] }
24
+ bnc = @array unless bnc.any?
25
+ bnc.each { |bn| bn.to_xml opts[:builder] }
26
+ end
27
+ end
28
+
2
29
  class BiblioNote < FormattedString
3
30
  # @return [String, NilClass]
4
31
  attr_reader :type