judges 0.42.0 → 0.42.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 +4 -4
- data/.github/workflows/typos.yml +19 -0
- data/.gitignore +2 -2
- data/Gemfile.lock +10 -9
- data/README.md +3 -3
- data/REUSE.toml +7 -7
- data/features/test.feature +2 -2
- data/judges.gemspec +1 -1
- data/lib/judges/commands/eval.rb +6 -0
- data/lib/judges/commands/import.rb +6 -0
- data/lib/judges/commands/inspect.rb +6 -0
- data/lib/judges/commands/join.rb +6 -0
- data/lib/judges/commands/print.rb +2 -0
- data/lib/judges/commands/pull.rb +2 -0
- data/lib/judges/commands/push.rb +2 -0
- data/lib/judges/commands/test.rb +6 -4
- data/lib/judges/commands/trim.rb +2 -0
- data/lib/judges/commands/update.rb +3 -1
- data/lib/judges/impex.rb +11 -0
- data/lib/judges/judges.rb +16 -5
- data/lib/judges/options.rb +7 -0
- data/lib/judges/to_rel.rb +1 -0
- data/lib/judges.rb +1 -1
- data/package-lock.json +1292 -407
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08d3de03e1b95604d047cef9fc57b854df50472735347fa9eefdb760ade40b2f'
|
4
|
+
data.tar.gz: cfabae3261cdbbfe3a0960f30bde15705c2934f9acbba96032832fb88b1e69d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83c656135bbaae9ee295b8022ec3a6105fb2be8f9fecbac23cb28c1402d72260ae03872eb887fbe1224a989e7bf41512724b01d3687a9c78673757ded36927f3
|
7
|
+
data.tar.gz: 11df07fc1c6049286aaac01f7af3c3fe6dc75cad176b3907dd2cb006f7ecc9936ea49b43949143874e42a7590fbc08662eec4f8013b792e808ee0be6736923da
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
3
|
+
---
|
4
|
+
# yamllint disable rule:line-length
|
5
|
+
name: typos
|
6
|
+
'on':
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
pull_request:
|
11
|
+
branches:
|
12
|
+
- master
|
13
|
+
jobs:
|
14
|
+
typos:
|
15
|
+
timeout-minutes: 15
|
16
|
+
runs-on: ubuntu-24.04
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
- uses: crate-ci/typos@v1.32.0
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -73,14 +73,14 @@ GEM
|
|
73
73
|
cucumber-tag-expressions (6.1.2)
|
74
74
|
date (3.4.1)
|
75
75
|
decoor (0.0.1)
|
76
|
-
diff-lcs (1.6.
|
76
|
+
diff-lcs (1.6.2)
|
77
77
|
docile (1.4.1)
|
78
78
|
elapsed (0.0.1)
|
79
79
|
loog (> 0)
|
80
80
|
tago (> 0)
|
81
81
|
ethon (0.16.0)
|
82
82
|
ffi (>= 1.15.0)
|
83
|
-
factbase (0.10.
|
83
|
+
factbase (0.10.2)
|
84
84
|
backtrace (~> 0.4)
|
85
85
|
decoor (~> 0.0)
|
86
86
|
json (~> 2.7)
|
@@ -113,13 +113,14 @@ GEM
|
|
113
113
|
ostruct
|
114
114
|
hashdiff (1.1.2)
|
115
115
|
iri (0.10.0)
|
116
|
-
json (2.
|
117
|
-
language_server-protocol (3.17.0.
|
116
|
+
json (2.12.0)
|
117
|
+
language_server-protocol (3.17.0.5)
|
118
118
|
lint_roller (1.1.0)
|
119
119
|
logger (1.7.0)
|
120
|
-
loog (0.6.
|
120
|
+
loog (0.6.1)
|
121
|
+
logger (~> 1.0)
|
121
122
|
mini_mime (1.1.5)
|
122
|
-
mini_portile2 (2.8.
|
123
|
+
mini_portile2 (2.8.9)
|
123
124
|
minitest (5.25.5)
|
124
125
|
minitest-reporters (1.7.1)
|
125
126
|
ansi
|
@@ -157,11 +158,11 @@ GEM
|
|
157
158
|
ast (~> 2.4.1)
|
158
159
|
racc
|
159
160
|
prism (1.4.0)
|
160
|
-
psych (5.2.
|
161
|
+
psych (5.2.6)
|
161
162
|
date
|
162
163
|
stringio
|
163
164
|
public_suffix (6.0.2)
|
164
|
-
qbash (0.4.
|
165
|
+
qbash (0.4.5)
|
165
166
|
backtrace (> 0)
|
166
167
|
elapsed (> 0)
|
167
168
|
loog (> 0)
|
@@ -176,7 +177,7 @@ GEM
|
|
176
177
|
regexp_parser (2.10.0)
|
177
178
|
retries (0.0.5)
|
178
179
|
rexml (3.4.1)
|
179
|
-
rubocop (1.75.
|
180
|
+
rubocop (1.75.6)
|
180
181
|
json (~> 2.3)
|
181
182
|
language_server-protocol (~> 3.17.0.2)
|
182
183
|
lint_roller (~> 1.1.0)
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
[](https://github.com/yegor256/judges/blob/master/LICENSE.txt)
|
13
13
|
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fyegor256%2Fjudges?ref=badge_shield&issueType=license)
|
14
14
|
|
15
|
-
A command line tool and a Ruby gem for running so
|
15
|
+
A command line tool and a Ruby gem for running so-called judges against a
|
16
16
|
[factbase](https://github.com/yegor256/factbase).
|
17
17
|
|
18
18
|
Every "judge" is a directory with a single `.rb` file and a number
|
@@ -64,10 +64,10 @@ via the command line `--option` flag of the `update` command; and `expected` is
|
|
64
64
|
an array of XPath expressions that must be present in the XML of the Factbase
|
65
65
|
when the test is finished.
|
66
66
|
|
67
|
-
The `category` (default: `[]`) may have one or an array of categories,
|
67
|
+
The `category` (default: `[]`) may have one category or an array of categories,
|
68
68
|
which then may be turned on via the `--category` command line flag.
|
69
69
|
|
70
|
-
The `repeat` (default: `1`) makes `input` to be repeated multiple times
|
70
|
+
The `repeat` (default: `1`) makes the `input` to be repeated multiple times
|
71
71
|
(mostly useful for speed measuring on big data inputs).
|
72
72
|
|
73
73
|
The `runs` (default: `1`) is the number of times the `.rb` script should
|
data/REUSE.toml
CHANGED
@@ -4,10 +4,17 @@
|
|
4
4
|
version = 1
|
5
5
|
[[annotations]]
|
6
6
|
path = [
|
7
|
+
".DS_Store",
|
8
|
+
".gitattributes",
|
9
|
+
".gitignore",
|
10
|
+
".pdd",
|
7
11
|
"**.json",
|
8
12
|
"**.md",
|
9
13
|
"**.png",
|
10
14
|
"**.txt",
|
15
|
+
"**/.DS_Store",
|
16
|
+
"**/.gitignore",
|
17
|
+
"**/.pdd",
|
11
18
|
"**/*.csv",
|
12
19
|
"**/*.jpg",
|
13
20
|
"**/*.json",
|
@@ -17,15 +24,8 @@ path = [
|
|
17
24
|
"**/*.svg",
|
18
25
|
"**/*.txt",
|
19
26
|
"**/*.vm",
|
20
|
-
"**/.DS_Store",
|
21
|
-
"**/.gitignore",
|
22
|
-
"**/.pdd",
|
23
27
|
"**/CNAME",
|
24
28
|
"**/Gemfile.lock",
|
25
|
-
".DS_Store",
|
26
|
-
".gitattributes",
|
27
|
-
".gitignore",
|
28
|
-
".pdd",
|
29
29
|
"Gemfile.lock",
|
30
30
|
"README.md",
|
31
31
|
"renovate.json",
|
data/features/test.feature
CHANGED
@@ -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.10.
|
19
|
+
When I run bin/judges with "--factbase 0.10.2 --verbose test --judge guess ./fixtures"
|
20
20
|
Then Exit code is zero
|
21
|
-
And Stdout contains "Factbase version to be used: '0.10.
|
21
|
+
And Stdout contains "Factbase version to be used: '0.10.2'"
|
22
22
|
|
23
23
|
Scenario: Simple test of no judges
|
24
24
|
Given I run bin/judges with "test --judge absent_for_sure ./fixtures"
|
data/judges.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
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.42.
|
12
|
+
s.version = '0.42.1'
|
13
13
|
s.license = 'MIT'
|
14
14
|
s.summary = 'Command-Line Tool for a Factbase'
|
15
15
|
s.description =
|
data/lib/judges/commands/eval.rb
CHANGED
@@ -16,10 +16,16 @@ require_relative '../../judges/impex'
|
|
16
16
|
# Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
|
17
17
|
# License:: MIT
|
18
18
|
class Judges::Eval
|
19
|
+
# Initialize.
|
20
|
+
# @param [Loog] loog Logging facility
|
19
21
|
def initialize(loog)
|
20
22
|
@loog = loog
|
21
23
|
end
|
22
24
|
|
25
|
+
# Run the eval command.
|
26
|
+
# @param [Hash] opts Command line options (start with '--')
|
27
|
+
# @param [Array] args List of command line arguments
|
28
|
+
# @raise [RuntimeError] If not exactly two arguments provided
|
23
29
|
def run(opts, args)
|
24
30
|
raise 'Exactly two arguments required' unless args.size == 2
|
25
31
|
impex = Judges::Impex.new(@loog, args[0])
|
@@ -18,10 +18,16 @@ require_relative '../../judges/to_rel'
|
|
18
18
|
# Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
|
19
19
|
# License:: MIT
|
20
20
|
class Judges::Import
|
21
|
+
# Initialize.
|
22
|
+
# @param [Loog] loog Logging facility
|
21
23
|
def initialize(loog)
|
22
24
|
@loog = loog
|
23
25
|
end
|
24
26
|
|
27
|
+
# Run the import command.
|
28
|
+
# @param [Hash] opts Command line options (start with '--')
|
29
|
+
# @param [Array] args List of command line arguments
|
30
|
+
# @raise [RuntimeError] If not exactly two arguments provided or file not found
|
25
31
|
def run(opts, args)
|
26
32
|
raise 'Exactly two arguments required' unless args.size == 2
|
27
33
|
raise "File not found #{args[0].to_rel}" unless File.exist?(args[0])
|
@@ -15,10 +15,16 @@ require_relative '../../judges/impex'
|
|
15
15
|
# Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
|
16
16
|
# License:: MIT
|
17
17
|
class Judges::Inspect
|
18
|
+
# Initialize.
|
19
|
+
# @param [Loog] loog Logging facility
|
18
20
|
def initialize(loog)
|
19
21
|
@loog = loog
|
20
22
|
end
|
21
23
|
|
24
|
+
# Run the inspect command.
|
25
|
+
# @param [Hash] _opts Command line options (not used)
|
26
|
+
# @param [Array] args List of command line arguments
|
27
|
+
# @raise [RuntimeError] If no arguments provided
|
22
28
|
def run(_opts, args)
|
23
29
|
raise 'At lease one argument required' if args.empty?
|
24
30
|
fb = Judges::Impex.new(@loog, args[0]).import
|
data/lib/judges/commands/join.rb
CHANGED
@@ -16,10 +16,16 @@ require_relative '../../judges/impex'
|
|
16
16
|
# Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
|
17
17
|
# License:: MIT
|
18
18
|
class Judges::Join
|
19
|
+
# Initialize.
|
20
|
+
# @param [Loog] loog Logging facility
|
19
21
|
def initialize(loog)
|
20
22
|
@loog = loog
|
21
23
|
end
|
22
24
|
|
25
|
+
# Run the join command.
|
26
|
+
# @param [Hash] _opts Command line options (not used)
|
27
|
+
# @param [Array] args List of command line arguments
|
28
|
+
# @raise [RuntimeError] If not exactly two arguments provided
|
23
29
|
def run(_opts, args)
|
24
30
|
raise 'Exactly two arguments required' unless args.size == 2
|
25
31
|
master = Judges::Impex.new(@loog, args[0])
|
data/lib/judges/commands/pull.rb
CHANGED
data/lib/judges/commands/push.rb
CHANGED
data/lib/judges/commands/test.rb
CHANGED
@@ -23,6 +23,8 @@ require_relative '../../judges/categories'
|
|
23
23
|
# Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
|
24
24
|
# License:: MIT
|
25
25
|
class Judges::Test
|
26
|
+
# Initialize.
|
27
|
+
# @param [Loog] loog Logging facility
|
26
28
|
def initialize(loog)
|
27
29
|
@loog = loog
|
28
30
|
end
|
@@ -51,11 +53,11 @@ class Judges::Test
|
|
51
53
|
next unless include?(opts, judge.name, tname)
|
52
54
|
yaml = YAML.load_file(f, permitted_classes: [Time])
|
53
55
|
if yaml['skip']
|
54
|
-
@loog.info("
|
56
|
+
@loog.info("Skipped #{f.to_rel}")
|
55
57
|
next
|
56
58
|
end
|
57
59
|
unless Judges::Categories.new(opts['enable'], opts['disable']).ok?(yaml['category'])
|
58
|
-
@loog.info("
|
60
|
+
@loog.info("Skipped #{f.to_rel} because of its category")
|
59
61
|
next
|
60
62
|
end
|
61
63
|
@loog.info("🛠️ Testing #{f.to_rel}:")
|
@@ -122,8 +124,8 @@ class Judges::Test
|
|
122
124
|
def include?(opts, name, tname = nil)
|
123
125
|
judges = opts['judge'] || []
|
124
126
|
return true if judges.empty?
|
125
|
-
|
126
|
-
judges.any? { |n| n.match?(%r{^#{name}(/#{
|
127
|
+
re = tname.nil? ? '.+' : tname
|
128
|
+
judges.any? { |n| n.match?(%r{^#{name}(/#{re})?$}) }
|
127
129
|
end
|
128
130
|
|
129
131
|
def prepare(fb, yaml)
|
data/lib/judges/commands/trim.rb
CHANGED
@@ -26,6 +26,8 @@ require_relative '../../judges/to_rel'
|
|
26
26
|
# Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
|
27
27
|
# License:: MIT
|
28
28
|
class Judges::Update
|
29
|
+
# Initialize.
|
30
|
+
# @param [Loog] loog Logging facility
|
29
31
|
def initialize(loog)
|
30
32
|
@loog = loog
|
31
33
|
@start = Time.now
|
@@ -94,7 +96,7 @@ class Judges::Update
|
|
94
96
|
# @param [Factbase] fb The factbase
|
95
97
|
# @param [Churn] churn The churn
|
96
98
|
# @param [Array<String>] errors List of errors
|
97
|
-
# @param [Time] start
|
99
|
+
# @param [Time] start When we started
|
98
100
|
# @param [Integer] cycles How many cycles
|
99
101
|
def summarize(fb, churn, errors, start, cycles)
|
100
102
|
before = fb.query('(eq what "judges-summary")').each.to_a
|
data/lib/judges/impex.rb
CHANGED
@@ -14,11 +14,17 @@ require_relative '../judges/to_rel'
|
|
14
14
|
# Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
|
15
15
|
# License:: MIT
|
16
16
|
class Judges::Impex
|
17
|
+
# Initialize.
|
18
|
+
# @param [Loog] loog Logging facility
|
19
|
+
# @param [String] file File path for import/export operations
|
17
20
|
def initialize(loog, file)
|
18
21
|
@loog = loog
|
19
22
|
@file = file
|
20
23
|
end
|
21
24
|
|
25
|
+
# Import factbase from file.
|
26
|
+
# @param [Boolean] strict Whether to raise error if file doesn't exist
|
27
|
+
# @return [Factbase] The imported factbase
|
22
28
|
def import(strict: true)
|
23
29
|
fb = Factbase.new
|
24
30
|
if File.exist?(@file)
|
@@ -33,6 +39,9 @@ class Judges::Impex
|
|
33
39
|
fb
|
34
40
|
end
|
35
41
|
|
42
|
+
# Import factbase from file into existing factbase.
|
43
|
+
# @param [Factbase] fb The factbase to import into
|
44
|
+
# @raise [RuntimeError] If file doesn't exist
|
36
45
|
def import_to(fb)
|
37
46
|
raise "The factbase is absent at #{@file.to_rel}" unless File.exist?(@file)
|
38
47
|
elapsed(@loog, level: Logger::INFO) do
|
@@ -41,6 +50,8 @@ class Judges::Impex
|
|
41
50
|
end
|
42
51
|
end
|
43
52
|
|
53
|
+
# Export factbase to file.
|
54
|
+
# @param [Factbase] fb The factbase to export
|
44
55
|
def export(fb)
|
45
56
|
elapsed(@loog, level: Logger::INFO) do
|
46
57
|
FileUtils.mkdir_p(File.dirname(@file))
|
data/lib/judges/judges.rb
CHANGED
@@ -26,6 +26,13 @@ require_relative 'judge'
|
|
26
26
|
# Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
|
27
27
|
# License:: MIT
|
28
28
|
class Judges::Judges
|
29
|
+
# Initialize.
|
30
|
+
# @param [String] dir Directory containing judges
|
31
|
+
# @param [String] lib Library directory
|
32
|
+
# @param [Loog] loog Logging facility
|
33
|
+
# @param [Time] start Start time
|
34
|
+
# @param [String] shuffle Prefix for names of judges to shuffle
|
35
|
+
# @param [Array<String>] boost Names of judges to boost in priority
|
29
36
|
def initialize(dir, lib, loog, start: Time.now, shuffle: '', boost: [])
|
30
37
|
@dir = dir
|
31
38
|
@lib = lib
|
@@ -36,15 +43,18 @@ class Judges::Judges
|
|
36
43
|
end
|
37
44
|
|
38
45
|
# Get one judge by name.
|
39
|
-
# @
|
46
|
+
# @param [String] name The name of the judge
|
47
|
+
# @return [Judge] The judge object
|
48
|
+
# @raise [RuntimeError] If judge doesn't exist
|
40
49
|
def get(name)
|
41
50
|
d = File.absolute_path(File.join(@dir, name))
|
42
51
|
raise "Judge #{name} doesn't exist in #{@dir}" unless File.exist?(d)
|
43
52
|
Judges::Judge.new(d, @lib, @loog, start: @start)
|
44
53
|
end
|
45
54
|
|
46
|
-
# Iterate over
|
47
|
-
# @yield [Judge]
|
55
|
+
# Iterate over all judges.
|
56
|
+
# @yield [Judge] Yields each judge
|
57
|
+
# @return [Enumerator] If no block given
|
48
58
|
def each(&)
|
49
59
|
return to_enum(__method__) unless block_given?
|
50
60
|
list =
|
@@ -77,8 +87,9 @@ class Judges::Judges
|
|
77
87
|
ret.each(&)
|
78
88
|
end
|
79
89
|
|
80
|
-
# Iterate over
|
81
|
-
# @yield [
|
90
|
+
# Iterate over all judges with index.
|
91
|
+
# @yield [Judge, Integer] Yields each judge with its index
|
92
|
+
# @return [Integer] The total count of judges
|
82
93
|
def each_with_index
|
83
94
|
idx = 0
|
84
95
|
each do |p|
|
data/lib/judges/options.rb
CHANGED
@@ -17,10 +17,15 @@ class Judges::Options
|
|
17
17
|
@pairs = pairs
|
18
18
|
end
|
19
19
|
|
20
|
+
# Check if options are empty.
|
21
|
+
# @return [Boolean] true if no options are set
|
20
22
|
def empty?
|
21
23
|
to_h.empty?
|
22
24
|
end
|
23
25
|
|
26
|
+
# Merge with another Options object.
|
27
|
+
# @param [Judges::Options] other The other options to merge
|
28
|
+
# @return [Judges::Options] A new Options object with merged values
|
24
29
|
def +(other)
|
25
30
|
h = to_h
|
26
31
|
other.to_h.each do |k, v|
|
@@ -38,6 +43,8 @@ class Judges::Options
|
|
38
43
|
end.sort.join("\n")
|
39
44
|
end
|
40
45
|
|
46
|
+
# Convert options to hash.
|
47
|
+
# @return [Hash] The options as a hash with symbol keys
|
41
48
|
def to_h
|
42
49
|
@to_h ||=
|
43
50
|
begin
|
data/lib/judges/to_rel.rb
CHANGED
@@ -11,6 +11,7 @@ require 'pathname'
|
|
11
11
|
# License:: MIT
|
12
12
|
class Object
|
13
13
|
# Generates a relative name of a file (to the current dir).
|
14
|
+
# @return [String] Relative path to the file with optional quotes if it contains spaces
|
14
15
|
def to_rel
|
15
16
|
s = File.absolute_path(to_s)
|
16
17
|
p = Pathname.new(s).relative_path_from(Dir.getwd)
|
data/lib/judges.rb
CHANGED