ietfbib 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0367820eefa2525c5cb69b372a79f0f8fe4530ae656409065740cff97bfd105
4
- data.tar.gz: af75fafa123d5a0387673dfbcd4fc056932e0a7caca372c16c5b7b810a2e31f5
3
+ metadata.gz: d8a8def8e3225879205dbcec3b59aa711a8faeb7df55e819c1359e0aa133d050
4
+ data.tar.gz: 9acdc47cfb74ae75d9a96e55db94bad9857ec5863f4780ee4d16366914332900
5
5
  SHA512:
6
- metadata.gz: a4ed25eea4f125684e6ba1b9c8a0bfdd5d86b308c78184c30aebe79f83bce57a06ec80f817596f7593d957cfc1758359e003c64997e170cc03a655b7c40473a5
7
- data.tar.gz: 11664a2ff390405a8dece77307bb1a2f031404015bdee831fb08100b68c37d91de96bc495575932698655b4be588767a0463720eca33afcf63620f982d34e1a2
6
+ metadata.gz: 8d53401f56639f5cfb0d6a170f152f02b6d8dda034c58b9ebae611de68c9e1e24194b5203e4b06d3665abca1ee528f23d71e38c1677c14f0178a3f01b73af621
7
+ data.tar.gz: 98236167b8d6f28c5c2ab28689266bb1748e98ca0706bd531514d08089d78ff41aa595e24fd099758712c0aada57bfa4ba8402706f28ab74f031a7c2ea50a20b
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ietfbib (0.4.1)
5
- iso-bib-item (~> 0.3.0)
4
+ ietfbib (0.4.2)
5
+ iso-bib-item (~> 0.4.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -13,7 +13,7 @@ GEM
13
13
  docile (1.3.1)
14
14
  equivalent-xml (0.6.0)
15
15
  nokogiri (>= 1.4.3)
16
- iso-bib-item (0.3.0)
16
+ iso-bib-item (0.4.1)
17
17
  isoics (~> 0.1.6)
18
18
  nokogiri (~> 1.8.4)
19
19
  ruby_deep_clone (~> 0.8.0)
@@ -21,7 +21,7 @@ GEM
21
21
  json (2.1.0)
22
22
  method_source (0.9.0)
23
23
  mini_portile2 (2.3.0)
24
- nokogiri (1.8.4)
24
+ nokogiri (1.8.5)
25
25
  mini_portile2 (~> 2.3.0)
26
26
  pry (0.11.3)
27
27
  coderay (~> 1.1.0)
@@ -36,7 +36,7 @@ GEM
36
36
  rspec-mocks (~> 3.8.0)
37
37
  rspec-core (3.8.0)
38
38
  rspec-support (~> 3.8.0)
39
- rspec-expectations (3.8.1)
39
+ rspec-expectations (3.8.2)
40
40
  diff-lcs (>= 1.2.0, < 2.0)
41
41
  rspec-support (~> 3.8.0)
42
42
  rspec-mocks (3.8.0)
@@ -63,4 +63,4 @@ DEPENDENCIES
63
63
  simplecov
64
64
 
65
65
  BUNDLED WITH
66
- 1.16.2
66
+ 1.16.6
data/ietfbib.gemspec CHANGED
@@ -35,5 +35,5 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency 'rspec', '~> 3.0'
36
36
  spec.add_development_dependency 'simplecov'
37
37
 
38
- spec.add_dependency 'iso-bib-item', '~> 0.3.0'
38
+ spec.add_dependency 'iso-bib-item', '~> 0.4.1'
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module IETFBib
2
- VERSION = '0.4.1'.freeze
2
+ VERSION = '0.4.2'.freeze
3
3
  end
@@ -0,0 +1,66 @@
1
+ require 'nokogiri'
2
+
3
+ module IETFBib
4
+ class XMLParser < IsoBibItem::XMLParser
5
+ class << self
6
+ def from_xml(xml)
7
+ doc = Nokogiri::XML(xml)
8
+ IsoBibItem::BibliographicItem.new(
9
+ id: fetch_id(doc),
10
+ docid: fetch_docid(doc),
11
+ edition: doc.at('/bibitem/edition')&.text,
12
+ language: doc.xpath('/bibitem/language').map(&:text),
13
+ script: doc.xpath('/bibitem/script').map(&:text),
14
+ titles: fetch_titles(doc),
15
+ type: doc.at('bibitem')&.attr(:type),
16
+ ics: fetch_ics(doc),
17
+ dates: fetch_dates(doc),
18
+ contributors: fetch_contributors(doc),
19
+ workgroup: fetch_workgroup(doc),
20
+ abstract: fetch_abstract(doc),
21
+ copyright: fetch_copyright(doc),
22
+ link: fetch_link(doc),
23
+ relations: fetch_relations(doc),
24
+ series: fetch_series(doc)
25
+ )
26
+ end
27
+
28
+ private
29
+
30
+ def fetch_id(doc)
31
+ doc.at('/bibitem')[:id]
32
+ end
33
+
34
+ def fetch_titles(doc)
35
+ doc.xpath('/bibitem/title').map do |t|
36
+ { content: t.text, language: t[:language], script: t[:script] }
37
+ end
38
+ end
39
+
40
+ def fetch_series(doc)
41
+ doc.xpath('/bibitem/series').map do |s|
42
+ t = s.at('./title')
43
+ title = IsoBibItem::FormattedString.new(
44
+ content: t.text,
45
+ language: t[:language],
46
+ type: t[:format],
47
+ script: t[:script]
48
+ )
49
+ abbr = s.at('./abbreviation')
50
+ abbr = IsoBibItem::LocalizedString.new(abbr.text) if abbr
51
+ IsoBibItem::Series.new(
52
+ title: title,
53
+ type: s[:type],
54
+ place: s.at('./place')&.text,
55
+ organization: s.at('./organization')&.text,
56
+ abbreviation: abbr,
57
+ from: s.at('./from')&.text,
58
+ to: s.at('./to')&.text,
59
+ number: s.at('./number')&.text,
60
+ part_number: s.at('./part_numper')&.text
61
+ )
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
data/lib/ietfbib.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'ietfbib/version'
4
4
  require 'ietfbib/rfc_bibliography'
5
+ require 'ietfbib/xml_parser'
5
6
 
6
7
  if defined? Relaton
7
8
  require_relative 'relaton/processor'
@@ -1,4 +1,5 @@
1
1
  require 'relaton/processor'
2
+ require 'ietfbib/xml_parser'
2
3
 
3
4
  module Relaton
4
5
  module IETFBib
@@ -13,6 +14,10 @@ module Relaton
13
14
  def get(code, date, opts)
14
15
  ::IETFBib::RfcBibliography.get(code, date, opts)
15
16
  end
17
+
18
+ def from_xml(xml)
19
+ ::IETFBib::XMLParser.from_xml xml
20
+ end
16
21
  end
17
22
  end
18
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ietfbib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.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: 2018-09-10 00:00:00.000000000 Z
11
+ date: 2018-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.3.0
103
+ version: 0.4.1
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.3.0
110
+ version: 0.4.1
111
111
  description: "ietfbib: retrieve IETF Standards for bibliographic use \nusing the BibliographicItem
112
112
  model.\n\nFormerly known as rfcbib.\n"
113
113
  email:
@@ -132,6 +132,7 @@ files:
132
132
  - lib/ietfbib/rfc_bibliography.rb
133
133
  - lib/ietfbib/scrapper.rb
134
134
  - lib/ietfbib/version.rb
135
+ - lib/ietfbib/xml_parser.rb
135
136
  - lib/relaton/processor.rb
136
137
  homepage: https://github.com/riboseinc/ietfbib
137
138
  licenses: