judges 0.60.0 → 0.60.2

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: 5ac172cd19babb5a8fcbe6b7bc6311b70df9ff437dfb8bff633ffeeaf68218ce
4
- data.tar.gz: 34776e965033db141dfabd895e41f554fffb6977caeb7aa6a39718c61d67d228
3
+ metadata.gz: 1b8a66e3d51e2392f0f93f1520b688ab8720a530cffb0a2a929ee51d8a788351
4
+ data.tar.gz: edfdf8700f08f118988c1f03c77973d27695895eda3837f15a3ea3b19d2e60ba
5
5
  SHA512:
6
- metadata.gz: 6965159d5e0cf14900bb8a7ac9b546e809ba199b52c6581edd3819a1a0d477b8e1536ece942971e16aadf951987badcae88e16a93291965037f9693d42c32358
7
- data.tar.gz: 07313a43d4badf58218d153ba18264090ef4ad57bf3d195fce77a48009f891453b817eccbbc504b5be29fefa55266ad8c5ebb1ec8ab17a8a88a4836e9d229571
6
+ metadata.gz: f0df3c5a1be9698e575ba9853c51c0e868cdaf2870fba7c6e9fe222be299b58941bec182b2d3f1800f3cf33d1de12c053147290fe5ccb31c10912e3b4ec96036
7
+ data.tar.gz: c9bd376f7b8a1aca9add4af2132a77e229a24e4a7eb401bbd4c80f6799170f164b94b9bed0bdbd75ac2f13ad041a975d20bba8ead756a17fb4d628c0c6810090
data/Gemfile.lock CHANGED
@@ -13,6 +13,7 @@ PATH
13
13
  loog (~> 0.6)
14
14
  moments (~> 0.3)
15
15
  nokogiri (~> 1.10)
16
+ octokit (~> 10.0)
16
17
  others (~> 0.1)
17
18
  retries (~> 0.0)
18
19
  tago (~> 0.2)
@@ -23,7 +24,7 @@ PATH
23
24
  GEM
24
25
  remote: https://rubygems.org/
25
26
  specs:
26
- addressable (2.8.8)
27
+ addressable (2.8.9)
27
28
  public_suffix (>= 2.0.2, < 8.0)
28
29
  ansi (1.5.0)
29
30
  ast (2.4.3)
@@ -66,25 +67,26 @@ GEM
66
67
  cucumber-tag-expressions (> 6, < 9)
67
68
  cucumber-cucumber-expressions (19.0.0)
68
69
  bigdecimal
69
- cucumber-gherkin (38.0.0)
70
+ cucumber-gherkin (39.0.0)
70
71
  cucumber-messages (>= 31, < 33)
71
72
  cucumber-html-formatter (22.3.0)
72
73
  cucumber-messages (> 23, < 33)
73
- cucumber-messages (32.0.1)
74
+ cucumber-messages (32.2.0)
74
75
  cucumber-tag-expressions (8.1.0)
75
76
  date (3.5.1)
76
77
  decoor (0.1.0)
77
78
  diff-lcs (1.6.2)
78
79
  docile (1.4.1)
80
+ drb (2.2.3)
79
81
  elapsed (0.3.1)
80
82
  loog (~> 0.6)
81
83
  tago (~> 0.1)
82
84
  ellipsized (0.3.0)
83
- erb (6.0.1)
85
+ erb (6.0.2)
84
86
  ethon (0.18.0)
85
87
  ffi (>= 1.15.0)
86
88
  logger
87
- factbase (0.19.6)
89
+ factbase (0.19.9)
88
90
  backtrace (~> 0.4)
89
91
  decoor (~> 0.1)
90
92
  ellipsized (~> 0.3)
@@ -121,15 +123,21 @@ GEM
121
123
  hashdiff (1.2.1)
122
124
  iri (0.11.8)
123
125
  json (2.18.1)
126
+ json-schema (6.1.0)
127
+ addressable (~> 2.8)
128
+ bigdecimal (>= 3.1, < 5)
124
129
  language_server-protocol (3.17.0.5)
125
130
  lint_roller (1.1.0)
126
131
  logger (1.7.0)
127
132
  loog (0.8.0)
128
133
  ellipsized
129
134
  logger (~> 1.0)
135
+ mcp (0.7.1)
136
+ json-schema (>= 4.1)
130
137
  memoist3 (1.0.0)
131
138
  mini_mime (1.1.5)
132
- minitest (6.0.1)
139
+ minitest (6.0.2)
140
+ drb (~> 2.0)
133
141
  prism (~> 1.5)
134
142
  minitest-mock (5.27.0)
135
143
  minitest-reporters (1.7.1)
@@ -144,33 +152,36 @@ GEM
144
152
  multipart-post (2.4.1)
145
153
  net-http (0.9.1)
146
154
  uri (>= 0.11.1)
147
- nokogiri (1.19.0-aarch64-linux-gnu)
155
+ nokogiri (1.19.1-aarch64-linux-gnu)
148
156
  racc (~> 1.4)
149
- nokogiri (1.19.0-aarch64-linux-musl)
157
+ nokogiri (1.19.1-aarch64-linux-musl)
150
158
  racc (~> 1.4)
151
- nokogiri (1.19.0-arm-linux-gnu)
159
+ nokogiri (1.19.1-arm-linux-gnu)
152
160
  racc (~> 1.4)
153
- nokogiri (1.19.0-arm-linux-musl)
161
+ nokogiri (1.19.1-arm-linux-musl)
154
162
  racc (~> 1.4)
155
- nokogiri (1.19.0-arm64-darwin)
163
+ nokogiri (1.19.1-arm64-darwin)
156
164
  racc (~> 1.4)
157
- nokogiri (1.19.0-x64-mingw-ucrt)
165
+ nokogiri (1.19.1-x64-mingw-ucrt)
158
166
  racc (~> 1.4)
159
- nokogiri (1.19.0-x86_64-darwin)
167
+ nokogiri (1.19.1-x86_64-darwin)
160
168
  racc (~> 1.4)
161
- nokogiri (1.19.0-x86_64-linux-gnu)
169
+ nokogiri (1.19.1-x86_64-linux-gnu)
162
170
  racc (~> 1.4)
163
- nokogiri (1.19.0-x86_64-linux-musl)
171
+ nokogiri (1.19.1-x86_64-linux-musl)
164
172
  racc (~> 1.4)
173
+ octokit (10.0.0)
174
+ faraday (>= 1, < 3)
175
+ sawyer (~> 0.9)
165
176
  online (0.3.0)
166
177
  openssl (>= 3)
167
178
  timeout (~> 0.4)
168
- openssl (4.0.0)
179
+ openssl (4.0.1)
169
180
  os (1.1.4)
170
181
  ostruct (0.6.3)
171
182
  others (0.1.1)
172
183
  parallel (1.27.0)
173
- parser (3.3.10.1)
184
+ parser (3.3.10.2)
174
185
  ast (~> 2.4.1)
175
186
  racc
176
187
  prism (1.9.0)
@@ -178,7 +189,7 @@ GEM
178
189
  date
179
190
  stringio
180
191
  public_suffix (7.0.2)
181
- qbash (0.7.2)
192
+ qbash (0.8.0)
182
193
  backtrace (> 0)
183
194
  elapsed (> 0)
184
195
  loog (> 0)
@@ -195,10 +206,11 @@ GEM
195
206
  regexp_parser (2.11.3)
196
207
  retries (0.0.5)
197
208
  rexml (3.4.4)
198
- rubocop (1.84.2)
209
+ rubocop (1.85.0)
199
210
  json (~> 2.3)
200
211
  language_server-protocol (~> 3.17.0.2)
201
212
  lint_roller (~> 1.1.0)
213
+ mcp (~> 0.6)
202
214
  parallel (~> 1.10)
203
215
  parser (>= 3.3.0.2)
204
216
  rainbow (>= 2.2.2, < 4.0)
@@ -209,7 +221,7 @@ GEM
209
221
  rubocop-ast (1.49.0)
210
222
  parser (>= 3.3.7.2)
211
223
  prism (~> 1.7)
212
- rubocop-minitest (0.38.2)
224
+ rubocop-minitest (0.39.1)
213
225
  lint_roller (~> 1.1)
214
226
  rubocop (>= 1.75.0, < 2.0)
215
227
  rubocop-ast (>= 1.38.0, < 2.0)
@@ -221,6 +233,9 @@ GEM
221
233
  lint_roller (~> 1.1)
222
234
  rubocop (>= 1.72.1)
223
235
  ruby-progressbar (1.13.0)
236
+ sawyer (0.9.3)
237
+ addressable (>= 2.3.5)
238
+ faraday (>= 0.17.3, < 3)
224
239
  simplecov (0.22.0)
225
240
  docile (~> 1.1)
226
241
  simplecov-html (~> 0.11)
@@ -231,7 +246,7 @@ GEM
231
246
  simplecov-html (0.13.2)
232
247
  simplecov_json_formatter (0.1.4)
233
248
  stringio (3.2.0)
234
- sys-uname (1.4.1)
249
+ sys-uname (1.5.0)
235
250
  ffi (~> 1.1)
236
251
  memoist3 (~> 1.0.0)
237
252
  tago (0.7.0)
data/README.md CHANGED
@@ -90,8 +90,9 @@ Read
90
90
  [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
91
91
  Make sure your build is green before you contribute
92
92
  your pull request. You will need to have
93
- [Ruby](https://www.ruby-lang.org/en/) 3.0+ and
94
- [Bundler](https://bundler.io/) installed. Then:
93
+ [Ruby](https://www.ruby-lang.org/en/) 3.0+,
94
+ [Bundler](https://bundler.io/), and
95
+ [Tidy](https://www.html-tidy.org/) installed. Then:
95
96
 
96
97
  ```bash
97
98
  bundle update
@@ -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.6 --verbose test --judge guess ./fixtures"
19
+ When I run bin/judges with "--factbase 0.19.9 --verbose test --judge guess ./fixtures"
20
20
  Then Exit code is zero
21
- And Stdout contains "Factbase version to be used: '0.19.6'"
21
+ And Stdout contains "Factbase version to be used: '0.19.9'"
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.60.0'
12
+ s.version = '0.60.2'
13
13
  s.license = 'MIT'
14
14
  s.summary = 'Command-Line Tool for a Factbase'
15
15
  s.description =
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
36
36
  s.add_dependency 'loog', '~>0.6'
37
37
  s.add_dependency 'moments', '~>0.3'
38
38
  s.add_dependency 'nokogiri', '~>1.10'
39
+ s.add_dependency 'octokit', '~>10.0'
39
40
  s.add_dependency 'others', '~>0.1'
40
41
  s.add_dependency 'retries', '~>0.0'
41
42
  s.add_dependency 'tago', '~>0.2'
@@ -70,10 +70,10 @@ class Judges::Update
70
70
  epoch: @epoch, shuffle: opts['shuffle'], boost: opts['boost'],
71
71
  demote: opts['demote'], seed: opts['seed']
72
72
  )
73
- churn = nil
73
+ churn = Factbase::Churn.new
74
74
  begin
75
75
  Timeout.timeout(opts['lifetime']) do
76
- churn = loop_them(judges, fb, opts, options)
76
+ loop_them(judges, fb, churn, opts, options)
77
77
  end
78
78
  rescue Timeout::Error, Timeout::ExitException => e
79
79
  @loog.error("Terminated due to --lifetime=#{opts['lifetime']}")
@@ -90,9 +90,9 @@ class Judges::Update
90
90
 
91
91
  private
92
92
 
93
- def loop_them(judges, fb, opts, options)
93
+ def loop_them(judges, fb, churn, opts, options)
94
94
  c = 0
95
- churn = Factbase::Churn.new
95
+ ch = Factbase::Churn.new
96
96
  errors = []
97
97
  statistics = opts['statistics'] ? Judges::Statistics.new : nil
98
98
  sum = fb.query('(eq what "judges-summary")').each.to_a
@@ -115,8 +115,8 @@ class Judges::Update
115
115
  end
116
116
  @loog.info("\nStarting cycle ##{c}#{" (out of #{opts['max-cycles']})" if opts['max-cycles']}...")
117
117
  end
118
- delta = cycle(opts, judges, fb, options, errors, statistics)
119
- churn += delta
118
+ delta = cycle(opts, judges, fb, churn, options, errors, statistics)
119
+ ch += delta
120
120
  if delta.zero?
121
121
  @loog.info("The update cycle ##{c} has made no changes to the factbase, let's stop")
122
122
  break
@@ -131,16 +131,15 @@ class Judges::Update
131
131
  end
132
132
  @loog.info("The cycle #{c} did #{delta}")
133
133
  end
134
- throw :"👍 Update completed in #{c} cycle(s), did #{churn}"
134
+ throw :"👍 Update completed in #{c} cycle(s), did #{ch}"
135
135
  end
136
136
  statistics&.report(@loog)
137
- summarize(fb, churn, errors, c) if %w[add append].include?(opts['summary'])
138
- churn
137
+ summarize(fb, ch, errors, c) if %w[add append].include?(opts['summary'])
139
138
  end
140
139
 
141
140
  # Update the summary.
142
141
  # @param [Factbase] fb The factbase
143
- # @param [Churn] churn The churn
142
+ # @param [Factbase::Churn] churn The churn
144
143
  # @param [Array<String>] errors List of errors
145
144
  # @param [Integer] cycles How many cycles
146
145
  def summarize(fb, churn, errors, cycles)
@@ -176,11 +175,12 @@ class Judges::Update
176
175
  # @param [Hash] opts The command line options
177
176
  # @param [Judges::Judges] judges The judges
178
177
  # @param [Factbase] fb The factbase
178
+ # @param [Factbase::Churn] churn All modifications
179
179
  # @param [Judges::Options] options The options
180
180
  # @param [Array<String>] errors List of errors
181
181
  # @param [Judges::Statistics] statistics Statistics tracking object (optional)
182
- # @return [Factbase::Churn] How many modifications have been made
183
- def cycle(opts, judges, fb, options, errors, statistics = nil)
182
+ # @return [Factbase::Churn] How many modifications have been made in current cycle
183
+ def cycle(opts, judges, fb, churn, options, errors, statistics = nil)
184
184
  delta = Factbase::Churn.new
185
185
  global = {}
186
186
  used = 0
@@ -209,6 +209,7 @@ class Judges::Update
209
209
  elapsed(@loog, level: Logger::INFO) do
210
210
  impact = one_judge(opts, fb, judge, global, options, errors)
211
211
  delta += impact
212
+ churn.append(impact.inserted, impact.deleted, impact.added)
212
213
  throw :"👍 The '#{judge.name}' judge made zero changes to #{fb.size} facts" if impact.zero?
213
214
  throw :"👍 The '#{judge.name}' judge #{impact} out of #{fb.size} facts"
214
215
  end
data/lib/judges/judge.rb CHANGED
@@ -7,8 +7,10 @@ require 'elapsed'
7
7
  require 'tago'
8
8
  require 'timeout'
9
9
  require 'factbase/tallied'
10
+ require 'octokit'
10
11
  require_relative '../judges'
11
12
  require_relative '../judges/to_rel'
13
+ require_relative '../judges/pretty_exception'
12
14
 
13
15
  # A single judge.
14
16
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -82,6 +84,7 @@ class Judges::Judge
82
84
  rescue Exception => e
83
85
  # rubocop:enable Lint/RescueException
84
86
  raise e if e.is_a?(RuntimeError) && e.message == 'skip'
87
+ e = Judges::PrettyException.new(e) if e.is_a?(Octokit::ServerError)
85
88
  @loog.error(Backtrace.new(e))
86
89
  raise e if e.is_a?(StandardError)
87
90
  raise e if e.is_a?(Timeout::ExitException)
data/lib/judges/judges.rb CHANGED
@@ -84,10 +84,11 @@ class Judges::Judges
84
84
  list.sort_by!(&:name)
85
85
  all = list.each_with_index.to_a
86
86
  good = all.dup
87
- mapping = all
88
- .map { |a| [a[0].name, a[1], a[1]] }
89
- .reject { |a| !@shuffle.empty? && a[0].start_with?(@shuffle) }
90
- .to_h { |a| [a[1], a[2]] }
87
+ mapping =
88
+ all
89
+ .map { |a| [a[0].name, a[1], a[1]] }
90
+ .reject { |a| !@shuffle.empty? && a[0].start_with?(@shuffle) }
91
+ .to_h { |a| [a[1], a[2]] }
91
92
  positions = mapping.values.shuffle(random: Random.new(@seed))
92
93
  mapping.keys.zip(positions).to_h.each do |before, after|
93
94
  good[after] = all[before]
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ require 'delegate'
7
+ require 'ellipsized'
8
+ require_relative '../judges'
9
+
10
+ # Decorates the exception for show ellipsed message.
11
+ class Judges::PrettyException < SimpleDelegator
12
+ undef_method :class
13
+ undef_method :instance_of?
14
+ undef_method :kind_of?
15
+
16
+ def message
17
+ __getobj__.message.ellipsized(100, :right)
18
+ end
19
+ end
@@ -76,7 +76,7 @@ class Judges::Statistics
76
76
  # @return [String] Compact summary of results
77
77
  def summarize(results)
78
78
  return 'N/A' if results.empty?
79
- counts = results.each_with_object(Hash.new(0)) { |result, hash| hash[result] += 1 }
79
+ counts = results.tally
80
80
  return results.first if counts.size == 1
81
81
  counts.sort_by { |_, count| -count }.map { |result, count| "#{count}x#{result}" }.join(', ')
82
82
  end
data/lib/judges.rb CHANGED
@@ -8,5 +8,5 @@
8
8
  # Copyright:: Copyright (c) 2024-2026 Yegor Bugayenko
9
9
  # License:: MIT
10
10
  module Judges
11
- VERSION = '0.60.0' unless const_defined?(:VERSION)
11
+ VERSION = '0.60.2' unless const_defined?(:VERSION)
12
12
  end
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.60.0
4
+ version: 0.60.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -163,6 +163,20 @@ dependencies:
163
163
  - - "~>"
164
164
  - !ruby/object:Gem::Version
165
165
  version: '1.10'
166
+ - !ruby/object:Gem::Dependency
167
+ name: octokit
168
+ requirement: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '10.0'
173
+ type: :runtime
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '10.0'
166
180
  - !ruby/object:Gem::Dependency
167
181
  name: others
168
182
  requirement: !ruby/object:Gem::Requirement
@@ -312,6 +326,7 @@ files:
312
326
  - lib/judges/judge.rb
313
327
  - lib/judges/judges.rb
314
328
  - lib/judges/options.rb
329
+ - lib/judges/pretty_exception.rb
315
330
  - lib/judges/statistics.rb
316
331
  - lib/judges/to_rel.rb
317
332
  - package-lock.json