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
data/spec/timers/strict_spec.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe Timers::Group do
|
4
|
-
it "should not diverge too much" do
|
5
|
-
fired = :not_fired_yet
|
6
|
-
count = 0
|
7
|
-
quantum = 0.01
|
8
|
-
|
9
|
-
start_offset = subject.current_offset
|
10
|
-
Timers::Timer.new(subject, quantum, :strict, start_offset) do |offset|
|
11
|
-
fired = offset
|
12
|
-
count += 1
|
13
|
-
end
|
14
|
-
|
15
|
-
iterations = 1000
|
16
|
-
subject.wait while count < iterations
|
17
|
-
|
18
|
-
# In my testing on the JVM, without the :strict recurring, I noticed 60ms of error here.
|
19
|
-
expect(fired - start_offset).to be_within(quantum).of(iterations * quantum)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should only fire once" do
|
23
|
-
fired = :not_fired_yet
|
24
|
-
count = 0
|
25
|
-
|
26
|
-
start_offset = subject.current_offset
|
27
|
-
Timers::Timer.new(subject, 0, :strict, start_offset) do |offset|
|
28
|
-
fired = offset
|
29
|
-
count += 1
|
30
|
-
end
|
31
|
-
|
32
|
-
subject.wait
|
33
|
-
|
34
|
-
expect(count).to be == 1
|
35
|
-
end
|
36
|
-
end
|
data/spec/timers/wait_spec.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
require "timers/wait"
|
5
|
-
|
6
|
-
RSpec.describe Timers::Wait do
|
7
|
-
it "repeats until timeout expired" do
|
8
|
-
timeout = Timers::Wait.new(5)
|
9
|
-
count = 0
|
10
|
-
|
11
|
-
timeout.while_time_remaining do |remaining|
|
12
|
-
expect(remaining).to be_within(TIMER_QUANTUM).of(timeout.duration - count)
|
13
|
-
|
14
|
-
count += 1
|
15
|
-
sleep 1
|
16
|
-
end
|
17
|
-
|
18
|
-
expect(count).to eq(5)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "yields results as soon as possible" do
|
22
|
-
timeout = Timers::Wait.new(5)
|
23
|
-
|
24
|
-
result = timeout.while_time_remaining do |_remaining|
|
25
|
-
break :done
|
26
|
-
end
|
27
|
-
|
28
|
-
expect(result).to eq(:done)
|
29
|
-
end
|
30
|
-
end
|
data/timers.gemspec
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require File.expand_path("../lib/timers/version", __FILE__)
|
5
|
-
|
6
|
-
Gem::Specification.new do |gem|
|
7
|
-
gem.name = "timers"
|
8
|
-
gem.version = Timers::VERSION
|
9
|
-
gem.authors = ["Tony Arcieri"]
|
10
|
-
gem.email = ["bascule@gmail.com"]
|
11
|
-
gem.licenses = ["MIT"]
|
12
|
-
gem.homepage = "https://github.com/celluloid/timers"
|
13
|
-
gem.summary = "Pure Ruby one-shot and periodic timers"
|
14
|
-
gem.description = <<-DESCRIPTION.strip.gsub(/\s+/, " ")
|
15
|
-
Schedule procs to run after a certain time, or at periodic intervals,
|
16
|
-
using any API that accepts a timeout.
|
17
|
-
DESCRIPTION
|
18
|
-
|
19
|
-
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
20
|
-
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
21
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
22
|
-
gem.require_paths = ["lib"]
|
23
|
-
gem.add_runtime_dependency "hitimes"
|
24
|
-
|
25
|
-
gem.add_development_dependency "bundler"
|
26
|
-
end
|