async-tools 0.1.6 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/async/timer.rb +5 -6
- data/lib/async/tools/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30b2f096bcae3c902134fe3ad731ddcea3f566e72c63b474abdb21dc36e56bcc
|
4
|
+
data.tar.gz: 24d926ed9aaac361eef77fa395e5c3107fa3d1c105120cc8c3b6d46f4b8d6c3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deb046195c2fa54061921ae1448f947f1acfb6c6d62db211015242e737f356b3ba1960be512ca8e0d3563a5c2b0dec686d809d53a86d7e972cf4b90adcea893f
|
7
|
+
data.tar.gz: dae8dc2f7f8912bc83f24f4c4a6fce5b3ec2c24a66aac33a8ee434ea14336480274da533402aea719450f95f51bfe6f4beb04f180ba31aa8a8d4cd485276d823
|
data/Gemfile.lock
CHANGED
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
|
-
|
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
|
-
@
|
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 = @
|
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
|
data/lib/async/tools/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2023-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|