judges 0.29.0 → 0.30.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef7c67730c179f98b6f395fbad9be1df9229984b380c52ac6c64767b74ce241e
4
- data.tar.gz: bf6b63a2acd86e3c8b411f069367aebaed64f5c36a85997038bf31f19cded3c1
3
+ metadata.gz: f01a2691168164c12d039a3267c9d25ab1cd610a84ec1875979f13398200f4bd
4
+ data.tar.gz: 55942ba12539e3350f8e94a68b1bb92cec76dc90ee6ccc42ea8ab26fc35adec7
5
5
  SHA512:
6
- metadata.gz: e8c2dd385af7ec0e2f80080e27ddec8479812521efe16ae754726adfce6593c62396fae72d6a635ed9e925aa1dee1f2382f0cdedde24abcfb1a805da925f23f4
7
- data.tar.gz: 4597927deaf3e416a86083a2aab8db341469c604aa935e145119da1ad7bbb83319ffceaa6ac50778d33cada2cf5cd5209a5227aa5826c2febb4726b7efc36c28
6
+ metadata.gz: 8656a5a65cb356d16fdd7050d368f4ac676163e5306201a5c4637fa769d1fbfaca3520b12c1a58d9e2ed261e0fd738b570567bcb67d31800a7eaf9a237b3841b
7
+ data.tar.gz: e9f4a0043e70d85b6cb06a38d8de90dd2ce34c3f49c758d7ed3a38c8056bcd8c154212f61775eb0404824f42daa654008ea91b174db45b35b269742f1cf2d94c
data/bin/judges CHANGED
@@ -70,6 +70,8 @@ class JudgesGLI extend GLI::App
70
70
  command :update do |c|
71
71
  c.desc 'Options to pass to every judge'
72
72
  c.flag([:o, :option], multiple: true, arg_name: '<key=value>')
73
+ c.desc 'File with options, one k=v pair per line'
74
+ c.flag([:'options-file'])
73
75
  c.desc 'The location of a Ruby library (directory with .rb files to include)'
74
76
  c.flag([:lib])
75
77
  c.desc 'Maximum time in seconds to spend on every judge (forcefully terminate if over time)'
@@ -15,6 +15,24 @@ Feature: Update
15
15
  Then Stdout contains "Update finished in 3 cycle(s), modified 3/0 fact(s)"
16
16
  And Exit code is zero
17
17
 
18
+ Scenario: Use options from a file
19
+ Given I make a temp directory
20
+ Then I have a "simple/simple.rb" file with content:
21
+ """
22
+ n.kind.foo = $options.a1
23
+ """
24
+ Then I have a "opts.txt" file with content:
25
+ """
26
+ a1 = test
27
+ a2 = another test
28
+ """
29
+ Then I run bin/judges with "--verbose update --quiet --options-file opts.txt . simple.fb"
30
+ Then Stdout contains "A1 → "
31
+ Then Stdout contains "A2 → "
32
+ Then Stdout contains "1 judge(s) processed"
33
+ Then Stdout contains "Update finished"
34
+ And Exit code is zero
35
+
18
36
  Scenario: Simple run with a timeout for a judge
19
37
  Given I make a temp directory
20
38
  Then I have a "slow/slow.rb" file with content:
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.29.0'
29
+ s.version = '0.30.0'
30
30
  s.license = 'MIT'
31
31
  s.summary = 'Command-Line Tool for a Factbase'
32
32
  s.description =
@@ -58,6 +58,15 @@ class Judges::Update
58
58
  fb = impex.import(strict: false)
59
59
  fb = Factbase::Looged.new(fb, @loog) if opts['log']
60
60
  options = Judges::Options.new(opts['option'])
61
+ if opts['options-file']
62
+ options += Judges::Options.new(
63
+ File.readlines(opts['options-file'])
64
+ .compact
65
+ .reject(&:empty?)
66
+ .map { |ln| ln.strip.split('=', 1).map(&:strip).join('=') }
67
+ )
68
+ @loog.debug("Options loaded from #{opts['options-file']}")
69
+ end
61
70
  if options.empty?
62
71
  @loog.debug('No options provided by the --option flag')
63
72
  else
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.29.0'
28
+ VERSION = '0.30.0'
29
29
  end
@@ -81,6 +81,20 @@ class TestUpdate < Minitest::Test
81
81
  end
82
82
  end
83
83
 
84
+ def test_update_with_options_in_file
85
+ Dir.mktmpdir do |d|
86
+ save_it(File.join(d, 'foo/foo.rb'), '$fb.insert.foo = $options.bar')
87
+ file = File.join(d, 'base.fb')
88
+ opts = File.join(d, 'opts.txt')
89
+ save_it(opts, " bar = helloo \n bar = 444\n\n")
90
+ Judges::Update.new(Loog::NULL).run({ 'quiet' => true, 'max-cycles' => 1, 'options-file' => opts }, [d, file])
91
+ fb = Factbase.new
92
+ fb.import(File.binread(file))
93
+ xml = Nokogiri::XML.parse(Factbase::ToXML.new(fb).xml)
94
+ assert(!xml.xpath('/fb/f[foo="444"]').empty?, xml)
95
+ end
96
+ end
97
+
84
98
  def test_update_with_error_no_quiet
85
99
  assert_raises do
86
100
  Dir.mktmpdir do |d|
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.29.0
4
+ version: 0.30.0
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-12-24 00:00:00.000000000 Z
11
+ date: 2024-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace