iecbib 0.1.1
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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +4 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +80 -0
- data/LICENSE.txt +21 -0
- data/README.adoc +40 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/iecbib.gemspec +36 -0
- data/lib/iecbib.rb +10 -0
- data/lib/iecbib/hit.rb +51 -0
- data/lib/iecbib/hit_collection.rb +66 -0
- data/lib/iecbib/iec_bibliography.rb +137 -0
- data/lib/iecbib/scrapper.rb +392 -0
- data/lib/iecbib/statuses.yml +132 -0
- data/lib/iecbib/version.rb +3 -0
- data/lib/iecbib/workers_pool.rb +41 -0
- data/lib/relaton/processor.rb +19 -0
- metadata +193 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 26a37510b59074822007109b47913b77db41dc9caea1c15f6f4392f5ff092d77
|
|
4
|
+
data.tar.gz: f220aca85402102dfebf9c1a2b3904a20c3ba45e6e436d02e25c424281e15788
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 18a68279b7bc1cdf52b55c365fb3bb57f048af3ecc4525205ac160627a8172e2b085ae980940091787582d0c0504eddc1d377c213128bd4281fb0677d47a23bd
|
|
7
|
+
data.tar.gz: 7047b8f2a1d1344528c6ba51c978becc44db6418354960daf7d9155c6076f1c5da9c4e4605cfdc9e3989be8ee4486e2f74cbf742c8b45d075093c8c4df839a3b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
iecbib (0.1.1)
|
|
5
|
+
iso-bib-item (~> 0.3.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
addressable (2.5.2)
|
|
11
|
+
public_suffix (>= 2.0.2, < 4.0)
|
|
12
|
+
byebug (10.0.2)
|
|
13
|
+
coderay (1.1.2)
|
|
14
|
+
crack (0.4.3)
|
|
15
|
+
safe_yaml (~> 1.0.0)
|
|
16
|
+
diff-lcs (1.3)
|
|
17
|
+
docile (1.3.1)
|
|
18
|
+
equivalent-xml (0.6.0)
|
|
19
|
+
nokogiri (>= 1.4.3)
|
|
20
|
+
hashdiff (0.3.7)
|
|
21
|
+
iso-bib-item (0.3.0)
|
|
22
|
+
isoics (~> 0.1.6)
|
|
23
|
+
nokogiri (~> 1.8.4)
|
|
24
|
+
ruby_deep_clone (~> 0.8.0)
|
|
25
|
+
isoics (0.1.7)
|
|
26
|
+
json (2.1.0)
|
|
27
|
+
method_source (0.9.0)
|
|
28
|
+
mini_portile2 (2.3.0)
|
|
29
|
+
nokogiri (1.8.4)
|
|
30
|
+
mini_portile2 (~> 2.3.0)
|
|
31
|
+
pry (0.11.3)
|
|
32
|
+
coderay (~> 1.1.0)
|
|
33
|
+
method_source (~> 0.9.0)
|
|
34
|
+
pry-byebug (3.6.0)
|
|
35
|
+
byebug (~> 10.0)
|
|
36
|
+
pry (~> 0.10)
|
|
37
|
+
public_suffix (3.0.3)
|
|
38
|
+
rake (10.5.0)
|
|
39
|
+
rspec (3.8.0)
|
|
40
|
+
rspec-core (~> 3.8.0)
|
|
41
|
+
rspec-expectations (~> 3.8.0)
|
|
42
|
+
rspec-mocks (~> 3.8.0)
|
|
43
|
+
rspec-core (3.8.0)
|
|
44
|
+
rspec-support (~> 3.8.0)
|
|
45
|
+
rspec-expectations (3.8.1)
|
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
47
|
+
rspec-support (~> 3.8.0)
|
|
48
|
+
rspec-mocks (3.8.0)
|
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
50
|
+
rspec-support (~> 3.8.0)
|
|
51
|
+
rspec-support (3.8.0)
|
|
52
|
+
ruby_deep_clone (0.8.0)
|
|
53
|
+
safe_yaml (1.0.4)
|
|
54
|
+
simplecov (0.16.1)
|
|
55
|
+
docile (~> 1.1)
|
|
56
|
+
json (>= 1.8, < 3)
|
|
57
|
+
simplecov-html (~> 0.10.0)
|
|
58
|
+
simplecov-html (0.10.2)
|
|
59
|
+
vcr (4.0.0)
|
|
60
|
+
webmock (3.4.2)
|
|
61
|
+
addressable (>= 2.3.6)
|
|
62
|
+
crack (>= 0.3.2)
|
|
63
|
+
hashdiff
|
|
64
|
+
|
|
65
|
+
PLATFORMS
|
|
66
|
+
ruby
|
|
67
|
+
|
|
68
|
+
DEPENDENCIES
|
|
69
|
+
bundler (~> 1.16)
|
|
70
|
+
equivalent-xml (~> 0.6)
|
|
71
|
+
iecbib!
|
|
72
|
+
pry-byebug
|
|
73
|
+
rake (~> 10.0)
|
|
74
|
+
rspec (~> 3.0)
|
|
75
|
+
simplecov
|
|
76
|
+
vcr
|
|
77
|
+
webmock
|
|
78
|
+
|
|
79
|
+
BUNDLED WITH
|
|
80
|
+
1.16.2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Andrei Kislichenko
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
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:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.adoc
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
= Iecbib
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/iecbib`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
== Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
[source,ruby]
|
|
12
|
+
----
|
|
13
|
+
gem 'iecbib'
|
|
14
|
+
----
|
|
15
|
+
|
|
16
|
+
And then execute:
|
|
17
|
+
|
|
18
|
+
$ bundle
|
|
19
|
+
|
|
20
|
+
Or install it yourself as:
|
|
21
|
+
|
|
22
|
+
$ gem install iecbib
|
|
23
|
+
|
|
24
|
+
== Usage
|
|
25
|
+
|
|
26
|
+
TODO: Write usage instructions here
|
|
27
|
+
|
|
28
|
+
== Development
|
|
29
|
+
|
|
30
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
31
|
+
|
|
32
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
33
|
+
|
|
34
|
+
== Contributing
|
|
35
|
+
|
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/iecbib.
|
|
37
|
+
|
|
38
|
+
== License
|
|
39
|
+
|
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "iecbib"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/iecbib.gemspec
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "iecbib/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "iecbib"
|
|
8
|
+
spec.version = Iecbib::VERSION
|
|
9
|
+
spec.authors = ["Ribose Inc."]
|
|
10
|
+
spec.email = ["open.source@ribose.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = "IsoBib: retrieve ISO Standards for bibliographic use "\
|
|
13
|
+
"using the BibliographicItem model"
|
|
14
|
+
spec.description = "IsoBib: retrieve ISO Standards for bibliographic use "\
|
|
15
|
+
"using the BibliographicItem model"
|
|
16
|
+
spec.homepage = "https://github.com/riboseinc/isobib"
|
|
17
|
+
spec.license = "MIT"
|
|
18
|
+
|
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
|
21
|
+
end
|
|
22
|
+
spec.bindir = "exe"
|
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
|
+
spec.require_paths = ["lib"]
|
|
25
|
+
|
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
|
27
|
+
spec.add_development_dependency 'equivalent-xml', '~> 0.6'
|
|
28
|
+
spec.add_development_dependency 'pry-byebug'
|
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
31
|
+
spec.add_development_dependency 'simplecov'
|
|
32
|
+
spec.add_development_dependency 'vcr'
|
|
33
|
+
spec.add_development_dependency 'webmock'
|
|
34
|
+
|
|
35
|
+
spec.add_dependency 'iso-bib-item', '~> 0.3.0'
|
|
36
|
+
end
|
data/lib/iecbib.rb
ADDED
data/lib/iecbib/hit.rb
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Iecbib
|
|
4
|
+
# Hit.
|
|
5
|
+
class Hit
|
|
6
|
+
# @return [Isobib::HitCollection]
|
|
7
|
+
attr_reader :hit_collection
|
|
8
|
+
|
|
9
|
+
# @return [Array<Hash>]
|
|
10
|
+
attr_reader :hit
|
|
11
|
+
|
|
12
|
+
# @param hit [Hash]
|
|
13
|
+
# @param hit_collection [Isobib:HitCollection]
|
|
14
|
+
def initialize(hit, hit_collection = nil)
|
|
15
|
+
@hit = hit
|
|
16
|
+
@hit_collection = hit_collection
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Parse page.
|
|
20
|
+
# @return [Isobib::IsoBibliographicItem]
|
|
21
|
+
def fetch
|
|
22
|
+
@fetch ||= Scrapper.parse_page @hit
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @return [String]
|
|
26
|
+
def to_s
|
|
27
|
+
inspect
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @return [String]
|
|
31
|
+
def inspect
|
|
32
|
+
"<#{self.class}:#{format('%#.14x', object_id << 1)} "\
|
|
33
|
+
"@text=\"#{@hit_collection&.text}\" "\
|
|
34
|
+
"@fetched=\"#{!@fetch.nil?}\" "\
|
|
35
|
+
"@fullIdentifier=\"#{@fetch&.shortref(nil)}\" "\
|
|
36
|
+
"@title=\"#{@hit[:code]}\">"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# @return [String]
|
|
40
|
+
def to_xml(opts = {})
|
|
41
|
+
#if builder
|
|
42
|
+
#fetch.to_xml builder, opts
|
|
43
|
+
#else
|
|
44
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
|
45
|
+
fetch.to_xml xml, opts
|
|
46
|
+
end
|
|
47
|
+
builder.doc.root.to_xml
|
|
48
|
+
#end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'iecbib/hit'
|
|
4
|
+
|
|
5
|
+
module Iecbib
|
|
6
|
+
# Page of hit collection.
|
|
7
|
+
class HitCollection < Array
|
|
8
|
+
|
|
9
|
+
DOMAIN = 'https://webstore.iec.ch'
|
|
10
|
+
|
|
11
|
+
# @return [TrueClass, FalseClass]
|
|
12
|
+
attr_reader :fetched
|
|
13
|
+
|
|
14
|
+
# @return [String]
|
|
15
|
+
attr_reader :text
|
|
16
|
+
|
|
17
|
+
# @return [String]
|
|
18
|
+
attr_reader :year
|
|
19
|
+
|
|
20
|
+
# @param ref_nbr [String]
|
|
21
|
+
# @param year [String]
|
|
22
|
+
def initialize(ref_nbr, year = nil) #(text, hit_pages = nil)
|
|
23
|
+
@text = ref_nbr
|
|
24
|
+
@year = year
|
|
25
|
+
from, to = nil
|
|
26
|
+
if year
|
|
27
|
+
from = Date.strptime year, '%Y'
|
|
28
|
+
to = from.next_year.prev_day
|
|
29
|
+
end
|
|
30
|
+
url = "#{DOMAIN}/searchkey&RefNbr=#{ref_nbr}&From=#{from}&To=#{to}&start=1"
|
|
31
|
+
doc = Nokogiri::HTML OpenURI.open_uri(Addressable::URI.parse(url).normalize)
|
|
32
|
+
hits = doc.css('ul.search-results > li').map do |h|
|
|
33
|
+
link = h.at('a[@href!="#"]')
|
|
34
|
+
code = link.text.tr [194, 160].pack('c*').force_encoding('UTF-8'), ''
|
|
35
|
+
title = h.xpath('text()').text.gsub(/[\r\n]/, '')
|
|
36
|
+
url = DOMAIN + link[:href]
|
|
37
|
+
Hit.new({ code: code, title: title, url: url }, self)
|
|
38
|
+
end
|
|
39
|
+
concat hits
|
|
40
|
+
# concat(hits.map { |h| Hit.new(h, self) })
|
|
41
|
+
@fetched = false
|
|
42
|
+
# @hit_pages = hit_pages
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# @return [Iecbib::HitCollection]
|
|
46
|
+
def fetch
|
|
47
|
+
workers = WorkersPool.new 4
|
|
48
|
+
workers.worker(&:fetch)
|
|
49
|
+
each do |hit|
|
|
50
|
+
workers << hit
|
|
51
|
+
end
|
|
52
|
+
workers.end
|
|
53
|
+
workers.result
|
|
54
|
+
@fetched = true
|
|
55
|
+
self
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def to_s
|
|
59
|
+
inspect
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def inspect
|
|
63
|
+
"<#{self.class}:#{format('%#.14x', object_id << 1)} @fetched=#{@fetched}>"
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# require 'isobib/iso_bibliographic_item'
|
|
4
|
+
require 'iecbib/scrapper'
|
|
5
|
+
require 'iecbib/hit_collection'
|
|
6
|
+
|
|
7
|
+
module Iecbib
|
|
8
|
+
# Class methods for search ISO standards.
|
|
9
|
+
class IecBibliography
|
|
10
|
+
class << self
|
|
11
|
+
# @param text [String]
|
|
12
|
+
# @return [Iecbib::HitCollection]
|
|
13
|
+
def search(text, year = nil)
|
|
14
|
+
HitCollection.new text, year
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# @param text [String]
|
|
18
|
+
# @return [Array<IsoBibliographicItem>]
|
|
19
|
+
def search_and_fetch(text, year = nil)
|
|
20
|
+
Scrapper.get(text, year)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# @param code [String] the ISO standard Code to look up (e..g "ISO 9000")
|
|
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
|
|
26
|
+
# @return [String] Relaton XML serialisation of reference
|
|
27
|
+
def get(code, year, opts)
|
|
28
|
+
return iev if code.casecmp('IEV') == 0
|
|
29
|
+
code += '-1' if opts[:all_parts]
|
|
30
|
+
ret = iecbib_get1(code, year, opts)
|
|
31
|
+
return nil if ret.nil?
|
|
32
|
+
ret.to_most_recent_reference unless year
|
|
33
|
+
ret.to_all_parts if opts[:all_parts]
|
|
34
|
+
ret # .to_xml
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def fetch_ref_err(code, year, missed_years)
|
|
40
|
+
id = year ? "#{code}:#{year}" : code
|
|
41
|
+
warn "WARNING: no match found online for #{id}. "\
|
|
42
|
+
"The code must be exactly like it is on the standards website."
|
|
43
|
+
warn "(There was no match for #{year}, though there were matches "\
|
|
44
|
+
"found for #{missed_years.join(', ')}.)" unless missed_years.empty?
|
|
45
|
+
if /\d-\d/ =~ code
|
|
46
|
+
warn "The provided document part may not exist, or the document "\
|
|
47
|
+
"may no longer be published in parts."
|
|
48
|
+
else
|
|
49
|
+
warn "If you wanted to cite all document parts for the reference, "\
|
|
50
|
+
"use \"#{code} (all parts)\".\nIf the document is not a standard, "\
|
|
51
|
+
"use its document type abbreviation (TS, TR, PAS, Guide)."
|
|
52
|
+
end
|
|
53
|
+
nil
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def fetch_pages(s, n)
|
|
57
|
+
workers = WorkersPool.new n
|
|
58
|
+
workers.worker { |w| { i: w[:i], hit: w[:hit].fetch } }
|
|
59
|
+
s.each_with_index { |hit, i| workers << { i: i, hit: hit } }
|
|
60
|
+
workers.end
|
|
61
|
+
workers.result.sort { |x, y| x[:i] <=> y[:i] }.map { |x| x[:hit] }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def isobib_search_filter(code)
|
|
65
|
+
docidrx = %r{^(ISO|IEC)[^0-9]*\s[0-9-]+}
|
|
66
|
+
corrigrx = %r{^(ISO|IEC)[^0-9]*\s[0-9-]+:[0-9]+/}
|
|
67
|
+
warn "fetching #{code}..."
|
|
68
|
+
result = search(code)
|
|
69
|
+
result.select do |i|
|
|
70
|
+
i.hit[:code] &&
|
|
71
|
+
i.hit[:code].match(docidrx).to_s == code &&
|
|
72
|
+
corrigrx !~ i.hit[:code]
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def iev(code = "IEC 60050")
|
|
77
|
+
IsoBibItem.from_xml(<<~"END")
|
|
78
|
+
<bibitem type="international-standard" id="IEV">
|
|
79
|
+
<title format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary</title>
|
|
80
|
+
<link type="src">http://www.electropedia.org</link>
|
|
81
|
+
<docidentifier>#{code}:2011</docidentifier>
|
|
82
|
+
<date type="published"><on>2011</on></date>
|
|
83
|
+
<contributor>
|
|
84
|
+
<role type="publisher"/>
|
|
85
|
+
<organization>
|
|
86
|
+
<name>International Electrotechnical Commission</name>
|
|
87
|
+
<abbreviation>IEC</abbreviation>
|
|
88
|
+
<uri>www.iec.ch</uri>
|
|
89
|
+
</organization>
|
|
90
|
+
</contributor>
|
|
91
|
+
<language>en</language> <language>fr</language>
|
|
92
|
+
<script>Latn</script>
|
|
93
|
+
<status> <stage>60</stage> </status>
|
|
94
|
+
<copyright>
|
|
95
|
+
<from>2018</from>
|
|
96
|
+
<owner>
|
|
97
|
+
<organization>
|
|
98
|
+
<name>International Electrotechnical Commission</name>
|
|
99
|
+
<abbreviation>IEC</abbreviation>
|
|
100
|
+
<uri>www.iec.ch</uri>
|
|
101
|
+
</organization>
|
|
102
|
+
</owner>
|
|
103
|
+
</copyright>
|
|
104
|
+
</bibitem>
|
|
105
|
+
END
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Sort through the results from Isobib, fetching them three at a time,
|
|
109
|
+
# and return the first result that matches the code,
|
|
110
|
+
# matches the year (if provided), and which # has a title (amendments do not).
|
|
111
|
+
# Only expects the first page of results to be populated.
|
|
112
|
+
# Does not match corrigenda etc (e.g. ISO 3166-1:2006/Cor 1:2007)
|
|
113
|
+
# If no match, returns any years which caused mismatch, for error reporting
|
|
114
|
+
def isobib_results_filter(result, year)
|
|
115
|
+
missed_years = []
|
|
116
|
+
result.each_slice(3) do |s| # ISO website only allows 3 connections
|
|
117
|
+
fetch_pages(s, 3).each_with_index do |r, i|
|
|
118
|
+
return { ret: r } if !year
|
|
119
|
+
r.dates.select { |d| d.type == "published" }.each do |d|
|
|
120
|
+
return { ret: r } if year.to_i == d.on.year
|
|
121
|
+
missed_years << d.on.year
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
{ years: missed_years }
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def iecbib_get1(code, year, opts)
|
|
129
|
+
return iev if code.casecmp("IEV") == 0
|
|
130
|
+
result = isobib_search_filter(code) or return nil
|
|
131
|
+
ret = isobib_results_filter(result, year)
|
|
132
|
+
return ret[:ret] if ret[:ret]
|
|
133
|
+
fetch_ref_err(code, year, ret[:years])
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'iso_bib_item'
|
|
4
|
+
require 'iecbib/hit'
|
|
5
|
+
require 'nokogiri'
|
|
6
|
+
require 'net/http'
|
|
7
|
+
require 'iecbib/workers_pool'
|
|
8
|
+
|
|
9
|
+
# Capybara.request_driver :poltergeist do |app|
|
|
10
|
+
# Capybara::Poltergeist::Driver.new app, js_errors: false
|
|
11
|
+
# end
|
|
12
|
+
# Capybara.default_driver = :poltergeist
|
|
13
|
+
|
|
14
|
+
module Iecbib
|
|
15
|
+
# Scrapper.
|
|
16
|
+
# rubocop:disable Metrics/ModuleLength
|
|
17
|
+
module Scrapper
|
|
18
|
+
DOMAIN = 'https://webstore.iec.ch'
|
|
19
|
+
|
|
20
|
+
TYPES = {
|
|
21
|
+
'ISO' => 'international-standard',
|
|
22
|
+
'TS' => 'technicalSpecification',
|
|
23
|
+
'TR' => 'technicalReport',
|
|
24
|
+
'PAS' => 'publiclyAvailableSpecification',
|
|
25
|
+
'AWI' => 'appruvedWorkItem',
|
|
26
|
+
'CD' => 'committeeDraft',
|
|
27
|
+
'FDIS' => 'finalDraftInternationalStandard',
|
|
28
|
+
'NP' => 'newProposal',
|
|
29
|
+
'DIS' => 'draftInternationalStandard',
|
|
30
|
+
'WD' => 'workingDraft',
|
|
31
|
+
'R' => 'recommendation',
|
|
32
|
+
'Guide' => 'guide'
|
|
33
|
+
}.freeze
|
|
34
|
+
|
|
35
|
+
class << self
|
|
36
|
+
# @param text [String]
|
|
37
|
+
# @return [Array<Hash>]
|
|
38
|
+
# def get(text)
|
|
39
|
+
# iso_workers = WorkersPool.new 4
|
|
40
|
+
# iso_workers.worker { |hit| iso_worker(hit, iso_workers) }
|
|
41
|
+
# algolia_workers = start_algolia_search(text, iso_workers)
|
|
42
|
+
# iso_docs = iso_workers.result
|
|
43
|
+
# algolia_workers.end
|
|
44
|
+
# algolia_workers.result
|
|
45
|
+
# iso_docs
|
|
46
|
+
# end
|
|
47
|
+
|
|
48
|
+
# Parse page.
|
|
49
|
+
# @param hit [Hash]
|
|
50
|
+
# @return [Hash]
|
|
51
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
52
|
+
def parse_page(hit_data)
|
|
53
|
+
doc = get_page hit_data[:url]
|
|
54
|
+
|
|
55
|
+
# Fetch edition.
|
|
56
|
+
edition = doc.at("//th[contains(., 'Edition')]/following-sibling::td/span").text
|
|
57
|
+
|
|
58
|
+
status, relations = fetch_status_relations hit_data[:url]
|
|
59
|
+
|
|
60
|
+
IsoBibItem::IsoBibliographicItem.new(
|
|
61
|
+
docid: fetch_docid(doc),
|
|
62
|
+
edition: edition,
|
|
63
|
+
language: ['en'],
|
|
64
|
+
script: ['Latn'],
|
|
65
|
+
titles: fetch_titles(hit_data),
|
|
66
|
+
type: fetch_type(doc),
|
|
67
|
+
docstatus: status,
|
|
68
|
+
ics: fetch_ics(doc),
|
|
69
|
+
dates: fetch_dates(doc),
|
|
70
|
+
contributors: fetch_contributors(hit_data[:code]),
|
|
71
|
+
workgroup: fetch_workgroup(doc),
|
|
72
|
+
abstract: fetch_abstract(doc),
|
|
73
|
+
copyright: fetch_copyright(hit_data[:code], doc),
|
|
74
|
+
link: fetch_link(doc, hit_data[:url]),
|
|
75
|
+
relations: relations
|
|
76
|
+
)
|
|
77
|
+
end
|
|
78
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
|
79
|
+
|
|
80
|
+
private
|
|
81
|
+
|
|
82
|
+
# Start search workers.
|
|
83
|
+
# @param text[String]
|
|
84
|
+
# @param iec_workers [Isobib::WorkersPool]
|
|
85
|
+
# @reaturn [Isobib::WorkersPool]
|
|
86
|
+
# def start_algolia_search(text, iec_workers)
|
|
87
|
+
# index = Algolia::Index.new 'all_en'
|
|
88
|
+
# workers = WorkersPool.new
|
|
89
|
+
# workers.worker do |page|
|
|
90
|
+
# algolia_worker(index, text, page, workers, iec_workers)
|
|
91
|
+
# end
|
|
92
|
+
|
|
93
|
+
# # Add first page so search worker will start.
|
|
94
|
+
# workers << 0
|
|
95
|
+
# end
|
|
96
|
+
|
|
97
|
+
# Fetch ISO documents.
|
|
98
|
+
# @param hit [Hash]
|
|
99
|
+
# @param isiso_workers [Isobib::WorkersPool]
|
|
100
|
+
# def iso_worker(hit, iso_workers)
|
|
101
|
+
# print "Parse #{iso_workers.size} of #{iso_workers.nb_hits} \r"
|
|
102
|
+
# parse_page hit
|
|
103
|
+
# end
|
|
104
|
+
|
|
105
|
+
# Fetch hits from algolia search service.
|
|
106
|
+
# @param index[Algolia::Index]
|
|
107
|
+
# @param text [String]
|
|
108
|
+
# @param page [Integer]
|
|
109
|
+
# @param algolia_workers [Isobib::WorkersPool]
|
|
110
|
+
# @param isiso_workers [Isobib::WorkersPool]
|
|
111
|
+
# def algolia_worker(index, text, page, algolia_workers, iso_workers)
|
|
112
|
+
# res = index.search text, facetFilters: ['category:standard'], page: page
|
|
113
|
+
# next_page = res['page'] + 1
|
|
114
|
+
# algolia_workers << next_page if next_page < res['nbPages']
|
|
115
|
+
# res['hits'].each do |hit|
|
|
116
|
+
# iso_workers.nb_hits = res['nbHits']
|
|
117
|
+
# iso_workers << hit
|
|
118
|
+
# end
|
|
119
|
+
# iso_workers.end unless next_page < res['nbPages']
|
|
120
|
+
# end
|
|
121
|
+
|
|
122
|
+
# Fetch abstracts.
|
|
123
|
+
# @param doc [Nokigiri::HTML::Document]
|
|
124
|
+
# @return [Array<Array>]
|
|
125
|
+
def fetch_abstract(doc)
|
|
126
|
+
abstract_content = doc.at('//div[@itemprop="description"]').text
|
|
127
|
+
[{
|
|
128
|
+
content: abstract_content,
|
|
129
|
+
language: 'en',
|
|
130
|
+
script: 'Latn'
|
|
131
|
+
}]
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Get langs.
|
|
135
|
+
# @param doc [Nokogiri::HTML::Document]
|
|
136
|
+
# @return [Array<Hash>]
|
|
137
|
+
# def langs(doc)
|
|
138
|
+
# lgs = [{ lang: 'en' }]
|
|
139
|
+
# doc.css('ul#lang-switcher ul li a').each do |lang_link|
|
|
140
|
+
# lang_path = lang_link.attr('href')
|
|
141
|
+
# lang = lang_path.match(%r{^\/(fr)\/})
|
|
142
|
+
# lgs << { lang: lang[1], path: lang_path } if lang
|
|
143
|
+
# end
|
|
144
|
+
# lgs
|
|
145
|
+
# end
|
|
146
|
+
|
|
147
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
148
|
+
# Get page.
|
|
149
|
+
# @param path [String] page's path
|
|
150
|
+
# @return [Array<Nokogiri::HTML::Document, String>]
|
|
151
|
+
def get_page(url)
|
|
152
|
+
uri = URI url
|
|
153
|
+
resp = Net::HTTP.get_response(uri)#.encode("UTF-8")
|
|
154
|
+
if resp.code == '301'
|
|
155
|
+
path = resp['location']
|
|
156
|
+
url = DOMAIN + path
|
|
157
|
+
uri = URI url
|
|
158
|
+
resp = Net::HTTP.get_response(uri)#.encode("UTF-8")
|
|
159
|
+
end
|
|
160
|
+
# n = 0
|
|
161
|
+
# while resp.body !~ /<strong/ && n < 10
|
|
162
|
+
# resp = Net::HTTP.get_response(uri)#.encode("UTF-8")
|
|
163
|
+
# n += 1
|
|
164
|
+
# end
|
|
165
|
+
Nokogiri::HTML(resp.body)
|
|
166
|
+
end
|
|
167
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
|
168
|
+
|
|
169
|
+
# Fetch docid.
|
|
170
|
+
# @param doc [Nokogiri::HTML::Document]
|
|
171
|
+
# @return [Hash]
|
|
172
|
+
def fetch_docid(doc)
|
|
173
|
+
item_ref = doc.at("//span[@itemprop='productID']")
|
|
174
|
+
unless item_ref
|
|
175
|
+
return { project_number: '?', part_number: '', prefix: nil, id: '?' }
|
|
176
|
+
end
|
|
177
|
+
m = item_ref.text.match(/(?<=\s)(?<project>\d+)-?(?<part>(?<=-)\d+|)-?(?<subpart>(?<=-)\d+|)/)
|
|
178
|
+
{
|
|
179
|
+
project_number: m[:project],
|
|
180
|
+
part_number: m[:part],
|
|
181
|
+
subpart_number: m[:subpart],
|
|
182
|
+
prefix: nil,
|
|
183
|
+
type: 'IEC',
|
|
184
|
+
id: item_ref.text
|
|
185
|
+
}
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Fetch status.
|
|
189
|
+
# @param doc [Nokogiri::HTML::Document]
|
|
190
|
+
# @param status [String]
|
|
191
|
+
# @return [Hash]
|
|
192
|
+
def fetch_status(doc)
|
|
193
|
+
wip = doc.at('//ROW[STATUS[.="PREPARING"]]')
|
|
194
|
+
if wip
|
|
195
|
+
statuses = YAML.load_file 'lib/iecbib/statuses.yml'
|
|
196
|
+
s = wip.at('STAGE').text
|
|
197
|
+
stage, substage = statuses[s]['stage'].split '.'
|
|
198
|
+
status = statuses[s]['status']
|
|
199
|
+
else
|
|
200
|
+
status = 'Published'
|
|
201
|
+
stage = '60'
|
|
202
|
+
substage = '60'
|
|
203
|
+
end
|
|
204
|
+
{ status: status, stage: stage, substage: substage }
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# Fetch workgroup.
|
|
208
|
+
# @param doc [Nokogiri::HTML::Document]
|
|
209
|
+
# @return [Hash]
|
|
210
|
+
def fetch_workgroup(doc)
|
|
211
|
+
wg = doc.at('//th/abbr[.="TC"]/../following-sibling::td/a').text
|
|
212
|
+
{ name: 'International Electrotechnical Commission',
|
|
213
|
+
abbreviation: 'IEC',
|
|
214
|
+
url: 'webstore.iec.ch',
|
|
215
|
+
technical_committee: {
|
|
216
|
+
name: wg,
|
|
217
|
+
type: 'technicalCommittee',
|
|
218
|
+
number: wg.match(/\d+/)&.to_s&.to_i
|
|
219
|
+
} }
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# Fetch relations.
|
|
223
|
+
# @param doc [Nokogiri::HTML::Document]
|
|
224
|
+
# @return [Array<Hash>]
|
|
225
|
+
# rubocop:disable Metrics/MethodLength
|
|
226
|
+
def fetch_relations(doc)
|
|
227
|
+
doc.xpath('//ROW[STATUS[.!="PREPARING"]][STATUS[.!="PUBLISHED"]]').map do |r|
|
|
228
|
+
r_type = r.at('STATUS').text.downcase
|
|
229
|
+
type = case r_type
|
|
230
|
+
# when 'published' then 'obsoletes' # Valid
|
|
231
|
+
when 'revised', 'replaced' then 'updates'
|
|
232
|
+
when 'withdrawn' then 'obsoletes'
|
|
233
|
+
else r_type
|
|
234
|
+
end
|
|
235
|
+
url = DOMAIN + '/publication/' + r.at('PUB_ID').text
|
|
236
|
+
{ type: type, identifier: r.at('FULL_NAME').text, url: url }
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def fetch_status_relations(url)
|
|
241
|
+
pubid = url.match(/\d+$/).to_s
|
|
242
|
+
uri = URI DOMAIN + '/webstore/webstore.nsf/AjaxRequestXML?'\
|
|
243
|
+
'Openagent&url=http://www.iec.ch/dyn/www/f?'\
|
|
244
|
+
'p=103:390:::::P390_PUBLICATION_ID:' + pubid
|
|
245
|
+
resp = Net::HTTP.get_response uri
|
|
246
|
+
doc = Nokogiri::XML resp.body
|
|
247
|
+
status = fetch_status doc
|
|
248
|
+
relations = fetch_relations doc
|
|
249
|
+
[status, relations]
|
|
250
|
+
# doc.css('ul.steps li').inject([]) do |a, r|
|
|
251
|
+
# r_type = r.css('strong').text
|
|
252
|
+
# type = case r_type
|
|
253
|
+
# when 'Previously', 'Will be replaced by' then 'obsoletes'
|
|
254
|
+
# when 'Corrigenda/Amendments', 'Revised by', 'Now confirmed'
|
|
255
|
+
# 'updates'
|
|
256
|
+
# else r_type
|
|
257
|
+
# end
|
|
258
|
+
# if ['Now', 'Now under review'].include? type
|
|
259
|
+
# a
|
|
260
|
+
# else
|
|
261
|
+
# a + r.css('a').map do |id|
|
|
262
|
+
# { type: type, identifier: id.text, url: id['href'] }
|
|
263
|
+
# end
|
|
264
|
+
# end
|
|
265
|
+
# end
|
|
266
|
+
end
|
|
267
|
+
# rubocop:enable Metrics/MethodLength
|
|
268
|
+
|
|
269
|
+
# Fetch type.
|
|
270
|
+
# @param doc [Nokogiri::HTML::Document]
|
|
271
|
+
# @return [String]
|
|
272
|
+
def fetch_type(doc)
|
|
273
|
+
doc.at('//th[contains(., "Publication type")]/following-sibling::td/span')
|
|
274
|
+
.text.downcase.tr ' ', '-'
|
|
275
|
+
# type_match = title.match(%r{^(ISO|IWA|IEC)(?:(/IEC|/IEEE|/PRF|
|
|
276
|
+
# /NP)*\s|/)(TS|TR|PAS|AWI|CD|FDIS|NP|DIS|WD|R|Guide|(?=\d+))}x)
|
|
277
|
+
# #return "international-standard" if type_match.nil?
|
|
278
|
+
# if TYPES[type_match[2]]
|
|
279
|
+
# TYPES[type_match[2]]
|
|
280
|
+
# elsif type_match[1]
|
|
281
|
+
# elsif type_match[1] == 'ISO'
|
|
282
|
+
# 'international-standard'
|
|
283
|
+
# elsif type_match[1] == 'IWA'
|
|
284
|
+
# 'international-workshop-agreement'
|
|
285
|
+
# end
|
|
286
|
+
# # rescue => _e
|
|
287
|
+
# # puts 'Unknown document type: ' + title
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
# Fetch titles.
|
|
291
|
+
# @param hit_data [Hash]
|
|
292
|
+
# @return [Array<Hash>]
|
|
293
|
+
def fetch_titles(hit_data)
|
|
294
|
+
titles = hit_data[:title].split ' - '
|
|
295
|
+
case titles.size
|
|
296
|
+
when 0
|
|
297
|
+
intro, main, part = nil, "", nil
|
|
298
|
+
when 1
|
|
299
|
+
intro, main, part = nil, titles[0], nil
|
|
300
|
+
when 2
|
|
301
|
+
if /^(Part|Partie) \d+:/ =~ titles[1]
|
|
302
|
+
intro, main, part = nil, titles[0], titles[1]
|
|
303
|
+
else
|
|
304
|
+
intro, main, part = titles[0], titles[1], nil
|
|
305
|
+
end
|
|
306
|
+
when 3
|
|
307
|
+
intro, main, part = titles[0], titles[1], titles[2]
|
|
308
|
+
else
|
|
309
|
+
intro, main, part = titles[0], titles[1], titles[2..-1]&.join(" -- ")
|
|
310
|
+
end
|
|
311
|
+
[{
|
|
312
|
+
title_intro: intro,
|
|
313
|
+
title_main: main,
|
|
314
|
+
title_part: part,
|
|
315
|
+
language: 'en',
|
|
316
|
+
script: 'Latn'
|
|
317
|
+
}]
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
# Return ISO script code.
|
|
321
|
+
# @param lang [String]
|
|
322
|
+
# @return [String]
|
|
323
|
+
# def script(lang)
|
|
324
|
+
# case lang
|
|
325
|
+
# when 'en', 'fr' then 'Latn'
|
|
326
|
+
# end
|
|
327
|
+
# end
|
|
328
|
+
|
|
329
|
+
# Fetch dates
|
|
330
|
+
# @param doc [Nokogiri::HTML::Document]
|
|
331
|
+
# @return [Array<Hash>]
|
|
332
|
+
def fetch_dates(doc)
|
|
333
|
+
dates = []
|
|
334
|
+
publish_date = doc.at("//span[@itemprop='releaseDate']").text
|
|
335
|
+
unless publish_date.empty?
|
|
336
|
+
dates << { type: 'published', on: publish_date }
|
|
337
|
+
end
|
|
338
|
+
dates
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
def fetch_contributors(code)
|
|
342
|
+
code.sub(/\s.*/, '').split('/').map do |abbrev|
|
|
343
|
+
case abbrev
|
|
344
|
+
when 'ISO'
|
|
345
|
+
name = 'International Organization for Standardization'
|
|
346
|
+
url = 'www.iso.org'
|
|
347
|
+
when 'IEC'
|
|
348
|
+
name = 'International Electrotechnical Commission'
|
|
349
|
+
url = 'www.iec.ch'
|
|
350
|
+
end
|
|
351
|
+
{ entity: { name: name, url: url, abbreviation: abbrev },
|
|
352
|
+
roles: ['publisher'] }
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
# Fetch ICS.
|
|
357
|
+
# @param doc [Nokogiri::HTML::Document]
|
|
358
|
+
# @return [Array<Hash>]
|
|
359
|
+
def fetch_ics(doc)
|
|
360
|
+
doc.xpath('//th[contains(text(), "ICS")]/following-sibling::td/a').map do |i|
|
|
361
|
+
code = i.text.match(/[\d\.]+/).to_s.split '.'
|
|
362
|
+
{ field: code[0], group: code[1], subgroup: code[2] }
|
|
363
|
+
end
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
# Fetch links.
|
|
367
|
+
# @param doc [Nokogiri::HTML::Document]
|
|
368
|
+
# @param url [String]
|
|
369
|
+
# @return [Array<Hash>]
|
|
370
|
+
def fetch_link(doc, url)
|
|
371
|
+
links = [{ type: 'src', content: url }]
|
|
372
|
+
obp_elms = doc.at_css('p.btn-preview a')
|
|
373
|
+
links << { type: 'obp', content: obp_elms[:href] } if obp_elms
|
|
374
|
+
links
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
# Fetch copyright.
|
|
378
|
+
# @param title [String]
|
|
379
|
+
# @return [Hash]
|
|
380
|
+
def fetch_copyright(code, doc)
|
|
381
|
+
owner_name = code.match(/.*?(?=\s)/).to_s
|
|
382
|
+
from = code.match(/(?<=:)\d{4}/).to_s
|
|
383
|
+
if from.empty?
|
|
384
|
+
from = doc.xpath("//span[@itemprop='releaseDate']").text
|
|
385
|
+
.match(/\d{4}/).to_s
|
|
386
|
+
end
|
|
387
|
+
{ owner: { name: owner_name }, from: from }
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
end
|
|
391
|
+
# rubocop:enable Metrics/ModuleLength
|
|
392
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
ACD:
|
|
2
|
+
status: Approved for CD
|
|
3
|
+
stage: '20.99'
|
|
4
|
+
ACDV:
|
|
5
|
+
status: Approved for CDV
|
|
6
|
+
stage: '30.99'
|
|
7
|
+
ADTR:
|
|
8
|
+
status: Approved for DTR
|
|
9
|
+
stage: '40.99'
|
|
10
|
+
ADTS:
|
|
11
|
+
status: Approved for DTS
|
|
12
|
+
stage: '40.99'
|
|
13
|
+
AFDIS:
|
|
14
|
+
status: Approved for FDIS
|
|
15
|
+
stage: '40.99'
|
|
16
|
+
APUB:
|
|
17
|
+
status: Approved for publication
|
|
18
|
+
stage: '50.99'
|
|
19
|
+
BPUB:
|
|
20
|
+
status: Being published
|
|
21
|
+
stage: '60.00'
|
|
22
|
+
CAN:
|
|
23
|
+
status: Draft cancelled
|
|
24
|
+
stage: '20.98'
|
|
25
|
+
CD:
|
|
26
|
+
status: Draft circulated as CD
|
|
27
|
+
stage: '30.00'
|
|
28
|
+
CDM:
|
|
29
|
+
status: CD to be discussed at meeting
|
|
30
|
+
stage: '30.20'
|
|
31
|
+
CCDV:
|
|
32
|
+
status: Draft circulated as CDV
|
|
33
|
+
stage: '40.00'
|
|
34
|
+
CDVM:
|
|
35
|
+
status: Rejected CDV to be discussed at a meeting
|
|
36
|
+
stage: '40.93'
|
|
37
|
+
CFDIS:
|
|
38
|
+
status: Draft circulated as FDIS
|
|
39
|
+
stage: '50.20'
|
|
40
|
+
CDPAS:
|
|
41
|
+
status: Draft circulated as DPAS
|
|
42
|
+
stage: '50.20'
|
|
43
|
+
CDTR:
|
|
44
|
+
status: Draft circulated as DTR
|
|
45
|
+
stage: '50.20'
|
|
46
|
+
CDTS:
|
|
47
|
+
status: Draft circulated as DTS
|
|
48
|
+
stage: '50.20'
|
|
49
|
+
DTRM:
|
|
50
|
+
status: Rejected DTR to be discussed at meeting
|
|
51
|
+
stage: '50.92'
|
|
52
|
+
DTSM:
|
|
53
|
+
status: Rejected DTS to be discussed at meeting
|
|
54
|
+
stage: '50.92'
|
|
55
|
+
DECFDIS:
|
|
56
|
+
status: FDIS at editing check
|
|
57
|
+
stage: '50.60'
|
|
58
|
+
DECPUB:
|
|
59
|
+
status: Publication at editing check
|
|
60
|
+
stage: '60.00'
|
|
61
|
+
DEL:
|
|
62
|
+
status: Deleted/abandoned
|
|
63
|
+
stage: '00.99'
|
|
64
|
+
DELPUB:
|
|
65
|
+
status: Deleted publication
|
|
66
|
+
stage: '90.99'
|
|
67
|
+
NCDV:
|
|
68
|
+
status: CDV rejected
|
|
69
|
+
stage: '40.98'
|
|
70
|
+
NDTR:
|
|
71
|
+
status: DTR rejected
|
|
72
|
+
stage: '50.98'
|
|
73
|
+
NDTS:
|
|
74
|
+
status: DTS rejected
|
|
75
|
+
stage: '50.98'
|
|
76
|
+
NFDIS:
|
|
77
|
+
status: FDIS rejected
|
|
78
|
+
stage: '50.98'
|
|
79
|
+
PCC:
|
|
80
|
+
status: Preparation of CC
|
|
81
|
+
stage: '30.92'
|
|
82
|
+
PNW:
|
|
83
|
+
status: New work item proposal
|
|
84
|
+
stage: '10.00'
|
|
85
|
+
PPUB:
|
|
86
|
+
status: Publication issued
|
|
87
|
+
stage: '60.60' # ?
|
|
88
|
+
PRVC:
|
|
89
|
+
status: Preparation of RVC
|
|
90
|
+
stage: '40.92'
|
|
91
|
+
PRVD:
|
|
92
|
+
status: Preparation of RVD
|
|
93
|
+
stage: '40.92'
|
|
94
|
+
PRVDPAS:
|
|
95
|
+
status: Preparation of RVDPAS
|
|
96
|
+
stage: '40.92'
|
|
97
|
+
PRVDTR:
|
|
98
|
+
status: Preparation of RVDTR
|
|
99
|
+
stage: '40.92'
|
|
100
|
+
PRVDTS:
|
|
101
|
+
status: Preparation of RVDTS
|
|
102
|
+
stage: '40.92'
|
|
103
|
+
PRVN:
|
|
104
|
+
status: Preparation of RVN
|
|
105
|
+
stage: '40.92'
|
|
106
|
+
PWI:
|
|
107
|
+
status: Preliminary work item
|
|
108
|
+
stage: '00.00'
|
|
109
|
+
RFDIS:
|
|
110
|
+
status: FDIS received and registered
|
|
111
|
+
stage: '50.00'
|
|
112
|
+
RPUB:
|
|
113
|
+
status: Publication received and registered
|
|
114
|
+
stage: '60.60'
|
|
115
|
+
TCDV:
|
|
116
|
+
status: Translation of CDV
|
|
117
|
+
stage: '50.00'
|
|
118
|
+
TDTR:
|
|
119
|
+
status: Translation of DTR
|
|
120
|
+
stage: '50.00'
|
|
121
|
+
TDTS:
|
|
122
|
+
status: Translation of DTS
|
|
123
|
+
stage: '50.00'
|
|
124
|
+
TFDIS:
|
|
125
|
+
status: Translation of FDIS
|
|
126
|
+
stage: '50.00'
|
|
127
|
+
TPUB:
|
|
128
|
+
status: Translation of publication
|
|
129
|
+
stage: '60.00'
|
|
130
|
+
WPUB:
|
|
131
|
+
status: Publication withdrawn
|
|
132
|
+
stage: '95.99'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Workers poll.
|
|
4
|
+
class WorkersPool
|
|
5
|
+
attr_accessor :nb_hits
|
|
6
|
+
|
|
7
|
+
def initialize(num_workers = 2)
|
|
8
|
+
@num_workers = num_workers < 2 ? 2 : num_workers
|
|
9
|
+
@queue = SizedQueue.new(num_workers * 2)
|
|
10
|
+
@result = []
|
|
11
|
+
@nb_hits = 0
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def worker(&block)
|
|
15
|
+
@threads = Array.new @num_workers do
|
|
16
|
+
Thread.new do
|
|
17
|
+
until (item = @queue.pop) == :END
|
|
18
|
+
@result << yield(item) if block
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def result
|
|
25
|
+
@threads.each(&:join)
|
|
26
|
+
@result
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def <<(item)
|
|
30
|
+
@queue << item
|
|
31
|
+
self
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def end
|
|
35
|
+
@num_workers.times { @queue << :END }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def size
|
|
39
|
+
@result.size
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require "relaton/processor"
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Iecbib
|
|
5
|
+
class Processor < Relaton::Processor
|
|
6
|
+
|
|
7
|
+
def initialize
|
|
8
|
+
@short = :iecbib
|
|
9
|
+
@prefix = "IEC"
|
|
10
|
+
@defaultprefix = %r{^(IEC)[ /]|^IEV($| )}
|
|
11
|
+
@idtype = "IEC"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def get(code, date, opts)
|
|
15
|
+
::Iecbib::IecBibliography.get(code, date, opts)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: iecbib
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ribose Inc.
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-09-19 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: equivalent-xml
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0.6'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0.6'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: pry-byebug
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rake
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '10.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '10.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rspec
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '3.0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '3.0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: simplecov
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: vcr
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: webmock
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: iso-bib-item
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: 0.3.0
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: 0.3.0
|
|
139
|
+
description: 'IsoBib: retrieve ISO Standards for bibliographic use using the BibliographicItem
|
|
140
|
+
model'
|
|
141
|
+
email:
|
|
142
|
+
- open.source@ribose.com
|
|
143
|
+
executables: []
|
|
144
|
+
extensions: []
|
|
145
|
+
extra_rdoc_files: []
|
|
146
|
+
files:
|
|
147
|
+
- ".gitignore"
|
|
148
|
+
- ".rspec"
|
|
149
|
+
- ".rubocop.yml"
|
|
150
|
+
- ".travis.yml"
|
|
151
|
+
- Gemfile
|
|
152
|
+
- Gemfile.lock
|
|
153
|
+
- LICENSE.txt
|
|
154
|
+
- README.adoc
|
|
155
|
+
- Rakefile
|
|
156
|
+
- bin/console
|
|
157
|
+
- bin/setup
|
|
158
|
+
- iecbib.gemspec
|
|
159
|
+
- lib/iecbib.rb
|
|
160
|
+
- lib/iecbib/hit.rb
|
|
161
|
+
- lib/iecbib/hit_collection.rb
|
|
162
|
+
- lib/iecbib/iec_bibliography.rb
|
|
163
|
+
- lib/iecbib/scrapper.rb
|
|
164
|
+
- lib/iecbib/statuses.yml
|
|
165
|
+
- lib/iecbib/version.rb
|
|
166
|
+
- lib/iecbib/workers_pool.rb
|
|
167
|
+
- lib/relaton/processor.rb
|
|
168
|
+
homepage: https://github.com/riboseinc/isobib
|
|
169
|
+
licenses:
|
|
170
|
+
- MIT
|
|
171
|
+
metadata: {}
|
|
172
|
+
post_install_message:
|
|
173
|
+
rdoc_options: []
|
|
174
|
+
require_paths:
|
|
175
|
+
- lib
|
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
|
+
requirements:
|
|
178
|
+
- - ">="
|
|
179
|
+
- !ruby/object:Gem::Version
|
|
180
|
+
version: '0'
|
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
|
+
requirements:
|
|
183
|
+
- - ">="
|
|
184
|
+
- !ruby/object:Gem::Version
|
|
185
|
+
version: '0'
|
|
186
|
+
requirements: []
|
|
187
|
+
rubyforge_project:
|
|
188
|
+
rubygems_version: 2.7.6
|
|
189
|
+
signing_key:
|
|
190
|
+
specification_version: 4
|
|
191
|
+
summary: 'IsoBib: retrieve ISO Standards for bibliographic use using the BibliographicItem
|
|
192
|
+
model'
|
|
193
|
+
test_files: []
|