relaton-iho 1.3.1 → 1.6.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +2 -0
- data/README.adoc +41 -29
- data/grammars/iho.rng +37 -6
- data/grammars/isodoc.rng +136 -21
- data/lib/relaton_iho/hash_converter.rb +6 -0
- data/lib/relaton_iho/iho_bibliographic_item.rb +7 -5
- data/lib/relaton_iho/iho_bibliography.rb +2 -2
- data/lib/relaton_iho/processor.rb +1 -1
- data/lib/relaton_iho/version.rb +1 -1
- data/relaton_iho.gemspec +1 -1
- metadata +6 -7
- data/lib/relaton_iho/hit_collection.rb +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f6b35618da8db83fd5fcab35e3649701563b9fa6bdad118a734926cb50559c2
|
4
|
+
data.tar.gz: c6e090cd41d76ed1b251664e9d7632b8ff9da12cfcf09dd9929f49e05c888292
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d252969dbe456a60ae675a4393d85da370bfc9c3041a41e048b2497902cf749e2744232e9ab9c26edc589a8e9c8f8ddb877b620c867081a7fd6fe54bdbdb4cbd
|
7
|
+
data.tar.gz: 49aeba39f6efe70e9df04efe6ebb48511cc7e84ea3b4def5ef5b762ab6b1b3da03e93981602e113cae300b1b3e2c17c34e341a6c89c69575edfdd4b782f97ffc
|
data/.github/workflows/macos.yml
CHANGED
@@ -26,6 +26,8 @@ jobs:
|
|
26
26
|
- name: Update gems
|
27
27
|
run: |
|
28
28
|
sudo gem install bundler --force
|
29
|
+
ruby -v | grep 2.5 && bundle config set build.debase --with-cflags="-Wno-error=implicit-function-declaration"
|
30
|
+
ruby -v | grep 2.5 && bundle config set build.ruby-debug-ide --with-cflags="-Wno-error=implicit-function-declaration"
|
29
31
|
bundle install --jobs 4 --retry 3
|
30
32
|
- name: Run specs
|
31
33
|
run: |
|
data/README.adoc
CHANGED
@@ -32,7 +32,7 @@ Or install it yourself as:
|
|
32
32
|
|
33
33
|
[source,sh]
|
34
34
|
----
|
35
|
-
$ gem install
|
35
|
+
$ gem install relaton-iho
|
36
36
|
----
|
37
37
|
|
38
38
|
== Usage
|
@@ -41,11 +41,13 @@ $ gem install relaton_iho
|
|
41
41
|
|
42
42
|
[source,ruby]
|
43
43
|
----
|
44
|
-
|
45
|
-
=>
|
44
|
+
pry(main)> require 'relaton_iho'
|
45
|
+
=> true
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
item = RelatonIho::IhoBibliography.search("B-11")
|
48
|
+
[relaton-iho] ("B-11") fetching...
|
49
|
+
[relaton-iho] ("B-11") found B-11
|
50
|
+
=> #<RelatonIho::IhoBibliographicItem:0x007fe74fc80800
|
49
51
|
...
|
50
52
|
----
|
51
53
|
|
@@ -53,14 +55,12 @@ tem = hits[0].fetch
|
|
53
55
|
[source,ruby]
|
54
56
|
----
|
55
57
|
item.to_xml
|
56
|
-
=> "<bibitem id="
|
57
|
-
<
|
58
|
-
<title type="main" format="text/plain" language="en"
|
59
|
-
<
|
60
|
-
<
|
61
|
-
<
|
62
|
-
<on>2019</on>
|
63
|
-
</date>
|
58
|
+
=> "<bibitem id="B-11" type="standard">
|
59
|
+
<fetched>2020-03-29</fetched>
|
60
|
+
<title type="main" format="text/plain" language="en">IHO-IOC GEBCO Cook Book</title>
|
61
|
+
<title type="main" format="text/plain" language="fr">Livre de recettes GEBCO OHI-COI</title>
|
62
|
+
<uri type="pdf">https://www.star.nesdis.noaa.gov/socd/lsa/GEBCO_Cookbook/documents/CookBook_20191031.pdf</uri>
|
63
|
+
<docidentifier type="IHO">B-11</docidentifier>
|
64
64
|
...
|
65
65
|
</bibitem>"
|
66
66
|
----
|
@@ -69,33 +69,45 @@ With argument `bibdata: true` it ouputs XML wrapped by `bibdata` element and add
|
|
69
69
|
----
|
70
70
|
item.to_xml bibdata: true
|
71
71
|
=> "<bibdata type="standard">
|
72
|
-
<
|
73
|
-
<title type="main" format="text/plain" language="en"
|
74
|
-
<
|
75
|
-
<
|
76
|
-
<
|
77
|
-
<on>2019</on>
|
78
|
-
</date>
|
72
|
+
<fetched>2020-03-29</fetched>
|
73
|
+
<title type="main" format="text/plain" language="en">IHO-IOC GEBCO Cook Book</title>
|
74
|
+
<title type="main" format="text/plain" language="fr">Livre de recettes GEBCO OHI-COI</title>
|
75
|
+
<uri type="pdf">https://www.star.nesdis.noaa.gov/socd/lsa/GEBCO_Cookbook/documents/CookBook_20191031.pdf</uri>
|
76
|
+
<docidentifier type="IHO">B-11</docidentifier>
|
79
77
|
...
|
80
78
|
<ext>
|
81
|
-
<
|
79
|
+
<editorialgroup>
|
80
|
+
<committee>
|
81
|
+
<name>Hydrographic Services and Standards Committee</name>
|
82
|
+
<abbreviation>HSSC</abbreviation>
|
83
|
+
</committee>
|
84
|
+
<committee>
|
85
|
+
<name>Inter-Regional Coordination Committee</name>
|
86
|
+
<abbreviation>IRCC</abbreviation>
|
87
|
+
<committee>
|
88
|
+
<name>JOINT IHO-IOC GUIDING COMMITTEE FOR THE GENERAL BATHYMETRIC CHART OF THE OCEANS</name>
|
89
|
+
<abbreviation>GEBCO</abbreviation>
|
90
|
+
</committee>
|
91
|
+
</committee>
|
92
|
+
</editorialgroup>
|
82
93
|
</ext>
|
83
94
|
</bibdata>"
|
84
95
|
----
|
85
96
|
|
86
|
-
=== Get code
|
97
|
+
=== Get code
|
87
98
|
[source,ruby]
|
88
99
|
----
|
89
|
-
RelatonIho::IhoBibliography.get "
|
90
|
-
|
91
|
-
|
100
|
+
RelatonIho::IhoBibliography.get "IHO B-11"
|
101
|
+
[relaton-iho] ("IHO B-11") fetching...
|
102
|
+
[relaton-iho] ("IHO B-11") found B-11
|
103
|
+
=> #<RelatonIho::IhoBibliographicItem:0x007fe78dbb7c78
|
92
104
|
...
|
93
105
|
----
|
94
106
|
|
95
107
|
=== Create bibliographic item from XML
|
96
108
|
[source,ruby]
|
97
109
|
----
|
98
|
-
RelatonIho::XMLParser.from_xml File.read('spec/fixtures/
|
110
|
+
RelatonIho::XMLParser.from_xml File.read('spec/fixtures/iho.xml')
|
99
111
|
=> #<RelatonIho::IhoBibliographicItem:0x007fc322ea82c8
|
100
112
|
...
|
101
113
|
----
|
@@ -103,12 +115,12 @@ RelatonIho::XMLParser.from_xml File.read('spec/fixtures/ogc_bib_item.xml')
|
|
103
115
|
=== Create bibliographic item from YAML
|
104
116
|
[source,ruby]
|
105
117
|
----
|
106
|
-
hash = YAML.load_file 'spec/fixtures/
|
107
|
-
=> {"id"=>"
|
118
|
+
hash = YAML.load_file 'spec/fixtures/iho.yaml'
|
119
|
+
=> {"id"=>"B-11",
|
108
120
|
...
|
109
121
|
|
110
122
|
bib_hash = RelatonIho::HashConverter.hash_to_bib hash
|
111
|
-
=> {:id=>"
|
123
|
+
=> {:id=>"B-11",
|
112
124
|
...
|
113
125
|
|
114
126
|
RelatonIho::IhoBibliographicItem.new bib_hash
|
data/grammars/iho.rng
CHANGED
@@ -23,8 +23,13 @@
|
|
23
23
|
</define>
|
24
24
|
<define name="editorialgroup">
|
25
25
|
<element name="editorialgroup">
|
26
|
-
<
|
27
|
-
|
26
|
+
<oneOrMore>
|
27
|
+
<choice>
|
28
|
+
<ref name="committee"/>
|
29
|
+
<ref name="workgroup"/>
|
30
|
+
<ref name="commission"/>
|
31
|
+
</choice>
|
32
|
+
</oneOrMore>
|
28
33
|
</element>
|
29
34
|
</define>
|
30
35
|
<define name="BibDataExtensionType">
|
@@ -94,16 +99,35 @@
|
|
94
99
|
</include>
|
95
100
|
<define name="committee">
|
96
101
|
<element name="committee">
|
97
|
-
<
|
98
|
-
<value>hssc</value>
|
99
|
-
<value>ircc</value>
|
100
|
-
</choice>
|
102
|
+
<ref name="IHO_Group"/>
|
101
103
|
</element>
|
102
104
|
</define>
|
103
105
|
<define name="workgroup">
|
104
106
|
<element name="workgroup">
|
107
|
+
<ref name="IHO_Group"/>
|
108
|
+
</element>
|
109
|
+
</define>
|
110
|
+
<define name="commission">
|
111
|
+
<element name="commission">
|
112
|
+
<ref name="IHO_Group"/>
|
113
|
+
</element>
|
114
|
+
</define>
|
115
|
+
<define name="IHO_Group">
|
116
|
+
<optional>
|
117
|
+
<element name="name">
|
118
|
+
<text/>
|
119
|
+
</element>
|
120
|
+
</optional>
|
121
|
+
<element name="abbreviation">
|
105
122
|
<text/>
|
106
123
|
</element>
|
124
|
+
<optional>
|
125
|
+
<choice>
|
126
|
+
<ref name="committee"/>
|
127
|
+
<ref name="workgroup"/>
|
128
|
+
<ref name="commission"/>
|
129
|
+
</choice>
|
130
|
+
</optional>
|
107
131
|
</define>
|
108
132
|
<define name="annex-appendix">
|
109
133
|
<element name="appendix">
|
@@ -124,6 +148,13 @@
|
|
124
148
|
</define>
|
125
149
|
<define name="iho-standard">
|
126
150
|
<element name="iho-standard">
|
151
|
+
<attribute name="version"/>
|
152
|
+
<attribute name="type">
|
153
|
+
<choice>
|
154
|
+
<value>semantic</value>
|
155
|
+
<value>presentation</value>
|
156
|
+
</choice>
|
157
|
+
</attribute>
|
127
158
|
<ref name="bibdata"/>
|
128
159
|
<zeroOrMore>
|
129
160
|
<ref name="termdocsource"/>
|
data/grammars/isodoc.rng
CHANGED
@@ -43,7 +43,9 @@
|
|
43
43
|
<define name="xref">
|
44
44
|
<element name="xref">
|
45
45
|
<attribute name="target">
|
46
|
-
<data type="
|
46
|
+
<data type="string">
|
47
|
+
<param name="pattern">\i\c*|\c+#\c+</param>
|
48
|
+
</data>
|
47
49
|
</attribute>
|
48
50
|
<optional>
|
49
51
|
<attribute name="type">
|
@@ -61,6 +63,11 @@
|
|
61
63
|
</choice>
|
62
64
|
</attribute>
|
63
65
|
</optional>
|
66
|
+
<optional>
|
67
|
+
<attribute name="droploc">
|
68
|
+
<data type="boolean"/>
|
69
|
+
</attribute>
|
70
|
+
</optional>
|
64
71
|
<text/>
|
65
72
|
</element>
|
66
73
|
</define>
|
@@ -578,6 +585,8 @@
|
|
578
585
|
<ref name="ol"/>
|
579
586
|
<ref name="dl"/>
|
580
587
|
<ref name="formula"/>
|
588
|
+
<ref name="quote"/>
|
589
|
+
<ref name="sourcecode"/>
|
581
590
|
</choice>
|
582
591
|
</oneOrMore>
|
583
592
|
</element>
|
@@ -661,6 +670,16 @@
|
|
661
670
|
</choice>
|
662
671
|
</attribute>
|
663
672
|
</optional>
|
673
|
+
<optional>
|
674
|
+
<attribute name="valign">
|
675
|
+
<choice>
|
676
|
+
<value>top</value>
|
677
|
+
<value>middle</value>
|
678
|
+
<value>bottom</value>
|
679
|
+
<value>baseline</value>
|
680
|
+
</choice>
|
681
|
+
</attribute>
|
682
|
+
</optional>
|
664
683
|
<choice>
|
665
684
|
<zeroOrMore>
|
666
685
|
<choice>
|
@@ -697,6 +716,16 @@
|
|
697
716
|
</choice>
|
698
717
|
</attribute>
|
699
718
|
</optional>
|
719
|
+
<optional>
|
720
|
+
<attribute name="valign">
|
721
|
+
<choice>
|
722
|
+
<value>top</value>
|
723
|
+
<value>middle</value>
|
724
|
+
<value>bottom</value>
|
725
|
+
<value>baseline</value>
|
726
|
+
</choice>
|
727
|
+
</attribute>
|
728
|
+
</optional>
|
700
729
|
<choice>
|
701
730
|
<zeroOrMore>
|
702
731
|
<choice>
|
@@ -834,6 +863,13 @@
|
|
834
863
|
</define>
|
835
864
|
<define name="standard-document">
|
836
865
|
<element name="standard-document">
|
866
|
+
<attribute name="version"/>
|
867
|
+
<attribute name="type">
|
868
|
+
<choice>
|
869
|
+
<value>semantic</value>
|
870
|
+
<value>presentation</value>
|
871
|
+
</choice>
|
872
|
+
</attribute>
|
837
873
|
<ref name="bibdata"/>
|
838
874
|
<optional>
|
839
875
|
<ref name="boilerplate"/>
|
@@ -855,7 +891,7 @@
|
|
855
891
|
<oneOrMore>
|
856
892
|
<choice>
|
857
893
|
<ref name="content"/>
|
858
|
-
<ref name="
|
894
|
+
<ref name="abstract"/>
|
859
895
|
<ref name="foreword"/>
|
860
896
|
<ref name="introduction"/>
|
861
897
|
<ref name="acknowledgements"/>
|
@@ -922,6 +958,9 @@
|
|
922
958
|
<optional>
|
923
959
|
<attribute name="script"/>
|
924
960
|
</optional>
|
961
|
+
<optional>
|
962
|
+
<attribute name="type"/>
|
963
|
+
</optional>
|
925
964
|
<optional>
|
926
965
|
<attribute name="obligation">
|
927
966
|
<choice>
|
@@ -961,9 +1000,6 @@
|
|
961
1000
|
</define>
|
962
1001
|
<define name="content-subsection">
|
963
1002
|
<element name="clause">
|
964
|
-
<optional>
|
965
|
-
<attribute name="type"/>
|
966
|
-
</optional>
|
967
1003
|
<ref name="Content-Section"/>
|
968
1004
|
</element>
|
969
1005
|
</define>
|
@@ -992,6 +1028,9 @@
|
|
992
1028
|
</choice>
|
993
1029
|
</attribute>
|
994
1030
|
</optional>
|
1031
|
+
<optional>
|
1032
|
+
<attribute name="type"/>
|
1033
|
+
</optional>
|
995
1034
|
<optional>
|
996
1035
|
<ref name="section-title"/>
|
997
1036
|
</optional>
|
@@ -1011,9 +1050,6 @@
|
|
1011
1050
|
</define>
|
1012
1051
|
<define name="clause">
|
1013
1052
|
<element name="clause">
|
1014
|
-
<optional>
|
1015
|
-
<attribute name="type"/>
|
1016
|
-
</optional>
|
1017
1053
|
<ref name="Clause-Section"/>
|
1018
1054
|
</element>
|
1019
1055
|
</define>
|
@@ -1042,18 +1078,24 @@
|
|
1042
1078
|
</choice>
|
1043
1079
|
</attribute>
|
1044
1080
|
</optional>
|
1081
|
+
<optional>
|
1082
|
+
<attribute name="type"/>
|
1083
|
+
</optional>
|
1045
1084
|
<optional>
|
1046
1085
|
<ref name="section-title"/>
|
1047
1086
|
</optional>
|
1048
1087
|
<group>
|
1049
|
-
<
|
1050
|
-
<
|
1051
|
-
<
|
1052
|
-
|
1053
|
-
|
1054
|
-
<
|
1055
|
-
|
1056
|
-
|
1088
|
+
<choice>
|
1089
|
+
<group>
|
1090
|
+
<zeroOrMore>
|
1091
|
+
<ref name="BasicBlock"/>
|
1092
|
+
</zeroOrMore>
|
1093
|
+
<zeroOrMore>
|
1094
|
+
<ref name="note"/>
|
1095
|
+
</zeroOrMore>
|
1096
|
+
</group>
|
1097
|
+
<ref name="amend"/>
|
1098
|
+
</choice>
|
1057
1099
|
<zeroOrMore>
|
1058
1100
|
<choice>
|
1059
1101
|
<ref name="clause-subsection"/>
|
@@ -1180,6 +1222,9 @@
|
|
1180
1222
|
<optional>
|
1181
1223
|
<attribute name="script"/>
|
1182
1224
|
</optional>
|
1225
|
+
<optional>
|
1226
|
+
<attribute name="type"/>
|
1227
|
+
</optional>
|
1183
1228
|
<optional>
|
1184
1229
|
<attribute name="obligation">
|
1185
1230
|
<choice>
|
@@ -1447,11 +1492,6 @@
|
|
1447
1492
|
</optional>
|
1448
1493
|
</element>
|
1449
1494
|
</define>
|
1450
|
-
<define name="preface_abstract">
|
1451
|
-
<element name="abstract">
|
1452
|
-
<ref name="Basic-Section"/>
|
1453
|
-
</element>
|
1454
|
-
</define>
|
1455
1495
|
<define name="term-clause">
|
1456
1496
|
<element name="clause">
|
1457
1497
|
<optional>
|
@@ -1501,4 +1541,79 @@
|
|
1501
1541
|
<ref name="CitationType"/>
|
1502
1542
|
</element>
|
1503
1543
|
</define>
|
1544
|
+
<define name="amend">
|
1545
|
+
<element name="amend">
|
1546
|
+
<optional>
|
1547
|
+
<attribute name="id">
|
1548
|
+
<data type="ID"/>
|
1549
|
+
</attribute>
|
1550
|
+
</optional>
|
1551
|
+
<attribute name="change">
|
1552
|
+
<choice>
|
1553
|
+
<value>add</value>
|
1554
|
+
<value>modify</value>
|
1555
|
+
<value>delete</value>
|
1556
|
+
</choice>
|
1557
|
+
</attribute>
|
1558
|
+
<optional>
|
1559
|
+
<attribute name="path"/>
|
1560
|
+
</optional>
|
1561
|
+
<optional>
|
1562
|
+
<attribute name="path_end"/>
|
1563
|
+
</optional>
|
1564
|
+
<optional>
|
1565
|
+
<attribute name="title"/>
|
1566
|
+
</optional>
|
1567
|
+
<optional>
|
1568
|
+
<element name="location">
|
1569
|
+
<zeroOrMore>
|
1570
|
+
<ref name="locality"/>
|
1571
|
+
</zeroOrMore>
|
1572
|
+
</element>
|
1573
|
+
</optional>
|
1574
|
+
<zeroOrMore>
|
1575
|
+
<ref name="autonumber"/>
|
1576
|
+
</zeroOrMore>
|
1577
|
+
<optional>
|
1578
|
+
<element name="description">
|
1579
|
+
<zeroOrMore>
|
1580
|
+
<ref name="BasicBlock"/>
|
1581
|
+
</zeroOrMore>
|
1582
|
+
</element>
|
1583
|
+
</optional>
|
1584
|
+
<optional>
|
1585
|
+
<element name="newcontent">
|
1586
|
+
<zeroOrMore>
|
1587
|
+
<ref name="BasicBlock"/>
|
1588
|
+
</zeroOrMore>
|
1589
|
+
</element>
|
1590
|
+
</optional>
|
1591
|
+
<optional>
|
1592
|
+
<element name="description">
|
1593
|
+
<zeroOrMore>
|
1594
|
+
<ref name="BasicBlock"/>
|
1595
|
+
</zeroOrMore>
|
1596
|
+
</element>
|
1597
|
+
</optional>
|
1598
|
+
</element>
|
1599
|
+
</define>
|
1600
|
+
<define name="autonumber">
|
1601
|
+
<element name="autonumber">
|
1602
|
+
<attribute name="type">
|
1603
|
+
<choice>
|
1604
|
+
<value>requirement</value>
|
1605
|
+
<value>recommendation</value>
|
1606
|
+
<value>permission</value>
|
1607
|
+
<value>table</value>
|
1608
|
+
<value>figure</value>
|
1609
|
+
<value>admonition</value>
|
1610
|
+
<value>formula</value>
|
1611
|
+
<value>sourcecode</value>
|
1612
|
+
<value>example</value>
|
1613
|
+
<value>note</value>
|
1614
|
+
</choice>
|
1615
|
+
</attribute>
|
1616
|
+
<text/>
|
1617
|
+
</element>
|
1618
|
+
</define>
|
1504
1619
|
</grammar>
|
@@ -15,6 +15,12 @@ module RelatonIho
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
+
# @param item_hash [Hash]
|
19
|
+
# @return [RelatonBib::BibliographicItem]
|
20
|
+
def bib_item(item_hash)
|
21
|
+
IhoBibliographicItem.new item_hash
|
22
|
+
end
|
23
|
+
|
18
24
|
# @param ret [Hash]
|
19
25
|
def commentperiod_hash_to_bib(ret)
|
20
26
|
ret[:commentperiod] &&= CommentPeriond.new(ret[:commentperiod])
|
@@ -13,11 +13,13 @@ module RelatonIho
|
|
13
13
|
super
|
14
14
|
end
|
15
15
|
|
16
|
-
# @param
|
17
|
-
# @
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
# @param opts [Hash]
|
17
|
+
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
18
|
+
# @option opts [Boolean] :bibdata
|
19
|
+
# @option opts [String] :lang language
|
20
|
+
# @return [String] XML
|
21
|
+
def to_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
22
|
+
super ext: !commentperiod.nil?, **opts do |b|
|
21
23
|
if opts[:bibdata] && (doctype || editorialgroup&.presence? ||
|
22
24
|
ics.any? || commentperiod)
|
23
25
|
b.ext do
|
@@ -10,7 +10,7 @@ module RelatonIho
|
|
10
10
|
# @return [RelatonIho::IhoBibliographicItem]
|
11
11
|
def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
12
12
|
warn "[relaton-iho] (\"#{text}\") fetching..."
|
13
|
-
ref = text.sub(/^IHO\s/, "").downcase
|
13
|
+
ref = text.sub(/^IHO\s/, "").downcase.sub /^([[:alpha:]]+)(\d+)/, '\1-\2'
|
14
14
|
uri = URI("#{ENDPOINT}#{ref}.yaml")
|
15
15
|
resp = Net::HTTP.get_response uri
|
16
16
|
return unless resp.code == "200"
|
@@ -21,7 +21,7 @@ module RelatonIho
|
|
21
21
|
item
|
22
22
|
rescue SocketError, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
23
23
|
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
24
|
-
Net::ProtocolError, Net::ReadTimeout, OpenSSL::SSL::SSLError,
|
24
|
+
Net::ProtocolError, Net::ReadTimeout, # OpenSSL::SSL::SSLError,
|
25
25
|
Errno::ETIMEDOUT => e
|
26
26
|
raise RelatonBib::RequestError, "Could not access #{uri}: #{e.message}"
|
27
27
|
end
|
data/lib/relaton_iho/version.rb
CHANGED
data/relaton_iho.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-iho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1.
|
159
|
+
version: 1.6.pre
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 1.
|
166
|
+
version: 1.6.pre
|
167
167
|
description: 'RelatonIho: retrieve IHO Standards for bibliographic using the BibliographicItem
|
168
168
|
model'
|
169
169
|
email:
|
@@ -192,7 +192,6 @@ files:
|
|
192
192
|
- lib/relaton_iho/editorial_group.rb
|
193
193
|
- lib/relaton_iho/eg.yml
|
194
194
|
- lib/relaton_iho/hash_converter.rb
|
195
|
-
- lib/relaton_iho/hit_collection.rb
|
196
195
|
- lib/relaton_iho/iho_bibliographic_item.rb
|
197
196
|
- lib/relaton_iho/iho_bibliography.rb
|
198
197
|
- lib/relaton_iho/iho_group.rb
|
@@ -215,9 +214,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
214
|
version: 2.4.0
|
216
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
216
|
requirements:
|
218
|
-
- - "
|
217
|
+
- - ">"
|
219
218
|
- !ruby/object:Gem::Version
|
220
|
-
version:
|
219
|
+
version: 1.3.1
|
221
220
|
requirements: []
|
222
221
|
rubygems_version: 3.0.6
|
223
222
|
signing_key:
|
@@ -1,73 +0,0 @@
|
|
1
|
-
require "faraday"
|
2
|
-
require "yaml"
|
3
|
-
require "fileutils"
|
4
|
-
|
5
|
-
module RelatonIho
|
6
|
-
class HitCollection < RelatonBib::HitCollection
|
7
|
-
ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-iho/master/data/".freeze
|
8
|
-
|
9
|
-
# @param ref [Strig]
|
10
|
-
# @param year [String]
|
11
|
-
# @param opts [Hash]
|
12
|
-
def initialize(ref, year = nil)
|
13
|
-
super
|
14
|
-
@array = from_yaml(ref).sort_by do |hit|
|
15
|
-
hit.hit["revdate"] ? Date.parse(hit.hit["revdate"]) : Date.new
|
16
|
-
end.reverse
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
#
|
22
|
-
# Fetch data form yaml
|
23
|
-
#
|
24
|
-
# @param docid [String]
|
25
|
-
def from_yaml(docid, **_opts)
|
26
|
-
data["root"]["items"].select do |doc|
|
27
|
-
doc["docid"] && doc["docid"]["id"].include?(docid)
|
28
|
-
end.map { |h| Hit.new(h, self) }
|
29
|
-
end
|
30
|
-
|
31
|
-
#
|
32
|
-
# Fetches YAML data
|
33
|
-
#
|
34
|
-
# @return [Hash]
|
35
|
-
def data
|
36
|
-
FileUtils.mkdir_p DATADIR
|
37
|
-
ctime = File.ctime DATAFILE if File.exist? DATAFILE
|
38
|
-
fetch_data if !ctime || ctime.to_date < Date.today
|
39
|
-
@data ||= YAML.safe_load File.read(DATAFILE, encoding: "UTF-8")
|
40
|
-
end
|
41
|
-
|
42
|
-
#
|
43
|
-
# fetch data form server and save it to file.
|
44
|
-
#
|
45
|
-
def fetch_data
|
46
|
-
resp = Faraday.new(ENDPOINT, headers: { "If-None-Match" => etag }).get
|
47
|
-
# return if there aren't any changes since last fetching
|
48
|
-
return unless resp.status == 200
|
49
|
-
|
50
|
-
self.etag = resp[:etag]
|
51
|
-
@data = YAML.safe_load resp.body
|
52
|
-
File.write DATAFILE, @data.to_yaml, encoding: "UTF-8"
|
53
|
-
end
|
54
|
-
|
55
|
-
#
|
56
|
-
# Read ETag form file
|
57
|
-
#
|
58
|
-
# @return [String, NilClass]
|
59
|
-
def etag
|
60
|
-
@etag ||= if File.exist? ETAGFILE
|
61
|
-
File.read ETAGFILE, encoding: "UTF-8"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
#
|
66
|
-
# Save ETag to file
|
67
|
-
#
|
68
|
-
# @param tag [String]
|
69
|
-
def etag=(e_tag)
|
70
|
-
File.write ETAGFILE, e_tag, encoding: "UTF-8"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|