judges 0.0.17 → 0.0.18
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 +4 -4
- data/bin/judges +3 -1
- data/features/cli.feature +4 -2
- data/judges.gemspec +2 -2
- data/lib/judges/commands/update.rb +22 -1
- data/test/commands/test_update.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8399b8c8623c0d099deeb50055658e072bae333b0d851cd0aaef22f441655950
|
4
|
+
data.tar.gz: c8ef8e75705e8d0cf3bdb8033c054f7ac4c239566bf0cb80b6a9cc0943932986
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a187a9441700826cf7b539ed264a7d80e5e749169219c62d717cee1451cd77e78f5e9a130617dd2e589ad0c13d504e27482527db2dc6b80da12561ff8d1e3e4
|
7
|
+
data.tar.gz: 38c5ae3b4af2981b56d9069a794d791ea107cfae27421f12dce9b001a8ff1d60f38c972362fbd659c4e53f750b35a6192ff66b4869280510286c3d585073d0ae
|
data/bin/judges
CHANGED
@@ -29,7 +29,7 @@ require 'factbase'
|
|
29
29
|
Encoding.default_external = Encoding::UTF_8
|
30
30
|
Encoding.default_internal = Encoding::UTF_8
|
31
31
|
|
32
|
-
ver = '0.0.
|
32
|
+
ver = '0.0.18'
|
33
33
|
|
34
34
|
include GLI::App
|
35
35
|
|
@@ -58,6 +58,8 @@ desc 'Update the factbase by passing all judges one by one'
|
|
58
58
|
command :update do |c|
|
59
59
|
c.desc 'Options to pass to every judge'
|
60
60
|
c.flag([:o, :option], multiple: true, arg_name: '<key=value>')
|
61
|
+
c.desc 'Maximum number of update cycles to run'
|
62
|
+
c.flag([:'max-cycles'], default_value: 8)
|
61
63
|
c.action do |global, options, args|
|
62
64
|
require_relative '../lib/judges/commands/update'
|
63
65
|
Judges::Update.new(loog).run(options, args)
|
data/features/cli.feature
CHANGED
@@ -19,7 +19,7 @@ Feature: Simple Run
|
|
19
19
|
n.kind = 'yes!'
|
20
20
|
end
|
21
21
|
"""
|
22
|
-
Then I run bin/judges with "--verbose update -o foo=1 -o bar=2 . simple.fb"
|
22
|
+
Then I run bin/judges with "--verbose update -o foo=1 -o bar=2 --max-cycles 2 . simple.fb"
|
23
23
|
Then Stdout contains "foo → "
|
24
24
|
Then Stdout contains "bar → "
|
25
25
|
Then Stdout contains "1 judges processed"
|
@@ -44,17 +44,19 @@ Feature: Simple Run
|
|
44
44
|
Given I make a temp directory
|
45
45
|
Then I have a "simple/simple_judge.rb" file with content:
|
46
46
|
"""
|
47
|
+
return if $fb.size > 2
|
47
48
|
$fb.insert.time = Time.now - 100 * 60 * 60 * 24
|
48
49
|
"""
|
49
50
|
Then I run bin/judges with "--verbose update . simple.fb"
|
50
51
|
Given I run bin/judges with "trim --days 5 simple.fb"
|
51
|
-
Then Stdout contains "
|
52
|
+
Then Stdout contains "3 facts deleted"
|
52
53
|
And Exit code is zero
|
53
54
|
|
54
55
|
Scenario: Simple print of a small factbase
|
55
56
|
Given I make a temp directory
|
56
57
|
Then I have a "simple/simple_judge.rb" file with content:
|
57
58
|
"""
|
59
|
+
return if $fb.size > 2
|
58
60
|
n = $fb.insert
|
59
61
|
n.kind = 'yes!'
|
60
62
|
"""
|
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.0.
|
29
|
+
s.version = '0.0.18'
|
30
30
|
s.license = 'MIT'
|
31
31
|
s.summary = 'Command-Line Tool for a Factbase'
|
32
32
|
s.description = '
|
@@ -42,7 +42,7 @@ Gem::Specification.new do |s|
|
|
42
42
|
s.rdoc_options = ['--charset=UTF-8']
|
43
43
|
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
44
44
|
s.add_runtime_dependency 'backtrace', '~> 0.3'
|
45
|
-
s.add_runtime_dependency 'factbase', '~>0.0.
|
45
|
+
s.add_runtime_dependency 'factbase', '~>0.0.16'
|
46
46
|
s.add_runtime_dependency 'gli', '~>2.21'
|
47
47
|
s.add_runtime_dependency 'loog', '~>0.2'
|
48
48
|
s.add_runtime_dependency 'nokogiri', '~> 1.10'
|
@@ -44,8 +44,27 @@ class Judges::Update
|
|
44
44
|
fb = impex.import(strict: false)
|
45
45
|
options = Judges::Options.new(opts['option'])
|
46
46
|
@loog.debug("The following options provided:\n\t#{options.to_s.gsub("\n", "\n\t")}")
|
47
|
+
packs = Judges::Packs.new(dir, @loog)
|
48
|
+
c = 0
|
49
|
+
loop do
|
50
|
+
diff = cycle(packs, fb, impex, options)
|
51
|
+
break if diff.zero?
|
52
|
+
if !opts['max-cycles'].nil? && c > opts['max-cycles']
|
53
|
+
@loog.info('Too many cycles already, as set by --max-cycles, breaking')
|
54
|
+
break
|
55
|
+
end
|
56
|
+
c += 1
|
57
|
+
@loog.info("#{diff} modifications at the cycle ##{c}")
|
58
|
+
end
|
59
|
+
@loog.info("Update finished in #{c} cycles")
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def cycle(packs, fb, impex, options)
|
47
65
|
errors = []
|
48
|
-
|
66
|
+
diff = 0
|
67
|
+
done = packs.each_with_index do |p, i|
|
49
68
|
@loog.info("Running #{p.dir.to_rel} (##{i})...")
|
50
69
|
before = fb.size
|
51
70
|
begin
|
@@ -56,9 +75,11 @@ class Judges::Update
|
|
56
75
|
end
|
57
76
|
after = fb.size
|
58
77
|
@loog.info("Pack #{p.dir.to_rel} added #{after - before} facts") if after > before
|
78
|
+
diff += after - before
|
59
79
|
end
|
60
80
|
@loog.info("#{done} judges processed (#{errors.size} errors)")
|
61
81
|
raise "Failed to update correctly (#{errors.size} errors)" unless errors.empty?
|
62
82
|
impex.export(fb)
|
83
|
+
diff
|
63
84
|
end
|
64
85
|
end
|
@@ -33,7 +33,7 @@ require_relative '../../lib/judges/commands/update'
|
|
33
33
|
class TestUpdate < Minitest::Test
|
34
34
|
def test_build_factbase_from_scratch
|
35
35
|
Dir.mktmpdir do |d|
|
36
|
-
File.write(File.join(d, 'foo.rb'), '$fb.insert.zzz = $options.foo_bar + 1')
|
36
|
+
File.write(File.join(d, 'foo.rb'), 'return if $fb.size > 2; $fb.insert.zzz = $options.foo_bar + 1')
|
37
37
|
file = File.join(d, 'base.fb')
|
38
38
|
Judges::Update.new(Loog::VERBOSE).run({ 'option' => ['foo_bar=42'] }, [d, file])
|
39
39
|
fb = Factbase.new
|
@@ -49,7 +49,7 @@ class TestUpdate < Minitest::Test
|
|
49
49
|
fb = Factbase.new
|
50
50
|
fb.insert.foo_bar = 42
|
51
51
|
File.binwrite(file, fb.export)
|
52
|
-
File.write(File.join(d, 'foo.rb'), '$fb.insert.tt = 4')
|
52
|
+
File.write(File.join(d, 'foo.rb'), 'return if $fb.size > 2; $fb.insert.tt = 4')
|
53
53
|
Judges::Update.new(Loog::VERBOSE).run({}, [d, file])
|
54
54
|
fb = Factbase.new
|
55
55
|
fb.import(File.binread(file))
|
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.0.
|
4
|
+
version: 0.0.18
|
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-05-
|
11
|
+
date: 2024-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0.
|
33
|
+
version: 0.0.16
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.0.
|
40
|
+
version: 0.0.16
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: gli
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|