judges 0.4.0 → 0.6.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: 2cc71c6f27206802eb89caac6ea4cf95558c5f36f484efea771e5ad5c442084d
4
- data.tar.gz: 717c6de821765a54a916dc2eabafaf63827fd5a522584c7af866f5beea5475c7
3
+ metadata.gz: 14d7a10c327b1cbd22dcc87773e6c3f218598a5f7d879f6f8c3ff2ddabc9018c
4
+ data.tar.gz: '0106468efd8e11754252950a2249ab0f2cbd22a9ed2081867e88e154ae2c0cc0'
5
5
  SHA512:
6
- metadata.gz: 895ea9f8d9b1527113c1a33d1c5e5a5d18b16994d00593d7f3eaf5c135c9a9eb9787c7ca969bcbced5b025eef8ff03e3927ecc90d3ee0738b9cee3cf1b948799
7
- data.tar.gz: 2c86328e14c85f7685fb46b8cf78bcac87058725db51b57ca447186c61cbf5650dee93570c7000c11105792a14d8b8879d54e861325c1f12a97f200b09e33bb3
6
+ metadata.gz: 7035bfcbf8e162ef9c4504fdb9953ad275bae7c00123d692bfd8b612bef16745e144b3b51e10560890d79681c48fb37d1f2d3a9030f6caba8896c0a76a6925e6
7
+ data.tar.gz: '09533523b712227e1fced16b32a74abd450e9f454d217574c9b35334564718f034283bd9b61cdc39ee1e654798ddb4f439199284d6ed66827024dcb347299c50'
@@ -18,40 +18,13 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
19
  # SOFTWARE.
20
20
  ---
21
- name: license
21
+ name: copyrights
22
22
  'on':
23
23
  push:
24
- branches:
25
- - master
26
24
  pull_request:
27
- branches:
28
- - master
29
25
  jobs:
30
- license:
26
+ copyrights:
31
27
  runs-on: ubuntu-22.04
32
28
  steps:
33
29
  - uses: actions/checkout@v4
34
- - shell: bash
35
- run: |
36
- header="Copyright (c) $(date +%Y) Yegor Bugayenko"
37
- failed="false"
38
- while IFS= read -r file; do
39
- if ! grep -q "${header}" "${file}"; then
40
- failed="true"
41
- echo "⚠️ Copyright header is not found in: ${file}"
42
- else
43
- echo "File looks good: ${file}"
44
- fi
45
- done < <(find . -type f \( \
46
- -name "Dockerfile" -o \
47
- -name "LICENSE.txt" -o \
48
- -name "Makefile" -o \
49
- -name "Rakefile" -o \
50
- -name "*.sh" -o \
51
- -name "*.rb" -o \
52
- -name "*.fe" -o \
53
- -name "*.yml" \
54
- \) -print)
55
- if [ "${failed}" = "true" ]; then
56
- exit 1
57
- fi
30
+ - uses: yegor256/copyrights-action@0.0.3
data/Gemfile.lock CHANGED
@@ -47,7 +47,7 @@ GEM
47
47
  backtrace (0.4.0)
48
48
  base64 (0.2.0)
49
49
  bigdecimal (3.1.8)
50
- builder (3.2.4)
50
+ builder (3.3.0)
51
51
  concurrent-ruby (1.2.3)
52
52
  connection_pool (2.4.1)
53
53
  crack (1.0.0)
@@ -85,7 +85,7 @@ GEM
85
85
  erubi (1.12.0)
86
86
  ethon (0.16.0)
87
87
  ffi (>= 1.15.0)
88
- factbase (0.0.42)
88
+ factbase (0.0.44)
89
89
  json (~> 2.7)
90
90
  loog (~> 0.2)
91
91
  nokogiri (~> 1.10)
data/bin/judges CHANGED
@@ -138,6 +138,8 @@ class App
138
138
  c.flag([:enable], multiple: true)
139
139
  c.desc 'Name of the judge to run (directory name)'
140
140
  c.flag([:judge], multiple: true)
141
+ c.desc 'How many times to run?'
142
+ c.flag([:runs], type: Integer, default_value: 1)
141
143
  c.desc 'The location of a Ruby library (directory with .rb files to include)'
142
144
  c.flag([:lib])
143
145
  c.desc 'Stay quiet even if some tests fail or simply no tests executed?'
@@ -155,9 +157,9 @@ class App
155
157
  c.desc 'The IP/hostname of the server'
156
158
  c.flag([:host], default_value: 'www.zerocracy.com')
157
159
  c.desc 'The TCP port number of the server'
158
- c.flag([:port], default_value: 443)
160
+ c.flag([:port], default_value: 443, type: Integer)
159
161
  c.desc 'Connection and read time in seconds'
160
- c.flag([:timeout], default_value: 30)
162
+ c.flag([:timeout], default_value: 30, type: Integer)
161
163
  c.desc 'Shall SSL be used?'
162
164
  c.switch([:ssl], default_value: true)
163
165
  c.action do |global, options, args|
@@ -170,12 +172,14 @@ class App
170
172
  command :pull do |c|
171
173
  c.desc 'Authentication token'
172
174
  c.flag([:token])
175
+ c.desc 'How many seconds to wait'
176
+ c.flag([:wait], default_value: 10 * 60, arg_name: '<seconds>', type: Integer)
173
177
  c.desc 'The IP/hostname of the server'
174
178
  c.flag([:host], default_value: 'www.zerocracy.com')
175
179
  c.desc 'The TCP port number of the server'
176
- c.flag([:port], default_value: 443)
180
+ c.flag([:port], default_value: 443, type: Integer)
177
181
  c.desc 'Connection and read time in seconds'
178
- c.flag([:timeout], default_value: 30)
182
+ c.flag([:timeout], default_value: 30, type: Integer)
179
183
  c.desc 'Shall SSL be used?'
180
184
  c.switch([:ssl], default_value: true)
181
185
  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.6.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|
@@ -122,12 +122,14 @@ class Judges::Test
122
122
  end
123
123
  end
124
124
  options = Judges::Options.new(opts['option']) + Judges::Options.new(yaml['options'])
125
- judge.run(Factbase::Looged.new(fb, @loog), {}, {}, options)
125
+ (1..(opts['runs'] || 1)).each do
126
+ judge.run(Factbase::Looged.new(fb, @loog), {}, {}, options)
127
+ end
126
128
  xpaths = yaml['expected']
127
129
  return if xpaths.nil?
128
130
  xml = Nokogiri::XML.parse(Factbase::ToXML.new(fb).xml)
129
131
  xpaths.each do |xp|
130
- raise "#{judge.script} doesn't match '#{xp}':\n#{xml}" if xml.xpath(xp).empty?
132
+ raise "#{judge.name}/#{tname} doesn't match '#{xp}':\n#{xml}" if xml.xpath(xp).empty?
131
133
  end
132
134
  end
133
135
  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.6.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,14 +1,14 @@
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.6.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-06-06 00:00:00.000000000 Z
11
+ date: 2024-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -151,7 +151,7 @@ files:
151
151
  - ".gitattributes"
152
152
  - ".github/workflows/actionlint.yml"
153
153
  - ".github/workflows/codecov.yml"
154
- - ".github/workflows/license.yml"
154
+ - ".github/workflows/copyrights.yml"
155
155
  - ".github/workflows/markdown-lint.yml"
156
156
  - ".github/workflows/pdd.yml"
157
157
  - ".github/workflows/rake.yml"