judges 0.18.0 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -9
- data/judges.gemspec +1 -1
- data/lib/judges/baza.rb +26 -1
- data/lib/judges/commands/eval.rb +5 -1
- data/lib/judges/commands/import.rb +5 -1
- data/lib/judges/commands/inspect.rb +5 -1
- data/lib/judges/commands/join.rb +5 -1
- data/lib/judges/commands/print.rb +5 -1
- data/lib/judges/commands/pull.rb +5 -1
- data/lib/judges/commands/push.rb +5 -1
- data/lib/judges/commands/test.rb +10 -2
- data/lib/judges/commands/trim.rb +5 -1
- data/lib/judges/commands/update.rb +5 -1
- data/lib/judges/judge.rb +1 -0
- data/lib/judges.rb +1 -1
- data/test/commands/test_test.rb +9 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dc4d51701430ff754d2fb33b4938d6ad105f0d08590c875c88095b0992bab17
|
4
|
+
data.tar.gz: 7b5b223a403e3d5d82128589a4838ac66b8518644e0c110e5a688e6139fa92d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a293823a64b90aa7edb793b4d9fc35c7e06d7012d70073e96a9080232d48b5c12ec0f0f1b20759412eb033a4921cbeef43129101050c784b90ecf11e55d4900
|
7
|
+
data.tar.gz: 5cd0c89a797662738454256c960afa5edf46b77e6109157cb8d8d44c534a130a7dcd0522dfe5091c878f7e9f3c0a7e95c1f47c283696ba4cd0fb7e592e61d3de
|
data/Gemfile.lock
CHANGED
@@ -79,7 +79,7 @@ GEM
|
|
79
79
|
bigdecimal
|
80
80
|
cucumber-gherkin (27.0.0)
|
81
81
|
cucumber-messages (>= 19.1.4, < 23)
|
82
|
-
cucumber-html-formatter (21.4.
|
82
|
+
cucumber-html-formatter (21.4.1)
|
83
83
|
cucumber-messages (> 19, < 25)
|
84
84
|
cucumber-messages (22.0.0)
|
85
85
|
cucumber-tag-expressions (6.1.0)
|
@@ -90,14 +90,14 @@ GEM
|
|
90
90
|
erubi (1.13.0)
|
91
91
|
ethon (0.16.0)
|
92
92
|
ffi (>= 1.15.0)
|
93
|
-
factbase (0.0
|
94
|
-
backtrace (
|
95
|
-
decoor (
|
93
|
+
factbase (0.2.0)
|
94
|
+
backtrace (> 0)
|
95
|
+
decoor (> 0)
|
96
96
|
json (~> 2.7)
|
97
|
-
loog (
|
97
|
+
loog (> 0)
|
98
98
|
nokogiri (~> 1.10)
|
99
|
-
others (
|
100
|
-
tago (
|
99
|
+
others (> 0)
|
100
|
+
tago (> 0)
|
101
101
|
yaml (~> 0.3)
|
102
102
|
ffi (1.17.0-aarch64-linux-gnu)
|
103
103
|
ffi (1.17.0-arm-linux-gnu)
|
@@ -106,7 +106,7 @@ GEM
|
|
106
106
|
ffi (1.17.0-x86-linux-gnu)
|
107
107
|
ffi (1.17.0-x86_64-darwin)
|
108
108
|
ffi (1.17.0-x86_64-linux-gnu)
|
109
|
-
gli (2.21.
|
109
|
+
gli (2.21.5)
|
110
110
|
hashdiff (1.1.0)
|
111
111
|
i18n (1.14.5)
|
112
112
|
concurrent-ruby (~> 1.0)
|
@@ -187,7 +187,7 @@ GEM
|
|
187
187
|
reline (0.5.9)
|
188
188
|
io-console (~> 0.5)
|
189
189
|
retries (0.0.5)
|
190
|
-
rexml (3.3.
|
190
|
+
rexml (3.3.2)
|
191
191
|
strscan
|
192
192
|
rspec-core (3.13.0)
|
193
193
|
rspec-support (~> 3.13.0)
|
data/judges.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
27
27
|
s.required_ruby_version = '>=3.2'
|
28
28
|
s.name = 'judges'
|
29
|
-
s.version = '0.
|
29
|
+
s.version = '0.19.0'
|
30
30
|
s.license = 'MIT'
|
31
31
|
s.summary = 'Command-Line Tool for a Factbase'
|
32
32
|
s.description =
|
data/lib/judges/baza.rb
CHANGED
@@ -28,7 +28,12 @@ require 'base64'
|
|
28
28
|
require_relative '../judges'
|
29
29
|
require_relative '../judges/elapsed'
|
30
30
|
|
31
|
-
#
|
31
|
+
# Interface to the API of zerocracy.com.
|
32
|
+
#
|
33
|
+
# You make an instance of this class and then call one of its methods.
|
34
|
+
# The object will make HTTP request to www.zerocracy.com and interpret the
|
35
|
+
# results returned.
|
36
|
+
#
|
32
37
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
33
38
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
34
39
|
# License:: MIT
|
@@ -43,6 +48,11 @@ class Judges::Baza
|
|
43
48
|
@retries = retries
|
44
49
|
end
|
45
50
|
|
51
|
+
# Push factbase to the server.
|
52
|
+
# @param [String] name The name of the job on the server
|
53
|
+
# @param [Bytes] data The data to push to the server (binary)
|
54
|
+
# @param [Array<String>] meta List of metas, possibly empty
|
55
|
+
# @return [Integer] Job ID on the server
|
46
56
|
def push(name, data, meta)
|
47
57
|
id = 0
|
48
58
|
hdrs = headers.merge(
|
@@ -70,6 +80,9 @@ class Judges::Baza
|
|
70
80
|
id
|
71
81
|
end
|
72
82
|
|
83
|
+
# Pull factbase from the server.
|
84
|
+
# @param [Integer] id The ID of the job on the server
|
85
|
+
# @return [Bytes] Binary data pulled
|
73
86
|
def pull(id)
|
74
87
|
data = 0
|
75
88
|
elapsed(@loog) do
|
@@ -99,6 +112,8 @@ class Judges::Baza
|
|
99
112
|
end
|
100
113
|
|
101
114
|
# The job with this ID is finished already?
|
115
|
+
# @param [Integer] id The ID of the job on the server
|
116
|
+
# @return [Boolean] TRUE if the job is already finished
|
102
117
|
def finished?(id)
|
103
118
|
finished = false
|
104
119
|
elapsed(@loog) do
|
@@ -117,6 +132,8 @@ class Judges::Baza
|
|
117
132
|
end
|
118
133
|
|
119
134
|
# Lock the name.
|
135
|
+
# @param [String] name The name of the job on the server
|
136
|
+
# @param [String] owner The owner of the lock (any string)
|
120
137
|
def lock(name, owner)
|
121
138
|
elapsed(@loog) do
|
122
139
|
with_retries(max_tries: @retries) do
|
@@ -132,6 +149,8 @@ class Judges::Baza
|
|
132
149
|
end
|
133
150
|
|
134
151
|
# Unlock the name.
|
152
|
+
# @param [String] name The name of the job on the server
|
153
|
+
# @param [String] owner The owner of the lock (any string)
|
135
154
|
def unlock(name, owner)
|
136
155
|
elapsed(@loog) do
|
137
156
|
with_retries(max_tries: @retries) do
|
@@ -146,6 +165,9 @@ class Judges::Baza
|
|
146
165
|
end
|
147
166
|
end
|
148
167
|
|
168
|
+
# Get the ID of the job by the name.
|
169
|
+
# @param [String] name The name of the job on the server
|
170
|
+
# @return [Integer] The ID of the job on the server
|
149
171
|
def recent(name)
|
150
172
|
job = 0
|
151
173
|
elapsed(@loog) do
|
@@ -163,6 +185,9 @@ class Judges::Baza
|
|
163
185
|
job
|
164
186
|
end
|
165
187
|
|
188
|
+
# Check whether the name of the job exists on the server.
|
189
|
+
# @param [String] name The name of the job on the server
|
190
|
+
# @return [Boolean] TRUE if such name exists
|
166
191
|
def name_exists?(name)
|
167
192
|
exists = 0
|
168
193
|
elapsed(@loog) do
|
data/lib/judges/commands/eval.rb
CHANGED
@@ -25,7 +25,11 @@ require_relative '../../judges'
|
|
25
25
|
require_relative '../../judges/impex'
|
26
26
|
require_relative '../../judges/elapsed'
|
27
27
|
|
28
|
-
#
|
28
|
+
# The +eval+ command.
|
29
|
+
#
|
30
|
+
# This class is instantiated by the +bin/judge+ command line interface. You
|
31
|
+
# are not supposed to instantiate it yourself.
|
32
|
+
#
|
29
33
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
30
34
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
31
35
|
# License:: MIT
|
@@ -27,7 +27,11 @@ require_relative '../../judges/impex'
|
|
27
27
|
require_relative '../../judges/to_rel'
|
28
28
|
require_relative '../../judges/elapsed'
|
29
29
|
|
30
|
-
#
|
30
|
+
# The +import+ command.
|
31
|
+
#
|
32
|
+
# This class is instantiated by the +bin/judge+ command line interface. You
|
33
|
+
# are not supposed to instantiate it yourself.
|
34
|
+
#
|
31
35
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
32
36
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
33
37
|
# License:: MIT
|
@@ -23,7 +23,11 @@
|
|
23
23
|
require_relative '../../judges'
|
24
24
|
require_relative '../../judges/impex'
|
25
25
|
|
26
|
-
#
|
26
|
+
# The +inspect+ command.
|
27
|
+
#
|
28
|
+
# This class is instantiated by the +bin/judge+ command line interface. You
|
29
|
+
# are not supposed to instantiate it yourself.
|
30
|
+
#
|
27
31
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
28
32
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
29
33
|
# License:: MIT
|
data/lib/judges/commands/join.rb
CHANGED
@@ -24,7 +24,11 @@ require_relative '../../judges'
|
|
24
24
|
require_relative '../../judges/impex'
|
25
25
|
require_relative '../../judges/elapsed'
|
26
26
|
|
27
|
-
#
|
27
|
+
# The +join+ command.
|
28
|
+
#
|
29
|
+
# This class is instantiated by the +bin/judge+ command line interface. You
|
30
|
+
# are not supposed to instantiate it yourself.
|
31
|
+
#
|
28
32
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
29
33
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
30
34
|
# License:: MIT
|
@@ -28,7 +28,11 @@ require_relative '../../judges'
|
|
28
28
|
require_relative '../../judges/impex'
|
29
29
|
require_relative '../../judges/elapsed'
|
30
30
|
|
31
|
-
#
|
31
|
+
# The +print+ command.
|
32
|
+
#
|
33
|
+
# This class is instantiated by the +bin/judge+ command line interface. You
|
34
|
+
# are not supposed to instantiate it yourself.
|
35
|
+
#
|
32
36
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
33
37
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
34
38
|
# License:: MIT
|
data/lib/judges/commands/pull.rb
CHANGED
@@ -26,7 +26,11 @@ require_relative '../../judges'
|
|
26
26
|
require_relative '../../judges/impex'
|
27
27
|
require_relative '../../judges/baza'
|
28
28
|
|
29
|
-
#
|
29
|
+
# The +pull+ command.
|
30
|
+
#
|
31
|
+
# This class is instantiated by the +bin/judge+ command line interface. You
|
32
|
+
# are not supposed to instantiate it yourself.
|
33
|
+
#
|
30
34
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
35
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
32
36
|
# License:: MIT
|
data/lib/judges/commands/push.rb
CHANGED
@@ -26,7 +26,11 @@ require_relative '../../judges'
|
|
26
26
|
require_relative '../../judges/impex'
|
27
27
|
require_relative '../../judges/baza'
|
28
28
|
|
29
|
-
#
|
29
|
+
# The +push+ command.
|
30
|
+
#
|
31
|
+
# This class is instantiated by the +bin/judge+ command line interface. You
|
32
|
+
# are not supposed to instantiate it yourself.
|
33
|
+
#
|
30
34
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
35
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
32
36
|
# License:: MIT
|
data/lib/judges/commands/test.rb
CHANGED
@@ -32,7 +32,11 @@ require_relative '../../judges/options'
|
|
32
32
|
require_relative '../../judges/categories'
|
33
33
|
require_relative '../../judges/elapsed'
|
34
34
|
|
35
|
-
#
|
35
|
+
# The +test+ command.
|
36
|
+
#
|
37
|
+
# This class is instantiated by the +bin/judge+ command line interface. You
|
38
|
+
# are not supposed to instantiate it yourself.
|
39
|
+
#
|
36
40
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
37
41
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
38
42
|
# License:: MIT
|
@@ -71,6 +75,7 @@ class Judges::Test
|
|
71
75
|
@loog.info("🛠️ Testing #{f.to_rel}:")
|
72
76
|
begin
|
73
77
|
fb = Factbase.new
|
78
|
+
prepare(fb, yaml)
|
74
79
|
yaml['before']&.each do |n|
|
75
80
|
j = judges.get(n)
|
76
81
|
@loog.info("Running #{j.script} judge as a pre-condition...")
|
@@ -113,7 +118,7 @@ class Judges::Test
|
|
113
118
|
judges.any? { |n| n.match?(%r{^#{name}(/#{tre})?$}) }
|
114
119
|
end
|
115
120
|
|
116
|
-
def
|
121
|
+
def prepare(fb, yaml)
|
117
122
|
inputs = yaml['input']
|
118
123
|
inputs&.each do |i|
|
119
124
|
f = fb.insert
|
@@ -127,6 +132,9 @@ class Judges::Test
|
|
127
132
|
end
|
128
133
|
end
|
129
134
|
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_one(fb, opts, judge, tname, yaml, assert: true)
|
130
138
|
options = Judges::Options.new(opts['option']) + Judges::Options.new(yaml['options'])
|
131
139
|
runs = opts['runs'] || yaml['runs'] || 1
|
132
140
|
(1..runs).each do |r|
|
data/lib/judges/commands/trim.rb
CHANGED
@@ -25,7 +25,11 @@ require_relative '../../judges'
|
|
25
25
|
require_relative '../../judges/impex'
|
26
26
|
require_relative '../../judges/elapsed'
|
27
27
|
|
28
|
-
#
|
28
|
+
# The +trim+ command.
|
29
|
+
#
|
30
|
+
# This class is instantiated by the +bin/judge+ command line interface. You
|
31
|
+
# are not supposed to instantiate it yourself.
|
32
|
+
#
|
29
33
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
30
34
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
31
35
|
# License:: MIT
|
@@ -30,7 +30,11 @@ require_relative '../../judges/options'
|
|
30
30
|
require_relative '../../judges/impex'
|
31
31
|
require_relative '../../judges/elapsed'
|
32
32
|
|
33
|
-
#
|
33
|
+
# The +update+ command.
|
34
|
+
#
|
35
|
+
# This class is instantiated by the +bin/judge+ command line interface. You
|
36
|
+
# are not supposed to instantiate it yourself.
|
37
|
+
#
|
34
38
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
35
39
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
36
40
|
# License:: MIT
|
data/lib/judges/judge.rb
CHANGED
@@ -46,6 +46,7 @@ class Judges::Judge
|
|
46
46
|
$global = global
|
47
47
|
$local = local
|
48
48
|
$valve = FakeValve.new unless defined?($valve)
|
49
|
+
options.to_h.each { |k, v| ENV.store(k.to_s, v.to_s) }
|
49
50
|
unless @lib.nil?
|
50
51
|
raise "Lib dir #{@lib.to_rel} is absent" unless File.exist?(@lib)
|
51
52
|
raise "Lib #{@lib.to_rel} is not a directory" unless File.directory?(@lib)
|
data/lib/judges.rb
CHANGED
data/test/commands/test_test.rb
CHANGED
@@ -92,25 +92,22 @@ class TestTest < Minitest::Test
|
|
92
92
|
Dir.mktmpdir do |d|
|
93
93
|
home = File.join(d, 'judges')
|
94
94
|
FileUtils.mkdir_p(File.join(home, 'first'))
|
95
|
-
File.write(File.join(d, 'judges/first/the-first.rb'), '$fb.insert.foo =
|
95
|
+
File.write(File.join(d, 'judges/first/the-first.rb'), 'x = $fb.size; $fb.insert.foo = x')
|
96
96
|
FileUtils.mkdir_p(File.join(home, 'second'))
|
97
|
-
File.write(File.join(d, 'judges/second/the-second.rb'), '$fb.insert.
|
98
|
-
File.write(
|
99
|
-
File.join(d, 'judges/first/something.yml'),
|
100
|
-
<<-YAML
|
101
|
-
input: []
|
102
|
-
expected:
|
103
|
-
- /fb[count(f)=1]
|
104
|
-
YAML
|
105
|
-
)
|
97
|
+
File.write(File.join(d, 'judges/second/the-second.rb'), '$fb.insert.bar = 55')
|
106
98
|
File.write(
|
107
99
|
File.join(d, 'judges/second/something.yml'),
|
108
100
|
<<-YAML
|
109
|
-
input:
|
101
|
+
input:
|
102
|
+
-
|
103
|
+
hi: 42
|
110
104
|
before:
|
111
105
|
- first
|
112
106
|
expected:
|
113
|
-
- /fb[count(f)=
|
107
|
+
- /fb[count(f)=3]
|
108
|
+
- /fb/f[hi=42]
|
109
|
+
- /fb/f[foo=1]
|
110
|
+
- /fb/f[bar=55]
|
114
111
|
YAML
|
115
112
|
)
|
116
113
|
Judges::Test.new(Loog::NULL).run({}, [home])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: judges
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|