relaton-iho 1.16.1 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +19 -8
- data/grammars/basicdoc.rng +18 -2
- data/grammars/biblio.rng +1 -0
- data/lib/relaton_iho/document_type.rb +17 -0
- data/lib/relaton_iho/hash_converter.rb +47 -43
- data/lib/relaton_iho/iho_bibliographic_item.rb +1 -4
- data/lib/relaton_iho/iho_bibliography.rb +3 -3
- data/lib/relaton_iho/version.rb +1 -1
- data/lib/relaton_iho.rb +1 -0
- data/relaton_iho.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a34fe61f191f15b4f9bd2896026ad6135ca6ae4e9682668ccc44b3015a83e367
|
4
|
+
data.tar.gz: fb58a578ac9a5af772237ee218cfb160e18b932cf88fa79497da1410e30cd220
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf24b4b1dfec02601c32c3be5b0130d5a099bf3cd238dc091834d601c0290fecc89a3fc1a6b9e669996cff94ce968a638ce182edf299a0001b9e250c78cd309c
|
7
|
+
data.tar.gz: a927a1545ff80aeda7cf65cdb888b27fda1d2f7d878fefd96cafcfe1085fb2fbf283cae2163dbf722b9cb1e76717eaf7b40d35eed5b5a04d6aa1547776b9e794
|
data/README.adoc
CHANGED
@@ -37,26 +37,37 @@ $ gem install relaton-iho
|
|
37
37
|
|
38
38
|
== Usage
|
39
39
|
|
40
|
-
===
|
40
|
+
=== Configuration
|
41
41
|
|
42
|
-
|
42
|
+
Configuration is optional. The available option is `logger` which is a `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level. To change the logger level, use `RelatonIho.configure` block.
|
43
43
|
|
44
44
|
[source,ruby]
|
45
45
|
----
|
46
46
|
require 'relaton_iho'
|
47
47
|
=> true
|
48
48
|
|
49
|
+
RelatonIho.configure do |config|
|
50
|
+
config.logger.level = Logger::DEBUG
|
51
|
+
end
|
52
|
+
----
|
53
|
+
|
54
|
+
=== Search for a standard using keywords
|
55
|
+
|
56
|
+
Reference can be specified with or without an edition. References without an edition will return the latest edition of the standard. References with an edition will return the standard with the specified edition.
|
57
|
+
|
58
|
+
[source,ruby]
|
59
|
+
----
|
49
60
|
# Search for a standard using a reference without an edition
|
50
61
|
item = RelatonIho::IhoBibliography.search("IHO B-11")
|
51
|
-
[relaton-iho] (
|
52
|
-
[relaton-iho] (
|
62
|
+
[relaton-iho] (IHO B-11) Fetching from Relaton repository ...
|
63
|
+
[relaton-iho] (IHO B-11) Found: `B-11`
|
53
64
|
=> #<RelatonIho::IhoBibliographicItem:0x007fe74fc80800
|
54
65
|
...
|
55
66
|
|
56
67
|
# Search for a standard using a reference with an edition
|
57
68
|
item = RelatonIho::IhoBibliography.search("IHO B-11 1.0.0")
|
58
|
-
[relaton-iho] (
|
59
|
-
[relaton-iho] (
|
69
|
+
[relaton-iho] (IHO B-11 1.0.0) Fetchint from Rlaont repository ...
|
70
|
+
[relaton-iho] (IHO B-11 1.0.0) Found: `B-11`
|
60
71
|
=> #<RelatonIho::IhoBibliographicItem:0x00007fe79d0ed698
|
61
72
|
...
|
62
73
|
----
|
@@ -95,8 +106,8 @@ item.to_xml bibdata: true
|
|
95
106
|
[source,ruby]
|
96
107
|
----
|
97
108
|
RelatonIho::IhoBibliography.get "IHO B-11"
|
98
|
-
[relaton-iho] (
|
99
|
-
[relaton-iho] (
|
109
|
+
[relaton-iho] (IHO B-11) Fetching from Relaton repository ...
|
110
|
+
[relaton-iho] (IHO B-11) Found: `B-11`
|
100
111
|
=> #<RelatonIho::IhoBibliographicItem:0x007fe78dbb7c78
|
101
112
|
...
|
102
113
|
----
|
data/grammars/basicdoc.rng
CHANGED
@@ -346,6 +346,8 @@
|
|
346
346
|
<ref name="keyword"/>
|
347
347
|
<ref name="xref"/>
|
348
348
|
<ref name="hyperlink"/>
|
349
|
+
<ref name="index"/>
|
350
|
+
<ref name="index-xref"/>
|
349
351
|
</choice>
|
350
352
|
</oneOrMore>
|
351
353
|
</element>
|
@@ -623,6 +625,8 @@
|
|
623
625
|
<ref name="eref"/>
|
624
626
|
<ref name="xref"/>
|
625
627
|
<ref name="hyperlink"/>
|
628
|
+
<ref name="index"/>
|
629
|
+
<ref name="index-xref"/>
|
626
630
|
</choice>
|
627
631
|
</zeroOrMore>
|
628
632
|
</element>
|
@@ -636,6 +640,8 @@
|
|
636
640
|
<ref name="eref"/>
|
637
641
|
<ref name="xref"/>
|
638
642
|
<ref name="hyperlink"/>
|
643
|
+
<ref name="index"/>
|
644
|
+
<ref name="index-xref"/>
|
639
645
|
</choice>
|
640
646
|
</zeroOrMore>
|
641
647
|
</element>
|
@@ -648,6 +654,8 @@
|
|
648
654
|
<ref name="eref"/>
|
649
655
|
<ref name="xref"/>
|
650
656
|
<ref name="hyperlink"/>
|
657
|
+
<ref name="index"/>
|
658
|
+
<ref name="index-xref"/>
|
651
659
|
</choice>
|
652
660
|
</zeroOrMore>
|
653
661
|
</element>
|
@@ -655,7 +663,11 @@
|
|
655
663
|
<define name="keyword">
|
656
664
|
<element name="keyword">
|
657
665
|
<zeroOrMore>
|
658
|
-
<
|
666
|
+
<choice>
|
667
|
+
<ref name="PureTextElement"/>
|
668
|
+
<ref name="index"/>
|
669
|
+
<ref name="index-xref"/>
|
670
|
+
</choice>
|
659
671
|
</zeroOrMore>
|
660
672
|
</element>
|
661
673
|
</define>
|
@@ -676,7 +688,11 @@
|
|
676
688
|
<define name="strike">
|
677
689
|
<element name="strike">
|
678
690
|
<zeroOrMore>
|
679
|
-
<
|
691
|
+
<choice>
|
692
|
+
<ref name="PureTextElement"/>
|
693
|
+
<ref name="index"/>
|
694
|
+
<ref name="index-xref"/>
|
695
|
+
</choice>
|
680
696
|
</zeroOrMore>
|
681
697
|
</element>
|
682
698
|
</define>
|
data/grammars/biblio.rng
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
module RelatonIho
|
2
|
+
class DocumentType < RelatonBib::DocumentType
|
3
|
+
DOCTYPES = %w[policy-and-procedures best-practices supporting-document
|
4
|
+
report legal directives proposal standard].freeze
|
5
|
+
|
6
|
+
def initialize(type:, abbreviation: nil)
|
7
|
+
check_type type
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def check_type(type)
|
12
|
+
unless DOCTYPES.include? type
|
13
|
+
Util.warn "WARNING: invalid doctype: `#{type}`"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,54 +1,58 @@
|
|
1
1
|
module RelatonIho
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
module HashConverter
|
3
|
+
include RelatonBib::HashConverter
|
4
|
+
extend self
|
5
|
+
# @override RelatonIsoBib::HashConverter.hash_to_bib
|
6
|
+
# @param args [Hash]
|
7
|
+
# @param nested [TrueClass, FalseClass]
|
8
|
+
# @return [Hash]
|
9
|
+
def hash_to_bib(args)
|
10
|
+
ret = super
|
11
|
+
return if ret.nil?
|
12
|
+
|
13
|
+
commentperiod_hash_to_bib ret
|
14
|
+
ret
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
+
private
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
# @param item_hash [Hash]
|
20
|
+
# @return [RelatonBib::BibliographicItem]
|
21
|
+
def bib_item(**item_hash)
|
22
|
+
IhoBibliographicItem.new(**item_hash)
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
# @param ret [Hash]
|
26
|
+
def commentperiod_hash_to_bib(ret)
|
27
|
+
ret[:commentperiod] &&= CommentPeriond.new(**ret[:commentperiod])
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
# @param ret [Hash]
|
31
|
+
def editorialgroup_hash_to_bib(ret)
|
32
|
+
eg = ret[:editorialgroup]
|
33
|
+
return unless eg.is_a?(Hash) || eg&.any?
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
ret[:editorialgroup] = EditorialGroupCollection.new collection
|
35
|
+
collection = RelatonBib.array(eg).map do |g|
|
36
|
+
EditorialGroup.new(RelatonBib.array(g).map { |wg| iho_workgroup wg })
|
38
37
|
end
|
38
|
+
ret[:editorialgroup] = EditorialGroupCollection.new collection
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
41
|
+
# @param ihowg [Hash]
|
42
|
+
# @return [RelatonIho::Committee, RelatonIho::Workgroup,
|
43
|
+
# RelatonIho::Commission]
|
44
|
+
def iho_workgroup(ihowg)
|
45
|
+
key, value = ihowg&.first
|
46
|
+
return unless key && value.is_a?(Hash)
|
47
|
+
|
48
|
+
klass = Object.const_get "RelatonIho::#{key.capitalize}"
|
49
|
+
wgs = %i[committee workgroup commission]
|
50
|
+
subwg = value.select { |k, _| wgs.include? k }
|
51
|
+
klass.new value[:abbreviation], value[:name], iho_workgroup(subwg)
|
52
|
+
end
|
53
|
+
|
54
|
+
def create_doctype(**args)
|
55
|
+
DocumentType.new(**args)
|
52
56
|
end
|
53
57
|
end
|
54
58
|
end
|
@@ -1,8 +1,5 @@
|
|
1
1
|
module RelatonIho
|
2
2
|
class IhoBibliographicItem < RelatonBib::BibliographicItem
|
3
|
-
TYPES = %w[policy-and-procedures best-practices supporting-document
|
4
|
-
report legal directives proposal standard].freeze
|
5
|
-
|
6
3
|
# @return [RelatonIho::CommentPeriod, NilClass]
|
7
4
|
attr_reader :commentperiod
|
8
5
|
|
@@ -39,7 +36,7 @@ module RelatonIho
|
|
39
36
|
if opts[:bibdata] && (doctype || editorialgroup&.presence? ||
|
40
37
|
ics.any? || commentperiod)
|
41
38
|
ext = b.ext do
|
42
|
-
|
39
|
+
doctype&.to_xml b
|
43
40
|
editorialgroup&.to_xml b
|
44
41
|
ics.each { |i| i.to_xml b }
|
45
42
|
commentperiod&.to_xml b
|
@@ -14,12 +14,12 @@ module RelatonIho
|
|
14
14
|
# @return [RelatonIho::IhoBibliographicItem, nil] the IHO standard or nil if not found
|
15
15
|
#
|
16
16
|
def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
17
|
-
Util.warn "(#{text})
|
17
|
+
Util.warn "(#{text}) Fetching from Relaton repository ..."
|
18
18
|
ref = text.sub(/^IHO\s/, "").sub(/^([[:alpha:]]+)(\d+)/, '\1-\2')
|
19
19
|
index = Relaton::Index.find_or_create :iho, url: "#{ENDPOINT}index.zip"
|
20
20
|
row = index.search(ref).max_by { |r| r[:id] }
|
21
21
|
unless row
|
22
|
-
Util.warn "(#{text})
|
22
|
+
Util.warn "(#{text}) Not found."
|
23
23
|
return
|
24
24
|
end
|
25
25
|
|
@@ -33,7 +33,7 @@ module RelatonIho
|
|
33
33
|
hash = HashConverter.hash_to_bib yaml
|
34
34
|
hash[:fetched] = Date.today.to_s
|
35
35
|
item = IhoBibliographicItem.new(**hash)
|
36
|
-
Util.warn "(#{text})
|
36
|
+
Util.warn "(#{text}) Found: `#{item.docidentifier.first.id}`"
|
37
37
|
item
|
38
38
|
rescue SocketError, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
39
39
|
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
data/lib/relaton_iho/version.rb
CHANGED
data/lib/relaton_iho.rb
CHANGED
@@ -5,6 +5,7 @@ require "relaton/index"
|
|
5
5
|
require "relaton_iho/version"
|
6
6
|
require "relaton_iho/config"
|
7
7
|
require "relaton_iho/util"
|
8
|
+
require "relaton_iho/document_type"
|
8
9
|
require "relaton_iho/iho_bibliography"
|
9
10
|
require "relaton_iho/hash_converter"
|
10
11
|
require "relaton_iho/xml_parser"
|
data/relaton_iho.gemspec
CHANGED
@@ -21,6 +21,6 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
s.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
23
23
|
|
24
|
-
s.add_dependency "relaton-bib", "~> 1.
|
24
|
+
s.add_dependency "relaton-bib", "~> 1.17.0"
|
25
25
|
s.add_dependency "relaton-index", "~> 0.2.0"
|
26
26
|
end
|
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.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: relaton-bib
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.17.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.17.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: relaton-index
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/relaton_iho.rb
|
64
64
|
- lib/relaton_iho/comment_periond.rb
|
65
65
|
- lib/relaton_iho/config.rb
|
66
|
+
- lib/relaton_iho/document_type.rb
|
66
67
|
- lib/relaton_iho/editorial_group.rb
|
67
68
|
- lib/relaton_iho/eg.yml
|
68
69
|
- lib/relaton_iho/hash_converter.rb
|