timers 4.1.2 → 4.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/timers.rb +23 -3
- data/lib/timers/events.rb +138 -106
- data/lib/timers/group.rb +139 -119
- data/lib/timers/interval.rb +58 -0
- data/lib/timers/timer.rb +138 -117
- data/lib/timers/version.rb +21 -1
- data/lib/timers/wait.rb +62 -42
- metadata +29 -45
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -17
- data/.rspec +0 -6
- data/.rubocop.yml +0 -28
- data/.ruby-version +0 -1
- data/.travis.yml +0 -21
- data/AUTHORS.md +0 -15
- data/CHANGES.md +0 -62
- data/Gemfile +0 -19
- data/LICENSE +0 -23
- data/README.md +0 -113
- data/Rakefile +0 -10
- data/spec/spec_helper.rb +0 -21
- data/spec/timers/cancel_spec.rb +0 -45
- data/spec/timers/events_spec.rb +0 -56
- data/spec/timers/every_spec.rb +0 -33
- data/spec/timers/group_spec.rb +0 -255
- data/spec/timers/performance_spec.rb +0 -96
- data/spec/timers/strict_spec.rb +0 -36
- data/spec/timers/wait_spec.rb +0 -30
- data/timers.gemspec +0 -26
metadata
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Samuel Williams
|
7
8
|
- Tony Arcieri
|
8
|
-
autorequire:
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2020-09-04 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
+
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
18
|
- - ">="
|
18
19
|
- !ruby/object:Gem::Version
|
19
20
|
version: '0'
|
20
|
-
type: :
|
21
|
+
type: :development
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
@@ -25,7 +26,7 @@ dependencies:
|
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '0'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
+
name: covered
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
32
|
- - ">="
|
@@ -38,46 +39,38 @@ dependencies:
|
|
38
39
|
- - ">="
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: '0'
|
41
|
-
|
42
|
-
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.0'
|
56
|
+
description:
|
43
57
|
email:
|
44
|
-
- bascule@gmail.com
|
45
58
|
executables: []
|
46
59
|
extensions: []
|
47
60
|
extra_rdoc_files: []
|
48
61
|
files:
|
49
|
-
- ".coveralls.yml"
|
50
|
-
- ".gitignore"
|
51
|
-
- ".rspec"
|
52
|
-
- ".rubocop.yml"
|
53
|
-
- ".ruby-version"
|
54
|
-
- ".travis.yml"
|
55
|
-
- AUTHORS.md
|
56
|
-
- CHANGES.md
|
57
|
-
- Gemfile
|
58
|
-
- LICENSE
|
59
|
-
- README.md
|
60
|
-
- Rakefile
|
61
62
|
- lib/timers.rb
|
62
63
|
- lib/timers/events.rb
|
63
64
|
- lib/timers/group.rb
|
65
|
+
- lib/timers/interval.rb
|
64
66
|
- lib/timers/timer.rb
|
65
67
|
- lib/timers/version.rb
|
66
68
|
- lib/timers/wait.rb
|
67
|
-
|
68
|
-
- spec/timers/cancel_spec.rb
|
69
|
-
- spec/timers/events_spec.rb
|
70
|
-
- spec/timers/every_spec.rb
|
71
|
-
- spec/timers/group_spec.rb
|
72
|
-
- spec/timers/performance_spec.rb
|
73
|
-
- spec/timers/strict_spec.rb
|
74
|
-
- spec/timers/wait_spec.rb
|
75
|
-
- timers.gemspec
|
76
|
-
homepage: https://github.com/celluloid/timers
|
69
|
+
homepage: https://github.com/socketry/timers
|
77
70
|
licenses:
|
78
71
|
- MIT
|
79
72
|
metadata: {}
|
80
|
-
post_install_message:
|
73
|
+
post_install_message:
|
81
74
|
rdoc_options: []
|
82
75
|
require_paths:
|
83
76
|
- lib
|
@@ -92,17 +85,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
85
|
- !ruby/object:Gem::Version
|
93
86
|
version: '0'
|
94
87
|
requirements: []
|
95
|
-
|
96
|
-
|
97
|
-
signing_key:
|
88
|
+
rubygems_version: 3.1.2
|
89
|
+
signing_key:
|
98
90
|
specification_version: 4
|
99
|
-
summary: Pure Ruby one-shot and periodic timers
|
100
|
-
test_files:
|
101
|
-
- spec/spec_helper.rb
|
102
|
-
- spec/timers/cancel_spec.rb
|
103
|
-
- spec/timers/events_spec.rb
|
104
|
-
- spec/timers/every_spec.rb
|
105
|
-
- spec/timers/group_spec.rb
|
106
|
-
- spec/timers/performance_spec.rb
|
107
|
-
- spec/timers/strict_spec.rb
|
108
|
-
- spec/timers/wait_spec.rb
|
91
|
+
summary: Pure Ruby one-shot and periodic timers.
|
92
|
+
test_files: []
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service-name: travis-pro
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
DisplayCopNames: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# Style
|
6
|
-
#
|
7
|
-
|
8
|
-
LineLength:
|
9
|
-
Max: 128
|
10
|
-
|
11
|
-
Style/NumericPredicate:
|
12
|
-
Enabled: false
|
13
|
-
|
14
|
-
Style/SafeNavigation:
|
15
|
-
Enabled: false
|
16
|
-
|
17
|
-
Style/StringLiterals:
|
18
|
-
EnforcedStyle: double_quotes
|
19
|
-
|
20
|
-
#
|
21
|
-
# Metrics
|
22
|
-
#
|
23
|
-
|
24
|
-
Metrics/ClassLength:
|
25
|
-
Max: 100
|
26
|
-
|
27
|
-
Metrics/MethodLength:
|
28
|
-
Max: 25
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.3.3
|
data/.travis.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: false
|
3
|
-
|
4
|
-
bundler_args: --without development doc
|
5
|
-
|
6
|
-
rvm:
|
7
|
-
- 2.0.0
|
8
|
-
- 2.1.10
|
9
|
-
- 2.2.6
|
10
|
-
- 2.3.3
|
11
|
-
- jruby-9.1.6.0
|
12
|
-
|
13
|
-
matrix:
|
14
|
-
fast_finish: true
|
15
|
-
|
16
|
-
branches:
|
17
|
-
only:
|
18
|
-
- master
|
19
|
-
|
20
|
-
notifications:
|
21
|
-
irc: "irc.freenode.org#celluloid"
|
data/AUTHORS.md
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# The Celluloid timers gem is beamed directly to you from the minds of...
|
2
|
-
|
3
|
-
- Tony Arcieri <bascule@gmail.com>
|
4
|
-
- Jeremy Hinegardner
|
5
|
-
- Sean Gregory
|
6
|
-
- Chuck Remes
|
7
|
-
- Utenmiki
|
8
|
-
- Ron Evans
|
9
|
-
- Larry Lv
|
10
|
-
- Bruno Enten
|
11
|
-
- Jesse Cooke
|
12
|
-
- Nicholas Evans
|
13
|
-
- Dimitrij Denissenko
|
14
|
-
- Ryan LeCompte
|
15
|
-
- Samuel G. D. Williams
|
data/CHANGES.md
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
## 4.1.2 (2016-11-26)
|
2
|
-
|
3
|
-
* RuboCop reformatting
|
4
|
-
|
5
|
-
## 4.1.1 (2015-08-21)
|
6
|
-
|
7
|
-
* Remove `RubyProf` from Gemfile and a test, due to it providing no substantial benefit while increasing problems building bundles under Rubinius.
|
8
|
-
|
9
|
-
## 4.1.0 (2015-08-16)
|
10
|
-
|
11
|
-
* Addition of `now_and_every` method; fires block immediately, then sets recurring timer.
|
12
|
-
* Includes `now_and_after` method; does the same as above for one-shot timers: essentially a "two-shot" timer.
|
13
|
-
|
14
|
-
# 4.0.4 (2015-09-01)
|
15
|
-
|
16
|
-
* Re-release of the `4.1.1` version under the `4.0.4` designation to work-around issues caused by yanking `4.0.2` a couple weeks ago.
|
17
|
-
|
18
|
-
## 4.0.1 (2014-09-10)
|
19
|
-
|
20
|
-
* Memory leak fixes
|
21
|
-
* mathn fix for those crazy enough to use it
|
22
|
-
|
23
|
-
## 4.0.0 (2014-07-27)
|
24
|
-
|
25
|
-
* Replace Timers::Timeout with Timers::Wait
|
26
|
-
* Timers::Group#wait_interval now returns nil when no timers, a positive or
|
27
|
-
negative interval which if positive is the amount of time required to wait
|
28
|
-
and if negative, how far in the past the latest timer should have fired
|
29
|
-
* Performance improvements
|
30
|
-
|
31
|
-
## 3.0.1 (2014-06-27)
|
32
|
-
|
33
|
-
* Require 'set' automatically
|
34
|
-
|
35
|
-
# 3.0.0 (2014-06-14)
|
36
|
-
|
37
|
-
* Refactor `Timers` class into `Timers::Group`
|
38
|
-
* Add `Timers::Timeout` class for implementing timeouts
|
39
|
-
* Fix timer fudging
|
40
|
-
* Update to RSpec 3
|
41
|
-
|
42
|
-
## 2.0.0 (2013-12-30)
|
43
|
-
|
44
|
-
* Switch to Hitimes for high precision monotonic counters
|
45
|
-
* Removed Timers#time. Replaced with Timers#current_offset which provides a
|
46
|
-
monotonic time counter.
|
47
|
-
|
48
|
-
## 1.1.0
|
49
|
-
|
50
|
-
* Timers#after_milliseconds and #after_ms for waiting in milliseconds
|
51
|
-
|
52
|
-
## 1.0.2
|
53
|
-
|
54
|
-
* Handle overdue timers correctly
|
55
|
-
|
56
|
-
## 1.0.1
|
57
|
-
|
58
|
-
* Explicitly require Forwardable from stdlib
|
59
|
-
|
60
|
-
## 1.0.0
|
61
|
-
|
62
|
-
* Initial release
|
data/Gemfile
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gemspec
|
6
|
-
|
7
|
-
group :development do
|
8
|
-
gem "pry", require: false
|
9
|
-
end
|
10
|
-
|
11
|
-
group :test do
|
12
|
-
gem "rspec", "~> 3", require: false
|
13
|
-
gem "rubocop", "0.45.0", require: false
|
14
|
-
gem "coveralls", require: false
|
15
|
-
end
|
16
|
-
|
17
|
-
group :development, :test do
|
18
|
-
gem "rake"
|
19
|
-
end
|
data/LICENSE
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
Copyright (c) 2012-16 The Celluloid Timers Developers: given in the file
|
2
|
-
AUTHORS.md at https://github.com/celluloid/timers/blob/master/AUTHORS.md
|
3
|
-
|
4
|
-
MIT License
|
5
|
-
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
-
a copy of this software and associated documentation files (the
|
8
|
-
"Software"), to deal in the Software without restriction, including
|
9
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
-
permit persons to whom the Software is furnished to do so, subject to
|
12
|
-
the following conditions:
|
13
|
-
|
14
|
-
The above copyright notice and this permission notice shall be
|
15
|
-
included in all copies or substantial portions of the Software.
|
16
|
-
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
# Timers for Ruby [![Gem Version][gem-image]][gem-link] [![Build Status][build-image]][build-link] [![Code Climate][codeclimate-image]][codeclimate-link] [![Coverage Status][coverage-image]][coverage-link] [![MIT licensed][license-image]][license-link]
|
2
|
-
|
3
|
-
[gem-image]: https://badge.fury.io/rb/timers.svg
|
4
|
-
[gem-link]: http://rubygems.org/gems/timers
|
5
|
-
[build-image]: https://secure.travis-ci.org/celluloid/timers.svg?branch=master
|
6
|
-
[build-link]: https://travis-ci.org/celluloid/timers
|
7
|
-
[codeclimate-image]: https://codeclimate.com/github/celluloid/timers.svg
|
8
|
-
[codeclimate-link]: https://codeclimate.com/github/celluloid/timers
|
9
|
-
[coverage-image]: https://coveralls.io/repos/celluloid/timers/badge.svg?branch=master
|
10
|
-
[coverage-link]: https://coveralls.io/r/celluloid/timers
|
11
|
-
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg
|
12
|
-
[license-link]: https://github.com/celluloid/timers/master/LICENSE.txt
|
13
|
-
|
14
|
-
Collections of one-shot and periodic timers, intended for use with event loops.
|
15
|
-
|
16
|
-
**Does not require Celluloid!** Though this gem was originally written
|
17
|
-
to provide the timer subsystem for [Celluloid], it can be used independently
|
18
|
-
in any sort of event loop context, or can provide a purely timer-based event
|
19
|
-
loop itself.
|
20
|
-
|
21
|
-
[Celluloid]: https://github.com/celluloid/celluloid/
|
22
|
-
|
23
|
-
## Supported platforms
|
24
|
-
|
25
|
-
* Ruby 2.0, 2.1, 2.2, and 2.3
|
26
|
-
* JRuby 9000
|
27
|
-
|
28
|
-
## Usage
|
29
|
-
|
30
|
-
Create a new timer group with `Timers::Group.new`:
|
31
|
-
|
32
|
-
```ruby
|
33
|
-
require 'timers'
|
34
|
-
|
35
|
-
timers = Timers::Group.new
|
36
|
-
```
|
37
|
-
|
38
|
-
Schedule a proc to run after 5 seconds with `Timers::Group#after`:
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
five_second_timer = timers.after(5) { puts "Take five" }
|
42
|
-
```
|
43
|
-
|
44
|
-
The `five_second_timer` variable is now bound to a Timers::Timer object. To
|
45
|
-
cancel a timer, use `Timers::Timer#cancel`
|
46
|
-
|
47
|
-
Once you've scheduled a timer, you can wait until the next timer fires with `Timers::Group#wait`:
|
48
|
-
|
49
|
-
```ruby
|
50
|
-
# Waits 5 seconds
|
51
|
-
timers.wait
|
52
|
-
|
53
|
-
# The script will now print "Take five"
|
54
|
-
```
|
55
|
-
|
56
|
-
You can schedule a block to run periodically with `Timers::Group#every`:
|
57
|
-
|
58
|
-
```ruby
|
59
|
-
every_five_seconds = timers.every(5) { puts "Another 5 seconds" }
|
60
|
-
|
61
|
-
loop { timers.wait }
|
62
|
-
```
|
63
|
-
|
64
|
-
You can also schedule a block to run immediately and periodically with `Timers::Group#now_and_every`:
|
65
|
-
```ruby
|
66
|
-
now_and_every_five_seconds = timers.now_and_every(5) { puts "Now and in another 5 seconds" }
|
67
|
-
|
68
|
-
loop { timers.wait }
|
69
|
-
```
|
70
|
-
|
71
|
-
If you'd like another method to do the waiting for you, e.g. `Kernel.select`,
|
72
|
-
you can use `Timers::Group#wait_interval` to obtain the amount of time to wait. When
|
73
|
-
a timeout is encountered, you can fire all pending timers with `Timers::Group#fire`:
|
74
|
-
|
75
|
-
```ruby
|
76
|
-
loop do
|
77
|
-
interval = timers.wait_interval
|
78
|
-
ready_readers, ready_writers = select readers, writers, nil, interval
|
79
|
-
|
80
|
-
if ready_readers || ready_writers
|
81
|
-
# Handle IO
|
82
|
-
...
|
83
|
-
else
|
84
|
-
# Timeout!
|
85
|
-
timers.fire
|
86
|
-
end
|
87
|
-
end
|
88
|
-
```
|
89
|
-
|
90
|
-
You can also pause and continue individual timers, or all timers:
|
91
|
-
|
92
|
-
```ruby
|
93
|
-
paused_timer = timers.every(5) { puts "I was paused" }
|
94
|
-
|
95
|
-
paused_timer.pause
|
96
|
-
10.times { timers.wait } # will not fire paused timer
|
97
|
-
|
98
|
-
paused_timer.resume
|
99
|
-
10.times { timers.wait } # will fire timer
|
100
|
-
|
101
|
-
timers.pause
|
102
|
-
10.times { timers.wait } # will not fire any timers
|
103
|
-
|
104
|
-
timers.resume
|
105
|
-
10.times { timers.wait } # will fire all timers
|
106
|
-
```
|
107
|
-
|
108
|
-
## License
|
109
|
-
|
110
|
-
Copyright (c) 2012-2016 Celluloid timers project developers (given in the file
|
111
|
-
AUTHORS.md).
|
112
|
-
|
113
|
-
Distributed under the MIT License. See LICENSE file for further details.
|