judges 0.60.3 → 0.60.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26d69625988cf52b0a58b477b38399fa6131ce5ef2fca9e41fad8b3f0d9409e9
4
- data.tar.gz: 49a6f1decdb471de65037f19d249cd4a5f3208e53a7ca3b9e23a8b7a225dbbe4
3
+ metadata.gz: 8713c9bc8dbf041fd7c451cfabc5cb8af4f9c9b0b0a267eec76b69b388f279a3
4
+ data.tar.gz: 8354129d0ed9db6da51bb68ad194c458f9d0f18a1956e41f417bf6677da68fa6
5
5
  SHA512:
6
- metadata.gz: 3222d9734c7ed4e2afe39f61ba91fc9c69ba8ef17ea7639de5112e886a3a5f42cd7a84af6fb024dc96e817750f0cb567f04cd8bf08d93b894500c081323ce5a5
7
- data.tar.gz: 74bc0d47b424a70b03221212a3626e83999234370003aa97f33d7500c1c2fff7fa175186664c170371ac45a3fa54302ea84920679306079a033f0e0883a8d526
6
+ metadata.gz: 7a4ff1a0889fc324cfad12044de49a9d22c215737c5070863290c940d8e2e0de6da0e21a5fb615ffcff2d668f193e019e0282eb92730d709c251700488b2c432
7
+ data.tar.gz: cae9f5c7e70893f7d60228d1a625932e0d16594894505a8b96f8f1f25d2bb1cf61838d92a7c3827750eb1a284a5239b3a96155039f831760bb74efbf956c1c3d
data/Gemfile CHANGED
@@ -8,7 +8,7 @@ gemspec
8
8
 
9
9
  gem 'base64', '~>0.3'
10
10
  gem 'cucumber', '~>11.0', require: false
11
- gem 'diff-lcs', '1.6.2', require: false # GPL
11
+ gem 'diff-lcs', '1.6.2', require: false
12
12
  gem 'minitest', '~>6.0', require: false
13
13
  gem 'minitest-mock', '~>5.27', require: false
14
14
  gem 'minitest-reporters', '~>1.7', require: false
@@ -18,8 +18,9 @@ gem 'os', '~>1.1', require: false
18
18
  gem 'qbash', '~>0.4', require: false
19
19
  gem 'rake', '~>13.2', require: false
20
20
  gem 'random-port', '~>0.7', require: false
21
- gem 'rdoc', '7.2.0', require: false # GPL
21
+ gem 'rdoc', '7.2.0', require: false
22
22
  gem 'rubocop', '~>1.74', require: false
23
+ gem 'rubocop-elegant', '~>0.5', require: false
23
24
  gem 'rubocop-minitest', '~>0.38', require: false
24
25
  gem 'rubocop-performance', '~>1.25', require: false
25
26
  gem 'rubocop-rake', '~>0.7', require: false
@@ -27,4 +28,4 @@ gem 'simplecov', '~>0.22', require: false
27
28
  gem 'simplecov-cobertura', '~>3.0', require: false
28
29
  gem 'w3c_validators', '~>1.3', require: false
29
30
  gem 'webmock', '~>3.25', require: false
30
- gem 'yard', '0.9.38', require: false # GPL
31
+ gem 'yard', '0.9.38', require: false
data/Gemfile.lock CHANGED
@@ -24,13 +24,13 @@ PATH
24
24
  GEM
25
25
  remote: https://rubygems.org/
26
26
  specs:
27
- addressable (2.8.9)
27
+ addressable (2.9.0)
28
28
  public_suffix (>= 2.0.2, < 8.0)
29
29
  ansi (1.6.0)
30
30
  ast (2.4.3)
31
31
  backtrace (0.4.1)
32
32
  base64 (0.3.0)
33
- baza.rb (0.14.3)
33
+ baza.rb (0.14.4)
34
34
  backtrace (~> 0.4)
35
35
  elapsed (~> 0.2)
36
36
  faraday (~> 2.13)
@@ -42,13 +42,13 @@ GEM
42
42
  retries (~> 0.0)
43
43
  tago (~> 0.2)
44
44
  typhoeus (~> 1.4)
45
- bigdecimal (4.1.1)
45
+ bigdecimal (4.1.2)
46
46
  builder (3.3.0)
47
47
  concurrent-ruby (1.3.6)
48
48
  crack (1.0.1)
49
49
  bigdecimal
50
50
  rexml
51
- cucumber (11.0.0)
51
+ cucumber (11.1.0)
52
52
  base64 (~> 0.2)
53
53
  builder (~> 3.2)
54
54
  cucumber-ci-environment (> 9, < 12)
@@ -65,9 +65,9 @@ GEM
65
65
  cucumber-gherkin (> 36, < 40)
66
66
  cucumber-messages (> 31, < 33)
67
67
  cucumber-tag-expressions (> 6, < 9)
68
- cucumber-cucumber-expressions (19.0.0)
68
+ cucumber-cucumber-expressions (19.0.1)
69
69
  bigdecimal
70
- cucumber-gherkin (39.0.0)
70
+ cucumber-gherkin (39.1.0)
71
71
  cucumber-messages (>= 31, < 33)
72
72
  cucumber-html-formatter (23.1.0)
73
73
  cucumber-messages (> 23, < 33)
@@ -82,11 +82,11 @@ GEM
82
82
  loog (~> 0.6)
83
83
  tago (~> 0.1)
84
84
  ellipsized (0.3.0)
85
- erb (6.0.2)
85
+ erb (6.0.4)
86
86
  ethon (0.18.0)
87
87
  ffi (>= 1.15.0)
88
88
  logger
89
- factbase (0.19.9)
89
+ factbase (0.19.10)
90
90
  backtrace (~> 0.4)
91
91
  decoor (~> 0.1)
92
92
  ellipsized (~> 0.3)
@@ -97,15 +97,15 @@ GEM
97
97
  others (~> 0.1)
98
98
  tago (~> 0.1)
99
99
  yaml (~> 0.3)
100
- faraday (2.14.1)
100
+ faraday (2.14.2)
101
101
  faraday-net_http (>= 2.0, < 3.5)
102
102
  json
103
103
  logger
104
- faraday-http-cache (2.6.1)
104
+ faraday-http-cache (2.7.0)
105
105
  faraday (>= 0.8)
106
106
  faraday-multipart (1.2.0)
107
107
  multipart-post (~> 2.0)
108
- faraday-net_http (3.4.2)
108
+ faraday-net_http (3.4.3)
109
109
  net-http (~> 0.5)
110
110
  faraday-retry (2.4.0)
111
111
  faraday (~> 2.0)
@@ -122,7 +122,7 @@ GEM
122
122
  ostruct
123
123
  hashdiff (1.2.1)
124
124
  iri (0.11.8)
125
- json (2.19.3)
125
+ json (2.19.7)
126
126
  language_server-protocol (3.17.0.5)
127
127
  lint_roller (1.1.0)
128
128
  logger (1.7.0)
@@ -131,7 +131,7 @@ GEM
131
131
  logger (~> 1.0)
132
132
  memoist3 (1.0.0)
133
133
  mini_mime (1.1.5)
134
- minitest (6.0.5)
134
+ minitest (6.0.6)
135
135
  drb (~> 2.0)
136
136
  prism (~> 1.5)
137
137
  minitest-mock (5.27.0)
@@ -147,23 +147,23 @@ GEM
147
147
  multipart-post (2.4.1)
148
148
  net-http (0.9.1)
149
149
  uri (>= 0.11.1)
150
- nokogiri (1.19.1-aarch64-linux-gnu)
150
+ nokogiri (1.19.3-aarch64-linux-gnu)
151
151
  racc (~> 1.4)
152
- nokogiri (1.19.1-aarch64-linux-musl)
152
+ nokogiri (1.19.3-aarch64-linux-musl)
153
153
  racc (~> 1.4)
154
- nokogiri (1.19.1-arm-linux-gnu)
154
+ nokogiri (1.19.3-arm-linux-gnu)
155
155
  racc (~> 1.4)
156
- nokogiri (1.19.1-arm-linux-musl)
156
+ nokogiri (1.19.3-arm-linux-musl)
157
157
  racc (~> 1.4)
158
- nokogiri (1.19.1-arm64-darwin)
158
+ nokogiri (1.19.3-arm64-darwin)
159
159
  racc (~> 1.4)
160
- nokogiri (1.19.1-x64-mingw-ucrt)
160
+ nokogiri (1.19.3-x64-mingw-ucrt)
161
161
  racc (~> 1.4)
162
- nokogiri (1.19.1-x86_64-darwin)
162
+ nokogiri (1.19.3-x86_64-darwin)
163
163
  racc (~> 1.4)
164
- nokogiri (1.19.1-x86_64-linux-gnu)
164
+ nokogiri (1.19.3-x86_64-linux-gnu)
165
165
  racc (~> 1.4)
166
- nokogiri (1.19.1-x86_64-linux-musl)
166
+ nokogiri (1.19.3-x86_64-linux-musl)
167
167
  racc (~> 1.4)
168
168
  octokit (10.0.0)
169
169
  faraday (>= 1, < 3)
@@ -171,11 +171,11 @@ GEM
171
171
  online (0.3.0)
172
172
  openssl (>= 3)
173
173
  timeout (~> 0.4)
174
- openssl (4.0.1)
174
+ openssl (4.0.2)
175
175
  os (1.1.4)
176
176
  ostruct (0.6.3)
177
177
  others (0.1.1)
178
- parallel (1.27.0)
178
+ parallel (2.1.0)
179
179
  parser (3.3.11.1)
180
180
  ast (~> 2.4.1)
181
181
  racc
@@ -184,7 +184,7 @@ GEM
184
184
  date
185
185
  stringio
186
186
  public_suffix (7.0.5)
187
- qbash (0.8.2)
187
+ qbash (0.8.4)
188
188
  backtrace (> 0)
189
189
  elapsed (> 0)
190
190
  loog (> 0)
@@ -198,10 +198,10 @@ GEM
198
198
  erb
199
199
  psych (>= 4.0.0)
200
200
  tsort
201
- regexp_parser (2.11.3)
201
+ regexp_parser (2.12.0)
202
202
  retries (0.0.5)
203
203
  rexml (3.4.4)
204
- rubocop (1.86.1)
204
+ rubocop (1.87.0)
205
205
  json (~> 2.3)
206
206
  language_server-protocol (~> 3.17.0.2)
207
207
  lint_roller (~> 1.1.0)
@@ -215,6 +215,9 @@ GEM
215
215
  rubocop-ast (1.49.1)
216
216
  parser (>= 3.3.7.2)
217
217
  prism (~> 1.7)
218
+ rubocop-elegant (0.5.1)
219
+ lint_roller (~> 1.1)
220
+ rubocop (~> 1.75)
218
221
  rubocop-minitest (0.39.1)
219
222
  lint_roller (~> 1.1)
220
223
  rubocop (>= 1.75.0, < 2.0)
@@ -248,11 +251,11 @@ GEM
248
251
  memoist3 (~> 1.0.0)
249
252
  win32ole
250
253
  tago (0.7.0)
251
- timeout (0.6.0)
254
+ timeout (0.6.1)
252
255
  total (0.4.2)
253
256
  tsort (0.2.0)
254
- typhoeus (1.4.1)
255
- ethon (>= 0.9.0)
257
+ typhoeus (1.6.0)
258
+ ethon (>= 0.18.0)
256
259
  unicode-display_width (3.2.0)
257
260
  unicode-emoji (~> 4.1)
258
261
  unicode-emoji (4.2.0)
@@ -296,6 +299,7 @@ DEPENDENCIES
296
299
  random-port (~> 0.7)
297
300
  rdoc (= 7.2.0)
298
301
  rubocop (~> 1.74)
302
+ rubocop-elegant (~> 0.5)
299
303
  rubocop-minitest (~> 0.38)
300
304
  rubocop-performance (~> 1.25)
301
305
  rubocop-rake (~> 0.7)
data/README.md CHANGED
@@ -30,9 +30,9 @@ global variables available to it:
30
30
  * `$local` — a hash map that is cleaned up when the execution of
31
31
  a judge is finished;
32
32
  * `$global` — a hash map that is never cleaned up;
33
- * `$judge` — the basename of the directory, where the `.rb` script is located.
34
- * `$epoch` — the time moment when plugin was started
35
- * `$kickoff` — the time moment when a judge was started
33
+ * `$judge` — the basename of the directory, where the `.rb` script is located;
34
+ * `$epoch` — the time moment when the plugin was started;
35
+ * `$kickoff` — the time moment when a judge was started.
36
36
 
37
37
  Every `.yml` file must be formatted as such:
38
38
 
data/Rakefile CHANGED
@@ -5,9 +5,9 @@
5
5
 
6
6
  require 'os'
7
7
  require 'qbash'
8
- require 'rubygems'
9
8
  require 'rake'
10
9
  require 'rake/clean'
10
+ require 'rubygems'
11
11
  require 'shellwords'
12
12
 
13
13
  def name
@@ -3,9 +3,9 @@
3
3
  # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
- require 'tmpdir'
7
6
  require 'English'
8
7
  require 'securerandom'
8
+ require 'tmpdir'
9
9
 
10
10
  Before do
11
11
  @cwd = Dir.pwd
@@ -58,21 +58,21 @@ end
58
58
 
59
59
  Then(/^([a-z].+) contains "([^"]*)"$/) do |file, txt|
60
60
  data = File.read(file)
61
- raise "The file #{file} doesn't contain '#{txt}':\n#{data}" unless data.include?(txt)
61
+ raise(StandardError, "The file #{file} doesn't contain '#{txt}':\n#{data}") unless data.include?(txt)
62
62
  end
63
63
 
64
64
  Then(/^Stdout contains "([^"]*)"$/) do |txt|
65
- raise "STDOUT doesn't contain '#{txt}':\n#{@stdout}" unless @stdout.include?(txt)
65
+ raise(StandardError, "STDOUT doesn't contain '#{txt}':\n#{@stdout}") unless @stdout.include?(txt)
66
66
  end
67
67
 
68
68
  Then(/^Stdout is empty$/) do
69
- raise "STDOUT is not empty:\n#{@stdout}" unless @stdout == ''
69
+ raise(StandardError, "STDOUT is not empty:\n#{@stdout}") unless @stdout == ''
70
70
  end
71
71
 
72
72
  Then(/^Exit code is zero$/) do
73
- raise "Non-zero exit #{@exitstatus}:\n#{@stdout}" unless @exitstatus.zero?
73
+ raise(StandardError, "Non-zero exit #{@exitstatus}:\n#{@stdout}") unless @exitstatus.zero?
74
74
  end
75
75
 
76
76
  Then(/^Exit code is not zero$/) do
77
- raise 'Zero exit code' if @exitstatus.zero?
77
+ raise(StandardError, 'Zero exit code') if @exitstatus.zero?
78
78
  end
@@ -16,9 +16,9 @@ Feature: Test
16
16
  And Exit code is zero
17
17
 
18
18
  Scenario: Factbase version can be set
19
- When I run bin/judges with "--factbase 0.19.9 --verbose test --judge guess ./fixtures"
19
+ When I run bin/judges with "--factbase 0.19.10 --verbose test --judge guess ./fixtures"
20
20
  Then Exit code is zero
21
- And Stdout contains "Factbase version to be used: '0.19.9'"
21
+ And Stdout contains "Factbase version to be used: '0.19.10'"
22
22
 
23
23
  Scenario: Simple test of no judges
24
24
  Given I run bin/judges with "test --judge absent_for_sure ./fixtures"
@@ -2,5 +2,3 @@
2
2
 
3
3
  # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
-
6
- # nothing to do here
data/judges.gemspec CHANGED
@@ -6,10 +6,10 @@
6
6
  require 'English'
7
7
 
8
8
  Gem::Specification.new do |s|
9
- s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
9
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?(:required_rubygems_version=)
10
10
  s.required_ruby_version = '>=3.2'
11
11
  s.name = 'judges'
12
- s.version = '0.60.3'
12
+ s.version = '0.60.4'
13
13
  s.license = 'MIT'
14
14
  s.summary = 'Command-Line Tool for a Factbase'
15
15
  s.description =
@@ -25,23 +25,23 @@ Gem::Specification.new do |s|
25
25
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
26
26
  s.rdoc_options = ['--charset=UTF-8']
27
27
  s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
28
- s.add_dependency 'backtrace', '~>0.4'
29
- s.add_dependency 'baza.rb', '~>0.10'
30
- s.add_dependency 'concurrent-ruby', '~>1.2'
31
- s.add_dependency 'elapsed', '~>0.2'
32
- s.add_dependency 'ellipsized', '~>0.3'
33
- s.add_dependency 'factbase', '~>0.16'
34
- s.add_dependency 'gli', '~>2.21'
35
- s.add_dependency 'iri', '~>0.11'
36
- s.add_dependency 'loog', '~>0.6'
37
- s.add_dependency 'moments', '~>0.3'
38
- s.add_dependency 'nokogiri', '~>1.10'
39
- s.add_dependency 'octokit', '~>10.0'
40
- s.add_dependency 'others', '~>0.1'
41
- s.add_dependency 'retries', '~>0.0'
42
- s.add_dependency 'tago', '~>0.2'
43
- s.add_dependency 'timeout', '~>0.4'
44
- s.add_dependency 'total', '~>0.4'
45
- s.add_dependency 'typhoeus', '~>1.3'
28
+ s.add_dependency('backtrace', '~>0.4')
29
+ s.add_dependency('baza.rb', '~>0.10')
30
+ s.add_dependency('concurrent-ruby', '~>1.2')
31
+ s.add_dependency('elapsed', '~>0.2')
32
+ s.add_dependency('ellipsized', '~>0.3')
33
+ s.add_dependency('factbase', '~>0.16')
34
+ s.add_dependency('gli', '~>2.21')
35
+ s.add_dependency('iri', '~>0.11')
36
+ s.add_dependency('loog', '~>0.6')
37
+ s.add_dependency('moments', '~>0.3')
38
+ s.add_dependency('nokogiri', '~>1.10')
39
+ s.add_dependency('octokit', '~>10.0')
40
+ s.add_dependency('others', '~>0.1')
41
+ s.add_dependency('retries', '~>0.0')
42
+ s.add_dependency('tago', '~>0.2')
43
+ s.add_dependency('timeout', '~>0.4')
44
+ s.add_dependency('total', '~>0.4')
45
+ s.add_dependency('typhoeus', '~>1.3')
46
46
  s.metadata['rubygems_mfa_required'] = 'true'
47
47
  end
@@ -14,7 +14,6 @@ require_relative '../judges'
14
14
  # Copyright:: Copyright (c) 2024-2026 Yegor Bugayenko
15
15
  # License:: MIT
16
16
  class Judges::AsciiLoog
17
- # Unicode to ASCII symbol mapping
18
17
  UNICODE_TO_ASCII = {
19
18
  '👍' => '+',
20
19
  '👎' => '-',
@@ -78,7 +77,7 @@ class Judges::AsciiLoog
78
77
 
79
78
  # Delegate all other methods to the original logger.
80
79
  def method_missing(method, *, &)
81
- @loog.send(method, *, &)
80
+ @loog.public_send(method, *, &)
82
81
  end
83
82
 
84
83
  # Check if the original logger responds to a method.
@@ -3,15 +3,15 @@
3
3
  # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
- require 'typhoeus'
7
- require 'iri'
8
6
  require 'baza-rb'
9
7
  require 'elapsed'
8
+ require 'iri'
9
+ require 'typhoeus'
10
10
  require_relative '../../judges'
11
11
 
12
12
  # The +download+ command.
13
13
  #
14
- # This class is instantiated by the +bin/judge+ command line interface. You
14
+ # This class is instantiated by the +bin/judges+ command line interface. You
15
15
  # are not supposed to instantiate it yourself.
16
16
  #
17
17
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -29,7 +29,7 @@ class Judges::Download
29
29
  # @param [Array] args List of command line arguments
30
30
  # @raise [RuntimeError] If not exactly two arguments provided
31
31
  def run(opts, args)
32
- raise 'Exactly two arguments required' unless args.size == 2
32
+ raise(ArgumentError, 'Exactly two arguments required') unless args.size == 2
33
33
  jname = args[0]
34
34
  path = args[1]
35
35
  name = File.basename(path)
@@ -50,8 +50,7 @@ class Judges::Download
50
50
  baza.durable_lock(id, opts['owner'] || 'default')
51
51
  begin
52
52
  baza.durable_load(id, path)
53
- size = File.size(path)
54
- throw :"👍 Downloaded durable ##{id} to #{path} (#{size} bytes)"
53
+ throw(:"👍 Downloaded durable ##{id} to #{path} (#{File.size(path)} bytes)")
55
54
  ensure
56
55
  baza.durable_unlock(id, opts['owner'] || 'default')
57
56
  end
@@ -9,7 +9,7 @@ require_relative '../../judges/impex'
9
9
 
10
10
  # The +eval+ command.
11
11
  #
12
- # This class is instantiated by the +bin/judge+ command line interface. You
12
+ # This class is instantiated by the +bin/judges+ command line interface. You
13
13
  # are not supposed to instantiate it yourself.
14
14
  #
15
15
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -27,20 +27,19 @@ class Judges::Eval
27
27
  # @param [Array] args List of command line arguments
28
28
  # @raise [RuntimeError] If not exactly two arguments provided
29
29
  def run(opts, args)
30
- raise 'Exactly two arguments required' unless args.size == 2
30
+ raise(ArgumentError, 'Exactly two arguments required') unless args.size == 2
31
31
  impex = Judges::Impex.new(@loog, args[0])
32
32
  elapsed(@loog, level: Logger::INFO) do
33
33
  $fb = impex.import(strict: false)
34
34
  if opts['log']
35
- require 'factbase/logged'
35
+ require('factbase/logged')
36
36
  $fb = Factbase::Logged.new($fb, @loog)
37
37
  end
38
- expr = args[1]
39
38
  # rubocop:disable Security/Eval
40
- eval(expr)
39
+ eval(args[1])
41
40
  # rubocop:enable Security/Eval
42
41
  impex.export($fb)
43
- throw :'👍 Evaluated successfully'
42
+ throw(:'👍 Evaluated successfully')
44
43
  end
45
44
  end
46
45
  end
@@ -11,7 +11,7 @@ require_relative '../../judges/to_rel'
11
11
 
12
12
  # The +import+ command.
13
13
  #
14
- # This class is instantiated by the +bin/judge+ command line interface. You
14
+ # This class is instantiated by the +bin/judges+ command line interface. You
15
15
  # are not supposed to instantiate it yourself.
16
16
  #
17
17
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -29,25 +29,25 @@ class Judges::Import
29
29
  # @param [Array] args List of command line arguments
30
30
  # @raise [RuntimeError] If not exactly two arguments provided or file not found
31
31
  def run(opts, args)
32
- raise 'Exactly two arguments required' unless args.size == 2
33
- raise "File not found #{args[0].to_rel}" unless File.exist?(args[0])
32
+ raise(ArgumentError, 'Exactly two arguments required') unless args.size == 2
33
+ raise(StandardError, "File not found #{args[0].to_rel}") unless File.exist?(args[0])
34
34
  elapsed(@loog, level: Logger::INFO) do
35
35
  yaml = YAML.load_file(args[0], permitted_classes: [Time])
36
36
  @loog.info("YAML loaded from #{args[0].to_rel} (#{yaml.size} facts)")
37
37
  impex = Judges::Impex.new(@loog, args[1])
38
38
  fb = impex.import(strict: false)
39
39
  if opts['log']
40
- require 'factbase/logged'
40
+ require('factbase/logged')
41
41
  fb = Factbase::Logged.new(fb, @loog)
42
42
  end
43
43
  yaml.each do |i|
44
44
  f = fb.insert
45
45
  i.each do |p, v|
46
- f.send(:"#{p}=", v)
46
+ f.public_send(:"#{p}=", v)
47
47
  end
48
48
  end
49
49
  impex.export(fb)
50
- throw :"👍 Import of #{yaml.size} facts completed"
50
+ throw(:"👍 Import of #{yaml.size} facts completed")
51
51
  end
52
52
  end
53
53
  end
@@ -9,7 +9,7 @@ require_relative '../../judges/impex'
9
9
 
10
10
  # The +inspect+ command.
11
11
  #
12
- # This class is instantiated by the +bin/judge+ command line interface. You
12
+ # This class is instantiated by the +bin/judges+ command line interface. You
13
13
  # are not supposed to instantiate it yourself.
14
14
  #
15
15
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -27,7 +27,7 @@ class Judges::Inspect
27
27
  # @param [Array] args List of command line arguments
28
28
  # @raise [RuntimeError] If no arguments provided
29
29
  def run(_opts, args)
30
- raise 'At least one argument required' if args.empty?
30
+ raise(ArgumentError, 'At least one argument required') if args.empty?
31
31
  fb = Judges::Impex.new(@loog, args[0]).import
32
32
  @loog.info("Facts: #{fb.size}")
33
33
  sum = fb.query('(eq what "judges-summary")').each.to_a
@@ -9,7 +9,7 @@ require_relative '../../judges/impex'
9
9
 
10
10
  # The +join+ command.
11
11
  #
12
- # This class is instantiated by the +bin/judge+ command line interface. You
12
+ # This class is instantiated by the +bin/judges+ command line interface. You
13
13
  # are not supposed to instantiate it yourself.
14
14
  #
15
15
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -27,14 +27,14 @@ class Judges::Join
27
27
  # @param [Array] args List of command line arguments
28
28
  # @raise [RuntimeError] If not exactly two arguments provided
29
29
  def run(_opts, args)
30
- raise 'Exactly two arguments required' unless args.size == 2
30
+ raise(ArgumentError, 'Exactly two arguments required') unless args.size == 2
31
31
  master = Judges::Impex.new(@loog, args[0])
32
32
  slave = Judges::Impex.new(@loog, args[1])
33
33
  elapsed(@loog, level: Logger::INFO) do
34
34
  fb = master.import
35
35
  slave.import_to(fb)
36
36
  master.export(fb)
37
- throw :'👍 Two factbases joined successfully'
37
+ throw(:'👍 Two factbases joined successfully')
38
38
  end
39
39
  end
40
40
  end
@@ -16,7 +16,7 @@ require_relative '../../judges/impex'
16
16
 
17
17
  # The +print+ command.
18
18
  #
19
- # This class is instantiated by the +bin/judge+ command line interface. You
19
+ # This class is instantiated by the +bin/judges+ command line interface. You
20
20
  # are not supposed to instantiate it yourself.
21
21
  #
22
22
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -33,15 +33,16 @@ class Judges::Print
33
33
  # @param [Hash] opts Command line options (start with '--')
34
34
  # @param [Array] args List of command line arguments
35
35
  # @raise [RuntimeError] If no arguments provided
36
+ # rubocop:disable Metrics/MethodLength
36
37
  def run(opts, args)
37
- raise 'At least one argument required' if args.empty?
38
+ raise(ArgumentError, 'At least one argument required') if args.empty?
38
39
  f = args[0]
39
40
  fb = Judges::Impex.new(@loog, f).import
40
41
  fb.query("(not #{opts['query']})").delete! unless opts['query'].nil?
41
42
  o = args[1]
42
43
  fmt = opts['format']&.downcase
43
44
  if o.nil?
44
- raise 'Either provide output file name or use --auto' unless opts['auto']
45
+ raise(ArgumentError, 'Either provide output file name or use --auto') unless opts['auto']
45
46
  o = File.join(File.dirname(f), File.basename(f).gsub(/\.[^.]*$/, ''))
46
47
  o = "#{o}.#{fmt}"
47
48
  end
@@ -54,35 +55,35 @@ class Judges::Print
54
55
  @loog.debug("The factbase #{f.to_rel} is younger than the target #{o.to_rel}, need to print")
55
56
  end
56
57
  elapsed(@loog, level: Logger::INFO) do
57
- output =
58
+ File.binwrite(
59
+ o,
58
60
  case fmt
59
61
  when 'yaml'
60
- require 'factbase/to_yaml'
62
+ require('factbase/to_yaml')
61
63
  Factbase::ToYAML.new(fb).yaml
62
64
  when 'json'
63
- require 'factbase/to_json'
65
+ require('factbase/to_json')
64
66
  Factbase::ToJSON.new(fb).json
65
67
  when 'xml'
66
- require 'factbase/to_xml'
68
+ require('factbase/to_xml')
67
69
  Factbase::ToXML.new(fb).xml
68
70
  when 'html'
69
71
  to_html(opts, fb)
70
72
  else
71
- raise "Unknown format '#{fmt}'"
73
+ raise(StandardError, "Unknown format '#{fmt}'")
72
74
  end
73
- File.binwrite(o, output)
74
- throw :"👍 Factbase printed to #{o.to_rel} (#{File.size(o)} bytes)"
75
+ )
76
+ throw(:"👍 Factbase printed to #{o.to_rel} (#{File.size(o)} bytes)")
75
77
  end
76
78
  end
79
+ # rubocop:enable Metrics/MethodLength
77
80
 
78
81
  private
79
82
 
80
83
  def to_html(opts, fb)
81
- xslt = Nokogiri::XSLT(File.read(File.join(__dir__, '../../../assets/index.xsl')))
82
- require 'factbase/to_xml'
83
- xml = Factbase::ToXML.new(fb).xml
84
- xslt.apply_to(
85
- Nokogiri::XML(xml),
84
+ require('factbase/to_xml')
85
+ Nokogiri::XSLT(File.read(File.join(__dir__, '../../../assets/index.xsl'))).apply_to(
86
+ Nokogiri::XML(Factbase::ToXML.new(fb).xml),
86
87
  Nokogiri::XSLT.quote_params(
87
88
  'title' => opts['title'],
88
89
  'date' => Time.now.utc.iso8601,
@@ -102,10 +103,9 @@ class Judges::Print
102
103
  url = "https://yegor256.github.io/judges/assets/#{asset}"
103
104
  http = Typhoeus::Request.get(url)
104
105
  return "Timeout at #{url.inspect}" if http.timed_out?
105
- raise "Failed to load #{url.inspect}" unless http.code == 200
106
- sha = Base64.strict_encode64(Digest::SHA256.digest(http.body))
107
- "sha256-#{sha}"
108
- rescue RuntimeError => e
106
+ raise(StandardError, "Failed to load #{url.inspect}") unless http.code == 200
107
+ "sha256-#{Base64.strict_encode64(Digest::SHA256.digest(http.body))}"
108
+ rescue StandardError => e
109
109
  e.message
110
110
  end
111
111
  end