relaton-iec 1.16.0 → 1.16.2
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/README.adoc +20 -9
- data/lib/relaton_iec/basic_block/image.rb +4 -4
- data/lib/relaton_iec/basic_block/reference_format.rb +2 -2
- data/lib/relaton_iec/basic_block/stem.rb +2 -2
- data/lib/relaton_iec/config.rb +10 -0
- data/lib/relaton_iec/iec_bibliographic_item.rb +4 -6
- data/lib/relaton_iec/iec_bibliography.rb +16 -25
- data/lib/relaton_iec/util.rb +9 -0
- data/lib/relaton_iec/version.rb +1 -1
- data/lib/relaton_iec.rb +6 -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: d3c632b6fb62b15fd360d801190ebac6742f05658b695e573304b5c4a7d38ed1
|
4
|
+
data.tar.gz: 271d54825baa3cc59e59bcc926da577aecb172bb81466cb7b1dd5c4248746357
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 283f22a20fceef3a4dbb3430f8bbdb69930b8286f5af0e00bc8c1648242c6024603b2a284efa7ae7fcdcf908db0f326f48533ba5fbad8389f3e534428a9059b6
|
7
|
+
data.tar.gz: 8327e80d5c36f179d692966ebb280fc00c66e89145d1da741e3198b1219655df2a33ca45735870466c3b045ae7b3f8bce7ba663396af76e29b0bdbcf06b8359b
|
data/README.adoc
CHANGED
@@ -31,6 +31,20 @@ Or install it yourself as:
|
|
31
31
|
|
32
32
|
== Usage
|
33
33
|
|
34
|
+
=== Configuration
|
35
|
+
|
36
|
+
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 `RelatonIec.configure` block.
|
37
|
+
|
38
|
+
[source,ruby]
|
39
|
+
----
|
40
|
+
require 'relaton_iec'
|
41
|
+
=> true
|
42
|
+
|
43
|
+
RelatonIec.configure do |config|
|
44
|
+
config.logger.level = Logger::DEBUG
|
45
|
+
end
|
46
|
+
----
|
47
|
+
|
34
48
|
=== Search for a standard using keywords
|
35
49
|
|
36
50
|
`RelatonIec::IecBibliography.search(ref, year)` method returns hits collection. Each hit can be used to fetch a document.
|
@@ -40,9 +54,6 @@ Or install it yourself as:
|
|
40
54
|
|
41
55
|
[source,ruby]
|
42
56
|
----
|
43
|
-
require 'relaton_iec'
|
44
|
-
=> true
|
45
|
-
|
46
57
|
hit_collection = RelatonIec::IecBibliography.search("60050")
|
47
58
|
=> <RelatonIec::HitCollection:0x007fe0d7126f28 @ref=60050 @fetched=false>
|
48
59
|
|
@@ -78,14 +89,14 @@ item.docidentifier.detect { |di| di.type == "URN" }.id
|
|
78
89
|
[source,ruby]
|
79
90
|
----
|
80
91
|
item = RelatonIec::IecBibliography.get("IEC 60050-112:2010")
|
81
|
-
[relaton-iec] (
|
82
|
-
[relaton-iec] (
|
92
|
+
[relaton-iec] (IEC 60050-112:2010) Fetching from Relaton repository ...
|
93
|
+
[relaton-iec] (IEC 60050-112:2010) Found: `IEC 60050-112:2010`
|
83
94
|
=> #<RelatonIec::IecBibliographicItem:0x00007f876525e8d0
|
84
95
|
...
|
85
96
|
|
86
97
|
item = RelatonIec::IecBibliography.get("IEC 60050-112", "2010", all_parts: true)
|
87
|
-
[relaton-iec] (
|
88
|
-
[relaton-iec] (
|
98
|
+
[relaton-iec] (IEC 60050-112) Fetching from Relaton repository ...
|
99
|
+
[relaton-iec] (IEC 60050-112) Found: `IEC 60050 (all parts)`
|
89
100
|
=> #<RelatonIec::IecBibliographicItem:0x00007f87851888f0
|
90
101
|
...
|
91
102
|
|
@@ -93,8 +104,8 @@ item.docidentifier.first
|
|
93
104
|
=> #<RelatonBib::DocumentIdentifier:0x00007f878518eea8 @id="IEC 60050 (all parts)", @language=nil, @primary=true, @scope=nil, @script=nil, @type="IEC">
|
94
105
|
|
95
106
|
item = RelatonIec::IecBibliography.get("IEC 60050-112", "2010")
|
96
|
-
[relaton-iec] (
|
97
|
-
[relaton-iec] (
|
107
|
+
[relaton-iec] (IEC 60050-112) Fetching from Relaton repository ...
|
108
|
+
[relaton-iec] (IEC 60050-112) Found: `IEC 60050-112:2010`
|
98
109
|
=> #<RelatonIec::IecBibliographicItem:0x007fa69f296da8
|
99
110
|
|
100
111
|
item.docidentifier.first
|
@@ -13,12 +13,12 @@ module BasicBlock
|
|
13
13
|
@mimetype = mimetype
|
14
14
|
@filename = args[:filename]
|
15
15
|
if args[:width] && !args[:width].is_a?(Integer) && args[:width] != "auto"
|
16
|
-
warn "[basic-block] WARNING:
|
17
|
-
warn "[basic-block]
|
16
|
+
warn "[basic-block] WARNING: Invalid image width attribute: \"#{args[:width]}"
|
17
|
+
warn "[basic-block] Image width should be integer or \"auto\""
|
18
18
|
end
|
19
19
|
if args[:height] && !args[:height].is_a?(Integer) && args[:height] != "auto"
|
20
|
-
warn "[basic-block] WARNING:
|
21
|
-
warn "[basic-block]
|
20
|
+
warn "[basic-block] WARNING: Invalid image height attribute: \"#{args[:height]}"
|
21
|
+
warn "[basic-block] Image height should be integer or \"auto\""
|
22
22
|
end
|
23
23
|
@width = args[:width]
|
24
24
|
@height = args[:height]
|
@@ -15,8 +15,8 @@ module RelatonIec
|
|
15
15
|
#
|
16
16
|
def initialize(format)
|
17
17
|
unless FORMATS.include? format
|
18
|
-
warn "[relaton-iec] WARNING:
|
19
|
-
warn "[relaton-iec]
|
18
|
+
warn "[relaton-iec] WARNING: Invalid reference format: \"#{format}\""
|
19
|
+
warn "[relaton-iec] Alloved reference formats are: #{FORMATS.join ', '}"
|
20
20
|
end
|
21
21
|
@format = format
|
22
22
|
end
|
@@ -11,8 +11,8 @@ module BasicBlock
|
|
11
11
|
#
|
12
12
|
def initialize(type:, content: [])
|
13
13
|
unless TYPES.include? type
|
14
|
-
warn "[relaton-iec] WARNING:
|
15
|
-
warn "[relaton-iec]
|
14
|
+
warn "[relaton-iec] WARNING: Invalud type: \"#{type}\""
|
15
|
+
warn "[relaton-iec] Allowed types are: #{TYPES.join ', '}"
|
16
16
|
end
|
17
17
|
@type = type
|
18
18
|
@content = content
|
@@ -34,15 +34,13 @@ module RelatonIec
|
|
34
34
|
#
|
35
35
|
def initialize(**args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
36
36
|
if args[:function] && !FUNCTION.include?(args[:function])
|
37
|
-
warn "
|
38
|
-
warn "
|
37
|
+
Util.warn "WARNING: Invalid function: `#{args[:function]}`"
|
38
|
+
Util.warn "Allowed function values are: `#{FUNCTION.join('`, `')}`"
|
39
39
|
end
|
40
40
|
if args[:updates_document_type] &&
|
41
41
|
!DOCTYPES.include?(args[:updates_document_type])
|
42
|
-
warn "
|
43
|
-
|
44
|
-
warn "[relaton-iec] allowed updates_document_type values are: " \
|
45
|
-
"#{DOCTYPES.join(', ')}"
|
42
|
+
Util.warn "WARNING: Invalid updates_document_type: `#{args[:updates_document_type]}`"
|
43
|
+
Util.warn "Allowed updates_document_type values are: `#{DOCTYPES.join('`, `')}`"
|
46
44
|
end
|
47
45
|
@function = args.delete :function
|
48
46
|
@updates_document_type = args.delete :updates_document_type
|
@@ -46,9 +46,8 @@ module RelatonIec
|
|
46
46
|
# @param missed_years [Array<String>]
|
47
47
|
def warn_missing_years(pubid, year, missed_years)
|
48
48
|
id = ref_with_year(pubid, year)
|
49
|
-
warn "
|
50
|
-
|
51
|
-
"but matches exist for #{missed_years.uniq.join(', ')}."
|
49
|
+
Util.warn "(#{id}) TIP: No match for edition year `#{year}`, " \
|
50
|
+
"but matches exist for `#{missed_years.uniq.join('`, `')}`."
|
52
51
|
end
|
53
52
|
|
54
53
|
# @param code [String]
|
@@ -57,9 +56,7 @@ module RelatonIec
|
|
57
56
|
def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
|
58
57
|
id = ref_with_year(code, year)
|
59
58
|
|
60
|
-
warn "
|
61
|
-
"Not found. "\
|
62
|
-
"The identifier must be exactly as shown on the IEC Webstore."
|
59
|
+
Util.warn "(#{id}) Not found."
|
63
60
|
|
64
61
|
if year && missed_years.any?
|
65
62
|
warn_missing_years(code, year, missed_years)
|
@@ -68,13 +65,11 @@ module RelatonIec
|
|
68
65
|
# TODO: change this to pubid-iec
|
69
66
|
has_part = /\d-\d/.match?(code)
|
70
67
|
if has_part
|
71
|
-
warn "
|
72
|
-
"If it cannot be found, the document may no longer be published in parts."
|
68
|
+
Util.warn "(#{id}) TIP: If it cannot be found, the document may no longer be published in parts."
|
73
69
|
|
74
70
|
else
|
75
|
-
warn "
|
76
|
-
|
77
|
-
"use (\"#{code} (all parts)\")."
|
71
|
+
Util.warn "(#{id}) TIP: If you wish to cite all document parts for " \
|
72
|
+
"the reference, use `#{code} (all parts)`."
|
78
73
|
end
|
79
74
|
|
80
75
|
# TODO: streamline after integration with pubid-iec
|
@@ -83,9 +78,8 @@ module RelatonIec
|
|
83
78
|
code.include?("#{t} ")
|
84
79
|
end
|
85
80
|
unless selected_doctype
|
86
|
-
warn "
|
87
|
-
|
88
|
-
"deliverable type abbreviation (#{doctypes.join(", ")})."
|
81
|
+
Util.warn "(#{id}) TIP: If the document is not an International Standard, use its " \
|
82
|
+
"deliverable type abbreviation `#{doctypes.join('`, `')}`."
|
89
83
|
end
|
90
84
|
|
91
85
|
nil
|
@@ -95,7 +89,7 @@ module RelatonIec
|
|
95
89
|
# @param year [String]
|
96
90
|
# @return [String]
|
97
91
|
def ref_with_year(ref, year)
|
98
|
-
year ? [ref, year].join(":") : ref
|
92
|
+
year && !ref.match?(/:\d{4}/) ? [ref, year].join(":") : ref
|
99
93
|
end
|
100
94
|
|
101
95
|
# @param ref [String]
|
@@ -131,7 +125,7 @@ module RelatonIec
|
|
131
125
|
# @return [RelatonIec::HitCollection]
|
132
126
|
def search_filter(ref, year)
|
133
127
|
code = ref.split(":").first
|
134
|
-
warn "
|
128
|
+
Util.warn "(#{ref_with_year(ref, year)}) Fetching from Relaton repsitory ..."
|
135
129
|
search(code)
|
136
130
|
end
|
137
131
|
|
@@ -256,17 +250,14 @@ module RelatonIec
|
|
256
250
|
id = ref_with_year(code, year)
|
257
251
|
docid = ret[:ret].docidentifier.first.id
|
258
252
|
|
259
|
-
if id == docid
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
end
|
253
|
+
# if id == docid then Util.warn "(#{id}) Found exact match."
|
254
|
+
# else
|
255
|
+
Util.warn "(#{id}) Found: `#{docid}`"
|
256
|
+
# end
|
264
257
|
|
265
258
|
if ret[:missed_parts]
|
266
|
-
warn "
|
267
|
-
|
268
|
-
"if you want to cite all parts, use "\
|
269
|
-
"(\"#{code} (all parts)\")."
|
259
|
+
Util.warn "(#{id}) TIP: `#{code}` also contains other parts, " \
|
260
|
+
"if you want to cite all parts, use `#{code} (all parts)`."
|
270
261
|
end
|
271
262
|
|
272
263
|
ret[:ret]
|
data/lib/relaton_iec/version.rb
CHANGED
data/lib/relaton_iec.rb
CHANGED
@@ -7,6 +7,8 @@ require "relaton/index"
|
|
7
7
|
require "relaton_iso_bib"
|
8
8
|
require "relaton_iec/hit"
|
9
9
|
require "relaton_iec/version"
|
10
|
+
require "relaton_iec/config"
|
11
|
+
require "relaton_iec/util"
|
10
12
|
require "relaton_iec/iec_bibliography"
|
11
13
|
require "relaton_iec/iec_bibliographic_item"
|
12
14
|
require "relaton_iec/xml_parser"
|
@@ -20,10 +22,10 @@ module RelatonIec
|
|
20
22
|
# Returns hash of XML reammar
|
21
23
|
# @return [String]
|
22
24
|
def grammar_hash
|
23
|
-
gem_path = File.expand_path "..", __dir__
|
24
|
-
grammars_path = File.join gem_path, "grammars", "*"
|
25
|
-
grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
26
|
-
Digest::MD5.hexdigest grammars
|
25
|
+
# gem_path = File.expand_path "..", __dir__
|
26
|
+
# grammars_path = File.join gem_path, "grammars", "*"
|
27
|
+
# grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
28
|
+
Digest::MD5.hexdigest RelatonIec::VERSION + RelatonIsoBib::VERSION + RelatonBib::VERSION # grammars
|
27
29
|
end
|
28
30
|
|
29
31
|
# @param code [String]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-iec
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/relaton_iec/basic_block/stem.rb
|
110
110
|
- lib/relaton_iec/basic_block/table.rb
|
111
111
|
- lib/relaton_iec/basic_block/text_element.rb
|
112
|
+
- lib/relaton_iec/config.rb
|
112
113
|
- lib/relaton_iec/data_fetcher.rb
|
113
114
|
- lib/relaton_iec/data_parser.rb
|
114
115
|
- lib/relaton_iec/hash_converter.rb
|
@@ -120,6 +121,7 @@ files:
|
|
120
121
|
- lib/relaton_iec/processor.rb
|
121
122
|
- lib/relaton_iec/statuses.yml
|
122
123
|
- lib/relaton_iec/tc_sc_officers_note.rb
|
124
|
+
- lib/relaton_iec/util.rb
|
123
125
|
- lib/relaton_iec/version.rb
|
124
126
|
- lib/relaton_iec/xml_parser.rb
|
125
127
|
- relaton_iec.gemspec
|