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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af0d2479c169453b9879f770a4dffbe7530f15665941200658d9255490a36db8
4
- data.tar.gz: 99aa6fe32517235bae4c0a8841658e40cf41d589b75bf1da1f160c12a27a5452
3
+ metadata.gz: '08d3de03e1b95604d047cef9fc57b854df50472735347fa9eefdb760ade40b2f'
4
+ data.tar.gz: cfabae3261cdbbfe3a0960f30bde15705c2934f9acbba96032832fb88b1e69d1
5
5
  SHA512:
6
- metadata.gz: 339dd1173c591e66b517c1665fef77e9c279f9286364abc964ef725275857f90d973cdedf7895da3ba25b48a07e1d71a532b0d7dd193f967490a67c9263c19a5
7
- data.tar.gz: 24b25cd92ef031e7459aa5c12f77a4ac88359795a58c878d387840e5ce94f4a011f624db305104c95a867c7397b6fb0c17e6fede0d9ccacfbdc71637cc583cd7
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
@@ -1,8 +1,8 @@
1
- *.gem
2
- .DS_Store
3
1
  .bundle/
2
+ .DS_Store
4
3
  .idea/
5
4
  .yardoc/
5
+ *.gem
6
6
  coverage/
7
7
  doc/
8
8
  node_modules/
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.1)
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.1)
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.11.3)
117
- language_server-protocol (3.17.0.4)
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.0)
120
+ loog (0.6.1)
121
+ logger (~> 1.0)
121
122
  mini_mime (1.1.5)
122
- mini_portile2 (2.8.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.3)
161
+ psych (5.2.6)
161
162
  date
162
163
  stringio
163
164
  public_suffix (6.0.2)
164
- qbash (0.4.0)
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.4)
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
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/judges/blob/master/LICENSE.txt)
13
13
  [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fyegor256%2Fjudges.svg?type=shield&issueType=license)](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 called judges against a
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",
@@ -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.1 --verbose test --judge guess ./fixtures"
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.1'"
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.0'
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 =
@@ -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
@@ -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])
@@ -23,6 +23,8 @@ require_relative '../../judges/impex'
23
23
  # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  class Judges::Print
26
+ # Initialize.
27
+ # @param [Loog] loog Logging facility
26
28
  def initialize(loog)
27
29
  @loog = loog
28
30
  end
@@ -19,6 +19,8 @@ require_relative '../../judges/impex'
19
19
  # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
20
20
  # License:: MIT
21
21
  class Judges::Pull
22
+ # Initialize.
23
+ # @param [Loog] loog Logging facility
22
24
  def initialize(loog)
23
25
  @loog = loog
24
26
  end
@@ -19,6 +19,8 @@ require_relative '../../judges/impex'
19
19
  # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
20
20
  # License:: MIT
21
21
  class Judges::Push
22
+ # Initialize.
23
+ # @param [Loog] loog Logging facility
22
24
  def initialize(loog)
23
25
  @loog = loog
24
26
  end
@@ -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("Skippped #{f.to_rel}")
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("Skippped #{f.to_rel} because of its category")
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
- tre = tname.nil? ? '.+' : tname
126
- judges.any? { |n| n.match?(%r{^#{name}(/#{tre})?$}) }
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)
@@ -17,6 +17,8 @@ require_relative '../../judges/impex'
17
17
  # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
18
18
  # License:: MIT
19
19
  class Judges::Trim
20
+ # Initialize.
21
+ # @param [Loog] loog Logging facility
20
22
  def initialize(loog)
21
23
  @loog = loog
22
24
  end
@@ -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 Whe we started
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
- # @return [Judge]
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 them all.
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 them all, with an index.
81
- # @yield [(Judge, Integer)]
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|
@@ -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
@@ -8,5 +8,5 @@
8
8
  # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
9
9
  # License:: MIT
10
10
  module Judges
11
- VERSION = '0.42.0' unless const_defined?(:VERSION)
11
+ VERSION = '0.42.1' unless const_defined?(:VERSION)
12
12
  end