always 0.1.0 → 0.2.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 +4 -4
- data/Gemfile +4 -4
- data/Gemfile.lock +22 -22
- data/README.md +7 -5
- data/Rakefile +0 -1
- data/always.gemspec +3 -3
- data/lib/always.rb +14 -12
- metadata +3 -23
- data/.0pdd.yml +0 -5
- data/.gitattributes +0 -7
- data/.github/workflows/actionlint.yml +0 -25
- data/.github/workflows/codecov.yml +0 -25
- data/.github/workflows/copyrights.yml +0 -19
- data/.github/workflows/markdown-lint.yml +0 -23
- data/.github/workflows/pdd.yml +0 -19
- data/.github/workflows/rake.yml +0 -28
- data/.github/workflows/reuse.yml +0 -19
- data/.github/workflows/typos.yml +0 -19
- data/.github/workflows/xcop.yml +0 -15
- data/.github/workflows/yamllint.yml +0 -19
- data/.gitignore +0 -11
- data/.pdd +0 -7
- data/.rubocop.yml +0 -24
- data/.rultor.yml +0 -28
- data/.simplecov +0 -24
- data/renovate.json +0 -6
- data/test/test__helper.rb +0 -31
- data/test/test_always.rb +0 -105
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 25308b6e2214b17ef2c68e68ebf2bb160c78d9667c9e5cffe79e46ac8971a10c
|
|
4
|
+
data.tar.gz: 8379f28c2d992d0376755b4da3e9445865adbd73f57719aa2019b2e96900a8e8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1b4b18ed1122fc6bc1c58a40f5776b437c0369b1c4abc2b02e9340bbd90bdf3e48dd0abf2182e55137afd6c8754aa9c63d0aee663cb694798c9e61dcaea991c
|
|
7
|
+
data.tar.gz: 30ecc3f6460995ed225cd91ca2e7294226a30abcacded97828e025631f93f88902b672b463566756760acf1db21391f0735759568790417e5e226a4f32768d0e
|
data/Gemfile
CHANGED
|
@@ -10,9 +10,9 @@ gem 'minitest', '~>5.25', require: false
|
|
|
10
10
|
gem 'minitest-reporters', '~>1.7', require: false
|
|
11
11
|
gem 'rake', '~>13.2', require: false
|
|
12
12
|
gem 'rubocop', '~>1.64', require: false
|
|
13
|
-
gem 'rubocop-minitest', '
|
|
14
|
-
gem 'rubocop-performance', '
|
|
15
|
-
gem 'rubocop-rake', '
|
|
13
|
+
gem 'rubocop-minitest', '~>0.38', require: false
|
|
14
|
+
gem 'rubocop-performance', '~>1.25', require: false
|
|
15
|
+
gem 'rubocop-rake', '~>0.7', require: false
|
|
16
16
|
gem 'simplecov', '~>0.22', require: false
|
|
17
|
-
gem 'simplecov-cobertura', '~>
|
|
17
|
+
gem 'simplecov-cobertura', '~>3.0', require: false
|
|
18
18
|
gem 'yard', '~>0.9', require: false
|
data/Gemfile.lock
CHANGED
|
@@ -12,26 +12,26 @@ GEM
|
|
|
12
12
|
builder (3.3.0)
|
|
13
13
|
concurrent-ruby (1.3.5)
|
|
14
14
|
docile (1.4.1)
|
|
15
|
-
json (2.
|
|
15
|
+
json (2.15.2)
|
|
16
16
|
language_server-protocol (3.17.0.5)
|
|
17
17
|
lint_roller (1.1.0)
|
|
18
|
-
minitest (5.
|
|
18
|
+
minitest (5.26.0)
|
|
19
19
|
minitest-reporters (1.7.1)
|
|
20
20
|
ansi
|
|
21
21
|
builder
|
|
22
22
|
minitest (>= 5.0)
|
|
23
23
|
ruby-progressbar
|
|
24
24
|
parallel (1.27.0)
|
|
25
|
-
parser (3.3.
|
|
25
|
+
parser (3.3.10.0)
|
|
26
26
|
ast (~> 2.4.1)
|
|
27
27
|
racc
|
|
28
|
-
prism (1.
|
|
28
|
+
prism (1.6.0)
|
|
29
29
|
racc (1.8.1)
|
|
30
30
|
rainbow (3.1.1)
|
|
31
|
-
rake (13.
|
|
32
|
-
regexp_parser (2.
|
|
33
|
-
rexml (3.4.
|
|
34
|
-
rubocop (1.
|
|
31
|
+
rake (13.3.0)
|
|
32
|
+
regexp_parser (2.11.3)
|
|
33
|
+
rexml (3.4.4)
|
|
34
|
+
rubocop (1.81.6)
|
|
35
35
|
json (~> 2.3)
|
|
36
36
|
language_server-protocol (~> 3.17.0.2)
|
|
37
37
|
lint_roller (~> 1.1.0)
|
|
@@ -39,20 +39,20 @@ GEM
|
|
|
39
39
|
parser (>= 3.3.0.2)
|
|
40
40
|
rainbow (>= 2.2.2, < 4.0)
|
|
41
41
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
42
|
-
rubocop-ast (>= 1.
|
|
42
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
43
43
|
ruby-progressbar (~> 1.7)
|
|
44
44
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
45
|
-
rubocop-ast (1.
|
|
45
|
+
rubocop-ast (1.47.1)
|
|
46
46
|
parser (>= 3.3.7.2)
|
|
47
47
|
prism (~> 1.4)
|
|
48
|
-
rubocop-minitest (0.38.
|
|
48
|
+
rubocop-minitest (0.38.2)
|
|
49
49
|
lint_roller (~> 1.1)
|
|
50
50
|
rubocop (>= 1.75.0, < 2.0)
|
|
51
51
|
rubocop-ast (>= 1.38.0, < 2.0)
|
|
52
|
-
rubocop-performance (1.
|
|
52
|
+
rubocop-performance (1.26.1)
|
|
53
53
|
lint_roller (~> 1.1)
|
|
54
54
|
rubocop (>= 1.75.0, < 2.0)
|
|
55
|
-
rubocop-ast (>= 1.
|
|
55
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
56
56
|
rubocop-rake (0.7.1)
|
|
57
57
|
lint_roller (~> 1.1)
|
|
58
58
|
rubocop (>= 1.72.1)
|
|
@@ -61,14 +61,14 @@ GEM
|
|
|
61
61
|
docile (~> 1.1)
|
|
62
62
|
simplecov-html (~> 0.11)
|
|
63
63
|
simplecov_json_formatter (~> 0.1)
|
|
64
|
-
simplecov-cobertura (
|
|
64
|
+
simplecov-cobertura (3.1.0)
|
|
65
65
|
rexml
|
|
66
66
|
simplecov (~> 0.19)
|
|
67
|
-
simplecov-html (0.13.
|
|
67
|
+
simplecov-html (0.13.2)
|
|
68
68
|
simplecov_json_formatter (0.1.4)
|
|
69
|
-
unicode-display_width (3.
|
|
70
|
-
unicode-emoji (~> 4.
|
|
71
|
-
unicode-emoji (4.0
|
|
69
|
+
unicode-display_width (3.2.0)
|
|
70
|
+
unicode-emoji (~> 4.1)
|
|
71
|
+
unicode-emoji (4.1.0)
|
|
72
72
|
yard (0.9.37)
|
|
73
73
|
|
|
74
74
|
PLATFORMS
|
|
@@ -87,11 +87,11 @@ DEPENDENCIES
|
|
|
87
87
|
minitest-reporters (~> 1.7)
|
|
88
88
|
rake (~> 13.2)
|
|
89
89
|
rubocop (~> 1.64)
|
|
90
|
-
rubocop-minitest (
|
|
91
|
-
rubocop-performance (
|
|
92
|
-
rubocop-rake (
|
|
90
|
+
rubocop-minitest (~> 0.38)
|
|
91
|
+
rubocop-performance (~> 1.25)
|
|
92
|
+
rubocop-rake (~> 0.7)
|
|
93
93
|
simplecov (~> 0.22)
|
|
94
|
-
simplecov-cobertura (~>
|
|
94
|
+
simplecov-cobertura (~> 3.0)
|
|
95
95
|
yard (~> 0.9)
|
|
96
96
|
|
|
97
97
|
BUNDLED WITH
|
data/README.md
CHANGED
|
@@ -15,14 +15,14 @@ This simple Ruby gem helps you run a loop forever, in a background thread.
|
|
|
15
15
|
|
|
16
16
|
```ruby
|
|
17
17
|
require 'always'
|
|
18
|
-
# Prepare, with five threads:
|
|
19
|
-
a = Always.new(5)
|
|
20
|
-
# Start them all together spinning forever with 30-seconds delay between cycles:
|
|
21
|
-
a.start(30) do
|
|
18
|
+
# Prepare, with five threads and a block:
|
|
19
|
+
a = Always.new(5) do
|
|
22
20
|
puts "I'm alive"
|
|
23
21
|
end
|
|
22
|
+
# Start them all together spinning forever with 30-seconds delay between cycles:
|
|
23
|
+
a.start!(30)
|
|
24
24
|
# Stop them all together:
|
|
25
|
-
a.stop
|
|
25
|
+
a.stop!
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
You may be interested to get the backtraces of the exceptions that
|
|
@@ -35,6 +35,8 @@ a = Always.new(5, max_backtraces: 10)
|
|
|
35
35
|
a.on_error do |exception, thread_id|
|
|
36
36
|
puts "Error in thread #{thread_id}: #{exception.message}"
|
|
37
37
|
end
|
|
38
|
+
# Start them:
|
|
39
|
+
a.start!
|
|
38
40
|
# Retrieve the backtraces:
|
|
39
41
|
p a.backtraces
|
|
40
42
|
```
|
data/Rakefile
CHANGED
data/always.gemspec
CHANGED
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
|
9
9
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
|
10
10
|
s.required_ruby_version = '>=3.2'
|
|
11
11
|
s.name = 'always'
|
|
12
|
-
s.version = '0.
|
|
12
|
+
s.version = '0.2.0'
|
|
13
13
|
s.license = 'MIT'
|
|
14
14
|
s.summary = 'A simple Ruby framework that spins a loop forever, in a background thread'
|
|
15
15
|
s.description =
|
|
@@ -18,8 +18,8 @@ Gem::Specification.new do |s|
|
|
|
18
18
|
'which you don\'t want to cause a termination of the entire routine cycle.'
|
|
19
19
|
s.authors = ['Yegor Bugayenko']
|
|
20
20
|
s.email = 'yegor256@gmail.com'
|
|
21
|
-
s.homepage = '
|
|
22
|
-
s.files = `git ls-files`.split($RS)
|
|
21
|
+
s.homepage = 'https://github.com/yegor256/always'
|
|
22
|
+
s.files = `git ls-files | grep -v -E '^(test/|\\.|renovate)'`.split($RS)
|
|
23
23
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
24
24
|
s.rdoc_options = ['--charset=UTF-8']
|
|
25
25
|
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
data/lib/always.rb
CHANGED
|
@@ -12,14 +12,14 @@ require 'securerandom'
|
|
|
12
12
|
# over and over again, with a 60-seconds pause between cycles, do this:
|
|
13
13
|
#
|
|
14
14
|
# require 'always'
|
|
15
|
-
# a = Always.new(5)
|
|
16
|
-
# a.start(60) do
|
|
15
|
+
# a = Always.new(5) do
|
|
17
16
|
# puts 'Hello, world!'
|
|
18
17
|
# end
|
|
18
|
+
# a.start!(60)
|
|
19
19
|
#
|
|
20
20
|
# Then, in order to stop them all together:
|
|
21
21
|
#
|
|
22
|
-
# a.stop
|
|
22
|
+
# a.stop!
|
|
23
23
|
#
|
|
24
24
|
# It's possible to get a quick summary of the thread pool, by calling +to_s+.
|
|
25
25
|
# The result will be a +"T/C/E"+ string, where +T+ is the total number of
|
|
@@ -40,15 +40,17 @@ class Always
|
|
|
40
40
|
attr_reader :backtraces
|
|
41
41
|
|
|
42
42
|
# The version of the framework.
|
|
43
|
-
VERSION = '0.
|
|
43
|
+
VERSION = '0.2.0'
|
|
44
44
|
|
|
45
45
|
# Constructor.
|
|
46
46
|
# @param [Integer] total The number of threads to run
|
|
47
47
|
# @param [Integer] max_backtraces How many backtraces to keep in memory?
|
|
48
|
-
|
|
48
|
+
# @param [Block] block The block to execute
|
|
49
|
+
def initialize(total, max_backtraces: 32, name: "always-#{SecureRandom.hex(4)}", &block)
|
|
49
50
|
raise "The number of threads (#{total}) must be positive" unless total.positive?
|
|
50
51
|
|
|
51
52
|
@total = total
|
|
53
|
+
@block = block
|
|
52
54
|
@on_error = nil
|
|
53
55
|
@name = name
|
|
54
56
|
@threads = []
|
|
@@ -78,13 +80,13 @@ class Always
|
|
|
78
80
|
|
|
79
81
|
# Start them all and let them run forever (until the +stop+ method is called).
|
|
80
82
|
# @param [Integer] pause The delay between cycles, in seconds
|
|
81
|
-
def start(pause = 0
|
|
83
|
+
def start!(pause = 0)
|
|
82
84
|
raise 'It is running now, call .stop() first' unless @threads.empty?
|
|
83
85
|
|
|
84
|
-
(0
|
|
86
|
+
(0..(@total - 1)).each do |i|
|
|
85
87
|
t =
|
|
86
88
|
Thread.new do
|
|
87
|
-
body(pause
|
|
89
|
+
body(pause)
|
|
88
90
|
end
|
|
89
91
|
t.name = "#{@name}-#{i + 1}"
|
|
90
92
|
@threads[i] = t
|
|
@@ -92,7 +94,7 @@ class Always
|
|
|
92
94
|
end
|
|
93
95
|
|
|
94
96
|
# Stop them all.
|
|
95
|
-
def stop
|
|
97
|
+
def stop!
|
|
96
98
|
raise 'It is not running now, call .start() first' if @threads.empty?
|
|
97
99
|
|
|
98
100
|
@threads.delete_if do |t|
|
|
@@ -119,9 +121,9 @@ class Always
|
|
|
119
121
|
private
|
|
120
122
|
|
|
121
123
|
# rubocop:disable Lint/RescueException
|
|
122
|
-
def body(pause
|
|
124
|
+
def body(pause)
|
|
123
125
|
loop do
|
|
124
|
-
one
|
|
126
|
+
one
|
|
125
127
|
@cycles.swap { |c| c + 1 }
|
|
126
128
|
sleep(pause) unless pause.zero?
|
|
127
129
|
rescue Exception
|
|
@@ -134,7 +136,7 @@ class Always
|
|
|
134
136
|
|
|
135
137
|
# rubocop:disable Lint/RescueException
|
|
136
138
|
def one
|
|
137
|
-
|
|
139
|
+
@block.call
|
|
138
140
|
rescue Exception => e
|
|
139
141
|
@errors.swap { |c| c + 1 }
|
|
140
142
|
@backtraces << e
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: always
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yegor Bugayenko
|
|
@@ -33,23 +33,6 @@ extra_rdoc_files:
|
|
|
33
33
|
- LICENSE.txt
|
|
34
34
|
- README.md
|
|
35
35
|
files:
|
|
36
|
-
- ".0pdd.yml"
|
|
37
|
-
- ".gitattributes"
|
|
38
|
-
- ".github/workflows/actionlint.yml"
|
|
39
|
-
- ".github/workflows/codecov.yml"
|
|
40
|
-
- ".github/workflows/copyrights.yml"
|
|
41
|
-
- ".github/workflows/markdown-lint.yml"
|
|
42
|
-
- ".github/workflows/pdd.yml"
|
|
43
|
-
- ".github/workflows/rake.yml"
|
|
44
|
-
- ".github/workflows/reuse.yml"
|
|
45
|
-
- ".github/workflows/typos.yml"
|
|
46
|
-
- ".github/workflows/xcop.yml"
|
|
47
|
-
- ".github/workflows/yamllint.yml"
|
|
48
|
-
- ".gitignore"
|
|
49
|
-
- ".pdd"
|
|
50
|
-
- ".rubocop.yml"
|
|
51
|
-
- ".rultor.yml"
|
|
52
|
-
- ".simplecov"
|
|
53
36
|
- Gemfile
|
|
54
37
|
- Gemfile.lock
|
|
55
38
|
- LICENSE.txt
|
|
@@ -59,10 +42,7 @@ files:
|
|
|
59
42
|
- Rakefile
|
|
60
43
|
- always.gemspec
|
|
61
44
|
- lib/always.rb
|
|
62
|
-
|
|
63
|
-
- test/test__helper.rb
|
|
64
|
-
- test/test_always.rb
|
|
65
|
-
homepage: http://github.com/yegor256/always
|
|
45
|
+
homepage: https://github.com/yegor256/always
|
|
66
46
|
licenses:
|
|
67
47
|
- MIT
|
|
68
48
|
metadata:
|
|
@@ -82,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
82
62
|
- !ruby/object:Gem::Version
|
|
83
63
|
version: '0'
|
|
84
64
|
requirements: []
|
|
85
|
-
rubygems_version: 3.6.
|
|
65
|
+
rubygems_version: 3.6.9
|
|
86
66
|
specification_version: 4
|
|
87
67
|
summary: A simple Ruby framework that spins a loop forever, in a background thread
|
|
88
68
|
test_files: []
|
data/.0pdd.yml
DELETED
data/.gitattributes
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: actionlint
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
jobs:
|
|
14
|
-
actionlint:
|
|
15
|
-
timeout-minutes: 15
|
|
16
|
-
runs-on: ubuntu-24.04
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- name: Download actionlint
|
|
20
|
-
id: get_actionlint
|
|
21
|
-
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
|
|
22
|
-
shell: bash
|
|
23
|
-
- name: Check workflow files
|
|
24
|
-
run: ${{ steps.get_actionlint.outputs.executable }} -color
|
|
25
|
-
shell: bash
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: codecov
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
jobs:
|
|
11
|
-
codecov:
|
|
12
|
-
timeout-minutes: 15
|
|
13
|
-
runs-on: ubuntu-24.04
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v4
|
|
16
|
-
- uses: ruby/setup-ruby@v1
|
|
17
|
-
with:
|
|
18
|
-
ruby-version: 3.3
|
|
19
|
-
bundler-cache: true
|
|
20
|
-
- run: bundle config set --global path "$(pwd)/vendor/bundle"
|
|
21
|
-
- run: bundle install --no-color
|
|
22
|
-
- run: bundle exec rake
|
|
23
|
-
- uses: codecov/codecov-action@v5
|
|
24
|
-
with:
|
|
25
|
-
token: ${{ secrets.CODECOV_TOKEN }}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: copyrights
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
jobs:
|
|
14
|
-
copyrights:
|
|
15
|
-
timeout-minutes: 15
|
|
16
|
-
runs-on: ubuntu-24.04
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- uses: yegor256/copyrights-action@0.0.8
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: markdown-lint
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
paths-ignore: ['paper/**', 'sandbox/**']
|
|
14
|
-
concurrency:
|
|
15
|
-
group: markdown-lint-${{ github.ref }}
|
|
16
|
-
cancel-in-progress: true
|
|
17
|
-
jobs:
|
|
18
|
-
markdown-lint:
|
|
19
|
-
timeout-minutes: 15
|
|
20
|
-
runs-on: ubuntu-24.04
|
|
21
|
-
steps:
|
|
22
|
-
- uses: actions/checkout@v4
|
|
23
|
-
- uses: DavidAnson/markdownlint-cli2-action@v20.0.0
|
data/.github/workflows/pdd.yml
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: pdd
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
jobs:
|
|
14
|
-
pdd:
|
|
15
|
-
timeout-minutes: 15
|
|
16
|
-
runs-on: ubuntu-24.04
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- uses: volodya-lombrozo/pdd-action@master
|
data/.github/workflows/rake.yml
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: rake
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
jobs:
|
|
14
|
-
rake:
|
|
15
|
-
strategy:
|
|
16
|
-
matrix:
|
|
17
|
-
os: [ubuntu-24.04, macos-15, windows-2022]
|
|
18
|
-
ruby: [3.3]
|
|
19
|
-
runs-on: ${{ matrix.os }}
|
|
20
|
-
steps:
|
|
21
|
-
- uses: actions/checkout@v4
|
|
22
|
-
- uses: ruby/setup-ruby@v1
|
|
23
|
-
with:
|
|
24
|
-
ruby-version: ${{ matrix.ruby }}
|
|
25
|
-
bundler-cache: true
|
|
26
|
-
- run: bundle config set --global path "$(pwd)/vendor/bundle"
|
|
27
|
-
- run: bundle install --no-color
|
|
28
|
-
- run: bundle exec rake
|
data/.github/workflows/reuse.yml
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: reuse
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
jobs:
|
|
14
|
-
reuse:
|
|
15
|
-
timeout-minutes: 15
|
|
16
|
-
runs-on: ubuntu-24.04
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- uses: fsfe/reuse-action@v5
|
data/.github/workflows/typos.yml
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: typos
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
jobs:
|
|
14
|
-
typos:
|
|
15
|
-
timeout-minutes: 15
|
|
16
|
-
runs-on: ubuntu-24.04
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- uses: crate-ci/typos@v1.32.0
|
data/.github/workflows/xcop.yml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: xcop
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
pull_request:
|
|
9
|
-
jobs:
|
|
10
|
-
xcop:
|
|
11
|
-
timeout-minutes: 15
|
|
12
|
-
runs-on: ubuntu-24.04
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v4
|
|
15
|
-
- uses: g4s8/xcop-action@master
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: yamllint
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
jobs:
|
|
14
|
-
yamllint:
|
|
15
|
-
timeout-minutes: 15
|
|
16
|
-
runs-on: ubuntu-24.04
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- uses: ibiqlik/action-yamllint@v3
|
data/.gitignore
DELETED
data/.pdd
DELETED
data/.rubocop.yml
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
AllCops:
|
|
5
|
-
Exclude:
|
|
6
|
-
- 'bin/**/*'
|
|
7
|
-
- 'assets/**/*'
|
|
8
|
-
- 'vendor/**/*'
|
|
9
|
-
DisplayCopNames: true
|
|
10
|
-
TargetRubyVersion: 3.2
|
|
11
|
-
SuggestExtensions: false
|
|
12
|
-
NewCops: enable
|
|
13
|
-
plugins:
|
|
14
|
-
- rubocop-rake
|
|
15
|
-
- rubocop-minitest
|
|
16
|
-
- rubocop-performance
|
|
17
|
-
Minitest/EmptyLineBeforeAssertionMethods:
|
|
18
|
-
Enabled: false
|
|
19
|
-
Layout/EndOfLine:
|
|
20
|
-
EnforcedStyle: lf
|
|
21
|
-
Style/EvalWithLocation:
|
|
22
|
-
Enabled: false
|
|
23
|
-
Metrics/MethodLength:
|
|
24
|
-
Max: 20
|
data/.rultor.yml
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
docker:
|
|
6
|
-
image: yegor256/ruby
|
|
7
|
-
assets:
|
|
8
|
-
rubygems.yml: yegor256/home#assets/rubygems.yml
|
|
9
|
-
install: |
|
|
10
|
-
pdd -f /dev/null
|
|
11
|
-
bundle install --no-color
|
|
12
|
-
release:
|
|
13
|
-
pre: false
|
|
14
|
-
script: |-
|
|
15
|
-
[[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
|
|
16
|
-
bundle exec rake
|
|
17
|
-
rm -rf *.gem
|
|
18
|
-
sed -i "s/0\.0\.0/${tag}/g" always.gemspec
|
|
19
|
-
git add always.gemspec
|
|
20
|
-
sed -i "s/0\.0\.0/${tag}/g" lib/always.rb
|
|
21
|
-
git add lib/always.rb
|
|
22
|
-
git commit -m "version set to ${tag}"
|
|
23
|
-
gem build always.gemspec
|
|
24
|
-
chmod 0600 ../rubygems.yml
|
|
25
|
-
gem push *.gem --config-file ../rubygems.yml
|
|
26
|
-
merge:
|
|
27
|
-
script: |-
|
|
28
|
-
bundle exec rake
|
data/.simplecov
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
#
|
|
4
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
5
|
-
# SPDX-License-Identifier: MIT
|
|
6
|
-
|
|
7
|
-
if Gem.win_platform?
|
|
8
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
|
9
|
-
SimpleCov::Formatter::HTMLFormatter
|
|
10
|
-
]
|
|
11
|
-
SimpleCov.start do
|
|
12
|
-
add_filter '/test/'
|
|
13
|
-
add_filter '/features/'
|
|
14
|
-
end
|
|
15
|
-
else
|
|
16
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
|
17
|
-
[SimpleCov::Formatter::HTMLFormatter]
|
|
18
|
-
)
|
|
19
|
-
SimpleCov.start do
|
|
20
|
-
add_filter '/test/'
|
|
21
|
-
add_filter '/features/'
|
|
22
|
-
minimum_coverage 20
|
|
23
|
-
end
|
|
24
|
-
end
|
data/renovate.json
DELETED
data/test/test__helper.rb
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
4
|
-
# SPDX-License-Identifier: MIT
|
|
5
|
-
|
|
6
|
-
$stdout.sync = true
|
|
7
|
-
|
|
8
|
-
require 'simplecov'
|
|
9
|
-
require 'simplecov-cobertura'
|
|
10
|
-
unless SimpleCov.running || ENV['PICKS']
|
|
11
|
-
SimpleCov.command_name('test')
|
|
12
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
|
13
|
-
[
|
|
14
|
-
SimpleCov::Formatter::HTMLFormatter,
|
|
15
|
-
SimpleCov::Formatter::CoberturaFormatter
|
|
16
|
-
]
|
|
17
|
-
)
|
|
18
|
-
SimpleCov.minimum_coverage 95
|
|
19
|
-
SimpleCov.minimum_coverage_by_file 90
|
|
20
|
-
SimpleCov.start do
|
|
21
|
-
add_filter 'test/'
|
|
22
|
-
add_filter 'vendor/'
|
|
23
|
-
add_filter 'target/'
|
|
24
|
-
track_files 'lib/**/*.rb'
|
|
25
|
-
track_files '*.rb'
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
require 'minitest/autorun'
|
|
30
|
-
require 'minitest/reporters'
|
|
31
|
-
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
|
data/test/test_always.rb
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
4
|
-
# SPDX-License-Identifier: MIT
|
|
5
|
-
|
|
6
|
-
require 'concurrent/set'
|
|
7
|
-
require_relative '../lib/always'
|
|
8
|
-
require_relative 'test__helper'
|
|
9
|
-
|
|
10
|
-
# Test.
|
|
11
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
12
|
-
# Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
|
|
13
|
-
# License:: MIT
|
|
14
|
-
class TestAlways < Minitest::Test
|
|
15
|
-
def test_simple
|
|
16
|
-
a = Always.new(3)
|
|
17
|
-
a.start do
|
|
18
|
-
raise 'intentionally'
|
|
19
|
-
end
|
|
20
|
-
a.stop
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def test_threads_have_names
|
|
24
|
-
names = Concurrent::Set.new
|
|
25
|
-
total = 3
|
|
26
|
-
a = Always.new(total, name: 'foo').on_error { |e| puts e }
|
|
27
|
-
a.start do
|
|
28
|
-
names.add(Thread.current.name)
|
|
29
|
-
end
|
|
30
|
-
sleep(0.1)
|
|
31
|
-
a.stop
|
|
32
|
-
assert_equal(total, names.size)
|
|
33
|
-
total.times do |i|
|
|
34
|
-
assert_includes(names, "foo-#{i + 1}")
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def test_with_error
|
|
39
|
-
a = Always.new(5)
|
|
40
|
-
failures = 0
|
|
41
|
-
a.on_error { |_e| failures += 1 }.start do
|
|
42
|
-
raise 'intentionally'
|
|
43
|
-
end
|
|
44
|
-
sleep(0.1)
|
|
45
|
-
a.stop
|
|
46
|
-
assert_predicate(failures, :positive?)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def test_read_backtraces
|
|
50
|
-
max = 5
|
|
51
|
-
a = Always.new(5, max_backtraces: max)
|
|
52
|
-
failures = 0
|
|
53
|
-
a.on_error { |_e| failures += 1 }.start do
|
|
54
|
-
raise 'intentionally'
|
|
55
|
-
end
|
|
56
|
-
sleep(0.1)
|
|
57
|
-
a.stop
|
|
58
|
-
assert_predicate(failures, :positive?)
|
|
59
|
-
assert_equal(max, a.backtraces.size)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def test_converts_to_string
|
|
63
|
-
n = 6
|
|
64
|
-
a = Always.new(6)
|
|
65
|
-
a.start { sleep(0.01) }
|
|
66
|
-
sleep(0.1)
|
|
67
|
-
threads, cycles, errors = a.to_s.split('/')
|
|
68
|
-
assert_equal(n, threads.to_i)
|
|
69
|
-
assert_predicate(cycles.to_i, :positive?)
|
|
70
|
-
assert_predicate(errors.to_i, :zero?)
|
|
71
|
-
a.stop
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def test_stops_correctly
|
|
75
|
-
a = Always.new(6)
|
|
76
|
-
a.start { sleep(0.01) }
|
|
77
|
-
sleep(0.01)
|
|
78
|
-
a.stop
|
|
79
|
-
assert_equal('0/0/0', a.to_s)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def test_with_counter
|
|
83
|
-
a = Always.new(1)
|
|
84
|
-
done = 0
|
|
85
|
-
a.start do
|
|
86
|
-
done += 1
|
|
87
|
-
end
|
|
88
|
-
sleep(0.1)
|
|
89
|
-
a.stop
|
|
90
|
-
assert_predicate(done, :positive?)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def test_with_broken_syntax
|
|
94
|
-
a = Always.new(1)
|
|
95
|
-
failures = 0
|
|
96
|
-
a.on_error { |_e| failures += 1 }.start do
|
|
97
|
-
eval('broken$ruby$syntax')
|
|
98
|
-
end
|
|
99
|
-
sleep(0.1)
|
|
100
|
-
_, _, errors = a.to_s.split('/')
|
|
101
|
-
refute_predicate(errors.to_i, :zero?)
|
|
102
|
-
refute_predicate(failures, :zero?)
|
|
103
|
-
a.stop
|
|
104
|
-
end
|
|
105
|
-
end
|