relaton-itu 0.9.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/grammars/basicdoc.rng +12 -55
- data/grammars/biblio.rng +144 -49
- data/grammars/isodoc.rng +592 -29
- data/grammars/isostandard.rng +145 -472
- data/grammars/itu.rng +12 -52
- data/lib/relaton_itu.rb +0 -5
- data/lib/relaton_itu/editorial_group.rb +6 -4
- data/lib/relaton_itu/hash_converter.rb +9 -0
- data/lib/relaton_itu/hit.rb +2 -2
- data/lib/relaton_itu/hit_collection.rb +38 -12
- data/lib/relaton_itu/itu_bibliographic_item.rb +2 -2
- data/lib/relaton_itu/itu_bibliography.rb +23 -20
- data/lib/relaton_itu/scrapper.rb +52 -79
- 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
- data/relaton-itu.gemspec +1 -1
- metadata +5 -4
@@ -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
|
data/relaton-itu.gemspec
CHANGED
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:
|
4
|
+
version: 1.1.0
|
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-03
|
11
|
+
date: 2020-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debase
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
159
|
+
version: 1.1.0
|
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:
|
166
|
+
version: 1.1.0
|
167
167
|
description: 'RelatonItu: retrieve ITU Standards for bibliographic use using the BibliographicItem
|
168
168
|
model'
|
169
169
|
email:
|
@@ -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
|