relaton-bipm 1.4.0 → 1.6.1
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/grammars/bipm.rng +188 -0
- data/grammars/isodoc.rng +7 -1
- data/lib/relaton_bipm.rb +2 -2
- data/lib/relaton_bipm/bipm_bibliographic_item.rb +41 -28
- data/lib/relaton_bipm/bipm_bibliography.rb +1 -1
- data/lib/relaton_bipm/comment_periond.rb +1 -1
- data/lib/relaton_bipm/editorial_group.rb +56 -0
- data/lib/relaton_bipm/hash_converter.rb +28 -19
- data/lib/relaton_bipm/structured_identifier.rb +51 -0
- data/lib/relaton_bipm/version.rb +1 -1
- data/lib/relaton_bipm/xml_parser.rb +26 -26
- data/relaton_bipm.gemspec +2 -1
- metadata +23 -8
- data/lib/relaton_bipm/document_status.rb +0 -31
- data/lib/relaton_bipm/project_team.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d7a5ceebc3dca34d8a3b78bff607bbe9c371228c2daec7573754146115ab954
|
4
|
+
data.tar.gz: f3c03e5999e94a7419cc29ec121372bdd84556ceac60baac3d5fb5bc295c9c8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 027a41b07adfae1ae37fea8bd0d6c70951f1c6d274e1c343ec3f4dc4506f0b14989cf69ab0f695b08253cb723c05be13e5214a848188781dbe2ca26d2e383494
|
7
|
+
data.tar.gz: 74248e6a19fab3d461b9e0eae44b947a63224701a48844ab03f210e480deb4b2403da653a840eeaacc232f0b1f780265c231b5b966e5db5fd9972e729607745c
|
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/grammars/bipm.rng
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
3
|
+
<!--
|
4
|
+
Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
|
5
|
+
we cannot have a new default namespace: we will end up with a grammar with two different
|
6
|
+
namespaces, one for isostandard and one for csand additions. And we do not want that.
|
7
|
+
-->
|
8
|
+
<include href="isodoc.rng">
|
9
|
+
<start>
|
10
|
+
<ref name="bipm-standard"/>
|
11
|
+
</start>
|
12
|
+
<define name="xref">
|
13
|
+
<element name="xref">
|
14
|
+
<attribute name="target">
|
15
|
+
<data type="string">
|
16
|
+
<param name="pattern">\i\c*|\c+#\c+</param>
|
17
|
+
</data>
|
18
|
+
</attribute>
|
19
|
+
<optional>
|
20
|
+
<attribute name="type">
|
21
|
+
<ref name="ReferenceFormat"/>
|
22
|
+
</attribute>
|
23
|
+
</optional>
|
24
|
+
<optional>
|
25
|
+
<attribute name="alt"/>
|
26
|
+
</optional>
|
27
|
+
<optional>
|
28
|
+
<attribute name="case">
|
29
|
+
<choice>
|
30
|
+
<value>capital</value>
|
31
|
+
<value>lowercase</value>
|
32
|
+
</choice>
|
33
|
+
</attribute>
|
34
|
+
</optional>
|
35
|
+
<optional>
|
36
|
+
<attribute name="droploc">
|
37
|
+
<data type="boolean"/>
|
38
|
+
</attribute>
|
39
|
+
</optional>
|
40
|
+
<optional>
|
41
|
+
<attribute name="pagenumber">
|
42
|
+
<data type="boolean"/>
|
43
|
+
</attribute>
|
44
|
+
</optional>
|
45
|
+
<text/>
|
46
|
+
</element>
|
47
|
+
</define>
|
48
|
+
<define name="DocumentType">
|
49
|
+
<choice>
|
50
|
+
<value>brochure</value>
|
51
|
+
<value>mise-en-pratique</value>
|
52
|
+
<value>rapport</value>
|
53
|
+
<value>monographie</value>
|
54
|
+
<value>guide</value>
|
55
|
+
<value>meeting-report</value>
|
56
|
+
<value>technical-report</value>
|
57
|
+
<value>working-party-note</value>
|
58
|
+
<value>strategy</value>
|
59
|
+
<value>cipm-mra</value>
|
60
|
+
<value>resolution</value>
|
61
|
+
</choice>
|
62
|
+
</define>
|
63
|
+
<define name="editorialgroup">
|
64
|
+
<element name="editorialgroup">
|
65
|
+
<oneOrMore>
|
66
|
+
<ref name="committee"/>
|
67
|
+
</oneOrMore>
|
68
|
+
<oneOrMore>
|
69
|
+
<ref name="workgroup"/>
|
70
|
+
</oneOrMore>
|
71
|
+
</element>
|
72
|
+
</define>
|
73
|
+
<define name="structuredidentifier">
|
74
|
+
<element name="structuredidentifier">
|
75
|
+
<element name="docnumber">
|
76
|
+
<text/>
|
77
|
+
</element>
|
78
|
+
<optional>
|
79
|
+
<element name="part">
|
80
|
+
<text/>
|
81
|
+
</element>
|
82
|
+
</optional>
|
83
|
+
<optional>
|
84
|
+
<element name="appendix">
|
85
|
+
<text/>
|
86
|
+
</element>
|
87
|
+
</optional>
|
88
|
+
</element>
|
89
|
+
</define>
|
90
|
+
<define name="BibDataExtensionType">
|
91
|
+
<optional>
|
92
|
+
<ref name="doctype"/>
|
93
|
+
</optional>
|
94
|
+
<ref name="editorialgroup"/>
|
95
|
+
<optional>
|
96
|
+
<ref name="comment-period"/>
|
97
|
+
</optional>
|
98
|
+
<optional>
|
99
|
+
<ref name="si-aspect"/>
|
100
|
+
</optional>
|
101
|
+
<ref name="structuredidentifier"/>
|
102
|
+
</define>
|
103
|
+
</include>
|
104
|
+
<define name="comment-period">
|
105
|
+
<element name="comment-period">
|
106
|
+
<element name="from">
|
107
|
+
<ref name="ISO8601Date"/>
|
108
|
+
</element>
|
109
|
+
<element name="to">
|
110
|
+
<ref name="ISO8601Date"/>
|
111
|
+
</element>
|
112
|
+
</element>
|
113
|
+
</define>
|
114
|
+
<define name="si-aspect">
|
115
|
+
<element name="si-aspect">
|
116
|
+
<choice>
|
117
|
+
<value>A_e_deltanu</value>
|
118
|
+
<value>A_e</value>
|
119
|
+
<value>cd_Kcd_h_deltanu</value>
|
120
|
+
<value>cd_Kcd</value>
|
121
|
+
<value>full</value>
|
122
|
+
<value>K_k_deltanu</value>
|
123
|
+
<value>K_k</value>
|
124
|
+
<value>kg_h_c_deltanu</value>
|
125
|
+
<value>kg_h</value>
|
126
|
+
<value>m_c_deltanu</value>
|
127
|
+
<value>m_c</value>
|
128
|
+
<value>mol_NA</value>
|
129
|
+
<value>s_deltanu</value>
|
130
|
+
</choice>
|
131
|
+
</element>
|
132
|
+
</define>
|
133
|
+
<define name="committee">
|
134
|
+
<element name="committee">
|
135
|
+
<choice>
|
136
|
+
<value>CGPM</value>
|
137
|
+
<value>CIPM</value>
|
138
|
+
<value>BIPM</value>
|
139
|
+
<value>CCAUV</value>
|
140
|
+
<value>CCEM</value>
|
141
|
+
<value>CCL</value>
|
142
|
+
<value>CCM</value>
|
143
|
+
<value>CCPR</value>
|
144
|
+
<value>CCQM</value>
|
145
|
+
<value>CCRI</value>
|
146
|
+
<value>CCT</value>
|
147
|
+
<value>CCTF</value>
|
148
|
+
<value>CCU</value>
|
149
|
+
<value>CCL-CCTF</value>
|
150
|
+
<value>JCGM</value>
|
151
|
+
<value>JCRB</value>
|
152
|
+
<value>JCTLM</value>
|
153
|
+
<value>INetQI</value>
|
154
|
+
</choice>
|
155
|
+
</element>
|
156
|
+
</define>
|
157
|
+
<define name="workgroup">
|
158
|
+
<element name="workgroup">
|
159
|
+
<text/>
|
160
|
+
</element>
|
161
|
+
</define>
|
162
|
+
<define name="bipm-standard">
|
163
|
+
<element name="bipm-standard">
|
164
|
+
<attribute name="version"/>
|
165
|
+
<attribute name="type">
|
166
|
+
<choice>
|
167
|
+
<value>semantic</value>
|
168
|
+
<value>presentation</value>
|
169
|
+
</choice>
|
170
|
+
</attribute>
|
171
|
+
<ref name="bibdata"/>
|
172
|
+
<zeroOrMore>
|
173
|
+
<ref name="termdocsource"/>
|
174
|
+
</zeroOrMore>
|
175
|
+
<optional>
|
176
|
+
<ref name="boilerplate"/>
|
177
|
+
</optional>
|
178
|
+
<ref name="preface"/>
|
179
|
+
<oneOrMore>
|
180
|
+
<ref name="sections"/>
|
181
|
+
</oneOrMore>
|
182
|
+
<zeroOrMore>
|
183
|
+
<ref name="annex"/>
|
184
|
+
</zeroOrMore>
|
185
|
+
<ref name="bibliography"/>
|
186
|
+
</element>
|
187
|
+
</define>
|
188
|
+
</grammar>
|
data/grammars/isodoc.rng
CHANGED
@@ -42,7 +42,6 @@
|
|
42
42
|
</define>
|
43
43
|
<define name="xref">
|
44
44
|
<element name="xref">
|
45
|
-
<!-- attribute target { xsd:IDREF }, -->
|
46
45
|
<attribute name="target">
|
47
46
|
<data type="string">
|
48
47
|
<param name="pattern">\i\c*|\c+#\c+</param>
|
@@ -864,6 +863,13 @@
|
|
864
863
|
</define>
|
865
864
|
<define name="standard-document">
|
866
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>
|
867
873
|
<ref name="bibdata"/>
|
868
874
|
<optional>
|
869
875
|
<ref name="boilerplate"/>
|
data/lib/relaton_bipm.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "relaton_bib"
|
2
2
|
require "relaton_bipm/version"
|
3
|
-
require "relaton_bipm/
|
3
|
+
require "relaton_bipm/editorial_group"
|
4
|
+
require "relaton_bipm/structured_identifier"
|
4
5
|
require "relaton_bipm/bibliographic_date"
|
5
6
|
require "relaton_bipm/document_relation"
|
6
7
|
require "relaton_bipm/comment_periond"
|
7
|
-
require "relaton_bipm/document_status"
|
8
8
|
require "relaton_bipm/bipm_bibliographic_item"
|
9
9
|
require "relaton_bipm/bipm_bibliography"
|
10
10
|
require "relaton_bipm/hash_converter"
|
@@ -8,42 +8,54 @@ module RelatonBipm
|
|
8
8
|
|
9
9
|
STATUSES = %w[draft-proposal draft-development in-force retired].freeze
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
SI_ASPECTS = %w[
|
12
|
+
A_e_deltanu A_e cd_Kcd_h_deltanu cd_Kcd full K_k_deltanu K_k
|
13
|
+
kg_h_c_deltanu kg_h m_c_deltanu m_c mol_NA s_deltanu
|
14
|
+
].freeze
|
13
15
|
|
14
|
-
# @return [
|
15
|
-
attr_reader :
|
16
|
+
# @return [RelatonBipm::CommentPeriod, NilClass]
|
17
|
+
attr_reader :comment_period
|
18
|
+
|
19
|
+
# @return [String]
|
20
|
+
attr_reader :si_aspect
|
16
21
|
|
17
|
-
# @param project_group [Array<RelatonBipm::ProjectTeam>]
|
18
|
-
# @param title [Array<RelatonBib::FormattedString>]
|
19
|
-
# @param date [Array<RelatonBipm::BibliographicDate>]
|
20
22
|
# @param relation [Array<RelatonBipm::DocumentRelation>]
|
21
|
-
# @param
|
22
|
-
# @param
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
# @param editorialgroup [RelatonBipm::EditorialGroup]
|
24
|
+
# @param comment_period [RelatonBipm::CommentPeriod, NilClass]
|
25
|
+
# @param si_aspect [String]
|
26
|
+
# @param structuredidentifier [RelatonBipm::StructuredIdentifier]
|
27
|
+
def initialize(**args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
28
|
+
if args[:docstatus] && !STATUSES.include?(args[:docstatus].stage)
|
29
|
+
warn "[relaton-bipm] Warning: invalid docstatus: #{args[:docstatus]}. "\
|
26
30
|
"It should be one of: #{STATUSES}"
|
27
31
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
|
33
|
+
if args[:si_aspect] && !SI_ASPECTS.include?(args[:si_aspect])
|
34
|
+
warn "[relaton-bipm] Warning: invalid si_aspect: #{args[:si_aspect]}. "\
|
35
|
+
"It should be one of: #{SI_ASPECTS}"
|
36
|
+
end
|
37
|
+
|
38
|
+
@comment_period = args.delete :comment_period
|
39
|
+
@si_aspect = args.delete :si_aspect
|
31
40
|
super
|
32
41
|
end
|
33
42
|
|
34
|
-
# @param
|
35
|
-
# @
|
36
|
-
|
37
|
-
|
38
|
-
|
43
|
+
# @param opts [Hash]
|
44
|
+
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
45
|
+
# @option opts [Boolean] :bibdata
|
46
|
+
# @option opts [String] :lang language
|
47
|
+
# @return [String] XML
|
48
|
+
def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
49
|
+
super ext: !comment_period.nil?, **opts do |b|
|
39
50
|
if opts[:bibdata] && (doctype || editorialgroup&.presence? ||
|
40
|
-
|
51
|
+
si_aspect || comment_period ||
|
52
|
+
structuredidentifier)
|
41
53
|
b.ext do
|
42
54
|
b.doctype doctype if doctype
|
43
55
|
editorialgroup&.to_xml b
|
44
|
-
|
45
|
-
|
46
|
-
|
56
|
+
comment_period&.to_xml b
|
57
|
+
b.send "si-aspect", si_aspect if si_aspect
|
58
|
+
structuredidentifier&.to_xml b
|
47
59
|
end
|
48
60
|
end
|
49
61
|
end
|
@@ -52,17 +64,18 @@ module RelatonBipm
|
|
52
64
|
# @return [Hash]
|
53
65
|
def to_hash
|
54
66
|
hash = super
|
55
|
-
hash["
|
56
|
-
hash["
|
67
|
+
hash["comment_period"] = comment_period.to_hash if comment_period
|
68
|
+
hash["si_aspect"] = si_aspect if si_aspect
|
57
69
|
hash
|
58
70
|
end
|
59
71
|
|
60
72
|
# @param prefix [String]
|
61
73
|
# @return [String]
|
62
74
|
def to_asciibib(prefix = "")
|
75
|
+
pref = prefix.empty? ? prefix : prefix + "."
|
63
76
|
out = super
|
64
|
-
|
65
|
-
out +=
|
77
|
+
out += comment_period.to_asciibib prefix if comment_period
|
78
|
+
out += "#{pref}.si_aspect:: #{si_aspect}\n" if si_aspect
|
66
79
|
out
|
67
80
|
end
|
68
81
|
end
|
@@ -10,7 +10,7 @@ module RelatonBipm
|
|
10
10
|
# @return [RelatonBipm::BipmBibliographicItem]
|
11
11
|
def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
12
12
|
warn "[relaton-bipm] (\"#{text}\") fetching..."
|
13
|
-
ref = text.sub(/^BIPM\s/, "").downcase
|
13
|
+
ref = text.sub(/^BIPM\s/, "").downcase.split(" ").join "-"
|
14
14
|
uri = URI("#{ENDPOINT}#{ref}.yaml")
|
15
15
|
resp = Net::HTTP.get_response uri
|
16
16
|
return unless resp.code == "200"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module RelatonBipm
|
2
|
+
class EditorialGroup
|
3
|
+
include RelatonBib
|
4
|
+
|
5
|
+
COMMITTEES = %w[CGPM CIPM BIPM CCAUV CCEM CCL CCM CCPR CCQM CCRI CCT CCTF
|
6
|
+
CCU CCL-CCT JCGM JCRB JCTLM INetQI].freeze
|
7
|
+
|
8
|
+
# @return [Array<String>]
|
9
|
+
attr_reader :committee, :workgroup
|
10
|
+
|
11
|
+
# @param committee [Array<String>]
|
12
|
+
# @param workgroup [Array<String>]
|
13
|
+
def initialize(committee:, workgroup:)
|
14
|
+
committee.each do |c|
|
15
|
+
unless COMMITTEES.include? c
|
16
|
+
warn "[relaton-bipm] invalid committee: #{c}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
@committee = committee
|
21
|
+
@workgroup = workgroup
|
22
|
+
end
|
23
|
+
|
24
|
+
# @param builder [Nokogiri::XML::Builder]
|
25
|
+
def to_xml(builder)
|
26
|
+
builder.editorialgroup do |b|
|
27
|
+
committee.each { |c| b.committee c }
|
28
|
+
workgroup.each { |c| b.workgroup c }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# @param prefix [String]
|
33
|
+
# @return [String]
|
34
|
+
def to_asciibib(prefix = "")
|
35
|
+
pref = prefix.empty? ? prefix : prefix + "."
|
36
|
+
pref += "editorialgroup"
|
37
|
+
out = ""
|
38
|
+
committee.each { |c| out += "#{pref}.committee:: #{c}\n" }
|
39
|
+
workgroup.each { |w| out += "#{pref}.workgroup:: #{w}\n" }
|
40
|
+
out
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [Hash]
|
44
|
+
def to_hash
|
45
|
+
{
|
46
|
+
"committee" => single_element_array(committee),
|
47
|
+
"workgroup" => single_element_array(workgroup),
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return [true]
|
52
|
+
def presence?
|
53
|
+
true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -11,7 +11,7 @@ module RelatonBipm
|
|
11
11
|
ret = super
|
12
12
|
return if ret.nil?
|
13
13
|
|
14
|
-
project_group_hash_to_bib ret
|
14
|
+
# project_group_hash_to_bib ret
|
15
15
|
commentperiod_hash_to_bib ret
|
16
16
|
ret
|
17
17
|
end
|
@@ -26,32 +26,29 @@ module RelatonBipm
|
|
26
26
|
|
27
27
|
# @param ret [Hash]
|
28
28
|
def title_hash_to_bib(ret)
|
29
|
-
ret[:title] &&= array(ret[:title]).
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
ret[:title] &&= array(ret[:title]).reduce(
|
30
|
+
RelatonBib::TypedTitleStringCollection.new
|
31
|
+
) do |m, t|
|
32
|
+
m << if t.is_a? Hash
|
33
|
+
RelatonBib::TypedTitleString.new(t)
|
34
|
+
else
|
35
|
+
RelatonBib::TypedTitleString.new(content: t)
|
36
|
+
end
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
|
-
# @param ret [Hash]
|
39
|
-
def docstatus_hash_to_bib(ret)
|
40
|
-
ret[:docstatus] &&= DocumentStatus.new ret[:docstatus]
|
41
|
-
end
|
42
|
-
|
43
40
|
# @param ret [Hash]
|
44
41
|
def commentperiod_hash_to_bib(ret)
|
45
|
-
ret[:
|
42
|
+
ret[:comment_period] &&= CommentPeriond.new(ret[:comment_period])
|
46
43
|
end
|
47
44
|
|
48
45
|
# @param ret [Hash]
|
49
|
-
def project_group_hash_to_bib(ret)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
46
|
+
# def project_group_hash_to_bib(ret)
|
47
|
+
# ret[:project_group] &&= array(ret[:project_group]).map do |pg|
|
48
|
+
# wg = RelatonBib::FormattedString.new pg[:workgroup]
|
49
|
+
# ProjectTeam.new(committee: pg[:committee], workgroup: wg)
|
50
|
+
# end
|
51
|
+
# end
|
55
52
|
|
56
53
|
# @param ret [Hash]
|
57
54
|
def dates_hash_to_bib(ret)
|
@@ -68,6 +65,18 @@ module RelatonBipm
|
|
68
65
|
RelatonBipm::DocumentRelation.new r
|
69
66
|
end
|
70
67
|
end
|
68
|
+
|
69
|
+
# @param ret [Hash]
|
70
|
+
def editorialgroup_hash_to_bib(ret)
|
71
|
+
ret[:editorialgroup] &&= EditorialGroup.new ret[:editorialgroup]
|
72
|
+
end
|
73
|
+
|
74
|
+
# @param ret [Hash]
|
75
|
+
def structuredidentifier_hash_to_bib(ret)
|
76
|
+
ret[:structuredidentifier] &&= StructuredIdentifier.new(
|
77
|
+
**ret[:structuredidentifier]
|
78
|
+
)
|
79
|
+
end
|
71
80
|
end
|
72
81
|
end
|
73
82
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module RelatonBipm
|
2
|
+
class StructuredIdentifier
|
3
|
+
# @return [String]
|
4
|
+
attr_reader :docnumber
|
5
|
+
|
6
|
+
# @return [String, nil]
|
7
|
+
attr_reader :part, :appendix
|
8
|
+
|
9
|
+
# @param docnumber [String]
|
10
|
+
# @param part [String]
|
11
|
+
# @param appendix [String]
|
12
|
+
def initialize(docnumber:, part: nil, appendix: nil)
|
13
|
+
@docnumber = docnumber
|
14
|
+
@part = part
|
15
|
+
@appendix = appendix
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param builder [Nokogiri::XML::Builder]
|
19
|
+
def to_xml(builder)
|
20
|
+
builder.structuredidentifier do |b|
|
21
|
+
b.docnumber docnumber
|
22
|
+
b.part part if part
|
23
|
+
b.appendix appendix if appendix
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Hash]
|
28
|
+
def to_hash
|
29
|
+
hash = { "docnumber" => docnumber }
|
30
|
+
hash["part"] = part if part
|
31
|
+
hash["appendix"] = appendix if appendix
|
32
|
+
hash
|
33
|
+
end
|
34
|
+
|
35
|
+
# @param prefix [String]
|
36
|
+
# @return [String]
|
37
|
+
def to_asciibib(prefix = "")
|
38
|
+
pref = prefix.empty? ? prefix : prefix + "."
|
39
|
+
pref += "structuredidentifier"
|
40
|
+
out = "#{pref}.docnumber:: #{docnumber}\n"
|
41
|
+
out += "#{pref}.part:: #{part}\n" if part
|
42
|
+
out += "#{pref}.appendix:: #{appendix}\n" if appendix
|
43
|
+
out
|
44
|
+
end
|
45
|
+
|
46
|
+
# @return [true]
|
47
|
+
def presence?
|
48
|
+
true
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/relaton_bipm/version.rb
CHANGED
@@ -11,8 +11,8 @@ module RelatonBipm
|
|
11
11
|
ext = item.at "./ext"
|
12
12
|
return data unless ext
|
13
13
|
|
14
|
-
data[:
|
15
|
-
data[:
|
14
|
+
data[:comment_period] = fetch_commentperiond ext
|
15
|
+
data[:si_aspect] = ext.at("si-aspect")&.text
|
16
16
|
data
|
17
17
|
end
|
18
18
|
|
@@ -22,23 +22,11 @@ module RelatonBipm
|
|
22
22
|
BipmBibliographicItem.new item_hash
|
23
23
|
end
|
24
24
|
|
25
|
-
def fetch_project_group(ext)
|
26
|
-
ext.xpath("./project-group").map do |pg|
|
27
|
-
wg = pg.at "workgroup"
|
28
|
-
workgroup = RelatonBib::FormattedString.new(
|
29
|
-
content: wg.text, language: wg[:language], script: wg[:script],
|
30
|
-
format: wg[:format]
|
31
|
-
)
|
32
|
-
ProjectTeam.new(committee: pg.at("committee").text,
|
33
|
-
workgroup: workgroup)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
25
|
# @param item [Nokogiri::XML::Element]
|
38
26
|
# @return [Array<RelatonBib::FormattedString>]
|
39
27
|
def fetch_titles(item)
|
40
28
|
item.xpath("./title").map do |t|
|
41
|
-
RelatonBib::
|
29
|
+
RelatonBib::TypedTitleString.new(
|
42
30
|
content: t.text, language: t[:language], script: t[:script],
|
43
31
|
format: t[:format]
|
44
32
|
)
|
@@ -60,26 +48,38 @@ module RelatonBipm
|
|
60
48
|
|
61
49
|
# @param item [Nokogiri::XML::Element]
|
62
50
|
# @param klass [RelatonBipm::DocumentRelation.class]
|
63
|
-
# @return [Array<
|
51
|
+
# @return [Array<RelatonBipm::DocumentRelation>]
|
64
52
|
def fetch_relations(item, klass = DocumentRelation)
|
65
53
|
super
|
66
54
|
end
|
67
55
|
|
68
|
-
# @param
|
69
|
-
# @return [RelatonBipm::
|
70
|
-
def
|
71
|
-
|
72
|
-
return unless status
|
56
|
+
# @param ext [Nokogiri::XML::Element]
|
57
|
+
# @return [RelatonBipm::CommentPeriod, nil]
|
58
|
+
def fetch_commentperiond(ext)
|
59
|
+
return unless ext && (cp = ext.at "comment-period")
|
73
60
|
|
74
|
-
|
61
|
+
CommentPeriond.new from: cp.at("from")&.text, to: cp.at("to")&.text
|
75
62
|
end
|
76
63
|
|
77
64
|
# @param ext [Nokogiri::XML::Element]
|
78
|
-
# @return [
|
79
|
-
def
|
80
|
-
return unless ext && (
|
65
|
+
# @return [RelatonBipm::EditorialGroup, nil]
|
66
|
+
def fetch_editorialgroup(ext)
|
67
|
+
return unless ext && (eg = ext.at "editorialgroup")
|
81
68
|
|
82
|
-
|
69
|
+
cm = eg.xpath("committee").map &:text
|
70
|
+
wg = eg.xpath("workgroup").map &:text
|
71
|
+
EditorialGroup.new committee: cm, workgroup: wg
|
72
|
+
end
|
73
|
+
|
74
|
+
# @param ext [Nokogiri::XML::Element]
|
75
|
+
# @return [RelatonBipm::StructuredIdentifier]
|
76
|
+
def fetch_structuredidentifier(ext)
|
77
|
+
return unless ext && (sid = ext.at("structuredidentifier"))
|
78
|
+
|
79
|
+
StructuredIdentifier.new(
|
80
|
+
docnumber: sid.at("docnumber").text, part: sid.at("part")&.text,
|
81
|
+
appendix: sid.at("appendix")&.text
|
82
|
+
)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
data/relaton_bipm.gemspec
CHANGED
@@ -38,9 +38,10 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
38
38
|
spec.add_development_dependency "pry-byebug"
|
39
39
|
spec.add_development_dependency "rake", "~> 10.0"
|
40
40
|
spec.add_development_dependency "ruby-debug-ide"
|
41
|
+
spec.add_development_dependency "ruby-jing"
|
41
42
|
spec.add_development_dependency "simplecov"
|
42
43
|
spec.add_development_dependency "vcr"
|
43
44
|
spec.add_development_dependency "webmock"
|
44
45
|
|
45
|
-
spec.add_dependency "relaton-bib", "
|
46
|
+
spec.add_dependency "relaton-bib", "~> 1.6.0"
|
46
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-bipm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.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: 2020-
|
11
|
+
date: 2020-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: ruby-jing
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: simplecov
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,16 +154,16 @@ dependencies:
|
|
140
154
|
name: relaton-bib
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
|
-
- - "
|
157
|
+
- - "~>"
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.
|
159
|
+
version: 1.6.0
|
146
160
|
type: :runtime
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
|
-
- - "
|
164
|
+
- - "~>"
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version: 1.
|
166
|
+
version: 1.6.0
|
153
167
|
description: 'RelatonBipm: retrieve BIPM Standards for bibliographic use using the
|
154
168
|
BibliographicItem model'
|
155
169
|
email:
|
@@ -173,6 +187,7 @@ files:
|
|
173
187
|
- bin/setup
|
174
188
|
- grammars/basicdoc.rng
|
175
189
|
- grammars/biblio.rng
|
190
|
+
- grammars/bipm.rng
|
176
191
|
- grammars/isodoc.rng
|
177
192
|
- grammars/reqt.rng
|
178
193
|
- lib/relaton_bipm.rb
|
@@ -181,10 +196,10 @@ files:
|
|
181
196
|
- lib/relaton_bipm/bipm_bibliography.rb
|
182
197
|
- lib/relaton_bipm/comment_periond.rb
|
183
198
|
- lib/relaton_bipm/document_relation.rb
|
184
|
-
- lib/relaton_bipm/
|
199
|
+
- lib/relaton_bipm/editorial_group.rb
|
185
200
|
- lib/relaton_bipm/hash_converter.rb
|
186
201
|
- lib/relaton_bipm/processor.rb
|
187
|
-
- lib/relaton_bipm/
|
202
|
+
- lib/relaton_bipm/structured_identifier.rb
|
188
203
|
- lib/relaton_bipm/version.rb
|
189
204
|
- lib/relaton_bipm/xml_parser.rb
|
190
205
|
- relaton_bipm.gemspec
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RelatonBipm
|
4
|
-
# Document status.
|
5
|
-
class DocumentStatus
|
6
|
-
# @return [String]
|
7
|
-
attr_reader :status
|
8
|
-
|
9
|
-
# @param status [String]
|
10
|
-
def initialize(status)
|
11
|
-
@status = status
|
12
|
-
end
|
13
|
-
|
14
|
-
# @param [Nokogiri::XML::Builder]
|
15
|
-
def to_xml(builder)
|
16
|
-
builder.status status
|
17
|
-
end
|
18
|
-
|
19
|
-
# @return [String]
|
20
|
-
def to_hash
|
21
|
-
status
|
22
|
-
end
|
23
|
-
|
24
|
-
# @param prefix [String]
|
25
|
-
# @return [String]
|
26
|
-
def to_asciibib(prefix = "")
|
27
|
-
pref = prefix.empty? ? prefix : prefix + "."
|
28
|
-
"#{pref}docstatus:: #{status}\n"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module RelatonBipm
|
2
|
-
class ProjectTeam
|
3
|
-
COMMITTEES = %w[cgpm cipm bipm ccauv ccem ccl ccm ccpr ccqm ccri cct cctf
|
4
|
-
ccu ccl-cctfwg jcgm jcrb jctlm inetqi].freeze
|
5
|
-
|
6
|
-
# @return [String]
|
7
|
-
attr_reader :committee
|
8
|
-
|
9
|
-
# @return [RelatonBib::FormattedString]
|
10
|
-
attr_reader :workgroup
|
11
|
-
|
12
|
-
# @param committee [String]
|
13
|
-
# @param workgroup [RelatonBib::FormattedString]
|
14
|
-
def initialize(committee:, workgroup:)
|
15
|
-
unless COMMITTEES.include? committee
|
16
|
-
warn "[relaton-bipm] Warning: invalid committee: #{committee}. "\
|
17
|
-
"It should be one of: #{COMMITTEES}"
|
18
|
-
end
|
19
|
-
@committee = committee
|
20
|
-
@workgroup = workgroup
|
21
|
-
end
|
22
|
-
|
23
|
-
# @param builder [Nokogiri::XML::Builder]
|
24
|
-
def to_xml(builder)
|
25
|
-
builder.send "project-group" do |b|
|
26
|
-
b.committee committee
|
27
|
-
b.workgroup { workgroup.to_xml b }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# @return [Hash]
|
32
|
-
def to_hash
|
33
|
-
{ "committee" => committee, "workgroup" => workgroup.to_hash }
|
34
|
-
end
|
35
|
-
|
36
|
-
# @param prefix [String]
|
37
|
-
# 2param count [Integer]
|
38
|
-
# @return [String]
|
39
|
-
def to_asciibib(prefix = "", count = 1)
|
40
|
-
pref = prefix.empty? ? prefix : prefix + "."
|
41
|
-
pref += "project_group"
|
42
|
-
out = count > 1 ? "#{pref}::\n" : ""
|
43
|
-
out += "#{pref}.committee:: #{committee}\n"
|
44
|
-
out += workgroup.to_asciibib prefix
|
45
|
-
out
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|