judges 0.0.12 ā 0.0.13
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 +1 -1
- data/judges.gemspec +1 -1
- data/lib/judges/commands/test.rb +3 -3
- data/lib/judges/commands/update.rb +4 -4
- data/lib/judges/options.rb +5 -1
- data/lib/judges/to_rel.rb +4 -2
- data/test/commands/test_update.rb +1 -1
- data/test/test_options.rb +12 -0
- 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: f1b1028f7e8d932c33c2f0c761ede5fa5478a913d2292f56a70fe7ff0e8902aa
|
4
|
+
data.tar.gz: 0a48c55211f32ce7825a72f67c6c6f3757a3bdc6cf9067b1375712b6e5a3aba6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e497c35fb9aee490a9c85c911a195414c3ad17a60b60b0b4be0851b6b68a857f879fe66e16b0603db26c8ee0a85af910a15b919e89b997935de5118f288ca180
|
7
|
+
data.tar.gz: 6894d6010bbbf1f99de4c721821a6d449ca4a15fed9602751b9fa857865c37d730014e9cca48460357c2e8754873077876ca7983ef013c93f78428d77b50ff49
|
data/bin/judges
CHANGED
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.13'
|
30
30
|
s.license = 'MIT'
|
31
31
|
s.summary = 'Command-Line Tool for a Factbase'
|
32
32
|
s.description = '
|
data/lib/judges/commands/test.rb
CHANGED
@@ -40,13 +40,13 @@ class Judges::Test
|
|
40
40
|
def run(_opts, args)
|
41
41
|
raise 'Exactly one argument required' unless args.size == 1
|
42
42
|
dir = args[0]
|
43
|
-
@loog.info("Testing judges in
|
43
|
+
@loog.info("Testing judges in #{dir.to_rel}...")
|
44
44
|
errors = []
|
45
45
|
done = Judges::Packs.new(dir, @loog).each_with_index do |p, i|
|
46
|
-
@loog.info("\nš Testing
|
46
|
+
@loog.info("\nš Testing #{p.script} (##{i}) in #{p.dir.to_rel}...")
|
47
47
|
p.tests.each do |f|
|
48
48
|
yaml = YAML.load_file(f, permitted_classes: [Time])
|
49
|
-
@loog.info("Testing
|
49
|
+
@loog.info("Testing #{f.to_rel}:")
|
50
50
|
begin
|
51
51
|
test_one(p, yaml)
|
52
52
|
rescue StandardError => e
|
@@ -45,11 +45,11 @@ class Judges::Update
|
|
45
45
|
fb = Factbase.new
|
46
46
|
if File.exist?(file)
|
47
47
|
fb.import(File.read(file))
|
48
|
-
@loog.info("Factbase imported from
|
48
|
+
@loog.info("Factbase imported from #{file.to_rel} (#{File.size(file)} bytes)")
|
49
49
|
else
|
50
|
-
@loog.info("There is no Factbase to import from
|
50
|
+
@loog.info("There is no Factbase to import from #{file.to_rel} (file is absent)")
|
51
51
|
end
|
52
|
-
options = Judges::Options.new(opts['
|
52
|
+
options = Judges::Options.new(opts['option'])
|
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|
|
@@ -64,7 +64,7 @@ class Judges::Update
|
|
64
64
|
@loog.info("#{done} judges processed (#{errors.size} errors)")
|
65
65
|
FileUtils.mkdir_p(File.dirname(file))
|
66
66
|
File.write(file, fb.export)
|
67
|
-
@loog.info("Factbase exported to
|
67
|
+
@loog.info("Factbase exported to #{file.to_rel} (#{File.size(file)} bytes)")
|
68
68
|
raise "Failed to update correctly (#{errors.size} errors)" unless errors.empty?
|
69
69
|
end
|
70
70
|
end
|
data/lib/judges/options.rb
CHANGED
@@ -48,9 +48,13 @@ class Judges::Options
|
|
48
48
|
@hash ||= begin
|
49
49
|
pp = @pairs || []
|
50
50
|
pp = @pairs.map { |k, v| "#{k}=#{v}" } if pp.is_a?(Hash)
|
51
|
+
pp = pp.split(',') if pp.is_a?(String)
|
51
52
|
pp.to_h do |pair|
|
52
53
|
p = pair.split('=', 2)
|
53
|
-
|
54
|
+
k = p[0].strip
|
55
|
+
v = p[1]
|
56
|
+
v = v.nil? ? 'true' : v.strip
|
57
|
+
[k.to_sym, v.match?(/^[0-9]+$/) ? v.to_i : v]
|
54
58
|
end
|
55
59
|
end
|
56
60
|
k = args[0].downcase
|
data/lib/judges/to_rel.rb
CHANGED
@@ -31,10 +31,12 @@ class Object
|
|
31
31
|
def to_rel
|
32
32
|
s = File.absolute_path(to_s)
|
33
33
|
p = Pathname.new(s).relative_path_from(Dir.getwd)
|
34
|
+
t = p.to_s
|
35
|
+
t = "\"#{t}\"" if t.include?(' ')
|
34
36
|
if p.directory?
|
35
|
-
"#{
|
37
|
+
"#{t}/"
|
36
38
|
else
|
37
|
-
|
39
|
+
t
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
@@ -35,7 +35,7 @@ class TestUpdate < Minitest::Test
|
|
35
35
|
Dir.mktmpdir do |d|
|
36
36
|
File.write(File.join(d, 'foo.rb'), '$fb.insert.zzz = $options.foo_bar + 1')
|
37
37
|
file = File.join(d, 'base.fb')
|
38
|
-
Judges::Update.new(Loog::VERBOSE).run({ '
|
38
|
+
Judges::Update.new(Loog::VERBOSE).run({ 'option' => ['foo_bar=42'] }, [d, file])
|
39
39
|
fb = Factbase.new
|
40
40
|
fb.import(File.read(file))
|
41
41
|
xml = Nokogiri::XML.parse(fb.to_xml)
|
data/test/test_options.rb
CHANGED
@@ -35,11 +35,23 @@ class TestOptions < Minitest::Test
|
|
35
35
|
assert_equal(42, opts.max)
|
36
36
|
end
|
37
37
|
|
38
|
+
def test_stips_spaces
|
39
|
+
opts = Judges::Options.new([' token=a77 ', 'max = 42'])
|
40
|
+
assert_equal('a77', opts.token)
|
41
|
+
assert_equal(42, opts.max)
|
42
|
+
end
|
43
|
+
|
38
44
|
def test_with_nil
|
39
45
|
opts = Judges::Options.new(nil)
|
40
46
|
assert(opts.foo.nil?)
|
41
47
|
end
|
42
48
|
|
49
|
+
def test_with_string
|
50
|
+
opts = Judges::Options.new('a=1,b=42')
|
51
|
+
assert_equal(1, opts.a)
|
52
|
+
assert_equal(42, opts.b)
|
53
|
+
end
|
54
|
+
|
43
55
|
def test_with_hash
|
44
56
|
opts = Judges::Options.new('foo' => 42, 'bar' => 'hello')
|
45
57
|
assert_equal(42, opts.foo)
|