judges 0.38.0 → 0.38.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: 404a87a09b8eea92b27df18a4142207bc8f37ffbfe298fb3517aecffb78b9e78
4
- data.tar.gz: d4a29a3870b5ac2c1737f3c5659812d41596bec90b63fa567f50852477f47b5e
3
+ metadata.gz: 353058d96072ebe04e9e5f71c51be5905e113e6af9406eb8ad1c05eb61b72921
4
+ data.tar.gz: 04df0fe98d3933ca745928b3cf4802145393b2ea734635d0dff2ba1c96e96213
5
5
  SHA512:
6
- metadata.gz: 5aed5acd2b705a2d1774b56abfd912491637c714a3e811e7bf50568229fa59d310a96b74f8992794c3858321b5ae2326160696662c568472d8a59364000a3b3f
7
- data.tar.gz: 58a3bd4ce7094843409ff4cc50f23a9e9f48964afd95da8307b04c1680ffccdc0606c034a292e7427ea5c31345d617123aa44d660d10e77ca93c90ef029be80f
6
+ metadata.gz: ec6197e9fb2109bce6adf440aa3b770b0e8bc09117c8002f7e1c931f7759d6127161bba8d91e2cd8602ca98fb94309e8aec1a6f3fb7621898193510b3e1cafb6
7
+ data.tar.gz: 391300ee4ddfe82e9f967cea2b43f05db42439540ebf3a45a784f286df8eeb8adcb25548c614567320ac7fa674d3878dd3c565967e7b4a6d1d66f2d9645e2dbb
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.38.0'
12
+ s.version = '0.38.1'
13
13
  s.license = 'MIT'
14
14
  s.summary = 'Command-Line Tool for a Factbase'
15
15
  s.description =
data/lib/judges/judge.rb CHANGED
@@ -28,6 +28,12 @@ class Judges::Judge
28
28
  @start = start
29
29
  end
30
30
 
31
+ # Print it as a string.
32
+ # @return [String] Name of it
33
+ def to_s
34
+ name
35
+ end
36
+
31
37
  # Run it with the given Factbase and environment variables.
32
38
  #
33
39
  # @param [Factbase] fb The factbase
data/lib/judges/judges.rb CHANGED
@@ -57,13 +57,18 @@ class Judges::Judges
57
57
  list.sort_by!(&:name)
58
58
  all = list.each_with_index.to_a
59
59
  good = all.dup
60
- all.reject { |a| a[0].name.start_with?(@shuffle) }.map { |a| a[1] }.each_with_index do |i, idx|
61
- good[i] = all[idx]
60
+ mapping = all
61
+ .map { |a| [a[0].name, a[1], a[1]] }
62
+ .reject { |a| a[0].start_with?(@shuffle) }
63
+ .to_h { |a| [a[1], a[2]] }
64
+ positions = mapping.values.shuffle
65
+ mapping.keys.zip(positions).to_h.each do |before, after|
66
+ good[after] = all[before]
62
67
  end
63
68
  good.map { |a| a[0] }.each(&)
64
69
  end
65
70
 
66
- # Iterate over them all.
71
+ # Iterate over them all, with an index.
67
72
  # @yield [(Judge, Integer)]
68
73
  def each_with_index
69
74
  idx = 0
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.38.0' unless const_defined?(:VERSION)
11
+ VERSION = '0.38.1' unless const_defined?(:VERSION)
12
12
  end
data/test/test_judges.rb CHANGED
@@ -45,6 +45,23 @@ class TestJudges < Minitest::Test
45
45
  end
46
46
  end
47
47
 
48
+ def test_keeps_them_all
49
+ colors = %w[blue orange yellow black white pink magenta]
50
+ ['', 'b', 'ye'].each do |pfx|
51
+ Dir.mktmpdir do |d|
52
+ names = colors.sort
53
+ names.each do |n|
54
+ dir = File.join(d, n)
55
+ save_it(File.join(dir, "#{n}.rb"), 'puts 1')
56
+ end
57
+ after = Judges::Judges.new(d, nil, Loog::NULL, shuffle: pfx).each.to_a.map(&:name)
58
+ assert_equal(names.size, after.size)
59
+ names.each { |n| assert_includes(after, n, "#{n.inspect} is missing, with #{pfx.inspect}") }
60
+ after.each { |n| assert_includes(names, n, "#{n.inspect} is extra, with #{pfx.inspect}") }
61
+ end
62
+ end
63
+ end
64
+
48
65
  def test_get_one
49
66
  Dir.mktmpdir do |d|
50
67
  save_it(File.join(d, 'boo/boo.rb'), 'hey')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judges
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.38.0
4
+ version: 0.38.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko