judges 0.18.0 → 0.18.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01de840b5ca098985b5b4cbdc1ea16d96237d3bbed4617971662f5628fad46bf
4
- data.tar.gz: e502a04924b0186921fbbc2026e4f7d78eed0ee47ec2f6cdfcfb01c65e092050
3
+ metadata.gz: 8830243b63e62d966d91e5d59b768039df5da4441d83b1ba0c89fb920a782d36
4
+ data.tar.gz: 9f4fbc2cbe61760e6931f193cb92dd2fd764953ed7598c004476ed29de0e2e94
5
5
  SHA512:
6
- metadata.gz: 38e602fda2bc3a1cce738e1633094d7dc0bc8a50fb43ff97e1e28d4da36752bbdb56fac51f98a2cec884b7a3245b701566c7500d817f4a242fbfb0c28cd9b62d
7
- data.tar.gz: d9d5761f6384e7898da2cbab0b39a659d22f91a1af61a834f52c038f0162b8ebf08f576a8ea846b9a3818fb5f822c6d018552478d979365fa0226955f7cdc5d3
6
+ metadata.gz: 1843faa46e6a55657226e8a34d32242e069bff03325330ca48ec6026ecefe792781f2647dce0c1fe3c0f21e9e139f23e32d0402ddc8a9b2045b12e8edac0c570
7
+ data.tar.gz: e94b241263ce9b6fd1891312b38359481567ea9568fe76c0143d6680a8f4cab231ee46adc0ebca0c0b2a193c01a38991a74c874cab0798c47b5d38b23ada96b7
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.18.0'
29
+ s.version = '0.18.1'
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
- # Baza.
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
@@ -25,7 +25,11 @@ require_relative '../../judges'
25
25
  require_relative '../../judges/impex'
26
26
  require_relative '../../judges/elapsed'
27
27
 
28
- # Eval.
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
- # Import.
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
- # Inspect.
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
@@ -24,7 +24,11 @@ require_relative '../../judges'
24
24
  require_relative '../../judges/impex'
25
25
  require_relative '../../judges/elapsed'
26
26
 
27
- # Join.
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
- # Update.
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
@@ -26,7 +26,11 @@ require_relative '../../judges'
26
26
  require_relative '../../judges/impex'
27
27
  require_relative '../../judges/baza'
28
28
 
29
- # Pull.
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
@@ -26,7 +26,11 @@ require_relative '../../judges'
26
26
  require_relative '../../judges/impex'
27
27
  require_relative '../../judges/baza'
28
28
 
29
- # Push.
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
@@ -32,7 +32,11 @@ require_relative '../../judges/options'
32
32
  require_relative '../../judges/categories'
33
33
  require_relative '../../judges/elapsed'
34
34
 
35
- # Test.
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 test_one(fb, opts, judge, tname, yaml, assert: true)
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|
@@ -25,7 +25,11 @@ require_relative '../../judges'
25
25
  require_relative '../../judges/impex'
26
26
  require_relative '../../judges/elapsed'
27
27
 
28
- # Trim.
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
- # Update.
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.rb CHANGED
@@ -25,5 +25,5 @@
25
25
  # Copyright:: Copyright (c) 2024 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Judges
28
- VERSION = '0.18.0'
28
+ VERSION = '0.18.1'
29
29
  end
@@ -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 = 42')
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.foo = 55')
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)=2]
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judges
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko