isobib 0.2.3 → 0.2.5
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 +13 -13
- data/LICENSE.txt +25 -0
- data/isobib.gemspec +1 -1
- data/lib/isobib/iso_bibliography.rb +10 -14
- data/lib/isobib/scrapper.rb +5 -4
- data/lib/isobib/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ff27e088b8184634663981a6df34301e5958e02b04ff94af0c36e9a0aa1c2e8f
|
|
4
|
+
data.tar.gz: a31f26d8fef8e57b7b04932c120ff55e7c5630cfe7a43c2a749f2edea693c1f2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dfee675bebd17b8a4ede137b9e2006c5728335606c303501aaa8dfe495557e144c815d987d13f3549b44e857d5420becc0bde0631a9ea1e33b24c67bdd39d27f
|
|
7
|
+
data.tar.gz: aa37f8219f11525a6c02cff2f0f5b264c074739dcf81f0f6b13476f88ebd27a5798ba95cb5f94494612d28bb2d30beb82b4535420cf8aee2129153c7bff24cc9
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
isobib (0.2.
|
|
4
|
+
isobib (0.2.4)
|
|
5
5
|
algoliasearch
|
|
6
6
|
iso-bib-item (~> 0.2.4)
|
|
7
7
|
|
|
@@ -22,7 +22,7 @@ GEM
|
|
|
22
22
|
isoics (~> 0.1.6)
|
|
23
23
|
nokogiri (~> 1.8.4)
|
|
24
24
|
ruby_deep_clone (~> 0.8.0)
|
|
25
|
-
isoics (0.1.
|
|
25
|
+
isoics (0.1.7)
|
|
26
26
|
json (2.1.0)
|
|
27
27
|
method_source (0.9.0)
|
|
28
28
|
mini_portile2 (2.3.0)
|
|
@@ -35,19 +35,19 @@ GEM
|
|
|
35
35
|
byebug (~> 10.0)
|
|
36
36
|
pry (~> 0.10)
|
|
37
37
|
rake (10.5.0)
|
|
38
|
-
rspec (3.
|
|
39
|
-
rspec-core (~> 3.
|
|
40
|
-
rspec-expectations (~> 3.
|
|
41
|
-
rspec-mocks (~> 3.
|
|
42
|
-
rspec-core (3.
|
|
43
|
-
rspec-support (~> 3.
|
|
44
|
-
rspec-expectations (3.
|
|
38
|
+
rspec (3.8.0)
|
|
39
|
+
rspec-core (~> 3.8.0)
|
|
40
|
+
rspec-expectations (~> 3.8.0)
|
|
41
|
+
rspec-mocks (~> 3.8.0)
|
|
42
|
+
rspec-core (3.8.0)
|
|
43
|
+
rspec-support (~> 3.8.0)
|
|
44
|
+
rspec-expectations (3.8.1)
|
|
45
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
46
|
-
rspec-support (~> 3.
|
|
47
|
-
rspec-mocks (3.
|
|
46
|
+
rspec-support (~> 3.8.0)
|
|
47
|
+
rspec-mocks (3.8.0)
|
|
48
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
49
|
-
rspec-support (~> 3.
|
|
50
|
-
rspec-support (3.
|
|
49
|
+
rspec-support (~> 3.8.0)
|
|
50
|
+
rspec-support (3.8.0)
|
|
51
51
|
ruby_deep_clone (0.8.0)
|
|
52
52
|
simplecov (0.16.1)
|
|
53
53
|
docile (~> 1.1)
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
BSD 2-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018, Ribose
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
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/isobib.gemspec
CHANGED
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
|
16
16
|
'using the BibliographicItem model'
|
|
17
17
|
|
|
18
18
|
spec.homepage = 'https://github.com/riboseinc/isobib'
|
|
19
|
-
spec.license = '
|
|
19
|
+
spec.license = 'BSD-2-Clause'
|
|
20
20
|
|
|
21
21
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
22
22
|
f.match(%r{^(test|spec|features)/})
|
|
@@ -22,14 +22,15 @@ module Isobib
|
|
|
22
22
|
|
|
23
23
|
# @param code [String] the ISO standard Code to look up (e..g "ISO 9000")
|
|
24
24
|
# @param year [String] the year the standard was published (optional)
|
|
25
|
-
# @param opts [Hash] options; restricted to :all_parts if all-parts reference is required
|
|
25
|
+
# @param opts [Hash] options; restricted to :all_parts if all-parts reference is required,
|
|
26
|
+
# :keep_year if undated reference should return actual reference with year
|
|
26
27
|
# @return [String] Relaton XML serialisation of reference
|
|
27
28
|
def get(code, year, opts)
|
|
28
29
|
return iev if code.casecmp('IEV') == 0
|
|
29
30
|
code += '-1' if opts[:all_parts]
|
|
30
31
|
ret = isobib_get1(code, year, opts)
|
|
31
32
|
return nil if ret.nil?
|
|
32
|
-
ret.to_most_recent_reference unless year
|
|
33
|
+
ret.to_most_recent_reference unless year || opts[:keep_year]
|
|
33
34
|
ret.to_all_parts if opts[:all_parts]
|
|
34
35
|
ret # .to_xml
|
|
35
36
|
end
|
|
@@ -77,15 +78,13 @@ module Isobib
|
|
|
77
78
|
[]
|
|
78
79
|
end
|
|
79
80
|
|
|
80
|
-
|
|
81
|
-
def iev
|
|
81
|
+
def iev(code = "IEC 60050")
|
|
82
82
|
IsoBibItem.from_xml(<<~"END")
|
|
83
83
|
<bibitem type="international-standard" id="IEV">
|
|
84
|
-
<title format="text/plain" language="en" script="Latn">
|
|
85
|
-
The World's Online Electrotechnical Vocabulary</title>
|
|
84
|
+
<title format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary</title>
|
|
86
85
|
<link type="src">http://www.electropedia.org</link>
|
|
87
|
-
<docidentifier
|
|
88
|
-
<date type="published">
|
|
86
|
+
<docidentifier>#{code}</docidentifier>
|
|
87
|
+
<date type="published"><on>2011</on></date>
|
|
89
88
|
<contributor>
|
|
90
89
|
<role type="publisher"/>
|
|
91
90
|
<organization>
|
|
@@ -98,7 +97,7 @@ module Isobib
|
|
|
98
97
|
<script>Latn</script>
|
|
99
98
|
<status> <stage>60</stage> </status>
|
|
100
99
|
<copyright>
|
|
101
|
-
<from
|
|
100
|
+
<from>2018</from>
|
|
102
101
|
<owner>
|
|
103
102
|
<organization>
|
|
104
103
|
<name>International Electrotechnical Commission</name>
|
|
@@ -107,11 +106,6 @@ module Isobib
|
|
|
107
106
|
</organization>
|
|
108
107
|
</owner>
|
|
109
108
|
</copyright>
|
|
110
|
-
<relation type="updates">
|
|
111
|
-
<bibitem>
|
|
112
|
-
<formattedref>IEC 60050</formattedref>
|
|
113
|
-
</bibitem>
|
|
114
|
-
</relation>
|
|
115
109
|
</bibitem>
|
|
116
110
|
END
|
|
117
111
|
end
|
|
@@ -127,6 +121,7 @@ module Isobib
|
|
|
127
121
|
missed_years = []
|
|
128
122
|
result.each_slice(3) do |s| # ISO website only allows 3 connections
|
|
129
123
|
fetch_pages(s, 3).each_with_index do |r, i|
|
|
124
|
+
next if r.nil?
|
|
130
125
|
return { ret: r } if !year
|
|
131
126
|
r.dates.select { |d| d.type == "published" }.each do |d|
|
|
132
127
|
return { ret: r } if year.to_i == d.on.year
|
|
@@ -139,6 +134,7 @@ module Isobib
|
|
|
139
134
|
|
|
140
135
|
def isobib_get1(code, year, opts)
|
|
141
136
|
return iev if code.casecmp("IEV") == 0
|
|
137
|
+
return iev(code) if /^IEC 60050-/.match code
|
|
142
138
|
result = isobib_search_filter(code) or return nil
|
|
143
139
|
ret = isobib_results_filter(result, year)
|
|
144
140
|
return ret[:ret] if ret[:ret]
|
data/lib/isobib/scrapper.rb
CHANGED
|
@@ -26,7 +26,7 @@ module Isobib
|
|
|
26
26
|
'TS' => 'technicalSpecification',
|
|
27
27
|
'TR' => 'technicalReport',
|
|
28
28
|
'PAS' => 'publiclyAvailableSpecification',
|
|
29
|
-
'AWI' => '
|
|
29
|
+
'AWI' => 'approvedWorkItem',
|
|
30
30
|
'CD' => 'committeeDraft',
|
|
31
31
|
'FDIS' => 'finalDraftInternationalStandard',
|
|
32
32
|
'NP' => 'newProposal',
|
|
@@ -54,11 +54,12 @@ module Isobib
|
|
|
54
54
|
# @return [Hash]
|
|
55
55
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
56
56
|
def parse_page(hit_data)
|
|
57
|
+
return unless hit_data['path'].match(/\d+$/)
|
|
57
58
|
doc, url = get_page "/standard/#{hit_data['path'].match(/\d+$/)}.html"
|
|
58
59
|
|
|
59
60
|
# Fetch edition.
|
|
60
|
-
edition = doc
|
|
61
|
-
|
|
61
|
+
edition = doc&.xpath("//strong[contains(text(), 'Edition')]/..")
|
|
62
|
+
&.children&.last&.text&.match(/\d+/)&.to_s
|
|
62
63
|
|
|
63
64
|
titles, abstract = fetch_titles_abstract(doc)
|
|
64
65
|
|
|
@@ -219,7 +220,7 @@ module Isobib
|
|
|
219
220
|
url: 'www.iso.org',
|
|
220
221
|
technical_committee: {
|
|
221
222
|
name: wg_link.text + doc.css('div.entry-title')[0].text,
|
|
222
|
-
type: '
|
|
223
|
+
type: 'TC',
|
|
223
224
|
number: workgroup[1]&.match(/\d+/)&.to_s&.to_i
|
|
224
225
|
} }
|
|
225
226
|
end
|
data/lib/isobib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: isobib
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.5
|
|
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-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -151,6 +151,7 @@ files:
|
|
|
151
151
|
- CODE_OF_CONDUCT.md
|
|
152
152
|
- Gemfile
|
|
153
153
|
- Gemfile.lock
|
|
154
|
+
- LICENSE.txt
|
|
154
155
|
- README.adoc
|
|
155
156
|
- Rakefile
|
|
156
157
|
- bin/bundle
|
|
@@ -177,7 +178,7 @@ files:
|
|
|
177
178
|
- lib/relaton/processor.rb
|
|
178
179
|
homepage: https://github.com/riboseinc/isobib
|
|
179
180
|
licenses:
|
|
180
|
-
-
|
|
181
|
+
- BSD-2-Clause
|
|
181
182
|
metadata: {}
|
|
182
183
|
post_install_message:
|
|
183
184
|
rdoc_options: []
|