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.
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RelatonItu
2
- VERSION = "0.9.0".freeze
2
+ VERSION = "1.1.0".freeze
3
3
  end
@@ -3,21 +3,14 @@ require "nokogiri"
3
3
  module RelatonItu
4
4
  class XMLParser < RelatonIsoBib::XMLParser
5
5
  class << self
6
- # Override RelatonIsoBib::XMLParser.form_xml method.
7
- # @param xml [String]
6
+ private
7
+
8
+ # @param item_hash [Hash]
8
9
  # @return [RelatonItu::ItuBibliographicItem]
9
- def from_xml(xml)
10
- doc = Nokogiri::XML(xml)
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
@@ -37,5 +37,5 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency "vcr", "~> 5.0.0"
38
38
  spec.add_development_dependency "webmock"
39
39
 
40
- spec.add_dependency "relaton-iso-bib", "~> 0.9.0"
40
+ spec.add_dependency "relaton-iso-bib", "~> 1.1.0"
41
41
  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: 0.9.0
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-30 00:00:00.000000000 Z
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: 0.9.0
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: 0.9.0
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