relaton-iec 1.18.1 → 1.19.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42c487472fac6d984398b47924e667b918159cac919e25b17c5dccbdaecdcfd9
4
- data.tar.gz: 82074a9b66e1b8922d1fd9e71a9fb6be5b1cbe4978095dfa7a09a88f8ad6d6ac
3
+ metadata.gz: 7153721bcd73a90080e9ac70e5cc041cb3f943711f11cdd82ef335f01f07cf64
4
+ data.tar.gz: 9c84261060e5363ac7f5e961ca38c467703bd3043bd782e764054f407388cf83
5
5
  SHA512:
6
- metadata.gz: 99f6ef09cb747cbb3ca1ab4da67f1f12021785dbbde45e531019154f070c3b73439f13731239cf00ab5a22791a8dc771220e5b1f686e57f8af210ad5929eb79f
7
- data.tar.gz: 84374e46847c9d71ef6b0d70e403f1fd613961b6869041731f8bb20dc09aeb17be027d7c49f35b887e272691358c63e17ee072b31545b011e5e91f8a7bf800d6
6
+ metadata.gz: 10d2990ec6d73858fe68c0f85424c8bf0037205837a3ae3787dc0952de5883f3f104ef56bcf9cd266fed8816e35b5d32c5e0993ff2f2c7eebcb4792e755ab161
7
+ data.tar.gz: 900bffdce5c4b87976a351f10d0a75ea17c7efff1bdd8791a0660df5a352e3c6a4701b273882556b6822edc0f3af7dd0fbf439d5dfccc3ee3b491c904a5d65db
data/README.adoc CHANGED
@@ -31,20 +31,6 @@ 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
-
48
34
  === Search for a standard using keywords
49
35
 
50
36
  `RelatonIec::IecBibliography.search(ref, year)` method returns hits collection. Each hit can be used to fetch a document.
@@ -54,6 +40,9 @@ end
54
40
 
55
41
  [source,ruby]
56
42
  ----
43
+ require 'relaton_iec'
44
+ => true
45
+
57
46
  hit_collection = RelatonIec::IecBibliography.search("60050")
58
47
  => <RelatonIec::HitCollection:0x007fe0d7126f28 @ref=60050 @fetched=false>
59
48
 
@@ -271,6 +260,10 @@ Done in: 752 sec.
271
260
  => nil
272
261
  ----
273
262
 
263
+ === Logging
264
+
265
+ RelatonIec uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
266
+
274
267
  == Development
275
268
 
276
269
  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.
@@ -244,6 +244,9 @@
244
244
  <data type="ID"/>
245
245
  </attribute>
246
246
  <attribute name="reviewer"/>
247
+ <optional>
248
+ <attribute name="type"/>
249
+ </optional>
247
250
  <optional>
248
251
  <attribute name="date">
249
252
  <data type="dateTime"/>
@@ -7,8 +7,7 @@ module BasicBlock
7
7
  #
8
8
  def initialize(content)
9
9
  unless ALIGNS.include?(content)
10
- warn "[basic-block] WARNING: invalid alignment \"#{content}\""
11
- warn "[basic-block] alloved aligments are: #{ALIGNS.join ', '}"
10
+ Util.warn "invalid alignment `#{content}`\nalloved aligments are: `#{ALIGNS.join '`, `'}`"
12
11
  end
13
12
  @content = content
14
13
  end
@@ -13,12 +13,11 @@ 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: Invalid image width attribute: \"#{args[:width]}"
17
- warn "[basic-block] Image width should be integer or \"auto\""
16
+ Util.warn "Invalid image width attribute: `#{args[:width]}`\nImage width should be integer or `auto`"
18
17
  end
19
18
  if args[:height] && !args[:height].is_a?(Integer) && args[:height] != "auto"
20
- warn "[basic-block] WARNING: Invalid image height attribute: \"#{args[:height]}"
21
- warn "[basic-block] Image height should be integer or \"auto\""
19
+ Util.warn "Invalid image height attribute: `#{args[:height]}`\n" \
20
+ "Image height should be integer or `auto`"
22
21
  end
23
22
  @width = args[:width]
24
23
  @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: Invalid reference format: \"#{format}\""
19
- warn "[relaton-iec] Alloved reference formats are: #{FORMATS.join ', '}"
18
+ Util.warn "Invalid reference format: `#{format}`\n" \
19
+ "Alloved reference formats are: `#{FORMATS.join '`, `'}`"
20
20
  end
21
21
  @format = format
22
22
  end
@@ -11,8 +11,7 @@ module BasicBlock
11
11
  #
12
12
  def initialize(type:, content: [])
13
13
  unless TYPES.include? type
14
- warn "[relaton-iec] WARNING: Invalud type: \"#{type}\""
15
- warn "[relaton-iec] Allowed types are: #{TYPES.join ', '}"
14
+ Util.warn "Invalud type: `#{type}`\nAllowed types are: `#{TYPES.join '`, `'}`"
16
15
  end
17
16
  @type = type
18
17
  @content = content
@@ -74,12 +74,12 @@ module BasicBlock
74
74
  # @option args [String, nil] :valign
75
75
  def initialize(content, **args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
76
76
  if args[:align] && !ALIGNS.include?(args[:align])
77
- warn "[basic-block] WARNING: invalid table/tr/td align \"#{args[:align]}\""
78
- warn "[basic-block] alloved aligns are: #{ALIGNS.join ', '}"
77
+ Util.warn "invalid table/tr/td align `#{args[:align]}`\n" \
78
+ "alloved aligns are: `#{ALIGNS.join '`, `'}`"
79
79
  end
80
80
  if args[:valign] && !VALIGNS.include?(args[:valign])
81
- warn "[basic-block] WARNING: invalid table/tr/td valign \"#{args[:valign]}\""
82
- warn "[basic-block] alloved valigns are: #{VALIGNS.join ', '}"
81
+ Util.warn "invalid table/tr/td valign `#{args[:valign]}`\n" \
82
+ "alloved valigns are: `#{VALIGNS.join '`, `'}`"
83
83
  end
84
84
  @content = content
85
85
  @colspan = args[:colspan]
@@ -10,8 +10,7 @@ module BasicBlock
10
10
  #
11
11
  def initialize(tag:, content:)
12
12
  unless TAGS.include? tag
13
- warn "[basic-block] WARNING: invalid tag \"#{tag}\""
14
- warn "[basic-block] allowed tags are: #{TAGS.join ', '}"
13
+ Util.warn "invalid tag `#{tag}`\nallowed tags are: `#{TAGS.join '`, `'}`"
15
14
  end
16
15
  @tag = tag
17
16
  @content = content
@@ -51,8 +51,9 @@ module RelatonIec
51
51
  puts "Stopped at: #{t2}"
52
52
  puts "Done in: #{(t2 - t1).round} sec."
53
53
  rescue StandardError => e
54
- warn e.message
55
- warn e.backtrace.join("\n")
54
+ Util.error do
55
+ "#{e.message}\n#{e.backtrace.join("\n")}"
56
+ end
56
57
  end
57
58
 
58
59
  def create_index
@@ -90,7 +91,7 @@ module RelatonIec
90
91
  while next_page
91
92
  res = fetch_page_token page
92
93
  unless res.code == "200"
93
- warn "[relaton-iec] #{res.body}"
94
+ Util.warn "#{res.body}"
94
95
  break
95
96
  end
96
97
  json = JSON.parse res.body
@@ -162,7 +163,7 @@ module RelatonIec
162
163
  bib = DataParser.new(pub).parse
163
164
  did = bib.docidentifier.detect &:primary
164
165
  file = File.join(@output, "#{did.id.downcase.gsub(/[:\s\/]/, '_')}.#{@ext}")
165
- if @files.include? file then warn "File #{file} exists."
166
+ if @files.include? file then Util.warn "File #{file} exists."
166
167
  else
167
168
  @files << file
168
169
  # @index.add index_id(pub), file, pub["lastChangeTimestamp"]
@@ -110,12 +110,12 @@ module RelatonIec
110
110
  #
111
111
  # Parse titles.
112
112
  #
113
- # @return [Array<RelatonBib::TypedTitleString>] titles
113
+ # @return [RelatonBib::TypedTitleStringCollection] titles
114
114
  #
115
115
  def title
116
- @pub["title"].map do |t|
117
- RelatonBib::TypedTitleString.new(
118
- content: t["value"], language: t["lang"], script: lang_to_script(t["lang"]), type: "main",
116
+ @pub["title"].reduce(RelatonBib::TypedTitleStringCollection.new) do |a, t|
117
+ a + RelatonBib::TypedTitleString.from_string(
118
+ t["value"], t["lang"], lang_to_script(t["lang"])
119
119
  )
120
120
  end
121
121
  end
@@ -13,7 +13,7 @@ module RelatonIec
13
13
 
14
14
  def check_type(type)
15
15
  unless DOCTYPES.include? type
16
- Util.warn "WARNING: Invalid doctype: `#{type}`"
16
+ Util.warn "Invalid doctype: `#{type}`"
17
17
  end
18
18
  end
19
19
  end
@@ -28,13 +28,17 @@ module RelatonIec
28
28
  #
29
29
  def initialize(**args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
30
30
  if args[:function] && !FUNCTION.include?(args[:function])
31
- Util.warn "WARNING: Invalid function: `#{args[:function]}`"
32
- Util.warn "Allowed function values are: `#{FUNCTION.join('`, `')}`"
31
+ Util.warn do
32
+ "Invalid function: `#{args[:function]}`\n" \
33
+ "Allowed function values are: `#{FUNCTION.join('`, `')}`"
34
+ end
33
35
  end
34
36
  if args[:updates_document_type] &&
35
37
  !DocumentType::DOCTYPES.include?(args[:updates_document_type])
36
- Util.warn "WARNING: Invalid updates_document_type: `#{args[:updates_document_type]}`"
37
- Util.warn "Allowed updates_document_type values are: `#{DocumentType::DOCTYPES.join('`, `')}`"
38
+ Util.warn do
39
+ "WARNING: Invalid updates_document_type: `#{args[:updates_document_type]}`\n" \
40
+ "Allowed updates_document_type values are: `#{DocumentType::DOCTYPES.join('`, `')}`"
41
+ end
38
42
  end
39
43
  @function = args.delete :function
40
44
  @updates_document_type = args.delete :updates_document_type
@@ -46,8 +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
- Util.warn "(#{id}) TIP: No match for edition year `#{year}`, " \
50
- "but matches exist for `#{missed_years.uniq.join('`, `')}`."
49
+ Util.info "TIP: No match for edition year `#{year}`, " \
50
+ "but matches exist for `#{missed_years.uniq.join('`, `')}`.", key: id
51
51
  end
52
52
 
53
53
  # @param code [String]
@@ -56,7 +56,7 @@ module RelatonIec
56
56
  def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
57
57
  id = ref_with_year(code, year)
58
58
 
59
- Util.warn "(#{id}) Not found."
59
+ Util.info "Not found.", key: id
60
60
 
61
61
  if year && missed_years.any?
62
62
  warn_missing_years(code, year, missed_years)
@@ -65,11 +65,11 @@ module RelatonIec
65
65
  # TODO: change this to pubid-iec
66
66
  has_part = /\d-\d/.match?(code)
67
67
  if has_part
68
- Util.warn "(#{id}) TIP: If it cannot be found, the document may no longer be published in parts."
68
+ Util.info "TIP: If it cannot be found, the document may no longer be published in parts.", key: id
69
69
 
70
70
  else
71
- Util.warn "(#{id}) TIP: If you wish to cite all document parts for " \
72
- "the reference, use `#{code} (all parts)`."
71
+ Util.info "TIP: If you wish to cite all document parts for " \
72
+ "the reference, use `#{code} (all parts)`.", key: id
73
73
  end
74
74
 
75
75
  # TODO: streamline after integration with pubid-iec
@@ -78,11 +78,9 @@ module RelatonIec
78
78
  code.include?("#{t} ")
79
79
  end
80
80
  unless selected_doctype
81
- Util.warn "(#{id}) TIP: If the document is not an International Standard, use its " \
82
- "deliverable type abbreviation `#{doctypes.join('`, `')}`."
81
+ Util.info "TIP: If the document is not an International Standard, use its " \
82
+ "deliverable type abbreviation `#{doctypes.join('`, `')}`.", key: id
83
83
  end
84
-
85
- nil
86
84
  end
87
85
 
88
86
  # @param ref [String]
@@ -125,7 +123,7 @@ module RelatonIec
125
123
  # @return [RelatonIec::HitCollection]
126
124
  def search_filter(ref, year)
127
125
  code = ref.split(":").first
128
- Util.warn "(#{ref_with_year(ref, year)}) Fetching from Relaton repsitory ..."
126
+ Util.info "Fetching from Relaton repsitory ...", key: ref_with_year(ref, year)
129
127
  search(code)
130
128
  end
131
129
 
@@ -257,12 +255,12 @@ module RelatonIec
257
255
 
258
256
  # if id == docid then Util.warn "(#{id}) Found exact match."
259
257
  # else
260
- Util.warn "(#{id}) Found: `#{docid}`"
258
+ Util.info "Found: `#{docid}`", key: id
261
259
  # end
262
260
 
263
261
  if ret[:missed_parts]
264
- Util.warn "(#{id}) TIP: `#{code}` also contains other parts, " \
265
- "if you want to cite all parts, use `#{code} (all parts)`."
262
+ Util.info "TIP: `#{code}` also contains other parts, " \
263
+ "if you want to cite all parts, use `#{code} (all parts)`.", key: id
266
264
  end
267
265
 
268
266
  ret[:ret]
@@ -1,9 +1,6 @@
1
1
  module RelatonIec
2
2
  module Util
3
3
  extend RelatonBib::Util
4
-
5
- def self.logger
6
- RelatonIec.configuration.logger
7
- end
4
+ PROGNAME = "relaton-iec".freeze
8
5
  end
9
6
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIec
2
- VERSION = "1.18.1".freeze
2
+ VERSION = "1.19.1".freeze
3
3
  end
data/lib/relaton_iec.rb CHANGED
@@ -7,7 +7,6 @@ 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
10
  require "relaton_iec/util"
12
11
  require "relaton_iec/document_type"
13
12
  require "relaton_iec/iec_bibliography"
data/relaton_iec.gemspec CHANGED
@@ -24,7 +24,8 @@ Gem::Specification.new do |spec|
24
24
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
25
25
 
26
26
  spec.add_dependency "addressable"
27
+ spec.add_dependency "base64"
27
28
  spec.add_dependency "relaton-index", "~> 0.2.0"
28
- spec.add_dependency "relaton-iso-bib", "~> 1.18.1"
29
+ spec.add_dependency "relaton-iso-bib", "~> 1.19.0"
29
30
  spec.add_dependency "rubyzip"
30
31
  end
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.18.1
4
+ version: 1.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-02 00:00:00.000000000 Z
11
+ date: 2024-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: base64
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: relaton-index
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +58,14 @@ dependencies:
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: 1.18.1
61
+ version: 1.19.0
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: 1.18.1
68
+ version: 1.19.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rubyzip
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +123,6 @@ files:
109
123
  - lib/relaton_iec/basic_block/stem.rb
110
124
  - lib/relaton_iec/basic_block/table.rb
111
125
  - lib/relaton_iec/basic_block/text_element.rb
112
- - lib/relaton_iec/config.rb
113
126
  - lib/relaton_iec/data_fetcher.rb
114
127
  - lib/relaton_iec/data_parser.rb
115
128
  - lib/relaton_iec/document_type.rb
@@ -145,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
158
  - !ruby/object:Gem::Version
146
159
  version: '0'
147
160
  requirements: []
148
- rubygems_version: 3.3.26
161
+ rubygems_version: 3.3.27
149
162
  signing_key:
150
163
  specification_version: 4
151
164
  summary: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IecBibliographicItem
@@ -1,10 +0,0 @@
1
- module RelatonIec
2
- module Config
3
- include RelatonBib::Config
4
- end
5
- extend Config
6
-
7
- class Configuration < RelatonBib::Configuration
8
- PROGNAME = "relaton-iec".freeze
9
- end
10
- end