relaton-itu 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaton_itu/editorial_group.rb +6 -4
- data/lib/relaton_itu/hash_converter.rb +9 -0
- data/lib/relaton_itu/itu_bibliographic_item.rb +2 -2
- data/lib/relaton_itu/itu_bibliography.rb +1 -0
- data/lib/relaton_itu/structured_identifier.rb +37 -0
- data/lib/relaton_itu/version.rb +1 -1
- data/lib/relaton_itu/xml_parser.rb +17 -12
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0296cc075043482de147d46ed60967df09931278eda654caae1f92bcd4a30930'
|
4
|
+
data.tar.gz: 47645aff343e6f2d87e4022833ca3d2928be3a7d01ceb6c4456d19bcd7d98b82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17c721e761b2cb4e8a42f8b328bec1ce90935a6ee289810e9153088980719d7e2ce84aeb79dd331f148bbe91168c7cc1a2df7e0a990264daba0bdbc1921eda53
|
7
|
+
data.tar.gz: '0648252af5e10601c126fa2494966f0291fafbffb16dcc0f8f8782a3fdc7e8a6f3e6e4dfcd839c0444516fce76a2233732f93522f59f450234b7e361eaaaf74a'
|
@@ -16,8 +16,9 @@ module RelatonItu
|
|
16
16
|
# @param subgroup [Hash, RelatonItu::ItuGroup, NilClass]
|
17
17
|
# @param workgroup [Hash, RelatonItu::ItuGroup, NilClass]
|
18
18
|
def initialize(bureau:, group:, subgroup: nil, workgroup: nil)
|
19
|
-
|
20
|
-
|
19
|
+
unless BUREAUS.include? bureau
|
20
|
+
warn "[relaton-itu] WARNING: invalid bureau: #{bureau}"
|
21
|
+
end
|
21
22
|
@bureau = bureau
|
22
23
|
@group = group.is_a?(Hash) ? ItuGroup.new(group) : group
|
23
24
|
@subgroup = subgroup.is_a?(Hash) ? ItuGroup.new(subgroup) : subgroup
|
@@ -28,7 +29,7 @@ module RelatonItu
|
|
28
29
|
def to_xml(builder)
|
29
30
|
builder.editorialgroup do
|
30
31
|
builder.bureau bureau
|
31
|
-
builder.group { |b| group.to_xml b }
|
32
|
+
builder.group { |b| group.to_xml b } if group
|
32
33
|
builder.subgroup { |b| group.to_xml b } if subgroup
|
33
34
|
builder.workgroup { |b| group.to_xml b } if workgroup
|
34
35
|
end
|
@@ -36,7 +37,8 @@ module RelatonItu
|
|
36
37
|
|
37
38
|
# @return [Hash]
|
38
39
|
def to_hash
|
39
|
-
hash = { "bureau" => bureau
|
40
|
+
hash = { "bureau" => bureau }
|
41
|
+
hash["group"] = group.to_hash if group
|
40
42
|
hash["subgroup"] = subgroup.to_hash if subgroup
|
41
43
|
hash["workgroup"] = workgroup.to_hash if workgroup
|
42
44
|
hash
|
@@ -9,6 +9,15 @@ module RelatonItu
|
|
9
9
|
|
10
10
|
ret[:editorialgroup] = EditorialGroup.new eg
|
11
11
|
end
|
12
|
+
|
13
|
+
# @param ret [Hash]
|
14
|
+
def structuredidentifier_hash_to_bib(ret)
|
15
|
+
return unless ret[:structuredidentifier]
|
16
|
+
|
17
|
+
ret[:structuredidentifier] = StructuredIdentifier.new(
|
18
|
+
ret[:structuredidentifier],
|
19
|
+
)
|
20
|
+
end
|
12
21
|
end
|
13
22
|
end
|
14
23
|
end
|
@@ -7,12 +7,12 @@ module RelatonItu
|
|
7
7
|
joint-itu-iso-iec
|
8
8
|
].freeze
|
9
9
|
|
10
|
+
# @params structuredidentifier [RelatonItu::StructuredIdentifier]
|
10
11
|
def initialize(**args)
|
11
12
|
@doctype = args.delete :doctype
|
12
13
|
if doctype && !TYPES.include?(doctype)
|
13
|
-
|
14
|
+
warn "[relaton-itu] WARNING: invalid doctype: #{doctype}"
|
14
15
|
end
|
15
|
-
|
16
16
|
super
|
17
17
|
end
|
18
18
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module RelatonItu
|
2
|
+
class StructuredIdentifier
|
3
|
+
# @return [String]
|
4
|
+
attr_reader :bureau, :docnumber
|
5
|
+
|
6
|
+
# @return [String, NilClass]
|
7
|
+
attr_reader :annexid
|
8
|
+
|
9
|
+
# @param bureau [String] T, D, or R
|
10
|
+
# @param docnumber [String]
|
11
|
+
# @param annexid [String, NilClass]
|
12
|
+
def initialize(bureau:, docnumber:, annexid: nil)
|
13
|
+
unless EditorialGroup::BUREAUS.include? bureau
|
14
|
+
warn "[relaton-itu] WARNING: invalid bureau: #{bureau}"
|
15
|
+
end
|
16
|
+
@bureau = bureau
|
17
|
+
@docnumber = docnumber
|
18
|
+
@annexid = annexid
|
19
|
+
end
|
20
|
+
|
21
|
+
# @param builder [Nokogiri::XML::Builder]
|
22
|
+
def to_xml(builder)
|
23
|
+
builder.structuredidentifier do |b|
|
24
|
+
b.bureau bureau
|
25
|
+
b.docnumber docnumber
|
26
|
+
b.annexid annexid if annexid
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [Hash]
|
31
|
+
def to_hash
|
32
|
+
hash = { bureau: bureau, docnumber: docnumber }
|
33
|
+
hash[:annexid] = annexid if annexid
|
34
|
+
hash
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/relaton_itu/version.rb
CHANGED
@@ -3,21 +3,14 @@ require "nokogiri"
|
|
3
3
|
module RelatonItu
|
4
4
|
class XMLParser < RelatonIsoBib::XMLParser
|
5
5
|
class << self
|
6
|
-
|
7
|
-
|
6
|
+
private
|
7
|
+
|
8
|
+
# @param item_hash [Hash]
|
8
9
|
# @return [RelatonItu::ItuBibliographicItem]
|
9
|
-
def
|
10
|
-
|
11
|
-
ituitem = doc.at "/bibitem|/bibdata"
|
12
|
-
if ituitem
|
13
|
-
ItuBibliographicItem.new item_data(ituitem)
|
14
|
-
elsif
|
15
|
-
warn "[relaton-itu] can't find bibitem or bibdata element in the XML"
|
16
|
-
end
|
10
|
+
def bib_item(item_hash)
|
11
|
+
ItuBibliographicItem.new item_hash
|
17
12
|
end
|
18
13
|
|
19
|
-
private
|
20
|
-
|
21
14
|
# @param ext [Nokogiri::XML::Element]
|
22
15
|
# @return [RelatonItu::EditorialGroup]
|
23
16
|
def fetch_editorialgroup(ext)
|
@@ -54,6 +47,18 @@ module RelatonItu
|
|
54
47
|
start: period.at("start").text, finish: period.at("end")&.text,
|
55
48
|
)
|
56
49
|
end
|
50
|
+
|
51
|
+
# @param ext [Nokogiri::XML::Element]
|
52
|
+
# @return [RelatonItu::StructuredIdentifier]
|
53
|
+
def fetch_structuredidentifier(ext)
|
54
|
+
sid = ext.at "./structuredidentifier"
|
55
|
+
return unless sid
|
56
|
+
|
57
|
+
br = sid.at("bureau").text
|
58
|
+
dn = sid.at("docnumber").text
|
59
|
+
an = sid.at("annexid")&.text
|
60
|
+
StructuredIdentifier.new(bureau: br, docnumber: dn, annexid: an)
|
61
|
+
end
|
57
62
|
end
|
58
63
|
end
|
59
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-itu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
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-05-
|
11
|
+
date: 2020-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debase
|
@@ -200,6 +200,7 @@ files:
|
|
200
200
|
- lib/relaton_itu/itu_group.rb
|
201
201
|
- lib/relaton_itu/processor.rb
|
202
202
|
- lib/relaton_itu/scrapper.rb
|
203
|
+
- lib/relaton_itu/structured_identifier.rb
|
203
204
|
- lib/relaton_itu/version.rb
|
204
205
|
- lib/relaton_itu/xml_parser.rb
|
205
206
|
- relaton-itu.gemspec
|