isobib 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +3 -0
- data/.rubocop.yml +9 -3
- data/Gemfile.lock +4 -4
- data/lib/isobib/iso_bibliography.rb +6 -1
- data/lib/isobib/scrapper.rb +16 -11
- data/lib/isobib/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40b9acb94d63fd23c4e5c064a0e10748db58e8515e1e50487172f90800c4ff16
|
4
|
+
data.tar.gz: 33f349728dfebde96f83d833a2d26c3f89f5a78c1ca3124368c6e8022055be36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57145ba1597d569fb305004da9505b2ef91fbf9b4947626326c8c2f05eeceb511228cff6d15017c5eb4cdd3fd43bd4d5347da41ce9eb7301d25ff30155637770
|
7
|
+
data.tar.gz: 301778268405d04c2623f3ad19ec1113a22d61d995844cc812daba7d76b00b0f36ebd0baa056251986545f974443fa7f5f9101d4c17903ade2ea1045ee533589
|
data/.hound.yml
ADDED
data/.rubocop.yml
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
+
# This project follows the Ribose OSS style guide.
|
2
|
+
# https://github.com/riboseinc/oss-guides
|
3
|
+
# All project-specific additions and overrides should be specified in this file.
|
4
|
+
|
5
|
+
inherit_from:
|
6
|
+
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
1
7
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
3
|
-
|
4
|
-
|
8
|
+
TargetRubyVersion: 2.3
|
9
|
+
Rails:
|
10
|
+
Enabled: true
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
isobib (0.4.
|
4
|
+
isobib (0.4.2)
|
5
5
|
algoliasearch
|
6
6
|
iecbib (~> 0.2.1)
|
7
7
|
iso-bib-item (~> 0.4.2)
|
@@ -11,7 +11,7 @@ GEM
|
|
11
11
|
specs:
|
12
12
|
addressable (2.5.2)
|
13
13
|
public_suffix (>= 2.0.2, < 4.0)
|
14
|
-
algoliasearch (1.
|
14
|
+
algoliasearch (1.24.0)
|
15
15
|
httpclient (~> 2.8, >= 2.8.3)
|
16
16
|
json (>= 1.5.1)
|
17
17
|
byebug (10.0.2)
|
@@ -24,7 +24,7 @@ GEM
|
|
24
24
|
iecbib (0.2.1)
|
25
25
|
addressable
|
26
26
|
iso-bib-item (~> 0.4.2)
|
27
|
-
iso-bib-item (0.4.
|
27
|
+
iso-bib-item (0.4.4)
|
28
28
|
isoics (~> 0.1.6)
|
29
29
|
nokogiri (~> 1.8.4)
|
30
30
|
ruby_deep_clone (~> 0.8.0)
|
@@ -76,4 +76,4 @@ DEPENDENCIES
|
|
76
76
|
simplecov
|
77
77
|
|
78
78
|
BUNDLED WITH
|
79
|
-
1.
|
79
|
+
1.17.1
|
data/lib/isobib/scrapper.rb
CHANGED
@@ -40,13 +40,18 @@ module Isobib
|
|
40
40
|
# @param text [String]
|
41
41
|
# @return [Array<Hash>]
|
42
42
|
def get(text)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
begin
|
44
|
+
iso_workers = WorkersPool.new 4
|
45
|
+
iso_workers.worker { |hit| iso_worker(hit, iso_workers) }
|
46
|
+
algolia_workers = start_algolia_search(text, iso_workers)
|
47
|
+
iso_docs = iso_workers.result
|
48
|
+
algolia_workers.end
|
49
|
+
algolia_workers.result
|
50
|
+
iso_docs
|
51
|
+
rescue
|
52
|
+
warn "Could not connect to http://www.iso.org"
|
53
|
+
[]
|
54
|
+
end
|
50
55
|
end
|
51
56
|
|
52
57
|
# Parse page.
|
@@ -59,7 +64,7 @@ module Isobib
|
|
59
64
|
|
60
65
|
# Fetch edition.
|
61
66
|
edition = doc&.xpath("//strong[contains(text(), 'Edition')]/..")
|
62
|
-
|
67
|
+
&.children&.last&.text&.match(/\d+/)&.to_s
|
63
68
|
|
64
69
|
titles, abstract = fetch_titles_abstract(doc)
|
65
70
|
|
@@ -206,7 +211,7 @@ module Isobib
|
|
206
211
|
# @return [Hash]
|
207
212
|
def fetch_status(doc, status)
|
208
213
|
stage, substage = doc.css('li.dropdown.active span.stage-code > strong')
|
209
|
-
|
214
|
+
.text.split '.'
|
210
215
|
{ status: status, stage: stage, substage: substage }
|
211
216
|
end
|
212
217
|
|
@@ -256,7 +261,7 @@ module Isobib
|
|
256
261
|
# @return [String]
|
257
262
|
def fetch_type(title)
|
258
263
|
type_match = title.match(%r{^(ISO|IWA|IEC)(?:(/IEC|/IEEE|/PRF|
|
259
|
-
|
264
|
+
/NP)*\s|/)(TS|TR|PAS|AWI|CD|FDIS|NP|DIS|WD|R|Guide|(?=\d+))}x)
|
260
265
|
#return "international-standard" if type_match.nil?
|
261
266
|
if TYPES[type_match[2]]
|
262
267
|
TYPES[type_match[2]]
|
@@ -275,7 +280,7 @@ module Isobib
|
|
275
280
|
# @return [Hash]
|
276
281
|
def fetch_title(doc, lang)
|
277
282
|
titles = doc.at("//h3[@itemprop='description'] | //h2[@itemprop='description']")
|
278
|
-
|
283
|
+
.text.split ' -- '
|
279
284
|
case titles.size
|
280
285
|
when 0
|
281
286
|
intro, main, part = nil, "", nil
|
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.4.
|
4
|
+
version: 0.4.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: 2018-
|
11
|
+
date: 2018-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -159,6 +159,7 @@ extensions: []
|
|
159
159
|
extra_rdoc_files: []
|
160
160
|
files:
|
161
161
|
- ".gitignore"
|
162
|
+
- ".hound.yml"
|
162
163
|
- ".rspec"
|
163
164
|
- ".rubocop.yml"
|
164
165
|
- ".travis.yml"
|