timers 4.1.1 → 4.3.1
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 +24 -3
- data/lib/timers/events.rb +138 -111
- data/lib/timers/group.rb +144 -129
- data/lib/timers/interval.rb +58 -0
- data/lib/timers/timer.rb +147 -125
- data/lib/timers/version.rb +23 -1
- data/lib/timers/wait.rb +63 -44
- metadata +25 -53
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -17
- data/.rspec +0 -5
- data/.travis.yml +0 -18
- data/AUTHORS.md +0 -15
- data/CHANGES.md +0 -54
- data/Gemfile +0 -6
- data/LICENSE +0 -23
- data/README.md +0 -103
- data/Rakefile +0 -7
- data/spec/cancel_spec.rb +0 -46
- data/spec/events_spec.rb +0 -57
- data/spec/every_spec.rb +0 -34
- data/spec/group_spec.rb +0 -254
- data/spec/performance_spec.rb +0 -100
- data/spec/spec_helper.rb +0 -19
- data/spec/strict_spec.rb +0 -37
- data/spec/timeout_spec.rb +0 -29
- data/timers.gemspec +0 -23
data/spec/strict_spec.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe Timers::Group do
|
5
|
-
it "should not diverge too much" do
|
6
|
-
fired = :not_fired_yet
|
7
|
-
count = 0
|
8
|
-
quantum = 0.01
|
9
|
-
|
10
|
-
start_offset = subject.current_offset
|
11
|
-
Timers::Timer.new(subject, quantum, :strict, start_offset) do |offset|
|
12
|
-
fired = offset
|
13
|
-
count += 1
|
14
|
-
end
|
15
|
-
|
16
|
-
iterations = 1000
|
17
|
-
subject.wait while count < iterations
|
18
|
-
|
19
|
-
# In my testing on the JVM, without the :strict recurring, I noticed 60ms of error here.
|
20
|
-
expect(fired - start_offset).to be_within(quantum).of(iterations * quantum)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should only fire once" do
|
24
|
-
fired = :not_fired_yet
|
25
|
-
count = 0
|
26
|
-
|
27
|
-
start_offset = subject.current_offset
|
28
|
-
Timers::Timer.new(subject, 0, :strict, start_offset) do |offset|
|
29
|
-
fired = offset
|
30
|
-
count += 1
|
31
|
-
end
|
32
|
-
|
33
|
-
subject.wait
|
34
|
-
|
35
|
-
expect(count).to be == 1
|
36
|
-
end
|
37
|
-
end
|
data/spec/timeout_spec.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'timers/wait'
|
4
|
-
|
5
|
-
RSpec.describe Timers::Wait do
|
6
|
-
it "repeats until timeout expired" do
|
7
|
-
timeout = Timers::Wait.new(5)
|
8
|
-
count = 0
|
9
|
-
|
10
|
-
timeout.while_time_remaining do |remaining|
|
11
|
-
expect(remaining).to be_within(TIMER_QUANTUM).of (timeout.duration - count)
|
12
|
-
|
13
|
-
count += 1
|
14
|
-
sleep 1
|
15
|
-
end
|
16
|
-
|
17
|
-
expect(count).to eq(5)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "yields results as soon as possible" do
|
21
|
-
timeout = Timers::Wait.new(5)
|
22
|
-
|
23
|
-
result = timeout.while_time_remaining do |remaining|
|
24
|
-
break :done
|
25
|
-
end
|
26
|
-
|
27
|
-
expect(result).to eq(:done)
|
28
|
-
end
|
29
|
-
end
|
data/timers.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/timers/version', __FILE__)
|
3
|
-
|
4
|
-
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["Tony Arcieri"]
|
6
|
-
gem.email = ["tony.arcieri@gmail.com"]
|
7
|
-
gem.description = "Pure Ruby one-shot and periodic timers"
|
8
|
-
gem.summary = "Schedule procs to run after a certain time, or at periodic intervals, using any API that accepts a timeout"
|
9
|
-
gem.homepage = "https://github.com/celluloid/timers"
|
10
|
-
|
11
|
-
gem.files = `git ls-files`.split($\)
|
12
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
-
gem.name = "timers"
|
15
|
-
gem.require_paths = ["lib"]
|
16
|
-
gem.version = Timers::VERSION
|
17
|
-
gem.licenses = ['MIT']
|
18
|
-
|
19
|
-
gem.add_runtime_dependency 'hitimes'
|
20
|
-
|
21
|
-
gem.add_development_dependency 'rake'
|
22
|
-
gem.add_development_dependency 'rspec', '~> 3.0.0'
|
23
|
-
end
|