judges 0.4.0 ā†’ 0.5.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: 2cc71c6f27206802eb89caac6ea4cf95558c5f36f484efea771e5ad5c442084d
4
- data.tar.gz: 717c6de821765a54a916dc2eabafaf63827fd5a522584c7af866f5beea5475c7
3
+ metadata.gz: 8eed10a2293bdfe6ddfc33e7623d7eb8f905428f60fd002c55e7eb75afdcd96f
4
+ data.tar.gz: df6b6941021d0c4fbcdb22d4608d41365ca7e537104eda09909f56cb4dd8dd3d
5
5
  SHA512:
6
- metadata.gz: 895ea9f8d9b1527113c1a33d1c5e5a5d18b16994d00593d7f3eaf5c135c9a9eb9787c7ca969bcbced5b025eef8ff03e3927ecc90d3ee0738b9cee3cf1b948799
7
- data.tar.gz: 2c86328e14c85f7685fb46b8cf78bcac87058725db51b57ca447186c61cbf5650dee93570c7000c11105792a14d8b8879d54e861325c1f12a97f200b09e33bb3
6
+ metadata.gz: 07a943829af24cf0388303f9804f8b476449e3feea10ec3fa3703278ffb96e3b8c7a342d06e611e99168a8711397c380fdb70e8504fecaa22be48a6db0627550
7
+ data.tar.gz: 605f4d9c1598a4950098837ae6d8a8a432b882d1d4da75f93df78e530a584101642fbed0eb76d3df728f7dae4adbe30fb86c517ded6c16ff13f907b89ee4f797
data/bin/judges CHANGED
@@ -155,9 +155,9 @@ class App
155
155
  c.desc 'The IP/hostname of the server'
156
156
  c.flag([:host], default_value: 'www.zerocracy.com')
157
157
  c.desc 'The TCP port number of the server'
158
- c.flag([:port], default_value: 443)
158
+ c.flag([:port], default_value: 443, type: Integer)
159
159
  c.desc 'Connection and read time in seconds'
160
- c.flag([:timeout], default_value: 30)
160
+ c.flag([:timeout], default_value: 30, type: Integer)
161
161
  c.desc 'Shall SSL be used?'
162
162
  c.switch([:ssl], default_value: true)
163
163
  c.action do |global, options, args|
@@ -170,12 +170,14 @@ class App
170
170
  command :pull do |c|
171
171
  c.desc 'Authentication token'
172
172
  c.flag([:token])
173
+ c.desc 'How many seconds to wait'
174
+ c.flag([:wait], default_value: 10 * 60, arg_name: '<seconds>', type: Integer)
173
175
  c.desc 'The IP/hostname of the server'
174
176
  c.flag([:host], default_value: 'www.zerocracy.com')
175
177
  c.desc 'The TCP port number of the server'
176
- c.flag([:port], default_value: 443)
178
+ c.flag([:port], default_value: 443, type: Integer)
177
179
  c.desc 'Connection and read time in seconds'
178
- c.flag([:timeout], default_value: 30)
180
+ c.flag([:timeout], default_value: 30, type: Integer)
179
181
  c.desc 'Shall SSL be used?'
180
182
  c.switch([:ssl], default_value: true)
181
183
  c.action do |global, options, args|
@@ -4,7 +4,7 @@ Feature: Pull
4
4
  Scenario: Pull a small factbase
5
5
  Given We are online
6
6
  Given I make a temp directory
7
- Then I run bin/judges with "--verbose pull --token 00000000-0000-0000-0000-000000000000 simple simple.fb"
7
+ Then I run bin/judges with "--verbose pull --token 00000000-0000-0000-0000-000000000000 --wait=15 simple simple.fb"
8
8
  Then Stdout contains "Pulled"
9
9
  And Exit code is zero
10
10
  Then I run bin/judges with "inspect simple.fb"
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.4.0'
29
+ s.version = '0.5.0'
30
30
  s.license = 'MIT'
31
31
  s.summary = 'Command-Line Tool for a Factbase'
32
32
  s.description =
@@ -47,7 +47,7 @@ class Judges::Pull
47
47
  name = args[0]
48
48
  elapsed(@loog) do
49
49
  if baza.name_exists?(name)
50
- fb.import(baza.pull(wait(baza, baza.recent(name))))
50
+ fb.import(baza.pull(wait(baza, baza.recent(name), opts['wait'])))
51
51
  Judges::Impex.new(@loog, args[1]).export(fb)
52
52
  throw :"Pulled #{fb.size} facts by the name '#{name}'"
53
53
  else
@@ -58,12 +58,14 @@ class Judges::Pull
58
58
 
59
59
  private
60
60
 
61
- def wait(baza, id)
61
+ def wait(baza, id, limit)
62
+ raise 'Waiting time is nil' if limit.nil?
62
63
  start = Time.now
63
64
  loop do
64
65
  break if baza.finished?(id)
65
66
  sleep 1
66
- raise 'Time is over, the job is still not finished' if Time.now - start > 10 * 60
67
+ raise 'Time is over, the job is still not finished' if Time.now - start > limit
68
+ @loog.debug("Still waiting for the job ##{id} to finish... (#{format('%.2f', Time.now - start)}s already)")
67
69
  end
68
70
  id
69
71
  end
@@ -69,7 +69,7 @@ class Judges::Test
69
69
  end
70
70
  @loog.info("šŸ› ļø Testing #{f.to_rel}:")
71
71
  begin
72
- test_one(opts, p, yaml)
72
+ test_one(opts, p, tname, yaml)
73
73
  tests += 1
74
74
  rescue StandardError => e
75
75
  @loog.warn(Backtrace.new(e))
@@ -106,7 +106,7 @@ class Judges::Test
106
106
  judges.any? { |n| n.match?(%r{^#{name}(/#{tre})?$}) }
107
107
  end
108
108
 
109
- def test_one(opts, judge, yaml)
109
+ def test_one(opts, judge, tname, yaml)
110
110
  fb = Factbase.new
111
111
  inputs = yaml['input']
112
112
  inputs&.each do |i|
@@ -127,7 +127,7 @@ class Judges::Test
127
127
  return if xpaths.nil?
128
128
  xml = Nokogiri::XML.parse(Factbase::ToXML.new(fb).xml)
129
129
  xpaths.each do |xp|
130
- raise "#{judge.script} doesn't match '#{xp}':\n#{xml}" if xml.xpath(xp).empty?
130
+ raise "#{judge.name}/#{tname} doesn't match '#{xp}':\n#{xml}" if xml.xpath(xp).empty?
131
131
  end
132
132
  end
133
133
  end
@@ -82,7 +82,7 @@ class Judges::Update
82
82
  end
83
83
 
84
84
  def to_s
85
- "#{format('+%d', @added)}/#{format('+%d', -@removed)}"
85
+ "#{@added}/-#{@removed}"
86
86
  end
87
87
 
88
88
  def zero?
@@ -105,8 +105,10 @@ class Judges::Update
105
105
  elapsed(@loog) do
106
106
  done = judges.each_with_index do |p, i|
107
107
  @loog.info("\nšŸ‘‰ Running #{p.name} (##{i}) at #{p.dir.to_rel}...")
108
- churn += one_judge(fb, p, global, options)
109
- @loog.info("šŸ‘ The judge #{p.name} modified #{churn} facts")
108
+ elapsed(@loog) do
109
+ churn += one_judge(fb, p, global, options)
110
+ throw :"šŸ‘ The judge #{p.name} modified #{churn} facts\n"
111
+ end
110
112
  rescue StandardError, SyntaxError => e
111
113
  @loog.warn(Backtrace.new(e))
112
114
  errors << p.script
@@ -132,7 +134,7 @@ class Judges::Update
132
134
  if diff.positive?
133
135
  Churn.new(diff, 0)
134
136
  else
135
- Churn.new(0, diff)
137
+ Churn.new(0, -diff)
136
138
  end
137
139
  end
138
140
  end
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.4.0'
28
+ VERSION = '0.5.0'
29
29
  end
@@ -47,7 +47,8 @@ class TestPull < Minitest::Test
47
47
  'token' => '000',
48
48
  'host' => 'example.org',
49
49
  'port' => 80,
50
- 'ssl' => false
50
+ 'ssl' => false,
51
+ 'wait' => 10
51
52
  },
52
53
  ['foo', file]
53
54
  )
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.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko