always 0.1.0 → 0.3.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: 5f463f89d1eb06ec82e25f08dbc019f3691a37a8425a756346e3f76cece5a354
4
- data.tar.gz: 2bc316f8a0ce44ba64db65a49ad222de7bec77aeb70f6bd8e2f1ab138cc2aed7
3
+ metadata.gz: 51f44aa92893e18ed128a1e9b701e9da258afa730ff1455a01610e570426672d
4
+ data.tar.gz: 4d4b568c045f1a5e625b6a06fb2d9663992e95e2b4dd00033af272aec8f01192
5
5
  SHA512:
6
- metadata.gz: 205d8dfd793f6acbc23c306deb7cedb84f9183a3d6645aea8b2f69b007dab241c6c831a7cab2fe1c4f01800198409b0b4147db56557f8feba937f2e6ba82b633
7
- data.tar.gz: c52df4229a04f6774b26d33834f4e5c5a25a2b50dab335a7f1f5131dcfc9c1b5f0abdcb40f1fe3cdd064ec283cc494af3ca4176055e9ab0f5b1c5621987dde3a
6
+ metadata.gz: 2cf17c1132d00c1638160556afee332f100fc29ccb19a5f7f001a1dc4558edfea665ee8540b558fbe7cafc043d3c03d64272cbeff9a753970560c55292520952
7
+ data.tar.gz: 5c8483e2de654215d6a63967e8cce0140e0db2ada2298e53713320d5e98a4481975258dae6c08fd897465e772682d3a61e2ac6aeabe885568a2dda772850d651
data/Gemfile CHANGED
@@ -1,18 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
6
  source 'https://rubygems.org'
7
7
  gemspec
8
8
 
9
- gem 'minitest', '~>5.25', require: false
9
+ gem 'minitest', '~>6.0', 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', '>0', require: false
14
- gem 'rubocop-performance', '>0', require: false
15
- gem 'rubocop-rake', '>0', require: false
16
- gem 'simplecov', '~>0.22', require: false
17
- gem 'simplecov-cobertura', '~>2.1', require: false
13
+ gem 'rubocop-elegant', '~>0.5', require: false
14
+ gem 'rubocop-minitest', '~>0.38', require: false
15
+ gem 'rubocop-performance', '~>1.25', require: false
16
+ gem 'rubocop-rake', '~>0.7', require: false
17
+ gem 'simplecov', '~>1.0', require: false
18
+ gem 'simplecov-cobertura', '~>4.0', require: false
18
19
  gem 'yard', '~>0.9', require: false
data/Gemfile.lock CHANGED
@@ -7,69 +7,79 @@ PATH
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- ansi (1.5.0)
10
+ ansi (1.6.1)
11
+ logger
11
12
  ast (2.4.3)
12
13
  builder (3.3.0)
13
- concurrent-ruby (1.3.5)
14
- docile (1.4.1)
15
- json (2.12.0)
16
- language_server-protocol (3.17.0.5)
14
+ concurrent-ruby (1.3.8)
15
+ drb (2.2.3)
16
+ json (3.2.0)
17
+ language_server-protocol (3.17.0.6)
17
18
  lint_roller (1.1.0)
18
- minitest (5.25.5)
19
- minitest-reporters (1.7.1)
19
+ logger (1.7.0)
20
+ minitest (6.1.0)
21
+ drb (~> 2.0)
22
+ prism (>= 1.5, < 3)
23
+ minitest-reporters (1.8.0)
20
24
  ansi
21
25
  builder
22
- minitest (>= 5.0)
26
+ minitest (>= 5.0, < 7)
23
27
  ruby-progressbar
24
- parallel (1.27.0)
25
- parser (3.3.8.0)
28
+ parallel (2.3.0)
29
+ parser (3.3.14.0)
26
30
  ast (~> 2.4.1)
27
31
  racc
28
- prism (1.4.0)
32
+ prism (2.1.0)
33
+ prism (2.1.0-aarch64-linux-gnu)
34
+ prism (2.1.0-arm-linux-gnu)
35
+ prism (2.1.0-arm64-darwin)
36
+ prism (2.1.0-x64-mingw-ucrt)
37
+ prism (2.1.0-x86_64-darwin)
38
+ prism (2.1.0-x86_64-linux-gnu)
29
39
  racc (1.8.1)
30
40
  rainbow (3.1.1)
31
- rake (13.2.1)
32
- regexp_parser (2.10.0)
33
- rexml (3.4.1)
34
- rubocop (1.75.6)
35
- json (~> 2.3)
41
+ rake (13.4.2)
42
+ regexp_parser (2.13.4)
43
+ rexml (3.4.4)
44
+ rubocop (1.93.0)
45
+ json (>= 2.3)
36
46
  language_server-protocol (~> 3.17.0.2)
37
47
  lint_roller (~> 1.1.0)
38
- parallel (~> 1.10)
48
+ parallel (>= 1.10)
39
49
  parser (>= 3.3.0.2)
40
50
  rainbow (>= 2.2.2, < 4.0)
41
- regexp_parser (>= 2.9.3, < 3.0)
42
- rubocop-ast (>= 1.44.0, < 2.0)
51
+ regexp_parser (>= 2.11.3, < 3.0)
52
+ rubocop-ast (>= 1.54.0, < 2.0)
43
53
  ruby-progressbar (~> 1.7)
44
54
  unicode-display_width (>= 2.4.0, < 4.0)
45
- rubocop-ast (1.44.1)
55
+ rubocop-ast (1.54.0)
56
+ ast (~> 2.4)
46
57
  parser (>= 3.3.7.2)
47
- prism (~> 1.4)
48
- rubocop-minitest (0.38.0)
58
+ prism (>= 1.7)
59
+ racc
60
+ rubocop-elegant (0.8.0)
49
61
  lint_roller (~> 1.1)
50
- rubocop (>= 1.75.0, < 2.0)
51
- rubocop-ast (>= 1.38.0, < 2.0)
52
- rubocop-performance (1.25.0)
62
+ rubocop (~> 1.75)
63
+ rubocop-minitest (0.41.0)
53
64
  lint_roller (~> 1.1)
54
- rubocop (>= 1.75.0, < 2.0)
65
+ rubocop (>= 1.89.0, < 2.0)
55
66
  rubocop-ast (>= 1.38.0, < 2.0)
67
+ rubocop-performance (1.27.0)
68
+ lint_roller (~> 1.1)
69
+ rubocop (>= 1.89.0, < 2.0)
70
+ rubocop-ast (>= 1.47.1, < 2.0)
56
71
  rubocop-rake (0.7.1)
57
72
  lint_roller (~> 1.1)
58
73
  rubocop (>= 1.72.1)
59
74
  ruby-progressbar (1.13.0)
60
- simplecov (0.22.0)
61
- docile (~> 1.1)
62
- simplecov-html (~> 0.11)
63
- simplecov_json_formatter (~> 0.1)
64
- simplecov-cobertura (2.1.0)
75
+ simplecov (1.3.2)
76
+ simplecov-cobertura (4.0.0)
65
77
  rexml
66
- simplecov (~> 0.19)
67
- simplecov-html (0.13.1)
68
- simplecov_json_formatter (0.1.4)
69
- unicode-display_width (3.1.4)
70
- unicode-emoji (~> 4.0, >= 4.0.4)
71
- unicode-emoji (4.0.4)
72
- yard (0.9.37)
78
+ simplecov (~> 1.0)
79
+ unicode-display_width (3.3.0)
80
+ unicode-emoji (~> 4.3)
81
+ unicode-emoji (4.3.0)
82
+ yard (0.9.46)
73
83
 
74
84
  PLATFORMS
75
85
  aarch64-linux
@@ -83,15 +93,16 @@ PLATFORMS
83
93
 
84
94
  DEPENDENCIES
85
95
  always!
86
- minitest (~> 5.25)
96
+ minitest (~> 6.0)
87
97
  minitest-reporters (~> 1.7)
88
98
  rake (~> 13.2)
89
99
  rubocop (~> 1.64)
90
- rubocop-minitest (> 0)
91
- rubocop-performance (> 0)
92
- rubocop-rake (> 0)
93
- simplecov (~> 0.22)
94
- simplecov-cobertura (~> 2.1)
100
+ rubocop-elegant (~> 0.5)
101
+ rubocop-minitest (~> 0.38)
102
+ rubocop-performance (~> 1.25)
103
+ rubocop-rake (~> 0.7)
104
+ simplecov (~> 1.0)
105
+ simplecov-cobertura (~> 4.0)
95
106
  yard (~> 0.9)
96
107
 
97
108
  BUNDLED WITH
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2024-2025 Yegor Bugayenko
3
+ Copyright (c) 2024-2026 Yegor Bugayenko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the 'Software'), to deal
data/LICENSES/MIT.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2024-2025 Yegor Bugayenko
3
+ Copyright (c) 2024-2026 Yegor Bugayenko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the 'Software'), to deal
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 a 30-second 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
@@ -1,12 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
- require 'rubygems'
7
6
  require 'rake'
8
- require 'rdoc'
9
7
  require 'rake/clean'
8
+ require 'rubygems'
10
9
 
11
10
  def name
12
11
  @name ||= File.basename(Dir['*.gemspec'].first, '.*')
@@ -32,6 +31,7 @@ require 'yard'
32
31
  desc 'Build Yard documentation'
33
32
  YARD::Rake::YardocTask.new do |t|
34
33
  t.files = ['lib/**/*.rb']
34
+ t.options = ['--fail-on-warning']
35
35
  end
36
36
 
37
37
  require 'rubocop/rake_task'
data/always.gemspec CHANGED
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
6
  require 'English'
7
7
 
8
8
  Gem::Specification.new do |s|
9
- s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
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.1.0'
12
+ s.version = '0.3.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,11 +18,11 @@ 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 = 'http://github.com/yegor256/always'
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']
26
- s.add_dependency 'concurrent-ruby', '~>1.1'
26
+ s.add_dependency('concurrent-ruby', '~>1.1')
27
27
  s.metadata['rubygems_mfa_required'] = 'true'
28
28
  end
data/lib/always.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
6
  require 'concurrent/atom'
@@ -9,17 +9,17 @@ require 'securerandom'
9
9
  # Always.
10
10
  #
11
11
  # In order to start five threads performing the same piece of code
12
- # over and over again, with a 60-seconds pause between cycles, do this:
12
+ # over and over again, with a 60-second 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
@@ -27,28 +27,21 @@ require 'securerandom'
27
27
  # so far, and +E+ is the total number of all errors seen so far.
28
28
  #
29
29
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
30
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
30
+ # Copyright:: Copyright (c) 2024-2026 Yegor Bugayenko
31
31
  # License:: MIT
32
32
  class Always
33
- # Get the array of most recent exception backtraces.
34
- # @return [Array<Exception>] The array of exceptions caught
35
- # @example
36
- # a = Always.new(5, max_backtraces: 10)
37
- # a.start { raise 'Oops' }
38
- # sleep 1
39
- # puts a.backtraces.size # => number of exceptions caught
40
33
  attr_reader :backtraces
41
34
 
42
- # The version of the framework.
43
- VERSION = '0.1.0'
35
+ VERSION = '0.3.0'
44
36
 
45
37
  # Constructor.
46
38
  # @param [Integer] total The number of threads to run
47
39
  # @param [Integer] max_backtraces How many backtraces to keep in memory?
48
- def initialize(total, max_backtraces: 32, name: "always-#{SecureRandom.hex(4)}")
49
- raise "The number of threads (#{total}) must be positive" unless total.positive?
50
-
40
+ # @param [Block] block The block to execute
41
+ def initialize(total, max_backtraces: 32, name: "always-#{SecureRandom.hex(4)}", &block)
42
+ raise(ArgumentError, "The number of threads (#{total}) must be positive") unless total.positive?
51
43
  @total = total
44
+ @block = block
52
45
  @on_error = nil
53
46
  @name = name
54
47
  @threads = []
@@ -78,13 +71,12 @@ class Always
78
71
 
79
72
  # Start them all and let them run forever (until the +stop+ method is called).
80
73
  # @param [Integer] pause The delay between cycles, in seconds
81
- def start(pause = 0, &)
82
- raise 'It is running now, call .stop() first' unless @threads.empty?
83
-
84
- (0..@total - 1).each do |i|
74
+ def start!(pause = 0)
75
+ raise(StandardError, 'It is running now, call .stop() first') unless @threads.empty?
76
+ (0..(@total - 1)).each do |i|
85
77
  t =
86
78
  Thread.new do
87
- body(pause, &)
79
+ body(pause, i)
88
80
  end
89
81
  t.name = "#{@name}-#{i + 1}"
90
82
  @threads[i] = t
@@ -92,9 +84,8 @@ class Always
92
84
  end
93
85
 
94
86
  # Stop them all.
95
- def stop
96
- raise 'It is not running now, call .start() first' if @threads.empty?
97
-
87
+ def stop!
88
+ raise(StandardError, 'It is not running now, call .start() first') if @threads.empty?
98
89
  @threads.delete_if do |t|
99
90
  t.kill
100
91
  sleep(0.001) while t.alive?
@@ -107,7 +98,7 @@ class Always
107
98
  # Represent its internal state as a string.
108
99
  # @return [String] Something like "4/230/23", where 4 is the number of running
109
100
  # threads, 230 is the number of successful loops, and 23 is the number
110
- # of failures occurred so far.
101
+ # of failures that occurred so far.
111
102
  # @example
112
103
  # a = Always.new(5)
113
104
  # a.start(60) { puts 'Working...' }
@@ -118,28 +109,28 @@ class Always
118
109
 
119
110
  private
120
111
 
121
- # rubocop:disable Lint/RescueException
122
- def body(pause, &)
112
+ # rubocop:disable-next Lint/RescueException
113
+ def body(pause, idx = 0)
123
114
  loop do
124
- one(&)
115
+ one(idx)
125
116
  @cycles.swap { |c| c + 1 }
126
117
  sleep(pause) unless pause.zero?
127
118
  rescue Exception
128
- # If we reach this point, we must not even try to
129
- # do anything. Here we must quietly ignore everything
130
- # and let the daemon go to the next cycle.
119
+ nil
131
120
  end
132
121
  end
133
- # rubocop:enable Lint/RescueException
134
122
 
135
- # rubocop:disable Lint/RescueException
136
- def one
137
- yield
123
+ # rubocop:disable-next Lint/RescueException
124
+ def one(idx = 0)
125
+ @block.call
138
126
  rescue Exception => e
139
127
  @errors.swap { |c| c + 1 }
140
128
  @backtraces << e
141
129
  @backtraces.shift if @backtraces.size > @max_backtraces
142
- @on_error&.call(e, Thread.current.object_id)
130
+ begin
131
+ @on_error&.call(e, idx + 1)
132
+ rescue Exception
133
+ nil
134
+ end
143
135
  end
144
- # rubocop:enable Lint/RescueException
145
136
  end
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.1.0
4
+ version: 0.3.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
- - renovate.json
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.7
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
@@ -1,5 +0,0 @@
1
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
2
- # SPDX-License-Identifier: MIT
3
- ---
4
- errors:
5
- - yegor256@gmail.com
data/.gitattributes DELETED
@@ -1,7 +0,0 @@
1
- # Check out all text files in UNIX format, with LF as end of line
2
- # Don't change this file. If you have any ideas about it, please
3
- # submit a separate issue about it and we'll discuss.
4
-
5
- * text=auto eol=lf
6
- *.java ident
7
- *.xml ident
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -1,11 +0,0 @@
1
- .bundle/
2
- .DS_Store
3
- .idea/
4
- .yardoc/
5
- *.gem
6
- coverage/
7
- doc/
8
- node_modules/
9
- rdoc/
10
- temp/
11
- vendor/
data/.pdd DELETED
@@ -1,7 +0,0 @@
1
- --source=.
2
- --verbose
3
- --exclude target/**/*
4
- --exclude coverage/**/*
5
- --rule min-words:20
6
- --rule min-estimate:15
7
- --rule max-estimate:90
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
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": [
4
- "config:base"
5
- ]
6
- }
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