relaton-bsi 1.16.0 → 1.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +16 -5
- data/lib/relaton_bsi/bsi_bibliographic_item.rb +2 -2
- data/lib/relaton_bsi/bsi_bibliography.rb +11 -16
- data/lib/relaton_bsi/config.rb +10 -0
- data/lib/relaton_bsi/util.rb +9 -0
- data/lib/relaton_bsi/version.rb +1 -1
- data/lib/relaton_bsi.rb +13 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beee0d1d60affb54c0d473077b8b792271bd773a89462aa9668794a47c8c37b4
|
4
|
+
data.tar.gz: 3f4a940e53481c52b6ff1d155a0ae1e9cccdc20a768753d59efb042beed7a80b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d890a38ea4d5ba876d4e6e8497347e45bb3067aca5796f8c574a8d7de9e337836655158d9f3ce1ed1d1687c923750ee570b80994ea238be9e32df156bc6fd808
|
7
|
+
data.tar.gz: c12c4a02bd22a07cd63378de4a2a701df11e119e12717e8e28d74b7c6ce453712c123b8b55a10675f3b78e7bce23aebbc0187bb79ef5366e43aab0de46e7e3a5
|
data/README.adoc
CHANGED
@@ -27,13 +27,24 @@ Or install it yourself as:
|
|
27
27
|
|
28
28
|
== Usage
|
29
29
|
|
30
|
-
===
|
30
|
+
=== Configuration
|
31
|
+
|
32
|
+
Configuration is optional. The available option is `logger` which is a `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level. To change the logger level, use `RelatonBsi.configure` block.
|
31
33
|
|
32
34
|
[source,ruby]
|
33
35
|
----
|
34
36
|
require 'relaton_bsi'
|
35
37
|
=> true
|
36
38
|
|
39
|
+
RelatonBsi.configure do |config|
|
40
|
+
config.logger.level = Logger::DEBUG
|
41
|
+
end
|
42
|
+
----
|
43
|
+
|
44
|
+
=== Search for a standard using keywords
|
45
|
+
|
46
|
+
[source,ruby]
|
47
|
+
----
|
37
48
|
hit_collection = RelatonBsi::BsiBibliography.search("BS EN ISO 8848")
|
38
49
|
=> <RelatonBsi::HitCollection:0x007fead49fe1f8 @ref=BS EN ISO 8848 @fetched=false>
|
39
50
|
|
@@ -89,14 +100,14 @@ item.to_xml bibdata: true
|
|
89
100
|
[source,ruby]
|
90
101
|
----
|
91
102
|
RelatonBsi::BsiBibliography.get "BS EN ISO 8848:2021"
|
92
|
-
[relaton-bsi] (
|
93
|
-
[relaton-bsi] (
|
103
|
+
[relaton-bsi] (BS EN ISO 8848:2021) Fetching from shop.bsigroup.com ...
|
104
|
+
[relaton-bsi] (BS EN ISO 8848:2021) Found: `BS EN ISO 8848:2021`
|
94
105
|
=> #<RelatonBsi::BsiBibliographicItem:0x007feb14814ca8
|
95
106
|
...
|
96
107
|
|
97
108
|
RelatonBsi::BsiBibliography.get "BS EN ISO 8848", "2021"
|
98
|
-
[relaton-bsi] (
|
99
|
-
[relaton-bsi] (
|
109
|
+
[relaton-bsi] (BS EN ISO 8848) Fetching from shop.bsigroup.com ...
|
110
|
+
[relaton-bsi] (BS EN ISO 8848) Found: `BS EN ISO 8848:2021`
|
100
111
|
=> #<RelatonBsi::BsiBibliographicItem:0x007feaf59188a8
|
101
112
|
...
|
102
113
|
----
|
@@ -11,8 +11,8 @@ module RelatonBsi
|
|
11
11
|
|
12
12
|
def initialize(**args) # rubocop:disable Metrics/AbcSize
|
13
13
|
if args[:subdoctype] && !SUBDOCTYPES.include?(args[:subdoctype])
|
14
|
-
warn "
|
15
|
-
warn "
|
14
|
+
Util.warn "WARNING: invalid subdoctype: `#{args[:subdoctype]}`"
|
15
|
+
Util.warn "Allowed subdoctypes are: `#{SUBDOCTYPES.join('`, `')}`"
|
16
16
|
end
|
17
17
|
super
|
18
18
|
end
|
@@ -1,14 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# require "mechanize"
|
4
|
-
require "relaton_iso_bib"
|
5
|
-
require "relaton_bsi/bsi_bibliographic_item"
|
6
|
-
require "relaton_bsi/scrapper"
|
7
|
-
require "relaton_bsi/hit_collection"
|
8
|
-
require "relaton_bsi/hit"
|
9
|
-
require "relaton_bsi/xml_parser"
|
10
|
-
require "relaton_bsi/hash_converter"
|
11
|
-
|
12
3
|
module RelatonBsi
|
13
4
|
# Class methods for search ISO standards.
|
14
5
|
class BsiBibliography
|
@@ -64,11 +55,11 @@ module RelatonBsi
|
|
64
55
|
def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
|
65
56
|
y = code_parts(code)[:year]
|
66
57
|
id = year && !y ? "#{code}:#{year}" : code
|
67
|
-
warn "
|
68
|
-
|
58
|
+
Util.warn "WARNING: no match found online for `#{id}`. " \
|
59
|
+
"The code must be exactly like it is on the standards website."
|
69
60
|
unless missed_years.empty?
|
70
|
-
warn "
|
71
|
-
|
61
|
+
Util.warn "There was no match for `#{year}`, though there " \
|
62
|
+
"were matches found for `#{missed_years.join('`, `')}`."
|
72
63
|
end
|
73
64
|
# if /\d-\d/.match? code
|
74
65
|
# warn "[relaton-bsi] The provided document part may not exist, or "\
|
@@ -91,8 +82,11 @@ module RelatonBsi
|
|
91
82
|
#
|
92
83
|
def search_filter(code)
|
93
84
|
cp = code_parts code
|
94
|
-
warn "
|
95
|
-
|
85
|
+
Util.warn "(#{code}) Fetching from shop.bsigroup.com ..."
|
86
|
+
unless cp
|
87
|
+
Util.warn "(#{code}) Could not parse the reference"
|
88
|
+
return []
|
89
|
+
end
|
96
90
|
|
97
91
|
search(code).filter_hits!(cp)
|
98
92
|
end
|
@@ -121,9 +115,10 @@ module RelatonBsi
|
|
121
115
|
result = search_filter(code) || return
|
122
116
|
ret = results_filter(result, year)
|
123
117
|
if ret[:ret]
|
124
|
-
warn "
|
118
|
+
Util.warn "(#{code}) Found: `#{ret[:ret].docidentifier.first&.id}`"
|
125
119
|
ret[:ret]
|
126
120
|
else
|
121
|
+
Util.warn "(#{code}) No found"
|
127
122
|
fetch_ref_err(code, year, ret[:years])
|
128
123
|
end
|
129
124
|
end
|
data/lib/relaton_bsi/version.rb
CHANGED
data/lib/relaton_bsi.rb
CHANGED
@@ -1,15 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "relaton_iso_bib"
|
3
4
|
require_relative "relaton_bsi/version"
|
5
|
+
require "relaton_bsi/config"
|
6
|
+
require "relaton_bsi/util"
|
4
7
|
require "relaton_bsi/bsi_bibliography"
|
8
|
+
require "relaton_bsi/bsi_bibliographic_item"
|
9
|
+
require "relaton_bsi/scrapper"
|
10
|
+
require "relaton_bsi/hit_collection"
|
11
|
+
require "relaton_bsi/hit"
|
12
|
+
require "relaton_bsi/xml_parser"
|
13
|
+
require "relaton_bsi/hash_converter"
|
5
14
|
|
6
15
|
module RelatonBsi
|
7
16
|
# Returns hash of XML greammar
|
8
17
|
# @return [String]
|
9
18
|
def self.grammar_hash
|
10
|
-
gem_path = File.expand_path "..", __dir__
|
11
|
-
grammars_path = File.join gem_path, "grammars", "*"
|
12
|
-
grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
13
|
-
Digest::MD5.hexdigest grammars
|
19
|
+
# gem_path = File.expand_path "..", __dir__
|
20
|
+
# grammars_path = File.join gem_path, "grammars", "*"
|
21
|
+
# grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
22
|
+
Digest::MD5.hexdigest RelatonBsi::VERSION + RelatonIsoBib::VERSION + RelatonBib::VERSION # grammars
|
14
23
|
end
|
15
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-bsi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.16.
|
4
|
+
version: 1.16.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: 2023-
|
11
|
+
date: 2023-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: algolia
|
@@ -94,12 +94,14 @@ files:
|
|
94
94
|
- lib/relaton_bsi.rb
|
95
95
|
- lib/relaton_bsi/bsi_bibliographic_item.rb
|
96
96
|
- lib/relaton_bsi/bsi_bibliography.rb
|
97
|
+
- lib/relaton_bsi/config.rb
|
97
98
|
- lib/relaton_bsi/hash_converter.rb
|
98
99
|
- lib/relaton_bsi/hit.rb
|
99
100
|
- lib/relaton_bsi/hit_collection.rb
|
100
101
|
- lib/relaton_bsi/processor.rb
|
101
102
|
- lib/relaton_bsi/schema.json
|
102
103
|
- lib/relaton_bsi/scrapper.rb
|
104
|
+
- lib/relaton_bsi/util.rb
|
103
105
|
- lib/relaton_bsi/version.rb
|
104
106
|
- lib/relaton_bsi/xml_parser.rb
|
105
107
|
- relaton_bsi.gemspec
|