judges 0.25.1 → 0.26.0

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: 9985ec7aa091bbab98e33915b990f49cc3d6370ab0949f0b6b2820f848430b52
4
- data.tar.gz: a15f89c6a0be6b38fb4d0d2dc6f0c89fcb9149920e02692d9bcd4112271dbf32
3
+ metadata.gz: d7ddc9ee179c24bb4b9fb1fe4c1447bbc3bafe6efa533565aae29e310bb08efa
4
+ data.tar.gz: '084241cc86f8cbd93ff5fb83402ea7ebfb794e2ba303bbabbae6483185988908'
5
5
  SHA512:
6
- metadata.gz: b0b6120abac3e27fb11609e1932d7cb5a1d0317572c1f57c9b9642fdd021ca7552b8305ec364056d1d8184c4782f38a74ed20d7016139512627af3d3c1868d37
7
- data.tar.gz: 3f55277c36cff1c75798c0b24cb44a9f9a71a96a3be552f449942b49971d4a4be7b95c05f200533d4e476f839cee80f1a343beef942e19ad3bd9a11dea83cedc
6
+ metadata.gz: 7e4731457f4cf139056b1ff8bdc553d56d7f8344a5f9b076a2bfe91ab2da6234135b8967cb2dad34d3858477abb9eebfa791399876a0d030f08abc184417fb35
7
+ data.tar.gz: 4c1f6d824ca49f9374aef2a4bbb9bb4d585e7cc53d0458864110b6f7a99956df8d8ff1814e6a7e996b2b413b189913a41cdd88006ea404438cbbef0ee47529b2
data/Gemfile CHANGED
@@ -24,16 +24,17 @@ source 'https://rubygems.org'
24
24
  gemspec
25
25
 
26
26
  gem 'cucumber', '9.2.0', require: false
27
- gem 'minitest', '5.24.1', require: false
27
+ gem 'minitest', '5.25.1', require: false
28
28
  gem 'minitest-reporters', '1.7.1', require: false
29
29
  gem 'net-ping', '2.0.8', require: false
30
30
  gem 'rake', '13.2.1', require: false
31
31
  gem 'random-port', '~>0.0', require: false
32
- gem 'rspec-rails', '6.1.3', require: false
32
+ gem 'rspec-rails', '6.1.4', require: false
33
33
  gem 'rubocop', '1.65.1', require: false
34
34
  gem 'rubocop-performance', '1.21.1', require: false
35
35
  gem 'rubocop-rspec', '3.0.4', require: false
36
36
  gem 'simplecov', '0.22.0', require: false
37
37
  gem 'simplecov-cobertura', '2.1.0', require: false
38
+ gem 'w3c_validators', '1.3.7', require: false
38
39
  gem 'webmock', '3.23.1', require: false
39
40
  gem 'yard', '0.9.36', require: false
data/Gemfile.lock CHANGED
@@ -2,18 +2,19 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  judges (0.0.0)
5
- backtrace (~> 0)
6
- baza.rb (~> 0)
5
+ backtrace (> 0)
6
+ baza.rb (> 0)
7
7
  concurrent-ruby (~> 1.2)
8
- factbase (~> 0)
8
+ elapsed (> 0)
9
+ factbase (> 0)
9
10
  gli (~> 2.21)
10
- iri (~> 0)
11
- loog (~> 0)
11
+ iri (> 0)
12
+ loog (> 0)
12
13
  moments (~> 0.3)
13
14
  nokogiri (~> 1.10)
14
- others (~> 0)
15
- retries (~> 0)
16
- tago (~> 0)
15
+ others (> 0)
16
+ retries (> 0)
17
+ tago (> 0)
17
18
  typhoeus (~> 1.3)
18
19
 
19
20
  GEM
@@ -53,7 +54,7 @@ GEM
53
54
  ast (2.4.2)
54
55
  backtrace (0.4.0)
55
56
  base64 (0.2.0)
56
- baza.rb (0.0.4)
57
+ baza.rb (0.0.7)
57
58
  backtrace (> 0)
58
59
  faraday (> 0)
59
60
  faraday-http-cache (> 0)
@@ -93,18 +94,21 @@ GEM
93
94
  bigdecimal
94
95
  cucumber-gherkin (27.0.0)
95
96
  cucumber-messages (>= 19.1.4, < 23)
96
- cucumber-html-formatter (21.6.0)
97
- cucumber-messages (> 19, < 25)
97
+ cucumber-html-formatter (21.7.0)
98
+ cucumber-messages (> 19, < 27)
98
99
  cucumber-messages (22.0.0)
99
100
  cucumber-tag-expressions (6.1.0)
100
101
  decoor (0.0.1)
101
102
  diff-lcs (1.5.1)
102
103
  docile (1.4.1)
103
104
  drb (2.2.1)
105
+ elapsed (0.0.1)
106
+ loog (> 0)
107
+ tago (> 0)
104
108
  erubi (1.13.0)
105
109
  ethon (0.16.0)
106
110
  ffi (>= 1.15.0)
107
- factbase (0.3.0)
111
+ factbase (0.4.0)
108
112
  backtrace (> 0)
109
113
  decoor (> 0)
110
114
  json (~> 2.7)
@@ -148,7 +152,7 @@ GEM
148
152
  nokogiri (>= 1.12.0)
149
153
  loog (0.6.0)
150
154
  mini_mime (1.1.5)
151
- minitest (5.24.1)
155
+ minitest (5.25.1)
152
156
  minitest-reporters (1.7.1)
153
157
  ansi
154
158
  builder
@@ -175,7 +179,7 @@ GEM
175
179
  nokogiri (1.16.7-x86_64-linux)
176
180
  racc (~> 1.4)
177
181
  others (0.0.3)
178
- parallel (1.26.2)
182
+ parallel (1.26.3)
179
183
  parser (3.3.4.2)
180
184
  ast (~> 2.4.1)
181
185
  racc
@@ -225,7 +229,7 @@ GEM
225
229
  rspec-mocks (3.13.1)
226
230
  diff-lcs (>= 1.2.0, < 2.0)
227
231
  rspec-support (~> 3.13.0)
228
- rspec-rails (6.1.3)
232
+ rspec-rails (6.1.4)
229
233
  actionpack (>= 6.1)
230
234
  activesupport (>= 6.1)
231
235
  railties (>= 6.1)
@@ -276,6 +280,10 @@ GEM
276
280
  unicode-display_width (2.5.0)
277
281
  uri (0.13.0)
278
282
  useragent (0.16.10)
283
+ w3c_validators (1.3.7)
284
+ json (>= 1.8)
285
+ nokogiri (~> 1.6)
286
+ rexml (~> 3.2)
279
287
  webmock (3.23.1)
280
288
  addressable (>= 2.8.0)
281
289
  crack (>= 0.3.2)
@@ -297,17 +305,18 @@ PLATFORMS
297
305
  DEPENDENCIES
298
306
  cucumber (= 9.2.0)
299
307
  judges!
300
- minitest (= 5.24.1)
308
+ minitest (= 5.25.1)
301
309
  minitest-reporters (= 1.7.1)
302
310
  net-ping (= 2.0.8)
303
311
  rake (= 13.2.1)
304
312
  random-port (~> 0.0)
305
- rspec-rails (= 6.1.3)
313
+ rspec-rails (= 6.1.4)
306
314
  rubocop (= 1.65.1)
307
315
  rubocop-performance (= 1.21.1)
308
316
  rubocop-rspec (= 3.0.4)
309
317
  simplecov (= 0.22.0)
310
318
  simplecov-cobertura (= 2.1.0)
319
+ w3c_validators (= 1.3.7)
311
320
  webmock (= 3.23.1)
312
321
  yard (= 0.9.36)
313
322
 
data/assets/index.xsl CHANGED
@@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
23
  SOFTWARE.
24
24
  -->
25
25
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
26
- <xsl:output method="xml" doctype-system="about:legacy-compat" encoding="UTF-8" indent="yes"/>
26
+ <xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8" indent="yes"/>
27
27
  <xsl:param name="title"/>
28
28
  <xsl:param name="date"/>
29
29
  <xsl:param name="version"/>
@@ -36,9 +36,11 @@ SOFTWARE.
36
36
  </script>
37
37
  </xsl:template>
38
38
  <xsl:template match="/">
39
+ <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html&gt;</xsl:text>
39
40
  <html>
40
41
  <head>
41
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
42
+ <meta charset="UTF-8"/>
43
+ <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
42
44
  <title>
43
45
  <xsl:choose>
44
46
  <xsl:when test="$title = ''">
@@ -49,8 +51,6 @@ SOFTWARE.
49
51
  </xsl:otherwise>
50
52
  </xsl:choose>
51
53
  </title>
52
- <meta charset="UTF-8"/>
53
- <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
54
54
  <link rel="icon" href="https://www.zerocracy.com/svg/logo.svg" type="image/svg"/>
55
55
  <link href="https://cdn.jsdelivr.net/gh/yegor256/tacit@gh-pages/tacit-css.min.css" rel="stylesheet"/>
56
56
  <link href="https://cdn.jsdelivr.net/gh/yegor256/drops@gh-pages/drops.min.css" rel="stylesheet"/>
@@ -143,7 +143,7 @@ SOFTWARE.
143
143
  <xsl:call-template name="th">
144
144
  <xsl:with-param name="cols" select="$columns"/>
145
145
  </xsl:call-template>
146
- </th>
146
+ </tr>
147
147
  </thead>
148
148
  <tbody>
149
149
  <xsl:apply-templates select="f"/>
@@ -185,7 +185,7 @@ SOFTWARE.
185
185
  </xsl:when>
186
186
  <xsl:otherwise>
187
187
  <th>
188
- <xsl:text>&nbsp;</xsl:text>
188
+ <xsl:text> </xsl:text>
189
189
  </th>
190
190
  </xsl:otherwise>
191
191
  </xsl:choose>
@@ -259,4 +259,4 @@ SOFTWARE.
259
259
  </xsl:otherwise>
260
260
  </xsl:choose>
261
261
  </xsl:template>
262
- </xsl:stylesheet>
262
+ </xsl:stylesheet>
data/bin/judges CHANGED
@@ -150,7 +150,7 @@ class JudgesGLI extend GLI::App
150
150
  run_it(c, 'test')
151
151
  end
152
152
 
153
- desc 'Push the factbase to the server'
153
+ desc 'Push the factbase to the server and unlock it over there'
154
154
  command :push do |c|
155
155
  c.desc 'Authentication token'
156
156
  c.flag([:token])
@@ -173,7 +173,7 @@ class JudgesGLI extend GLI::App
173
173
  run_it(c, 'push')
174
174
  end
175
175
 
176
- desc 'Pull the factbase from the server'
176
+ desc 'Pull the factbase from the server and lock it over there'
177
177
  command :pull do |c|
178
178
  c.desc 'Authentication token'
179
179
  c.flag([:token])
@@ -8,5 +8,5 @@ Feature: Join
8
8
  Then I run bin/judges with "update . first.fb"
9
9
  Then I run bin/judges with "update . second.fb"
10
10
  Then I run bin/judges with "join first.fb second.fb"
11
- Then Stdout contains "joined"
12
- And Exit code is zero
11
+ Then Exit code is zero
12
+ And Stdout contains "joined"
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.25.1'
29
+ s.version = '0.26.0'
30
30
  s.license = 'MIT'
31
31
  s.summary = 'Command-Line Tool for a Factbase'
32
32
  s.description =
@@ -42,18 +42,19 @@ Gem::Specification.new do |s|
42
42
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
43
43
  s.rdoc_options = ['--charset=UTF-8']
44
44
  s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
45
- s.add_dependency 'backtrace', '~>0'
46
- s.add_dependency 'baza.rb', '~>0'
45
+ s.add_dependency 'backtrace', '>0'
46
+ s.add_dependency 'baza.rb', '>0'
47
47
  s.add_dependency 'concurrent-ruby', '~>1.2'
48
- s.add_dependency 'factbase', '~>0'
48
+ s.add_dependency 'elapsed', '>0'
49
+ s.add_dependency 'factbase', '>0'
49
50
  s.add_dependency 'gli', '~>2.21'
50
- s.add_dependency 'iri', '~>0'
51
- s.add_dependency 'loog', '~>0'
51
+ s.add_dependency 'iri', '>0'
52
+ s.add_dependency 'loog', '>0'
52
53
  s.add_dependency 'moments', '~>0.3'
53
54
  s.add_dependency 'nokogiri', '~>1.10'
54
- s.add_dependency 'others', '~>0'
55
- s.add_dependency 'retries', '~>0'
56
- s.add_dependency 'tago', '~>0'
55
+ s.add_dependency 'others', '>0'
56
+ s.add_dependency 'retries', '>0'
57
+ s.add_dependency 'tago', '>0'
57
58
  s.add_dependency 'typhoeus', '~>1.3'
58
59
  s.metadata['rubygems_mfa_required'] = 'true'
59
60
  end
@@ -20,10 +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 'elapsed'
23
24
  require 'factbase/looged'
24
25
  require_relative '../../judges'
25
26
  require_relative '../../judges/impex'
26
- require_relative '../../judges/elapsed'
27
27
 
28
28
  # The +eval+ command.
29
29
  #
@@ -41,7 +41,7 @@ class Judges::Eval
41
41
  def run(_opts, args)
42
42
  raise 'Exactly two arguments required' unless args.size == 2
43
43
  impex = Judges::Impex.new(@loog, args[0])
44
- elapsed(@loog) do
44
+ elapsed(@loog, level: Logger::INFO) do
45
45
  $fb = impex.import(strict: false)
46
46
  $fb = Factbase::Looged.new($fb, @loog)
47
47
  expr = args[1]
@@ -20,12 +20,12 @@
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 'elapsed'
23
24
  require 'time'
24
25
  require 'factbase/looged'
25
26
  require_relative '../../judges'
26
27
  require_relative '../../judges/impex'
27
28
  require_relative '../../judges/to_rel'
28
- require_relative '../../judges/elapsed'
29
29
 
30
30
  # The +import+ command.
31
31
  #
@@ -43,7 +43,7 @@ class Judges::Import
43
43
  def run(_opts, args)
44
44
  raise 'Exactly two arguments required' unless args.size == 2
45
45
  raise "File not found #{args[0].to_rel}" unless File.exist?(args[0])
46
- elapsed(@loog) do
46
+ elapsed(@loog, level: Logger::INFO) do
47
47
  yaml = YAML.load_file(args[0], permitted_classes: [Time])
48
48
  @loog.info("YAML loaded from #{args[0].to_rel} (#{yaml.size} facts)")
49
49
  impex = Judges::Impex.new(@loog, args[1])
@@ -20,9 +20,9 @@
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 'elapsed'
23
24
  require_relative '../../judges'
24
25
  require_relative '../../judges/impex'
25
- require_relative '../../judges/elapsed'
26
26
 
27
27
  # The +join+ command.
28
28
  #
@@ -41,7 +41,7 @@ class Judges::Join
41
41
  raise 'Exactly two arguments required' unless args.size == 2
42
42
  master = Judges::Impex.new(@loog, args[0])
43
43
  slave = Judges::Impex.new(@loog, args[1])
44
- elapsed(@loog) do
44
+ elapsed(@loog, level: Logger::INFO) do
45
45
  fb = master.import
46
46
  slave.import_to(fb)
47
47
  master.export(fb)
@@ -24,9 +24,9 @@ require 'time'
24
24
  require 'fileutils'
25
25
  require 'factbase'
26
26
  require 'nokogiri'
27
+ require 'elapsed'
27
28
  require_relative '../../judges'
28
29
  require_relative '../../judges/impex'
29
- require_relative '../../judges/elapsed'
30
30
 
31
31
  # The +print+ command.
32
32
  #
@@ -41,6 +41,9 @@ class Judges::Print
41
41
  @loog = loog
42
42
  end
43
43
 
44
+ # Run it (it is supposed to be called by the +bin/judges+ script.
45
+ # @param [Hash] opts Command line options (start with '--')
46
+ # @param [Array] args List of command line arguments
44
47
  def run(opts, args)
45
48
  raise 'At lease one argument required' if args.empty?
46
49
  f = args[0]
@@ -61,7 +64,7 @@ class Judges::Print
61
64
  end
62
65
  @loog.debug("The factbase #{f.to_rel} is younger than the target #{o.to_rel}, need to print")
63
66
  end
64
- elapsed(@loog) do
67
+ elapsed(@loog, level: Logger::INFO) do
65
68
  output =
66
69
  case fmt
67
70
  when 'yaml'
@@ -89,7 +92,7 @@ class Judges::Print
89
92
  xslt = Nokogiri::XSLT(File.read(File.join(__dir__, '../../../assets/index.xsl')))
90
93
  require 'factbase/to_xml'
91
94
  xml = Factbase::ToXML.new(fb).xml
92
- xslt.transform(
95
+ xslt.apply_to(
93
96
  Nokogiri::XML(xml),
94
97
  Nokogiri::XSLT.quote_params(
95
98
  'title' => opts['title'],
@@ -23,6 +23,7 @@
23
23
  require 'typhoeus'
24
24
  require 'iri'
25
25
  require 'baza-rb'
26
+ require 'elapsed'
26
27
  require_relative '../../judges'
27
28
  require_relative '../../judges/impex'
28
29
 
@@ -39,6 +40,9 @@ class Judges::Pull
39
40
  @loog = loog
40
41
  end
41
42
 
43
+ # Run it (it is supposed to be called by the +bin/judges+ script.
44
+ # @param [Hash] opts Command line options (start with '--')
45
+ # @param [Array] args List of command line arguments
42
46
  def run(opts, args)
43
47
  raise 'Exactly two arguments required' unless args.size == 2
44
48
  fb = Factbase.new
@@ -50,16 +54,21 @@ class Judges::Pull
50
54
  retries: (opts['retries'] || 3).to_i
51
55
  )
52
56
  name = args[0]
53
- elapsed(@loog) do
54
- baza.lock(name, opts['owner'])
57
+ elapsed(@loog, level: Logger::INFO) do
55
58
  if baza.name_exists?(name)
56
- jid = baza.recent(name)
57
- unless baza.exit_code(jid).zero?
58
- @loog.warn("STDOUT of the job ##{jid} (from the server):\n#{baza.stdout(jid)}")
59
- raise "The job ##{jid} ('#{name}') is broken, maybe you should expire it"
59
+ baza.lock(name, opts['owner'])
60
+ begin
61
+ jid = baza.recent(name)
62
+ unless baza.exit_code(jid).zero?
63
+ @loog.warn("STDOUT of the job ##{jid} (from the server):\n#{baza.stdout(jid)}")
64
+ raise "The job ##{jid} ('#{name}') is broken, maybe you should expire it"
65
+ end
66
+ fb.import(baza.pull(wait(name, baza, jid, opts['wait'])))
67
+ Judges::Impex.new(@loog, args[1]).export(fb)
68
+ rescue StandardError => e
69
+ baza.unlock(name, opts['owner'])
70
+ raise e
60
71
  end
61
- fb.import(baza.pull(wait(name, baza, jid, opts['wait'])))
62
- Judges::Impex.new(@loog, args[1]).export(fb)
63
72
  throw :"Pulled #{fb.size} facts by the name '#{name}'"
64
73
  else
65
74
  throw :"There is nothing to pull, the name '#{name}' is absent on the server"
@@ -23,6 +23,7 @@
23
23
  require 'typhoeus'
24
24
  require 'iri'
25
25
  require 'baza-rb'
26
+ require 'elapsed'
26
27
  require_relative '../../judges'
27
28
  require_relative '../../judges/impex'
28
29
 
@@ -39,6 +40,9 @@ class Judges::Push
39
40
  @loog = loog
40
41
  end
41
42
 
43
+ # Run it (it is supposed to be called by the +bin/judges+ script.
44
+ # @param [Hash] opts Command line options (start with '--')
45
+ # @param [Array] args List of command line arguments
42
46
  def run(opts, args)
43
47
  raise 'Exactly two arguments required' unless args.size == 2
44
48
  name = args[0]
@@ -51,11 +55,14 @@ class Judges::Push
51
55
  retries: (opts['retries'] || 3).to_i,
52
56
  compression: opts.fetch('zip', true)
53
57
  )
54
- elapsed(@loog) do
58
+ elapsed(@loog, level: Logger::INFO) do
55
59
  baza.lock(name, opts['owner'])
56
- id = baza.push(name, fb.export, opts['meta'] || [])
57
- baza.unlock(name, opts['owner'])
58
- throw :"Pushed #{fb.size} facts, job ID is #{id}"
60
+ begin
61
+ id = baza.push(name, fb.export, opts['meta'] || [])
62
+ throw :"Pushed #{fb.size} facts, job ID is #{id}"
63
+ ensure
64
+ baza.unlock(name, opts['owner'])
65
+ end
59
66
  end
60
67
  end
61
68
  end
@@ -25,12 +25,12 @@ require 'factbase'
25
25
  require 'backtrace'
26
26
  require 'factbase/looged'
27
27
  require 'factbase/to_xml'
28
+ require 'elapsed'
28
29
  require_relative '../../judges'
29
30
  require_relative '../../judges/to_rel'
30
31
  require_relative '../../judges/judges'
31
32
  require_relative '../../judges/options'
32
33
  require_relative '../../judges/categories'
33
- require_relative '../../judges/elapsed'
34
34
 
35
35
  # The +test+ command.
36
36
  #
@@ -45,6 +45,9 @@ class Judges::Test
45
45
  @loog = loog
46
46
  end
47
47
 
48
+ # Run it (it is supposed to be called by the +bin/judges+ script.
49
+ # @param [Hash] opts Command line options (start with '--')
50
+ # @param [Array] args List of command line arguments
48
51
  def run(opts, args)
49
52
  raise 'Exactly one argument required' unless args.size == 1
50
53
  dir = args[0]
@@ -54,7 +57,7 @@ class Judges::Test
54
57
  tests = 0
55
58
  visible = []
56
59
  judges = Judges::Judges.new(dir, opts['lib'], @loog)
57
- elapsed(@loog) do
60
+ elapsed(@loog, level: Logger::INFO) do
58
61
  judges.each_with_index do |judge, i|
59
62
  visible << judge.name
60
63
  next unless include?(opts, judge.name)
@@ -21,9 +21,9 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  require 'time'
24
+ require 'elapsed'
24
25
  require_relative '../../judges'
25
26
  require_relative '../../judges/impex'
26
- require_relative '../../judges/elapsed'
27
27
 
28
28
  # The +trim+ command.
29
29
  #
@@ -38,11 +38,14 @@ class Judges::Trim
38
38
  @loog = loog
39
39
  end
40
40
 
41
+ # Run it (it is supposed to be called by the +bin/judges+ script.
42
+ # @param [Hash] opts Command line options (start with '--')
43
+ # @param [Array] args List of command line arguments
41
44
  def run(opts, args)
42
45
  raise 'Exactly one argument required' unless args.size == 1
43
46
  impex = Judges::Impex.new(@loog, args[0])
44
47
  fb = impex.import
45
- elapsed(@loog) do
48
+ elapsed(@loog, level: Logger::INFO) do
46
49
  deleted = fb.query(opts['query']).delete!
47
50
  throw :'No facts deleted' if deleted.zero?
48
51
  impex.export(fb)
@@ -22,13 +22,13 @@
22
22
 
23
23
  require 'backtrace'
24
24
  require 'factbase/looged'
25
+ require 'elapsed'
25
26
  require_relative '../../judges'
26
27
  require_relative '../../judges/to_rel'
27
28
  require_relative '../../judges/judges'
28
29
  require_relative '../../judges/churn'
29
30
  require_relative '../../judges/options'
30
31
  require_relative '../../judges/impex'
31
- require_relative '../../judges/elapsed'
32
32
 
33
33
  # The +update+ command.
34
34
  #
@@ -43,6 +43,9 @@ class Judges::Update
43
43
  @loog = loog
44
44
  end
45
45
 
46
+ # Run it (it is supposed to be called by the +bin/judges+ script.
47
+ # @param [Hash] opts Command line options (start with '--')
48
+ # @param [Array] args List of command line arguments
46
49
  def run(opts, args)
47
50
  raise 'Exactly two arguments required' unless args.size == 2
48
51
  dir = args[0]
@@ -60,7 +63,7 @@ class Judges::Update
60
63
  judges = Judges::Judges.new(dir, opts['lib'], @loog)
61
64
  c = 0
62
65
  churn = Judges::Churn.new(0, 0)
63
- elapsed(@loog) do
66
+ elapsed(@loog, level: Logger::INFO) do
64
67
  loop do
65
68
  c += 1
66
69
  if c > 1
@@ -102,11 +105,11 @@ class Judges::Update
102
105
  def cycle(opts, judges, fb, options)
103
106
  churn = Judges::Churn.new(0, 0)
104
107
  global = {}
105
- elapsed(@loog) do
108
+ elapsed(@loog, level: Logger::INFO) do
106
109
  done =
107
110
  judges.each_with_index do |p, i|
108
111
  @loog.info("\n👉 Running #{p.name} (##{i}) at #{p.dir.to_rel}...")
109
- elapsed(@loog) do
112
+ elapsed(@loog, level: Logger::INFO) do
110
113
  c = one_judge(fb, p, global, options)
111
114
  churn += c
112
115
  throw :"👍 The judge #{p.name} modified #{c} facts out of #{fb.size}"
data/lib/judges/impex.rb CHANGED
@@ -22,9 +22,9 @@
22
22
 
23
23
  require 'factbase'
24
24
  require 'fileutils'
25
+ require 'elapsed'
25
26
  require_relative '../judges'
26
27
  require_relative '../judges/to_rel'
27
- require_relative '../judges/elapsed'
28
28
 
29
29
  # Import/Export of factbases.
30
30
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -39,7 +39,7 @@ class Judges::Impex
39
39
  def import(strict: true)
40
40
  fb = Factbase.new
41
41
  if File.exist?(@file)
42
- elapsed(@loog) do
42
+ elapsed(@loog, level: Logger::INFO) do
43
43
  fb.import(File.binread(@file))
44
44
  throw :"The factbase imported from #{@file.to_rel} (#{File.size(@file)} bytes, #{fb.size} facts)"
45
45
  end
@@ -52,14 +52,14 @@ class Judges::Impex
52
52
 
53
53
  def import_to(fb)
54
54
  raise "The factbase is absent at #{@file.to_rel}" unless File.exist?(@file)
55
- elapsed(@loog) do
55
+ elapsed(@loog, level: Logger::INFO) do
56
56
  fb.import(File.binread(@file))
57
57
  throw :"The factbase loaded from #{@file.to_rel} (#{File.size(@file)} bytes, #{fb.size} facts)"
58
58
  end
59
59
  end
60
60
 
61
61
  def export(fb)
62
- elapsed(@loog) do
62
+ elapsed(@loog, level: Logger::INFO) do
63
63
  FileUtils.mkdir_p(File.dirname(@file))
64
64
  File.binwrite(@file, fb.export)
65
65
  throw :"Factbase exported to #{@file.to_rel} (#{File.size(@file)} bytes, #{fb.size} facts)"
data/lib/judges/judge.rb CHANGED
@@ -20,9 +20,9 @@
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 'elapsed'
23
24
  require_relative '../judges'
24
25
  require_relative '../judges/to_rel'
25
- require_relative '../judges/elapsed'
26
26
 
27
27
  # A single judge.
28
28
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -56,7 +56,7 @@ class Judges::Judge
56
56
  end
57
57
  s = File.join(@dir, script)
58
58
  raise "Can't load '#{s}'" unless File.exist?(s)
59
- elapsed(@loog) do
59
+ elapsed(@loog, intro: "#{$judge} finished", level: Logger::INFO) do
60
60
  load(s, true)
61
61
  ensure
62
62
  $fb = $judge = $options = $loog = nil
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.25.1'
28
+ VERSION = '0.26.0'
29
29
  end
@@ -42,12 +42,14 @@ class TestJoin < Minitest::Test
42
42
  fb2 = Factbase.new
43
43
  fb2.insert.foo_bar = 42
44
44
  File.binwrite(slave, fb2.export)
45
- Judges::Join.new(Loog::NULL).run({}, [master, slave])
45
+ loog = Loog::Buffer.new
46
+ Judges::Join.new(loog).run({}, [master, slave])
46
47
  fb = Factbase.new
47
48
  fb.import(File.binread(master))
48
49
  xml = Nokogiri::XML.parse(Factbase::ToXML.new(fb).xml)
49
50
  assert(!xml.xpath('/fb/f[zz="5"]').empty?, xml)
50
51
  assert(!xml.xpath('/fb/f[foo_bar="42"]').empty?, xml)
52
+ assert(loog.to_s.include?('Two factbases joined'), loog.to_s)
51
53
  end
52
54
  end
53
55
  end
@@ -23,9 +23,12 @@
23
23
  require 'minitest/autorun'
24
24
  require 'loog'
25
25
  require 'factbase'
26
+ require 'nokogiri'
26
27
  require 'yaml'
27
28
  require 'fileutils'
28
29
  require 'securerandom'
30
+ require 'w3c_validators'
31
+ require 'webmock/minitest'
29
32
  require_relative '../../lib/judges'
30
33
  require_relative '../../lib/judges/commands/print'
31
34
 
@@ -70,6 +73,21 @@ class TestPrint < Minitest::Test
70
73
  [f, html]
71
74
  )
72
75
  end
76
+ doc = File.read(html)
77
+ xml =
78
+ begin
79
+ Nokogiri::XML.parse(doc) do |c|
80
+ c.norecover
81
+ c.strict
82
+ end
83
+ rescue StandardError => e
84
+ raise "#{doc}\n\n#{e}"
85
+ end
86
+ assert(xml.errors.empty?, xml)
87
+ assert(!xml.xpath('/html').empty?, xml)
88
+ WebMock.enable_net_connect!
89
+ v = W3CValidators::NuValidator.new.validate_file(html)
90
+ assert(v.errors.empty?, "#{doc}\n\n#{v.errors.join('; ')}")
73
91
  end
74
92
 
75
93
  def test_print_all_formats
@@ -39,6 +39,7 @@ class TestPull < Minitest::Test
39
39
  stub_request(:get, 'http://example.org/recent/foo.txt').to_return(body: '42')
40
40
  stub_request(:get, 'http://example.org/finished/42').to_return(body: 'yes')
41
41
  stub_request(:get, 'http://example.org/exit/42.txt').to_return(body: '0')
42
+ stub_request(:get, 'http://example.org/unlock/foo?owner=none').to_return(status: 302)
42
43
  fb = Factbase.new
43
44
  fb.insert.foo = 42
44
45
  stub_request(:get, 'http://example.org/pull/42.fb').to_return(body: fb.export)
@@ -68,6 +69,7 @@ class TestPull < Minitest::Test
68
69
  stub_request(:get, 'http://example.org/finished/42').to_return(body: 'yes')
69
70
  stub_request(:get, 'http://example.org/exit/42.txt').to_return(body: '1')
70
71
  stub_request(:get, 'http://example.org/stdout/42.txt').to_return(body: 'oops, some trouble here')
72
+ stub_request(:get, 'http://example.org/unlock/foo?owner=none').to_return(status: 302)
71
73
  Dir.mktmpdir do |d|
72
74
  file = File.join(d, 'base.fb')
73
75
  e =
@@ -60,6 +60,7 @@ class TestPush < Minitest::Test
60
60
  WebMock.disable_net_connect!
61
61
  stub_request(:get, 'http://example.org/lock/foo?owner=none').to_return(status: 302)
62
62
  stub_request(:put, 'http://example.org/push/foo').to_return(status: 500)
63
+ stub_request(:get, 'http://example.org/unlock/foo?owner=none').to_return(status: 302)
63
64
  Dir.mktmpdir do |d|
64
65
  file = File.join(d, 'base.fb')
65
66
  fb = Factbase.new
@@ -170,7 +170,7 @@ class TestTest < Minitest::Test
170
170
  expected_failure: true
171
171
  YAML
172
172
  )
173
- Judges::Test.new(Loog::VERBOSE).run({}, [d])
173
+ Judges::Test.new(Loog::NULL).run({}, [d])
174
174
  end
175
175
  end
176
176
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judges
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.1
4
+ version: 0.26.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-08-13 00:00:00.000000000 Z
11
+ date: 2024-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: baza.rb
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
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
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
@@ -52,18 +52,32 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: elapsed
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: factbase
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">"
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0'
62
76
  type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ">"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
@@ -84,28 +98,28 @@ dependencies:
84
98
  name: iri
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - "~>"
101
+ - - ">"
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
104
  type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - "~>"
108
+ - - ">"
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: loog
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - "~>"
115
+ - - ">"
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - "~>"
122
+ - - ">"
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  - !ruby/object:Gem::Dependency
@@ -140,42 +154,42 @@ dependencies:
140
154
  name: others
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
- - - "~>"
157
+ - - ">"
144
158
  - !ruby/object:Gem::Version
145
159
  version: '0'
146
160
  type: :runtime
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
- - - "~>"
164
+ - - ">"
151
165
  - !ruby/object:Gem::Version
152
166
  version: '0'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: retries
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
- - - "~>"
171
+ - - ">"
158
172
  - !ruby/object:Gem::Version
159
173
  version: '0'
160
174
  type: :runtime
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
- - - "~>"
178
+ - - ">"
165
179
  - !ruby/object:Gem::Version
166
180
  version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: tago
169
183
  requirement: !ruby/object:Gem::Requirement
170
184
  requirements:
171
- - - "~>"
185
+ - - ">"
172
186
  - !ruby/object:Gem::Version
173
187
  version: '0'
174
188
  type: :runtime
175
189
  prerelease: false
176
190
  version_requirements: !ruby/object:Gem::Requirement
177
191
  requirements:
178
- - - "~>"
192
+ - - ">"
179
193
  - !ruby/object:Gem::Version
180
194
  version: '0'
181
195
  - !ruby/object:Gem::Dependency
@@ -257,7 +271,6 @@ files:
257
271
  - lib/judges/commands/test.rb
258
272
  - lib/judges/commands/trim.rb
259
273
  - lib/judges/commands/update.rb
260
- - lib/judges/elapsed.rb
261
274
  - lib/judges/impex.rb
262
275
  - lib/judges/judge.rb
263
276
  - lib/judges/judges.rb
@@ -1,34 +0,0 @@
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
- require 'tago'
24
-
25
- def elapsed(loog)
26
- start = Time.now
27
- begin
28
- yield
29
- rescue UncaughtThrowError => e
30
- tag = e.tag
31
- throw e unless tag.is_a?(Symbol)
32
- loog.info("#{tag} in #{start.ago}")
33
- end
34
- end