always 0.0.5 → 0.1.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/.0pdd.yml +2 -19
- data/.github/workflows/actionlint.yml +5 -21
- data/.github/workflows/codecov.yml +9 -23
- data/.github/workflows/copyrights.yml +19 -0
- data/.github/workflows/markdown-lint.yml +6 -21
- data/.github/workflows/pdd.yml +6 -21
- data/.github/workflows/rake.yml +8 -24
- data/.github/workflows/reuse.yml +19 -0
- data/.github/workflows/typos.yml +19 -0
- data/.github/workflows/xcop.yml +6 -21
- data/.github/workflows/yamllint.yml +5 -20
- data/.gitignore +8 -6
- data/.rubocop.yml +10 -20
- data/.rultor.yml +4 -20
- data/.simplecov +2 -19
- data/Gemfile +12 -27
- data/Gemfile.lock +56 -144
- data/LICENSE.txt +1 -1
- data/LICENSES/MIT.txt +21 -0
- data/README.md +11 -7
- data/REUSE.toml +34 -0
- data/Rakefile +3 -30
- data/always.gemspec +4 -21
- data/lib/always.rb +29 -30
- data/test/test__helper.rb +22 -22
- data/test/test_always.rb +27 -28
- metadata +9 -8
- data/.github/workflows/license.yml +0 -57
data/test/test_always.rb
CHANGED
@@ -1,31 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
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.
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
22
5
|
|
23
|
-
require '
|
6
|
+
require 'concurrent/set'
|
24
7
|
require_relative '../lib/always'
|
8
|
+
require_relative 'test__helper'
|
25
9
|
|
26
10
|
# Test.
|
27
11
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
28
|
-
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
12
|
+
# Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
|
29
13
|
# License:: MIT
|
30
14
|
class TestAlways < Minitest::Test
|
31
15
|
def test_simple
|
@@ -36,6 +20,21 @@ class TestAlways < Minitest::Test
|
|
36
20
|
a.stop
|
37
21
|
end
|
38
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
|
+
|
39
38
|
def test_with_error
|
40
39
|
a = Always.new(5)
|
41
40
|
failures = 0
|
@@ -44,7 +43,7 @@ class TestAlways < Minitest::Test
|
|
44
43
|
end
|
45
44
|
sleep(0.1)
|
46
45
|
a.stop
|
47
|
-
|
46
|
+
assert_predicate(failures, :positive?)
|
48
47
|
end
|
49
48
|
|
50
49
|
def test_read_backtraces
|
@@ -56,7 +55,7 @@ class TestAlways < Minitest::Test
|
|
56
55
|
end
|
57
56
|
sleep(0.1)
|
58
57
|
a.stop
|
59
|
-
|
58
|
+
assert_predicate(failures, :positive?)
|
60
59
|
assert_equal(max, a.backtraces.size)
|
61
60
|
end
|
62
61
|
|
@@ -67,8 +66,8 @@ class TestAlways < Minitest::Test
|
|
67
66
|
sleep(0.1)
|
68
67
|
threads, cycles, errors = a.to_s.split('/')
|
69
68
|
assert_equal(n, threads.to_i)
|
70
|
-
|
71
|
-
|
69
|
+
assert_predicate(cycles.to_i, :positive?)
|
70
|
+
assert_predicate(errors.to_i, :zero?)
|
72
71
|
a.stop
|
73
72
|
end
|
74
73
|
|
@@ -88,7 +87,7 @@ class TestAlways < Minitest::Test
|
|
88
87
|
end
|
89
88
|
sleep(0.1)
|
90
89
|
a.stop
|
91
|
-
|
90
|
+
assert_predicate(done, :positive?)
|
92
91
|
end
|
93
92
|
|
94
93
|
def test_with_broken_syntax
|
@@ -99,8 +98,8 @@ class TestAlways < Minitest::Test
|
|
99
98
|
end
|
100
99
|
sleep(0.1)
|
101
100
|
_, _, errors = a.to_s.split('/')
|
102
|
-
|
103
|
-
|
101
|
+
refute_predicate(errors.to_i, :zero?)
|
102
|
+
refute_predicate(failures, :zero?)
|
104
103
|
a.stop
|
105
104
|
end
|
106
105
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: always
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: concurrent-ruby
|
@@ -31,17 +30,19 @@ email: yegor256@gmail.com
|
|
31
30
|
executables: []
|
32
31
|
extensions: []
|
33
32
|
extra_rdoc_files:
|
34
|
-
- README.md
|
35
33
|
- LICENSE.txt
|
34
|
+
- README.md
|
36
35
|
files:
|
37
36
|
- ".0pdd.yml"
|
38
37
|
- ".gitattributes"
|
39
38
|
- ".github/workflows/actionlint.yml"
|
40
39
|
- ".github/workflows/codecov.yml"
|
41
|
-
- ".github/workflows/
|
40
|
+
- ".github/workflows/copyrights.yml"
|
42
41
|
- ".github/workflows/markdown-lint.yml"
|
43
42
|
- ".github/workflows/pdd.yml"
|
44
43
|
- ".github/workflows/rake.yml"
|
44
|
+
- ".github/workflows/reuse.yml"
|
45
|
+
- ".github/workflows/typos.yml"
|
45
46
|
- ".github/workflows/xcop.yml"
|
46
47
|
- ".github/workflows/yamllint.yml"
|
47
48
|
- ".gitignore"
|
@@ -52,7 +53,9 @@ files:
|
|
52
53
|
- Gemfile
|
53
54
|
- Gemfile.lock
|
54
55
|
- LICENSE.txt
|
56
|
+
- LICENSES/MIT.txt
|
55
57
|
- README.md
|
58
|
+
- REUSE.toml
|
56
59
|
- Rakefile
|
57
60
|
- always.gemspec
|
58
61
|
- lib/always.rb
|
@@ -64,7 +67,6 @@ licenses:
|
|
64
67
|
- MIT
|
65
68
|
metadata:
|
66
69
|
rubygems_mfa_required: 'true'
|
67
|
-
post_install_message:
|
68
70
|
rdoc_options:
|
69
71
|
- "--charset=UTF-8"
|
70
72
|
require_paths:
|
@@ -80,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
82
|
- !ruby/object:Gem::Version
|
81
83
|
version: '0'
|
82
84
|
requirements: []
|
83
|
-
rubygems_version: 3.
|
84
|
-
signing_key:
|
85
|
+
rubygems_version: 3.6.7
|
85
86
|
specification_version: 4
|
86
87
|
summary: A simple Ruby framework that spins a loop forever, in a background thread
|
87
88
|
test_files: []
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in all
|
11
|
-
# copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
-
# SOFTWARE.
|
20
|
-
---
|
21
|
-
name: license
|
22
|
-
'on':
|
23
|
-
push:
|
24
|
-
branches:
|
25
|
-
- master
|
26
|
-
pull_request:
|
27
|
-
branches:
|
28
|
-
- master
|
29
|
-
jobs:
|
30
|
-
license:
|
31
|
-
runs-on: ubuntu-22.04
|
32
|
-
steps:
|
33
|
-
- 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
|