relaton-gb 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/lib/relaton_gb/ccs.rb +8 -0
- data/lib/relaton_gb/gb_bibliographic_item.rb +12 -2
- data/lib/relaton_gb/gb_scrapper.rb +2 -2
- data/lib/relaton_gb/gb_standard_type.rb +5 -0
- data/lib/relaton_gb/gb_technical_committee.rb +5 -0
- data/lib/relaton_gb/hash_converter.rb +1 -19
- data/lib/relaton_gb/sec_scrapper.rb +4 -2
- data/lib/relaton_gb/t_scrapper.rb +2 -2
- data/lib/relaton_gb/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0978ce217698027cca98e48fcad3fdf3060af8f
|
4
|
+
data.tar.gz: 3f9e4857d33b1b3aee204746098c003816ded415
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a52a32b85031f0b31005a562fa3c95e630f9a33e353b7b0371eee23ebb8483430cf770bc16f900406357609ecbabae3dcb8dab1af6e2ac5a9151866bb03ceb0
|
7
|
+
data.tar.gz: 9d3ab095b5681268b8113789b53c0b60140e4faf427918f29561460454fec99b9cff46bb9d39d5b6480df341f7d23396c17bcb8258fa95f413965a7f136f4e96
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
relaton-gb (0.6.
|
4
|
+
relaton-gb (0.6.2)
|
5
5
|
cnccs (~> 0.1.1)
|
6
6
|
gb-agencies (~> 0.0.1)
|
7
7
|
relaton-iso-bib (~> 0.3.0)
|
@@ -26,7 +26,7 @@ GEM
|
|
26
26
|
json (2.2.0)
|
27
27
|
method_source (0.9.2)
|
28
28
|
mini_portile2 (2.4.0)
|
29
|
-
nokogiri (1.10.
|
29
|
+
nokogiri (1.10.4)
|
30
30
|
mini_portile2 (~> 2.4.0)
|
31
31
|
pry (0.12.2)
|
32
32
|
coderay (~> 1.1.0)
|
@@ -36,10 +36,10 @@ GEM
|
|
36
36
|
pry (~> 0.10)
|
37
37
|
public_suffix (3.1.1)
|
38
38
|
rake (10.5.0)
|
39
|
-
relaton-bib (0.3.
|
39
|
+
relaton-bib (0.3.5)
|
40
40
|
addressable
|
41
41
|
nokogiri (~> 1.10)
|
42
|
-
relaton-iso-bib (0.3.
|
42
|
+
relaton-iso-bib (0.3.4)
|
43
43
|
isoics (~> 0.1.6)
|
44
44
|
relaton-bib (~> 0.3.0)
|
45
45
|
ruby_deep_clone (~> 0.8.0)
|
@@ -6,6 +6,7 @@ require "relaton_gb/gb_technical_committee"
|
|
6
6
|
require "relaton_gb/gb_standard_type"
|
7
7
|
require "relaton_gb/xml_parser"
|
8
8
|
require "relaton_gb/hash_converter"
|
9
|
+
require "relaton_gb/ccs"
|
9
10
|
|
10
11
|
module RelatonGb
|
11
12
|
# GB bibliographic item class.
|
@@ -49,6 +50,16 @@ module RelatonGb
|
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
53
|
+
# @return [Hash]
|
54
|
+
def to_hash
|
55
|
+
hash = super
|
56
|
+
hash["ccs"] = single_element_array(ccs) if ccs&.any?
|
57
|
+
hash["committee"] = committee.to_hash if committee
|
58
|
+
hash["plannumber"] = gbplannumber if gbplannumber
|
59
|
+
hash["gbtype"] = gbtype.to_hash
|
60
|
+
hash
|
61
|
+
end
|
62
|
+
|
52
63
|
# @return [String]
|
53
64
|
def inspect
|
54
65
|
"<#{self.class}:#{format('%#.14x', object_id << 1)}>"
|
@@ -97,9 +108,8 @@ module RelatonGb
|
|
97
108
|
# @param builder [Nokogiri::XML::Builder]
|
98
109
|
def render_gbxml(builder)
|
99
110
|
gbtype.to_xml builder
|
100
|
-
return unless ccs.any?
|
101
111
|
|
102
|
-
ccs
|
112
|
+
ccs&.each do |c|
|
103
113
|
builder.ccs do
|
104
114
|
builder.code c.code
|
105
115
|
builder.text_ c.description
|
@@ -23,7 +23,7 @@ module RelatonGb
|
|
23
23
|
Hit.new pid: h[:pid], title: h.text, scrapper: self
|
24
24
|
end
|
25
25
|
HitCollection.new hits
|
26
|
-
rescue OpenURI::HTTPError, SocketError
|
26
|
+
rescue OpenURI::HTTPError, SocketError, OpenSSL::SSL::SSLError
|
27
27
|
raise RelatonBib::RequestError, "Cannot access http://www.std.gov.cn/search/stdPage"
|
28
28
|
end
|
29
29
|
|
@@ -33,7 +33,7 @@ module RelatonGb
|
|
33
33
|
src = "http://www.std.gov.cn/gb/search/gbDetailed?id=" + pid
|
34
34
|
doc = Nokogiri::HTML OpenURI.open_uri(src)
|
35
35
|
GbBibliographicItem.new scrapped_data(doc, src: src)
|
36
|
-
rescue OpenURI::HTTPError, SocketError
|
36
|
+
rescue OpenURI::HTTPError, SocketError, OpenSSL::SSL::SSLError
|
37
37
|
raise RelatonBib::RequestError, "Cannot access #{src}"
|
38
38
|
end
|
39
39
|
|
@@ -11,32 +11,14 @@ module RelatonGb
|
|
11
11
|
ret = super
|
12
12
|
return if ret.nil?
|
13
13
|
|
14
|
-
committee_hash_to_bib(ret)
|
15
14
|
ccs_hash_to_bib(ret)
|
16
15
|
ret
|
17
16
|
end
|
18
17
|
|
19
18
|
private
|
20
19
|
|
21
|
-
def committee_hash_to_bib(ret)
|
22
|
-
return unless ret[:title]
|
23
|
-
|
24
|
-
ret[:title] = array(ret[:title])
|
25
|
-
ret[:title] = ret[:title].map do |t|
|
26
|
-
titleparts = {}
|
27
|
-
titleparts = split_title(t) unless t.is_a?(Hash)
|
28
|
-
if t.is_a?(Hash) && t[:content]
|
29
|
-
titleparts = split_title(t[:content], t[:language], t[:script])
|
30
|
-
end
|
31
|
-
if t.is_a?(Hash) then t.merge(titleparts)
|
32
|
-
else
|
33
|
-
{ content: t, language: "en", script: "Latn", format: "text/plain", type: "main" }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
20
|
def ccs_hash_to_bib(ret)
|
39
|
-
ret[:ccs] = ret
|
21
|
+
ret[:ccs] = array(ret[:ccs]).map do |ccs|
|
40
22
|
ccs[:code] ? Cnccs.fetch(ccs[:code]) : Cnccs.fetch(ccs)
|
41
23
|
end
|
42
24
|
end
|
@@ -25,7 +25,8 @@ module RelatonGb
|
|
25
25
|
end
|
26
26
|
HitCollection.new hits
|
27
27
|
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
28
|
-
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError
|
28
|
+
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
|
29
|
+
OpenSSL::SSL::SSLError
|
29
30
|
raise RelatonBib::RequestError, "Cannot access #{uri}"
|
30
31
|
end
|
31
32
|
|
@@ -37,7 +38,8 @@ module RelatonGb
|
|
37
38
|
doc = Nokogiri::HTML Net::HTTP.get(page_uri)
|
38
39
|
GbBibliographicItem.new scrapped_data(doc, src: src)
|
39
40
|
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
40
|
-
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError
|
41
|
+
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
|
42
|
+
OpenSSL::SSL::SSLError
|
41
43
|
raise RelatonBib::RequestError, "Cannot access #{src}"
|
42
44
|
end
|
43
45
|
|
@@ -30,7 +30,7 @@ module RelatonGb
|
|
30
30
|
Hit.new pid: h[:href].sub(%r{\/$}, ""), title: title, scrapper: self
|
31
31
|
end
|
32
32
|
HitCollection.new hits
|
33
|
-
rescue OpenURI::HTTPError, SocketError
|
33
|
+
rescue OpenURI::HTTPError, SocketError, OpenSSL::SSL::SSLError
|
34
34
|
raise RelatonBib::RequestError, "Cannot access http://www.ttbz.org.cn/Home/Standard"
|
35
35
|
end
|
36
36
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
@@ -41,7 +41,7 @@ module RelatonGb
|
|
41
41
|
src = "http://www.ttbz.org.cn#{pid}"
|
42
42
|
doc = Nokogiri::HTML OpenURI.open_uri(src), nil, Encoding::UTF_8.to_s
|
43
43
|
GbBibliographicItem.new scrapped_data(doc, src: src)
|
44
|
-
rescue OpenURI::HTTPError, SocketError
|
44
|
+
rescue OpenURI::HTTPError, SocketError, OpenSSL::SSL::SSLError
|
45
45
|
raise RelatonBib::RequestError, "Cannot access #{src}"
|
46
46
|
end
|
47
47
|
|
data/lib/relaton_gb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-gb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.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: 2019-08-
|
11
|
+
date: 2019-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- bin/setup
|
188
188
|
- lib/relaton/processor.rb
|
189
189
|
- lib/relaton_gb.rb
|
190
|
+
- lib/relaton_gb/ccs.rb
|
190
191
|
- lib/relaton_gb/gb_bibliographic_item.rb
|
191
192
|
- lib/relaton_gb/gb_bibliography.rb
|
192
193
|
- lib/relaton_gb/gb_scrapper.rb
|