gbbib 0.2.2 → 0.2.3
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 +4 -4
- data/Gemfile.lock +15 -15
- data/LICENSE.txt +21 -17
- data/gbbib.gemspec +1 -1
- data/lib/gbbib/gb_bibliographic_item.rb +5 -4
- data/lib/gbbib/gb_bibliography.rb +0 -38
- data/lib/gbbib/scrapper.rb +3 -3
- data/lib/gbbib/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b003d92490a9a1c6bc3ae124b2c315232336f57fd113ddeb0edc5a1cc3aab83
|
4
|
+
data.tar.gz: 5f75e05b76700d7901af1cbde25be569a2519c196b4e6753c8e8d82b2dee5b8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 236ebaf149fdfd887f88109f6941c11e29b826a5d25763fdd0e100e438c6b2244c162197de20c2f049d290e75b86339b2e0c50526fcd98095b5b5d910e2079a6
|
7
|
+
data.tar.gz: 63fc93e2558e790221d96fd367c30d009798d0b4971049e342d85475a71ae20a5b97e78e6c94d7c3a4d5ab9588b88e90c87c049dee5168450860cdf84c527bbc
|
data/Gemfile.lock
CHANGED
@@ -10,18 +10,18 @@ GEM
|
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
12
|
byebug (10.0.2)
|
13
|
-
cnccs (0.1.
|
13
|
+
cnccs (0.1.3)
|
14
14
|
coderay (1.1.2)
|
15
15
|
diff-lcs (1.3)
|
16
16
|
docile (1.3.1)
|
17
17
|
equivalent-xml (0.6.0)
|
18
18
|
nokogiri (>= 1.4.3)
|
19
|
-
gb-agencies (0.0.
|
20
|
-
iso-bib-item (0.2.
|
19
|
+
gb-agencies (0.0.3)
|
20
|
+
iso-bib-item (0.2.5)
|
21
21
|
isoics (~> 0.1.6)
|
22
22
|
nokogiri (~> 1.8.4)
|
23
23
|
ruby_deep_clone (~> 0.8.0)
|
24
|
-
isoics (0.1.
|
24
|
+
isoics (0.1.7)
|
25
25
|
json (2.1.0)
|
26
26
|
method_source (0.9.0)
|
27
27
|
mini_portile2 (2.3.0)
|
@@ -34,19 +34,19 @@ GEM
|
|
34
34
|
byebug (~> 10.0)
|
35
35
|
pry (~> 0.10)
|
36
36
|
rake (10.5.0)
|
37
|
-
rspec (3.
|
38
|
-
rspec-core (~> 3.
|
39
|
-
rspec-expectations (~> 3.
|
40
|
-
rspec-mocks (~> 3.
|
41
|
-
rspec-core (3.
|
42
|
-
rspec-support (~> 3.
|
43
|
-
rspec-expectations (3.
|
37
|
+
rspec (3.8.0)
|
38
|
+
rspec-core (~> 3.8.0)
|
39
|
+
rspec-expectations (~> 3.8.0)
|
40
|
+
rspec-mocks (~> 3.8.0)
|
41
|
+
rspec-core (3.8.0)
|
42
|
+
rspec-support (~> 3.8.0)
|
43
|
+
rspec-expectations (3.8.1)
|
44
44
|
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
-
rspec-support (~> 3.
|
46
|
-
rspec-mocks (3.
|
45
|
+
rspec-support (~> 3.8.0)
|
46
|
+
rspec-mocks (3.8.0)
|
47
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
-
rspec-support (~> 3.
|
49
|
-
rspec-support (3.
|
48
|
+
rspec-support (~> 3.8.0)
|
49
|
+
rspec-support (3.8.0)
|
50
50
|
ruby_deep_clone (0.8.0)
|
51
51
|
simplecov (0.16.1)
|
52
52
|
docile (~> 1.1)
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,25 @@
|
|
1
|
-
|
1
|
+
BSD 2-Clause License
|
2
2
|
|
3
|
-
Copyright (c) 2018
|
3
|
+
Copyright (c) 2018, Ribose
|
4
|
+
All rights reserved.
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
11
8
|
|
12
|
-
|
13
|
-
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
10
|
+
list of conditions and the following disclaimer.
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
14
|
+
and/or other materials provided with the distribution.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
20
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
21
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
22
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
23
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
24
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/gbbib.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.description = 'GdBib: retrieve Chinese GB Standards for bibliographic'\
|
15
15
|
' use using the BibliographicItem model.'
|
16
16
|
spec.homepage = 'https://github.com/riboseinc/gdbib'
|
17
|
-
spec.license = '
|
17
|
+
spec.license = 'BSD-2-Clause'
|
18
18
|
|
19
19
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
20
|
f.match(%r{^(test|spec|features)/})
|
@@ -58,11 +58,12 @@ module Gbbib
|
|
58
58
|
inspect
|
59
59
|
end
|
60
60
|
|
61
|
-
def id
|
61
|
+
def makeid(id, attribute, delim = '')
|
62
62
|
return nil if attribute && !@id_attribute
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
id = @docidentifier.reject { |i| i.type == "DOI" }[0] unless id
|
64
|
+
idstr = id.project_number.to_s
|
65
|
+
if id.part_number&.size&.positive?
|
66
|
+
idstr = idstr + "-#{id.part_number}"
|
66
67
|
end
|
67
68
|
idstr.strip
|
68
69
|
end
|
@@ -39,7 +39,6 @@ module Gbbib
|
|
39
39
|
# @param opts [Hash] options; restricted to :all_parts if all-parts reference is required
|
40
40
|
# @return [String] Relaton XML serialisation of reference
|
41
41
|
def get(code, year, opts)
|
42
|
-
return iev.to_xml if code.casecmp('IEV') == 0
|
43
42
|
code += '.1' if opts[:all_parts]
|
44
43
|
ret = get1(code, year, opts)
|
45
44
|
return nil if ret.nil?
|
@@ -68,7 +67,6 @@ module Gbbib
|
|
68
67
|
end
|
69
68
|
|
70
69
|
def get1(code, year, opts)
|
71
|
-
return iev if code.casecmp("IEV") == 0
|
72
70
|
result = search_filter(code) or return nil
|
73
71
|
ret = results_filter(result, year)
|
74
72
|
return ret[:ret] if ret[:ret]
|
@@ -115,42 +113,6 @@ module Gbbib
|
|
115
113
|
workers.end
|
116
114
|
workers.result.sort { |x, y| x[:i] <=> y[:i] }.map { |x| x[:hit] }
|
117
115
|
end
|
118
|
-
|
119
|
-
def iev
|
120
|
-
Nokogiri::XML.fragment(<<~"END")
|
121
|
-
<bibitem type="international-standard" id="IEV">
|
122
|
-
<title format="text/plain" language="en" script="Latn">Electropedia: The World's Online Electrotechnical Vocabulary</title>
|
123
|
-
<source type="src">http://www.electropedia.org</source>
|
124
|
-
<docidentifier>IEV</docidentifier>
|
125
|
-
<date type="published"> <on>#{Date.today.year}</on> </date>
|
126
|
-
<contributor>
|
127
|
-
<role type="publisher"/>
|
128
|
-
<organization>
|
129
|
-
<name>International Electrotechnical Commission</name>
|
130
|
-
<abbreviation>IEC</abbreviation>
|
131
|
-
<uri>www.iec.ch</uri>
|
132
|
-
</organization>
|
133
|
-
</contributor>
|
134
|
-
<language>en</language> <language>fr</language>
|
135
|
-
<script>Latn</script>
|
136
|
-
<copyright>
|
137
|
-
<from>#{Date.today.year}</from>
|
138
|
-
<owner>
|
139
|
-
<organization>
|
140
|
-
<name>International Electrotechnical Commission</name>
|
141
|
-
<abbreviation>IEC</abbreviation>
|
142
|
-
<uri>www.iec.ch</uri>
|
143
|
-
</organization>
|
144
|
-
</owner>
|
145
|
-
</copyright>
|
146
|
-
<relation type="updates">
|
147
|
-
<bibitem>
|
148
|
-
<formattedref>IEC 60050</formattedref>
|
149
|
-
</bibitem>
|
150
|
-
</relation>
|
151
|
-
</bibitem>
|
152
|
-
END
|
153
|
-
end
|
154
116
|
end
|
155
117
|
end
|
156
118
|
end
|
data/lib/gbbib/scrapper.rb
CHANGED
@@ -37,9 +37,9 @@ module Gbbib
|
|
37
37
|
# * :project_number [String]
|
38
38
|
# * :part_number [String]
|
39
39
|
def get_docid(doc, xpt = '//dt[text()="标准号"]/following-sibling::dd[1]')
|
40
|
-
item_ref = doc.xpath(xpt).text.match(
|
41
|
-
prefix = doc.xpath(xpt).text.match(/^[^\s]+/).to_s
|
42
|
-
{ project_number: item_ref[1], part_number: item_ref[2], prefix:
|
40
|
+
item_ref = doc.xpath(xpt).text.match(/^([^–—.-]*\d+)\.?((?<=\.)\d+|)/)
|
41
|
+
#prefix = doc.xpath(xpt).text.match(/^[^\s]+/).to_s
|
42
|
+
{ project_number: item_ref[1], part_number: item_ref[2], prefix: nil }
|
43
43
|
end
|
44
44
|
|
45
45
|
def get_contributors(doc, xpt = '//dt[text()="标准号"]/following-sibling::dd[1]')
|
data/lib/gbbib/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.3
|
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-08-
|
11
|
+
date: 2018-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -173,7 +173,7 @@ files:
|
|
173
173
|
- lib/relaton/processor.rb
|
174
174
|
homepage: https://github.com/riboseinc/gdbib
|
175
175
|
licenses:
|
176
|
-
-
|
176
|
+
- BSD-2-Clause
|
177
177
|
metadata: {}
|
178
178
|
post_install_message:
|
179
179
|
rdoc_options: []
|