judges 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/judges +2 -2
- data/features/cli.feature +3 -1
- data/judges.gemspec +1 -1
- data/lib/judges/commands/join.rb +3 -3
- data/lib/judges/commands/print.rb +2 -2
- data/lib/judges/commands/update.rb +7 -4
- data/lib/judges/options.rb +1 -1
- data/lib/judges/to_rel.rb +1 -0
- data/test/commands/test_join.rb +3 -3
- data/test/commands/test_print.rb +1 -1
- data/test/commands/test_update.rb +3 -3
- data/test/test_options.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e45e98c063327eedc9ae2731bb8c8c39358291ca8c687f6cf37997df37cf84aa
|
4
|
+
data.tar.gz: 811ae41514764e68e9cc4fa0a3ea0429bed9128eec2142268e4cdb779ce12b5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0414dfaa83953985ce7186c336eac2c1a53e71f88c73f9b89c8f1410208191c5d1ff106d91045fa7c6f6f0dd9eb59ed8c189138b51d4b546d5a0a9bbe4211546
|
7
|
+
data.tar.gz: d3b3e538af3fa858fd19d67afe3f4b10942c97befa99538fceefcb3eef770cb130bbb1631160191d4e7bac47c0dbe62a184959ba3f1c29956bdf86708f88eefe
|
data/bin/judges
CHANGED
@@ -35,7 +35,7 @@ loog = Loog::REGULAR
|
|
35
35
|
|
36
36
|
program_desc('Automated executor of judges for a factbase')
|
37
37
|
|
38
|
-
version('0.0.
|
38
|
+
version('0.0.14')
|
39
39
|
|
40
40
|
synopsis_format(:full)
|
41
41
|
|
@@ -54,7 +54,7 @@ end
|
|
54
54
|
desc 'Update the factbase by passing all judges one by one'
|
55
55
|
command :update do |c|
|
56
56
|
c.desc 'Options to pass to every judge'
|
57
|
-
c.flag([:o, :option],
|
57
|
+
c.flag([:o, :option], multiple: true, arg_name: '<key=value>')
|
58
58
|
c.action do |global, options, args|
|
59
59
|
require_relative '../lib/judges/commands/update'
|
60
60
|
Judges::Update.new(loog).run(options, args)
|
data/features/cli.feature
CHANGED
@@ -19,7 +19,9 @@ Feature: Simple Run
|
|
19
19
|
n.kind = 'yes!'
|
20
20
|
end
|
21
21
|
"""
|
22
|
-
Then I run bin/judges with "update . simple.fb"
|
22
|
+
Then I run bin/judges with "--verbose update -o foo=1 -o bar=2 . simple.fb"
|
23
|
+
Then Stdout contains "foo → "
|
24
|
+
Then Stdout contains "bar → "
|
23
25
|
Then Stdout contains "1 judges processed"
|
24
26
|
And Exit code is zero
|
25
27
|
|
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.14'
|
30
30
|
s.license = 'MIT'
|
31
31
|
s.summary = 'Command-Line Tool for a Factbase'
|
32
32
|
s.description = '
|
data/lib/judges/commands/join.rb
CHANGED
@@ -43,11 +43,11 @@ class Judges::Join
|
|
43
43
|
slave = args[1]
|
44
44
|
raise "The slave factbase is absent: #{slave.to_rel}" unless File.exist?(slave)
|
45
45
|
fb = Factbase.new
|
46
|
-
fb.import(File.
|
46
|
+
fb.import(File.binread(master))
|
47
47
|
@loog.info("Master factbase imported from #{master.to_rel} (#{File.size(master)} bytes)")
|
48
|
-
fb.import(File.
|
48
|
+
fb.import(File.binread(slave))
|
49
49
|
@loog.info("Slave factbase imported from #{slave.to_rel} (#{File.size(slave)} bytes)")
|
50
|
-
File.
|
50
|
+
File.binwrite(master, fb.export)
|
51
51
|
@loog.info("Master factbase exported to #{master.to_rel} (#{File.size(master)} bytes)")
|
52
52
|
end
|
53
53
|
end
|
@@ -46,7 +46,7 @@ class Judges::Print
|
|
46
46
|
o = "#{o}.#{opts[:format]}"
|
47
47
|
end
|
48
48
|
fb = Factbase.new
|
49
|
-
fb.import(File.
|
49
|
+
fb.import(File.binread(f))
|
50
50
|
@loog.info("Factbase imported from #{f.to_rel} (#{File.size(f)} bytes)")
|
51
51
|
FileUtils.mkdir_p(File.dirname(o))
|
52
52
|
output =
|
@@ -58,7 +58,7 @@ class Judges::Print
|
|
58
58
|
when 'xml'
|
59
59
|
fb.to_xml
|
60
60
|
end
|
61
|
-
File.
|
61
|
+
File.binwrite(o, output)
|
62
62
|
@loog.info("Factbase printed to #{o.to_rel} (#{File.size(o)} bytes)")
|
63
63
|
end
|
64
64
|
end
|
@@ -40,11 +40,11 @@ class Judges::Update
|
|
40
40
|
def run(opts, args)
|
41
41
|
raise 'Exactly two arguments required' unless args.size == 2
|
42
42
|
dir = args[0]
|
43
|
-
raise "The directory is absent: #{dir}" unless File.exist?(dir)
|
43
|
+
raise "The directory is absent: #{dir.to_rel}" unless File.exist?(dir)
|
44
44
|
file = args[1]
|
45
45
|
fb = Factbase.new
|
46
46
|
if File.exist?(file)
|
47
|
-
fb.import(File.
|
47
|
+
fb.import(File.binread(file))
|
48
48
|
@loog.info("Factbase imported from #{file.to_rel} (#{File.size(file)} bytes)")
|
49
49
|
else
|
50
50
|
@loog.info("There is no Factbase to import from #{file.to_rel} (file is absent)")
|
@@ -53,17 +53,20 @@ class Judges::Update
|
|
53
53
|
@loog.debug("The following options provided:\n\t#{options.to_s.gsub("\n", "\n\t")}")
|
54
54
|
errors = []
|
55
55
|
done = Judges::Packs.new(dir, @loog).each_with_index do |p, i|
|
56
|
-
@loog.info("
|
56
|
+
@loog.info("Running #{p.dir.to_rel} (##{i})...")
|
57
|
+
before = fb.size
|
57
58
|
begin
|
58
59
|
p.run(fb, options)
|
59
60
|
rescue StandardError => e
|
60
61
|
@loog.warn(Backtrace.new(e))
|
61
62
|
errors << p.script
|
62
63
|
end
|
64
|
+
after = fb.size
|
65
|
+
@loog.info("Pack #{p.dir.to_rel} added #{after - before} facts") if after > before
|
63
66
|
end
|
64
67
|
@loog.info("#{done} judges processed (#{errors.size} errors)")
|
65
68
|
FileUtils.mkdir_p(File.dirname(file))
|
66
|
-
File.
|
69
|
+
File.binwrite(file, fb.export)
|
67
70
|
@loog.info("Factbase exported to #{file.to_rel} (#{File.size(file)} bytes)")
|
68
71
|
raise "Failed to update correctly (#{errors.size} errors)" unless errors.empty?
|
69
72
|
end
|
data/lib/judges/options.rb
CHANGED
data/lib/judges/to_rel.rb
CHANGED
data/test/commands/test_join.rb
CHANGED
@@ -36,14 +36,14 @@ class TestJoin < Minitest::Test
|
|
36
36
|
master = File.join(d, 'master.fb')
|
37
37
|
fb1 = Factbase.new
|
38
38
|
fb1.insert.zz = 5
|
39
|
-
File.
|
39
|
+
File.binwrite(master, fb1.export)
|
40
40
|
slave = File.join(d, 'slave.fb')
|
41
41
|
fb2 = Factbase.new
|
42
42
|
fb2.insert.foo_bar = 42
|
43
|
-
File.
|
43
|
+
File.binwrite(slave, fb2.export)
|
44
44
|
Judges::Join.new(Loog::VERBOSE).run({}, [master, slave])
|
45
45
|
fb = Factbase.new
|
46
|
-
fb.import(File.
|
46
|
+
fb.import(File.binread(master))
|
47
47
|
xml = Nokogiri::XML.parse(fb.to_xml)
|
48
48
|
assert(!xml.xpath('/fb/f[zz="5"]').empty?, fb.to_xml)
|
49
49
|
assert(!xml.xpath('/fb/f[foo_bar="42"]').empty?, fb.to_xml)
|
data/test/commands/test_print.rb
CHANGED
@@ -37,7 +37,7 @@ class TestPrint < Minitest::Test
|
|
37
37
|
f = File.join(d, 'base.fb')
|
38
38
|
fb = Factbase.new
|
39
39
|
fb.insert
|
40
|
-
File.
|
40
|
+
File.binwrite(f, fb.export)
|
41
41
|
Judges::Print.new(Loog::VERBOSE).run({ format: 'yaml', auto: true }, [f])
|
42
42
|
y = File.join(d, 'base.yaml')
|
43
43
|
assert(File.exist?(y))
|
@@ -37,7 +37,7 @@ class TestUpdate < Minitest::Test
|
|
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
|
40
|
-
fb.import(File.
|
40
|
+
fb.import(File.binread(file))
|
41
41
|
xml = Nokogiri::XML.parse(fb.to_xml)
|
42
42
|
assert(!xml.xpath('/fb/f[zzz="43"]').empty?)
|
43
43
|
end
|
@@ -48,11 +48,11 @@ class TestUpdate < Minitest::Test
|
|
48
48
|
file = File.join(d, 'base.fb')
|
49
49
|
fb = Factbase.new
|
50
50
|
fb.insert.foo_bar = 42
|
51
|
-
File.
|
51
|
+
File.binwrite(file, fb.export)
|
52
52
|
File.write(File.join(d, 'foo.rb'), '$fb.insert.tt = 4')
|
53
53
|
Judges::Update.new(Loog::VERBOSE).run({}, [d, file])
|
54
54
|
fb = Factbase.new
|
55
|
-
fb.import(File.
|
55
|
+
fb.import(File.binread(file))
|
56
56
|
xml = Nokogiri::XML.parse(fb.to_xml)
|
57
57
|
assert(!xml.xpath('/fb/f[tt="4"]').empty?)
|
58
58
|
assert(!xml.xpath('/fb/f[foo_bar="42"]').empty?)
|
data/test/test_options.rb
CHANGED
@@ -61,6 +61,8 @@ class TestOptions < Minitest::Test
|
|
61
61
|
|
62
62
|
def test_converts_to_string
|
63
63
|
opts = Judges::Options.new('foo' => 44, 'bar' => 'long-string-maybe-secret')
|
64
|
-
|
64
|
+
s = opts.to_s
|
65
|
+
assert(s.include?('foo → "44"'))
|
66
|
+
assert(s.include?('"long********************"'))
|
65
67
|
end
|
66
68
|
end
|