judges 0.0.29 → 0.0.31

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: e4506ff0fe002c7bd8077f203ba8a0af5b9d5b9b788e1d42370c6f990d4b9479
4
- data.tar.gz: 8cf313cdaa8a859ffe1c286107c767aac93a0196420152c57337dd05d0ed4881
3
+ metadata.gz: 1c9e50999193ddf009d02379799add455856fae20b4f47e67a1760d56d7de3b0
4
+ data.tar.gz: af70fa8273042c07df059589181795769518c94d54c4430cf9fe9d2999da799a
5
5
  SHA512:
6
- metadata.gz: f19785b0268c7dce59b6d9478137e2e2e1172ebc03fd803b576d0c1d155eecadea11d38ecaa258f8ecefef031e183807660dee7b0f7aede0c875a42f101ae62d
7
- data.tar.gz: 433e49e718acd4b17ba9efdbce605181ca2b6cd88a7a36601bf71dc926f07185f652d57e1005750b28fe2c98467f05c1b93ddd93dee4461dd40f28a58a209097
6
+ metadata.gz: ce9ee17c4b5cf1aadc125678bde1e0a7b4bd07a6e1cb2e54696e5e478a68371f9e4c7a6c18f7961be77f056903a1e49eb943d4c9d949fedb96db71ed2f23350e
7
+ data.tar.gz: fbadf8ca9127b21114b483b7a7f5e6b109d8c804f101a27fe6140c6a77e68a0f522bda5b32a366415b946d1c59c01130ab509a22e9f5c95037dbf605414d7667
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.28)
6
+ factbase (~> 0.0.30)
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.28)
77
+ factbase (0.0.30)
78
78
  json (~> 2.7)
79
79
  loog (~> 0.2)
80
80
  nokogiri (~> 1.10)
@@ -112,7 +112,7 @@ GEM
112
112
  racc
113
113
  psych (5.1.2)
114
114
  stringio
115
- racc (1.7.3)
115
+ racc (1.8.0)
116
116
  rack (3.0.11)
117
117
  rack-session (2.0.0)
118
118
  rack (>= 3.0.0)
data/Rakefile CHANGED
@@ -69,6 +69,7 @@ end
69
69
  task :copyright do
70
70
  sh "grep -q -r '#{Date.today.strftime('%Y')}' \
71
71
  --include '*.rb' \
72
+ --include '*.yml' \
72
73
  --include '*.txt' \
73
74
  --include 'Rakefile' \
74
75
  ."
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.29'
35
+ ver = '0.0.31'
36
36
 
37
37
  loog = Loog::REGULAR
38
38
 
@@ -115,6 +115,8 @@ class App
115
115
  c.switch([:auto], default_value: false)
116
116
  c.desc 'Only the facts that match the expression are printed'
117
117
  c.flag([:query], default_value: '()')
118
+ c.desc 'Print even if target file already exists and is older than the factbase'
119
+ c.switch([:force], default_value: false)
118
120
  c.action do |global, options, args|
119
121
  require_relative '../lib/judges/commands/print'
120
122
  Judges::Print.new(loog).run(options, args)
@@ -13,5 +13,5 @@ Feature: Import
13
13
  z: 3.14
14
14
  """
15
15
  Then I run bin/judges with "--verbose import simple.yaml simple.fb"
16
- Then Stdout contains "Import finished"
16
+ Then Stdout contains "Import of 2 facts finished"
17
17
  And Exit code is zero
@@ -4,7 +4,6 @@ Feature: Print
4
4
  Scenario: Simple print of a small factbase, to YAML
5
5
  Given I make a temp directory
6
6
  Then I run bin/judges with "--verbose eval simple.fb '$fb.insert.foo = 42'"
7
- Then I run bin/judges with "update . simple.fb"
8
7
  Then I run bin/judges with "print --format=yaml simple.fb simple.yml"
9
8
  Then Stdout contains "printed"
10
9
  And Exit code is zero
@@ -12,7 +11,6 @@ Feature: Print
12
11
  Scenario: Simple print of a small factbase, to JSON
13
12
  Given I make a temp directory
14
13
  Then I run bin/judges with "--verbose eval simple.fb '$fb.insert.foo = 42'"
15
- Then I run bin/judges with "update . simple.fb"
16
14
  Then I run bin/judges with "print --format=json simple.fb simple.json"
17
15
  Then Stdout contains "printed"
18
16
  And Exit code is zero
@@ -20,7 +18,6 @@ Feature: Print
20
18
  Scenario: Simple print of a small factbase, to XML
21
19
  Given I make a temp directory
22
20
  Then I run bin/judges with "--verbose eval simple.fb '$fb.insert.foo = 42'"
23
- Then I run bin/judges with "update . simple.fb"
24
21
  Then I run bin/judges with "print --format=xml --auto simple.fb"
25
22
  Then Stdout contains "printed"
26
23
  And Exit code is zero
@@ -29,7 +26,15 @@ Feature: Print
29
26
  Given I make a temp directory
30
27
  Then I run bin/judges with "--verbose eval simple.fb '$fb.insert.foo = 42'"
31
28
  Then I run bin/judges with "--verbose eval simple.fb '$fb.insert.foo = 43'"
32
- Then I run bin/judges with "update . simple.fb"
33
29
  Then I run bin/judges with "print '--query=(eq foo 43)' --auto simple.fb"
34
30
  Then Stdout contains "printed"
35
31
  And Exit code is zero
32
+
33
+ Scenario: Print twice, without --force
34
+ Given I make a temp directory
35
+ Then I run bin/judges with "--verbose eval simple.fb '$fb.insert.foo = 42'"
36
+ Then I run bin/judges with "print --auto simple.fb"
37
+ Then Stdout contains "printed"
38
+ Then I run bin/judges with "print --auto simple.fb"
39
+ Then Stdout contains "No need to print"
40
+ And Exit code is zero
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'
29
+ s.version = '0.0.31'
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.28'
45
+ s.add_runtime_dependency 'factbase', '~>0.0.30'
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'
@@ -20,13 +20,10 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
- require 'backtrace'
24
23
  require 'factbase/looged'
25
24
  require_relative '../../judges'
26
- require_relative '../../judges/to_rel'
27
- require_relative '../../judges/packs'
28
- require_relative '../../judges/options'
29
25
  require_relative '../../judges/impex'
26
+ require_relative '../../judges/elapsed'
30
27
 
31
28
  # Eval.
32
29
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -40,12 +37,15 @@ class Judges::Eval
40
37
  def run(_opts, args)
41
38
  raise 'Exactly two arguments required' unless args.size == 2
42
39
  impex = Judges::Impex.new(@loog, args[0])
43
- $fb = impex.import(strict: false)
44
- $fb = Factbase::Looged.new($fb, @loog)
45
- expr = args[1]
46
- # rubocop:disable Security/Eval
47
- eval(expr)
48
- # rubocop:enable Security/Eval
49
- impex.export($fb)
40
+ elapsed(@loog) do
41
+ $fb = impex.import(strict: false)
42
+ $fb = Factbase::Looged.new($fb, @loog)
43
+ expr = args[1]
44
+ # rubocop:disable Security/Eval
45
+ eval(expr)
46
+ # rubocop:enable Security/Eval
47
+ impex.export($fb)
48
+ throw :'Evaluated successfully'
49
+ end
50
50
  end
51
51
  end
@@ -25,6 +25,7 @@ require 'factbase/looged'
25
25
  require_relative '../../judges'
26
26
  require_relative '../../judges/impex'
27
27
  require_relative '../../judges/to_rel'
28
+ require_relative '../../judges/elapsed'
28
29
 
29
30
  # Import.
30
31
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -38,18 +39,20 @@ class Judges::Import
38
39
  def run(_opts, args)
39
40
  raise 'Exactly two arguments required' unless args.size == 2
40
41
  raise "File not found #{args[0].to_rel}" unless File.exist?(args[0])
41
- start = Time.now
42
- yaml = YAML.load_file(args[0], permitted_classes: [Time])
43
- impex = Judges::Impex.new(@loog, args[1])
44
- fb = impex.import(strict: false)
45
- fb = Factbase::Looged.new(fb, @loog)
46
- yaml.each do |i|
47
- f = fb.insert
48
- i.each do |p, v|
49
- f.send("#{p}=", v)
42
+ elapsed(@loog) do
43
+ yaml = YAML.load_file(args[0], permitted_classes: [Time])
44
+ @loog.info("YAML loaded from #{args[0].to_rel} (#{yaml.size} facts)")
45
+ impex = Judges::Impex.new(@loog, args[1])
46
+ fb = impex.import(strict: false)
47
+ fb = Factbase::Looged.new(fb, @loog)
48
+ yaml.each do |i|
49
+ f = fb.insert
50
+ i.each do |p, v|
51
+ f.send("#{p}=", v)
52
+ end
50
53
  end
54
+ impex.export(fb)
55
+ throw :"Import of #{yaml.size} facts finished"
51
56
  end
52
- impex.export(fb)
53
- @loog.info("Import finished in #{format('%.02f', Time.now - start)}s")
54
57
  end
55
58
  end
@@ -22,6 +22,7 @@
22
22
 
23
23
  require_relative '../../judges'
24
24
  require_relative '../../judges/impex'
25
+ require_relative '../../judges/elapsed'
25
26
 
26
27
  # Join.
27
28
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -36,9 +37,11 @@ class Judges::Join
36
37
  raise 'Exactly two arguments required' unless args.size == 2
37
38
  master = Judges::Impex.new(@loog, args[0])
38
39
  slave = Judges::Impex.new(@loog, args[1])
39
- fb = master.import
40
- slave.import_to(fb)
41
- master.export(fb)
42
- @loog.info('Two factbases joined')
40
+ elapsed(@loog) do
41
+ fb = master.import
42
+ slave.import_to(fb)
43
+ master.export(fb)
44
+ throw :'Two factbases joined'
45
+ end
43
46
  end
44
47
  end
@@ -24,6 +24,7 @@ require 'fileutils'
24
24
  require 'factbase'
25
25
  require_relative '../../judges'
26
26
  require_relative '../../judges/impex'
27
+ require_relative '../../judges/elapsed'
27
28
 
28
29
  # Update.
29
30
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -36,29 +37,38 @@ class Judges::Print
36
37
 
37
38
  def run(opts, args)
38
39
  raise 'At lease one argument required' if args.empty?
39
- o = args[1]
40
40
  f = args[0]
41
41
  fb = Judges::Impex.new(@loog, f).import
42
42
  fb.query("(not #{opts['query']})").delete! unless opts['query'].nil?
43
+ o = args[1]
43
44
  if o.nil?
44
45
  raise 'Either provide output file name or use --auto' unless opts[:auto]
45
46
  o = File.join(File.dirname(f), File.basename(f).gsub(/\.[^.]*$/, ''))
46
47
  o = "#{o}.#{opts[:format]}"
47
48
  end
48
49
  FileUtils.mkdir_p(File.dirname(o))
49
- output =
50
- case opts[:format].downcase
51
- when 'yaml'
52
- require 'factbase/to_yaml'
53
- Factbase::ToYAML.new(fb).yaml
54
- when 'json'
55
- require 'factbase/to_json'
56
- Factbase::ToJSON.new(fb).json
57
- when 'xml'
58
- require 'factbase/to_xml'
59
- Factbase::ToXML.new(fb).xml
50
+ if !opts['force'] && File.exist?(o)
51
+ if File.mtime(f) < File.mtime(o)
52
+ @loog.info("No need to print to #{o.to_rel}, since it's up to date (#{File.size(o)} bytes)")
53
+ return
60
54
  end
61
- File.binwrite(o, output)
62
- @loog.info("Factbase printed to #{o.to_rel} (#{File.size(o)} bytes)")
55
+ @loog.debug("The factbase #{f.to_rel} is younger than the target #{o.to_rel}, need to print")
56
+ end
57
+ elapsed(@loog) do
58
+ output =
59
+ case opts[:format].downcase
60
+ when 'yaml'
61
+ require 'factbase/to_yaml'
62
+ Factbase::ToYAML.new(fb).yaml
63
+ when 'json'
64
+ require 'factbase/to_json'
65
+ Factbase::ToJSON.new(fb).json
66
+ when 'xml'
67
+ require 'factbase/to_xml'
68
+ Factbase::ToXML.new(fb).xml
69
+ end
70
+ File.binwrite(o, output)
71
+ throw :"Factbase printed to #{o.to_rel} (#{File.size(o)} bytes)"
72
+ end
63
73
  end
64
74
  end
@@ -29,6 +29,7 @@ require_relative '../../judges'
29
29
  require_relative '../../judges/to_rel'
30
30
  require_relative '../../judges/packs'
31
31
  require_relative '../../judges/options'
32
+ require_relative '../../judges/elapsed'
32
33
 
33
34
  # Test.
34
35
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -46,33 +47,29 @@ class Judges::Test
46
47
  errors = []
47
48
  done = 0
48
49
  global = {}
49
- start = Time.now
50
- Judges::Packs.new(dir, opts['lib'], @loog).each_with_index do |p, i|
51
- local = {}
52
- next unless include?(opts, p.name)
53
- @loog.info("\n👉 Testing #{p.script} (##{i}) in #{p.dir.to_rel}...")
54
- p.tests.each do |f|
55
- yaml = YAML.load_file(f, permitted_classes: [Time])
56
- @loog.info("Testing #{f.to_rel}:")
57
- begin
58
- test_one(p, global, local, yaml)
59
- rescue StandardError => e
60
- @loog.warn(Backtrace.new(e))
61
- errors << f
50
+ elapsed(@loog) do
51
+ Judges::Packs.new(dir, opts['lib'], @loog).each_with_index do |p, i|
52
+ local = {}
53
+ next unless include?(opts, p.name)
54
+ @loog.info("\n👉 Testing #{p.script} (##{i}) in #{p.dir.to_rel}...")
55
+ p.tests.each do |f|
56
+ yaml = YAML.load_file(f, permitted_classes: [Time])
57
+ @loog.info("Testing #{f.to_rel}:")
58
+ begin
59
+ test_one(p, global, local, yaml)
60
+ rescue StandardError => e
61
+ @loog.warn(Backtrace.new(e))
62
+ errors << f
63
+ end
62
64
  end
65
+ done += 1
63
66
  end
64
- done += 1
65
- end
66
- lapse = "in #{format('%.02f', Time.now - start)}s"
67
- if done.zero?
68
- raise 'No judges tested :(' unless opts['quiet']
69
- @loog.warn("\n👍 No judges tested #{lapse}")
70
- elsif errors.empty?
71
- @loog.info("\n👍 All #{done} judge(s) tested successfully #{lapse}")
72
- else
73
- @loog.info("\n❌ #{done} judge(s) tested, #{errors.size} of them failed #{lapse}")
74
- raise "#{errors.size} tests failed" unless opts['quiet']
67
+ throw :'👍 No judges tested' if done.zero?
68
+ throw :"👍 All #{done} judge(s) tested successfully" if errors.empty?
69
+ throw :" #{done} judge(s) tested, #{errors.size} of them failed"
75
70
  end
71
+ raise "#{errors.size} tests failed" unless opts['quiet'] || errors.empty?
72
+ raise 'No judges tested :(' unless opts['quiet'] || !done.zero?
76
73
  end
77
74
 
78
75
  private
@@ -23,6 +23,7 @@
23
23
  require 'time'
24
24
  require_relative '../../judges'
25
25
  require_relative '../../judges/impex'
26
+ require_relative '../../judges/elapsed'
26
27
 
27
28
  # Trim.
28
29
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -46,14 +47,11 @@ class Judges::Trim
46
47
  else
47
48
  raise 'Specify either --days or --query' unless opts['days'].nil?
48
49
  end
49
- start = Time.now
50
- deleted = fb.query(query).delete!
51
- lapse = "in #{format('%.02f', Time.now - start)}s"
52
- if deleted.zero?
53
- @loog.info("No facts deleted #{lapse}")
54
- else
55
- @loog.info("🗑 #{deleted} fact(s) deleted #{lapse}")
50
+ elapsed(@loog) do
51
+ deleted = fb.query(query).delete!
52
+ throw :'No facts deleted' if deleted.zero?
56
53
  impex.export(fb)
54
+ throw :"🗑 #{deleted} fact(s) deleted"
57
55
  end
58
56
  end
59
57
  end
@@ -27,6 +27,7 @@ require_relative '../../judges/to_rel'
27
27
  require_relative '../../judges/packs'
28
28
  require_relative '../../judges/options'
29
29
  require_relative '../../judges/impex'
30
+ require_relative '../../judges/elapsed'
30
31
 
31
32
  # Update.
32
33
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -48,23 +49,27 @@ class Judges::Update
48
49
  @loog.debug("The following options provided:\n\t#{options.to_s.gsub("\n", "\n\t")}")
49
50
  packs = Judges::Packs.new(dir, opts['lib'], @loog)
50
51
  c = 0
51
- start = Time.now
52
- loop do
53
- c += 1
54
- diff = cycle(opts, packs, fb, options)
55
- impex.export(fb)
56
- break if diff.zero?
57
- if !opts['max-cycles'].nil? && c >= opts['max-cycles']
58
- @loog.info('Too many cycles already, as set by --max-cycles, breaking')
59
- break
52
+ elapsed(@loog) do
53
+ loop do
54
+ c += 1
55
+ if c > 1
56
+ @loog.info("\n\nStarting cycle ##{c}#{opts['max-cycles'] ? " (out of #{opts['max-cycles']})" : ''}...")
57
+ end
58
+ diff = cycle(opts, packs, fb, options)
59
+ impex.export(fb)
60
+ break if diff.zero?
61
+ if !opts['max-cycles'].nil? && c >= opts['max-cycles']
62
+ @loog.info('Too many cycles already, as set by --max-cycles, breaking')
63
+ break
64
+ end
65
+ @loog.info(
66
+ "By #{diff} facts the factbase " \
67
+ "#{diff.positive? ? 'increased' : 'decreased'} " \
68
+ "its size at the cycle ##{c}"
69
+ )
60
70
  end
61
- @loog.info(
62
- "By #{diff} facts the factbase " \
63
- "#{diff.positive? ? 'increased' : 'decreased'} " \
64
- "its size at the cycle ##{c}"
65
- )
71
+ throw :"Update finished: #{c} cycles"
66
72
  end
67
- @loog.info("Update finished: #{c} cycles in #{format('%.02f', Time.now - start)}s")
68
73
  end
69
74
 
70
75
  private
@@ -73,26 +78,25 @@ class Judges::Update
73
78
  errors = []
74
79
  diff = 0
75
80
  global = {}
76
- done = packs.each_with_index do |p, i|
77
- local = {}
78
- @loog.info("👉 Running #{p.name} (##{i}) at #{p.dir.to_rel}...")
79
- before = fb.size
80
- begin
81
- p.run(fb, global, local, options)
82
- rescue StandardError => e
83
- @loog.warn(Backtrace.new(e))
84
- errors << p.script
81
+ elapsed(@loog) do
82
+ done = packs.each_with_index do |p, i|
83
+ local = {}
84
+ @loog.info("👉 Running #{p.name} (##{i}) at #{p.dir.to_rel}...")
85
+ before = fb.size
86
+ begin
87
+ p.run(fb, global, local, options)
88
+ rescue StandardError => e
89
+ @loog.warn(Backtrace.new(e))
90
+ errors << p.script
91
+ end
92
+ after = fb.size
93
+ @loog.info("👍 The judge #{p.dir.to_rel} added #{after - before} facts") if after > before
94
+ diff += after - before
85
95
  end
86
- after = fb.size
87
- @loog.info("👍 Pack #{p.dir.to_rel} added #{after - before} facts") if after > before
88
- diff += after - before
89
- end
90
- if errors.empty?
91
- @loog.info("👍 #{done} judge(s) processed")
92
- else
93
- @loog.info("❌ #{done} judge(s) processed with #{errors.size} errors")
94
- raise "Failed to update correctly (#{errors.size} errors)" unless opts['quiet']
96
+ throw :"👍 #{done} judge(s) processed" if errors.empty?
97
+ throw :" #{done} judge(s) processed with #{errors.size} errors"
95
98
  end
99
+ raise "Failed to update correctly (#{errors.size} errors)" unless errors.empty? || opts['quiet']
96
100
  diff
97
101
  end
98
102
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2024 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ def elapsed(loog)
24
+ start = Time.now
25
+ begin
26
+ yield
27
+ rescue UncaughtThrowError => e
28
+ tag = e.tag
29
+ throw e unless tag.is_a?(Symbol)
30
+ loog.info("#{tag} in #{format('%.02f', Time.now - start)}s")
31
+ end
32
+ end
data/lib/judges/pack.rb CHANGED
@@ -22,6 +22,7 @@
22
22
 
23
23
  require_relative '../judges'
24
24
  require_relative '../judges/to_rel'
25
+ require_relative '../judges/elapsed'
25
26
  require_relative '../judges/fb/once'
26
27
  require_relative '../judges/fb/if_absent'
27
28
 
@@ -55,8 +56,9 @@ class Judges::Pack
55
56
  end
56
57
  s = File.join(@dir, script)
57
58
  raise "Can't load '#{s}'" unless File.exist?(s)
58
- begin
59
+ elapsed(@loog) do
59
60
  load(s, true)
61
+ throw :"#{name} finished"
60
62
  ensure
61
63
  $fb = $judge = $options = $loog = nil
62
64
  end
@@ -44,4 +44,19 @@ class TestPrint < Minitest::Test
44
44
  assert_equal(1, YAML.load_file(y)['facts'].size)
45
45
  end
46
46
  end
47
+
48
+ def test_print_twice
49
+ Dir.mktmpdir do |d|
50
+ f = File.join(d, 'base.fb')
51
+ fb = Factbase.new
52
+ fb.insert
53
+ File.binwrite(f, fb.export)
54
+ Judges::Print.new(Loog::NULL).run({ format: 'yaml', auto: true }, [f])
55
+ y = File.join(d, 'base.yaml')
56
+ assert(File.exist?(y))
57
+ mtime = File.mtime(y)
58
+ Judges::Print.new(Loog::NULL).run({ format: 'yaml', auto: true }, [f])
59
+ assert_equal(mtime, File.mtime(y))
60
+ end
61
+ end
47
62
  end
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.0.29
4
+ version: 0.0.31
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-05-19 00:00:00.000000000 Z
11
+ date: 2024-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.28
33
+ version: 0.0.30
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.28
40
+ version: 0.0.30
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: gli
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -137,6 +137,7 @@ files:
137
137
  - lib/judges/commands/test.rb
138
138
  - lib/judges/commands/trim.rb
139
139
  - lib/judges/commands/update.rb
140
+ - lib/judges/elapsed.rb
140
141
  - lib/judges/fb/if_absent.rb
141
142
  - lib/judges/fb/once.rb
142
143
  - lib/judges/impex.rb