judges 0.0.25 → 0.0.26

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: 2326cabc04af248b0125f37645bd07fce0d9f19633f6ebaa10fdcf134da35b73
4
- data.tar.gz: ede2d649e85f3d5f637daaa963bf56887b2150345ede96bb7fd4c53f7e5f1400
3
+ metadata.gz: 0a2c905f28928721f9ed99956f7e9eea5e3b4eabf21a7bffdc324651ea2bf213
4
+ data.tar.gz: 4e6cb24b4b4aff6b8bab408d5038a8fee454382d293972ddcf78bab0d2c37b51
5
5
  SHA512:
6
- metadata.gz: 5ed7d4a0d763cd9f1a5a565033cd42e69e8d52b113f8b117832861ad8d9c22194667ef6759aa8c4c8806cc754435a3cb9583c9951183eba01c7cb3f4aa83f03e
7
- data.tar.gz: f3bfaee1fe32ff3315a533dc67019edc9e6c7fbb22db758917a17c0a643dc0a60a69e2e3641d9a954c426e39c928bef098ff1309dad18ce14bd69cf77aa061b0
6
+ metadata.gz: ad604005840c419cc0021cc0d55a64c010ca6ab64c73f5e30cfa72c9e43190382b5bf6783794389eb3f21cc6fd24d3b60c3c3f803f29f71480a0eb73cfa7995f
7
+ data.tar.gz: 4888625231190957df7b5c189215b49cb9ed1ec01c40edf795140a4d6896d7a9b6d7d24e4dd02bf931281ee25ec2db87590be3275d97aa2980cfd3eb7b44a1cf
data/Gemfile.lock CHANGED
@@ -3,7 +3,7 @@ PATH
3
3
  specs:
4
4
  judges (0.0.0)
5
5
  backtrace (~> 0.3)
6
- factbase (~> 0.0.22)
6
+ factbase (~> 0.0.23)
7
7
  gli (~> 2.21)
8
8
  loog (~> 0.2)
9
9
  nokogiri (~> 1.10)
@@ -74,7 +74,7 @@ GEM
74
74
  docile (1.4.0)
75
75
  drb (2.2.1)
76
76
  erubi (1.12.0)
77
- factbase (0.0.22)
77
+ factbase (0.0.23)
78
78
  json (~> 2.7)
79
79
  loog (~> 0.2)
80
80
  nokogiri (~> 1.10)
data/bin/judges CHANGED
@@ -32,7 +32,7 @@ Encoding.default_internal = Encoding::UTF_8
32
32
  class App
33
33
  extend GLI::App
34
34
 
35
- ver = '0.0.25'
35
+ ver = '0.0.26'
36
36
 
37
37
  loog = Loog::REGULAR
38
38
 
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.25'
29
+ s.version = '0.0.26'
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.22'
45
+ s.add_runtime_dependency 'factbase', '~>0.0.23'
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'
@@ -50,20 +50,23 @@ class Judges::Update
50
50
  c = 0
51
51
  loop do
52
52
  c += 1
53
- diff = cycle(packs, fb, impex, options)
53
+ diff = cycle(opts, packs, fb, options)
54
+ impex.export(fb)
54
55
  break if diff.zero?
55
56
  if !opts['max-cycles'].nil? && c >= opts['max-cycles']
56
57
  @loog.info('Too many cycles already, as set by --max-cycles, breaking')
57
58
  break
58
59
  end
59
- @loog.info("#{diff} modifications at the cycle ##{c}")
60
+ @loog.info("By #{diff} facts the factbase \
61
+ #{diff.positive? ? 'increased' : 'decreased'} \
62
+ its size at the cycle ##{c}")
60
63
  end
61
64
  @loog.info("Update finished in #{c} cycles")
62
65
  end
63
66
 
64
67
  private
65
68
 
66
- def cycle(packs, fb, impex, options)
69
+ def cycle(opts, packs, fb, options)
67
70
  errors = []
68
71
  diff = 0
69
72
  global = {}
@@ -87,7 +90,6 @@ class Judges::Update
87
90
  @loog.info("❌ #{done} judge(s) processed with #{errors.size} errors")
88
91
  raise "Failed to update correctly (#{errors.size} errors)" unless opts['quiet']
89
92
  end
90
- impex.export(fb)
91
93
  diff
92
94
  end
93
95
  end
data/lib/judges/impex.rb CHANGED
@@ -40,8 +40,9 @@ class Judges::Impex
40
40
  if File.exist?(@file)
41
41
  fb.import(File.binread(@file))
42
42
  @loog.info("The factbase imported from #{@file.to_rel} (#{File.size(@file)} bytes, #{fb.size} facts)")
43
- elsif strict
44
- raise "The factbase is absent at #{@file.to_rel}"
43
+ else
44
+ raise "The factbase is absent at #{@file.to_rel}" if strict
45
+ @loog.info("Nothing to import from #{@file.to_rel} (file not found)")
45
46
  end
46
47
  fb
47
48
  end
@@ -29,7 +29,7 @@ require_relative '../judges'
29
29
  class Judges::Options
30
30
  # Ctor.
31
31
  # @param pairs [Array<String>] List of pairs, like ["token=af73cd3", "max_speed=1"]
32
- def initialize(pairs)
32
+ def initialize(pairs = nil)
33
33
  @pairs = pairs
34
34
  end
35
35
 
@@ -58,4 +58,12 @@ class TestUpdate < Minitest::Test
58
58
  assert(!xml.xpath('/fb/f[foo_bar="42"]').empty?)
59
59
  end
60
60
  end
61
+
62
+ def test_update_with_error
63
+ Dir.mktmpdir do |d|
64
+ File.write(File.join(d, 'foo.rb'), 'this is a broken Ruby script')
65
+ file = File.join(d, 'base.fb')
66
+ Judges::Update.new(Loog::VERBOSE).run({ 'quiet' => true }, [d, file])
67
+ end
68
+ end
61
69
  end
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.25
4
+ version: 0.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.22
33
+ version: 0.0.23
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.22
40
+ version: 0.0.23
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: gli
43
43
  requirement: !ruby/object:Gem::Requirement