gbbib 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/gbbib.gemspec +1 -1
- data/lib/gbbib/gb_bibliographic_item.rb +1 -0
- data/lib/gbbib/version.rb +1 -1
- data/lib/gbbib/xml_parser.rb +56 -0
- data/lib/relaton/processor.rb +6 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd82764d26babcef9ad8c9e5882357bee50aa130f7ea98031a7e9950aed944b0
|
4
|
+
data.tar.gz: 63ba319a8bd84f5550301477c74412ab56cd75d94bf1dd0c25621d3c8430cfe1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb519815fe2e2c8a2bee7eaf9f83c34913b7ff84ddfdee5a87c98eb18e461d9d9a7601e6f09568e1ea517fb5b853688fb39b17d9895513515d0eb7a1d7f7fc04
|
7
|
+
data.tar.gz: 66bb74992020a9056b25cdedca2029f40322c5d29e6ee3fc7146f980bda2f71c720f60c0f5d39ee10c7f9d3cdb5330254483df3c32bbc4cbbdfbf18d4910e61a
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gbbib (0.
|
4
|
+
gbbib (0.4.0)
|
5
5
|
cnccs (~> 0.1.1)
|
6
6
|
gb-agencies (~> 0.0.1)
|
7
|
-
iso-bib-item (~> 0.
|
7
|
+
iso-bib-item (~> 0.4.1)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -17,7 +17,7 @@ GEM
|
|
17
17
|
equivalent-xml (0.6.0)
|
18
18
|
nokogiri (>= 1.4.3)
|
19
19
|
gb-agencies (0.0.3)
|
20
|
-
iso-bib-item (0.
|
20
|
+
iso-bib-item (0.4.1)
|
21
21
|
isoics (~> 0.1.6)
|
22
22
|
nokogiri (~> 1.8.4)
|
23
23
|
ruby_deep_clone (~> 0.8.0)
|
@@ -25,7 +25,7 @@ GEM
|
|
25
25
|
json (2.1.0)
|
26
26
|
method_source (0.9.0)
|
27
27
|
mini_portile2 (2.3.0)
|
28
|
-
nokogiri (1.8.
|
28
|
+
nokogiri (1.8.5)
|
29
29
|
mini_portile2 (~> 2.3.0)
|
30
30
|
pry (0.11.3)
|
31
31
|
coderay (~> 1.1.0)
|
@@ -40,7 +40,7 @@ GEM
|
|
40
40
|
rspec-mocks (~> 3.8.0)
|
41
41
|
rspec-core (3.8.0)
|
42
42
|
rspec-support (~> 3.8.0)
|
43
|
-
rspec-expectations (3.8.
|
43
|
+
rspec-expectations (3.8.2)
|
44
44
|
diff-lcs (>= 1.2.0, < 2.0)
|
45
45
|
rspec-support (~> 3.8.0)
|
46
46
|
rspec-mocks (3.8.0)
|
@@ -67,4 +67,4 @@ DEPENDENCIES
|
|
67
67
|
simplecov
|
68
68
|
|
69
69
|
BUNDLED WITH
|
70
|
-
1.16.
|
70
|
+
1.16.6
|
data/gbbib.gemspec
CHANGED
@@ -31,6 +31,6 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
32
32
|
|
33
33
|
spec.add_dependency 'cnccs', "~> 0.1.1"
|
34
|
-
spec.add_dependency 'iso-bib-item', "~> 0.
|
34
|
+
spec.add_dependency 'iso-bib-item', "~> 0.4.1"
|
35
35
|
spec.add_dependency 'gb-agencies', "~> 0.0.1"
|
36
36
|
end
|
data/lib/gbbib/version.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Gbbib
|
4
|
+
class XMLParser < IsoBibItem::XMLParser
|
5
|
+
class << self
|
6
|
+
def from_xml(xml)
|
7
|
+
doc = Nokogiri::XML(xml)
|
8
|
+
GbBibliographicItem.new(
|
9
|
+
docid: fetch_docid(doc),
|
10
|
+
edition: doc.at('/bibitem/edition')&.text,
|
11
|
+
language: doc.xpath('/bibitem/language').map(&:text),
|
12
|
+
script: doc.xpath('/bibitem/script').map(&:text),
|
13
|
+
titles: fetch_titles(doc),
|
14
|
+
type: doc.at('bibitem')&.attr(:type),
|
15
|
+
docstatus: fetch_status(doc),
|
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
|
+
committee: fetch_committee(doc),
|
25
|
+
ccs: fetch_ccs(doc),
|
26
|
+
gbtype: fetch_gbtype(doc)
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# Overrade get_id from IsoBibItem::XMLParser
|
33
|
+
def get_id(did)
|
34
|
+
id = did.text.match(/^(?<project>.*?\d+)(?<hyphen>-)?(?(<hyphen>)(?<year>\d*))/)
|
35
|
+
end
|
36
|
+
|
37
|
+
def fetch_committee(doc)
|
38
|
+
committee = doc.at '/bibitem/gbcommittee'
|
39
|
+
{ type: committee[:type], name: committee.text }
|
40
|
+
end
|
41
|
+
|
42
|
+
def fetch_ccs(doc)
|
43
|
+
doc.xpath('/bibitem/ccs/code').map &:text
|
44
|
+
end
|
45
|
+
|
46
|
+
def fetch_gbtype(doc)
|
47
|
+
gbtype = doc.at '/bibitem/gbtype'
|
48
|
+
{
|
49
|
+
scope: gbtype.at('gbscope').text,
|
50
|
+
prefix: gbtype.at('gbprefix').text,
|
51
|
+
mandate: gbtype.at('gbmandate').text
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/relaton/processor.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "relaton/processor"
|
2
4
|
|
3
5
|
module Relaton
|
@@ -14,6 +16,10 @@ module Relaton
|
|
14
16
|
def get(code, date, opts)
|
15
17
|
::Gbbib::GbBibliography.get(code, date, opts)
|
16
18
|
end
|
19
|
+
|
20
|
+
def from_xml(xml)
|
21
|
+
::Gbbib::XMLParser.from_xml xml
|
22
|
+
end
|
17
23
|
end
|
18
24
|
end
|
19
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gbbib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.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: 2018-
|
11
|
+
date: 2018-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 0.4.1
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: 0.4.1
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: gb-agencies
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- lib/gbbib/t_scrapper.rb
|
170
170
|
- lib/gbbib/version.rb
|
171
171
|
- lib/gbbib/workers_pool.rb
|
172
|
+
- lib/gbbib/xml_parser.rb
|
172
173
|
- lib/gbbib/yaml/prefixes.yaml
|
173
174
|
- lib/relaton/processor.rb
|
174
175
|
homepage: https://github.com/riboseinc/gdbib
|