async-tools 0.1.6 → 0.1.8

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: 76687d5e9ac4df8655c6253762cc47a84f36c05a163240f4d7b6ab81c31bc055
4
- data.tar.gz: 6a2faf932cd588989ff86ac47468e46f8c3571c3b3880d46b5505fe51973eb70
3
+ metadata.gz: 30b2f096bcae3c902134fe3ad731ddcea3f566e72c63b474abdb21dc36e56bcc
4
+ data.tar.gz: 24d926ed9aaac361eef77fa395e5c3107fa3d1c105120cc8c3b6d46f4b8d6c3d
5
5
  SHA512:
6
- metadata.gz: 46d9a99e8aa5a058048b1ee02298a1bdfb1ef1cc77b149cc79ab1f284932bbbf53a2e4ec7cee53a7ee3a8782f26a53ad5666db7c5f59663e901164d423bc074f
7
- data.tar.gz: cdbd6412192ea4d432ebe193378819bf9093183b6cf3e427431fd3a70b3667693d83efc9926e1de834a74e8daea6e5a997d78406c79a4580cff1cb0d150ad3c8
6
+ metadata.gz: deb046195c2fa54061921ae1448f947f1acfb6c6d62db211015242e737f356b3ba1960be512ca8e0d3563a5c2b0dec686d809d53a86d7e972cf4b90adcea893f
7
+ data.tar.gz: dae8dc2f7f8912bc83f24f4c4a6fce5b3ec2c24a66aac33a8ee434ea14336480274da533402aea719450f95f51bfe6f4beb04f180ba31aa8a8d4cd485276d823
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- async-tools (0.1.6)
4
+ async-tools (0.1.8)
5
5
  async (~> 2.3)
6
6
  zeitwerk (~> 2.6)
7
7
 
data/lib/async/timer.rb CHANGED
@@ -7,20 +7,21 @@ class Async::Timer
7
7
 
8
8
  class AlreadyStarted < Error; end
9
9
 
10
- def initialize(delay, repeat: true, start: true, run_on_start: false, parent: Async::Task.current, &block)
11
- raise ArgumentError, "Block must be given" if block.nil?
10
+ def initialize(delay, repeat: true, start: true, run_on_start: false, parent: Async::Task.current, call: nil, &block) # rubocop:disable Metrics/ParameterLists
11
+ callables = [call, block]
12
+ raise ArgumentError, "either block or call: must be given" if callables.all?(&:nil?) || callables.none?(&:nil?)
12
13
 
13
14
  @delay = delay
14
15
  @repeat = repeat
15
16
  @run_on_start = run_on_start
16
17
  @parent = parent
17
- @block = block
18
+ @callable = call || block
18
19
 
19
20
  self.start if start
20
21
  end
21
22
 
22
23
  def stop = @task.stop
23
- def call = @block.call
24
+ def call = @callable.call
24
25
 
25
26
  def active? = @active
26
27
 
@@ -42,8 +43,6 @@ class Async::Timer
42
43
  sleep(@delay)
43
44
  call
44
45
  break unless @repeat
45
- rescue Async::Stop, Async::TimeoutError
46
- break
47
46
  ensure
48
47
  @active = false
49
48
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Async # rubocop:disable Style/ClassAndModuleChildren
4
4
  module Tools
5
- VERSION = "0.1.6"
5
+ VERSION = "0.1.8"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Sinyavskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-26 00:00:00.000000000 Z
11
+ date: 2023-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async