judges 0.0.12 ā†’ 0.0.13

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: 63754c5826506b6066688aa2373dafcd87fc20cd193631c15ce67f1496dc361b
4
- data.tar.gz: a7c70946e0c24bffc91849d81e15866335ef0ebeb64b7f1cefd2c3d6c2d48506
3
+ metadata.gz: f1b1028f7e8d932c33c2f0c761ede5fa5478a913d2292f56a70fe7ff0e8902aa
4
+ data.tar.gz: 0a48c55211f32ce7825a72f67c6c6f3757a3bdc6cf9067b1375712b6e5a3aba6
5
5
  SHA512:
6
- metadata.gz: 6360db23fb5fc573d479a43d40b4c1d1e274bd21320cb4c2acba0e71a6ac8775c3398fef776dc1d7412ccd96782394e53d9631180c5a09314aab9e791738829a
7
- data.tar.gz: e5b7a0c2460d589bf9cb69e42183585d13ac6ac1b400f338e3c73057be0d2fdb9c703bcc2896f73d8dbd5f850b22452d8f5a2b147e299a1ed9fd2b1aabe2f564
6
+ metadata.gz: e497c35fb9aee490a9c85c911a195414c3ad17a60b60b0b4be0851b6b68a857f879fe66e16b0603db26c8ee0a85af910a15b919e89b997935de5118f288ca180
7
+ data.tar.gz: 6894d6010bbbf1f99de4c721821a6d449ca4a15fed9602751b9fa857865c37d730014e9cca48460357c2e8754873077876ca7983ef013c93f78428d77b50ff49
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.12')
38
+ version('0.0.13')
39
39
 
40
40
  synopsis_format(:full)
41
41
 
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.12'
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 = '
@@ -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 '#{dir.to_rel}'...")
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 '#{p.script}' (##{i}) in '#{p.dir.to_rel}'...")
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 '#{f.to_rel}':")
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 '#{file.to_rel}' (#{File.size(file)} bytes)")
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 '#{file.to_rel}' (file is absent)")
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['options'])
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 '#{file.to_rel}' (#{File.size(file)} bytes)")
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
@@ -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
- [p[0].to_sym, p[1].match?(/^[0-9]+$/) ? p[1].to_i : p[1]]
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
- "#{p}/"
37
+ "#{t}/"
36
38
  else
37
- p.to_s
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({ 'options' => ['foo_bar=42'] }, [d, file])
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)
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.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko