relaton-gb 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ubuntu.yml +1 -0
- data/.rubocop.yml +2 -2
- data/lib/relaton_gb/ccs.rb +12 -0
- data/lib/relaton_gb/gb_bibliographic_item.rb +8 -0
- data/lib/relaton_gb/t_scrapper.rb +5 -7
- data/lib/relaton_gb/version.rb +1 -1
- data/relaton_gb.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 272eba99fd1d47cd23a6cd3c6bef9e9f4ee9da3b92f67609a36125829ca3177c
|
4
|
+
data.tar.gz: ea2242879a194e9660662407fb35dd5cb7024b5b107c93b5c88fea24a67539b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c94507bc12aed5456d3a4cc886f1fec4285e06b2446a75098c7842ddb018526ea619557fbda8641b41fd22a43ea0bea9167d71902085295071fc2de2a7eb402
|
7
|
+
data.tar.gz: 4cfa54290c430b6a10156017862e0730b29f743f673bb265226c5e628747592f2f0465f648c63c4a21a26ce2e2eb1c280eb8466c9c6c9de2d53443dfa0cc8a97
|
data/.rubocop.yml
CHANGED
data/lib/relaton_gb/ccs.rb
CHANGED
@@ -4,5 +4,17 @@ module Cnccs
|
|
4
4
|
def to_hash
|
5
5
|
{ "code" => code }
|
6
6
|
end
|
7
|
+
|
8
|
+
# @param prefix [String]
|
9
|
+
# @param count [Integer]
|
10
|
+
# @return [String]
|
11
|
+
def to_aciibib(prefix = "", count = 1)
|
12
|
+
pref = prefix.empty? ? prefix : prefix + "."
|
13
|
+
pref += "ccs"
|
14
|
+
out = count > 1 ? "#{pref}::\n" : ""
|
15
|
+
out += "#{pref}.code:: #{code}\n" if code
|
16
|
+
out += "#{pref}.description:: #{description}\n" if description
|
17
|
+
out
|
18
|
+
end
|
7
19
|
end
|
8
20
|
end
|
@@ -60,6 +60,14 @@ module RelatonGb
|
|
60
60
|
hash
|
61
61
|
end
|
62
62
|
|
63
|
+
# @param prefix [String]
|
64
|
+
# @return [String]
|
65
|
+
def to_asciibib(prefix = "")
|
66
|
+
out = super
|
67
|
+
ccs.each { |c| out += c.to_aciibib prefix, ccs.size }
|
68
|
+
out
|
69
|
+
end
|
70
|
+
|
63
71
|
# @return [String]
|
64
72
|
def inspect
|
65
73
|
"<#{self.class}:#{format('%<id>#.14x', id: object_id << 1)}>"
|
@@ -21,7 +21,7 @@ module RelatonGb
|
|
21
21
|
def scrape_page(text)
|
22
22
|
search_html = OpenURI.open_uri(
|
23
23
|
"http://www.ttbz.org.cn/Home/Standard?searchType=2&key=" +
|
24
|
-
CGI.escape(text.tr("-", [8212].pack("U")))
|
24
|
+
CGI.escape(text.tr("-", [8212].pack("U")))
|
25
25
|
).read
|
26
26
|
header = Nokogiri::HTML search_html
|
27
27
|
xpath = '//table[contains(@class, "standard_list_table")]/tr/td/a'
|
@@ -85,7 +85,8 @@ module RelatonGb
|
|
85
85
|
|
86
86
|
def get_titles(doc)
|
87
87
|
xpz = '//td[contains(.,"中文标题")]/following-sibling::td[1]'
|
88
|
-
titles = RelatonBib::TypedTitleString.from_string doc.at(xpz)
|
88
|
+
titles = RelatonBib::TypedTitleString.from_string doc.at(xpz)
|
89
|
+
.text, "zh", "Hans"
|
89
90
|
xpe = '//td[contains(.,"英文标题")]/following-sibling::td[1]'
|
90
91
|
ten = doc.xpath(xpe).text
|
91
92
|
return titles if ten.empty?
|
@@ -94,13 +95,10 @@ module RelatonGb
|
|
94
95
|
end
|
95
96
|
|
96
97
|
def gbtype
|
97
|
-
{ scope: "social-group", prefix: "T", mandate: "mandatory",
|
98
|
+
{ scope: "social-group", prefix: "T", mandate: "mandatory",
|
99
|
+
topic: "other" }
|
98
100
|
end
|
99
101
|
|
100
|
-
# def get_group_code(ref)
|
101
|
-
# ref.match(%r{(?<=\/)[^\s]})
|
102
|
-
# end
|
103
|
-
|
104
102
|
def get_ccs(doc)
|
105
103
|
[doc.xpath('//td[contains(.,"中国标准分类号")]/following-sibling::td[1]')
|
106
104
|
.text.gsub(/[\r\n]/, "").strip.match(/^[^\s]+/).to_s]
|
data/lib/relaton_gb/version.rb
CHANGED
data/relaton_gb.gemspec
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: 1.
|
4
|
+
version: 1.3.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-
|
11
|
+
date: 2020-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debase
|
@@ -184,14 +184,14 @@ dependencies:
|
|
184
184
|
requirements:
|
185
185
|
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: 1.
|
187
|
+
version: 1.3.0
|
188
188
|
type: :runtime
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version: 1.
|
194
|
+
version: 1.3.0
|
195
195
|
description: 'RelatonGb: retrieve Chinese GB Standards for bibliographic use using
|
196
196
|
the BibliographicItem model.'
|
197
197
|
email:
|