execution_deadline 0.1.0 → 0.1.1
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 +4 -4
- data/Gemfile +3 -1
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/execution_deadline.gemspec +15 -14
- data/lib/execution_deadline/deadline.rb +6 -6
- data/lib/execution_deadline/helpers.rb +3 -6
- data/lib/execution_deadline/version.rb +3 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab73aac3e9d983dcbeae9b4ecfee3260588c84a73bc5371168f49702e54f9f01
|
4
|
+
data.tar.gz: f9b60401c580d89763e9e56be22494169d8706056b4b0a8300fb482b3c9f4390
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 877beba2aab5d7e4098dd574cd5fd1fa8a666e01263657c20bf90ef2a5c6a6505d1404ff82404e3e614296e91283a7b8afdd4e94d9aff4aa6630d00b1015f5ff
|
7
|
+
data.tar.gz: 40a4e52623b308287683dbe5a58901bd252ba2ed13ac0e5c11259abf91353231e1d32a761e9cb783e1a0ca5bae0a07bc9cdcf5bcc3a0e1942aeafc44b66cc0af
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'execution_deadline'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "execution_deadline"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/execution_deadline.gemspec
CHANGED
@@ -1,28 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
5
|
+
require 'execution_deadline/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'execution_deadline'
|
8
9
|
spec.version = ExecutionDeadline::VERSION
|
9
|
-
spec.authors = [
|
10
|
+
spec.authors = ['Brian Malinconico']
|
10
11
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
12
|
+
spec.summary = 'Manage code deadlines without the hard termination of Timeout'
|
13
|
+
spec.description = 'Easily create and enforce deadline timings for code without the harsh termination of the Timeout module.'
|
14
|
+
spec.homepage = 'https://github.com/arjes/execution_deadline'
|
15
|
+
spec.license = 'MIT'
|
15
16
|
|
16
17
|
# Specify which files should be added to the gem when it is released.
|
17
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
-
spec.files = Dir.chdir(File.expand_path(
|
19
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
19
20
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
21
|
end
|
21
|
-
spec.bindir =
|
22
|
+
spec.bindir = 'exe'
|
22
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
-
spec.require_paths = [
|
24
|
+
spec.require_paths = ['lib']
|
24
25
|
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
26
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
29
|
end
|
@@ -9,17 +9,17 @@ module ExecutionDeadline
|
|
9
9
|
@raises = raises
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
time_left <
|
12
|
+
def require_seconds_left!(seconds_left)
|
13
|
+
time_left < seconds_left &&
|
14
14
|
raise(
|
15
15
|
@raises || OutOfTime,
|
16
|
-
"Unable to run method expected run time #{
|
16
|
+
"Unable to run method expected run time #{seconds_left} " \
|
17
17
|
"but only #{time_left}s left"
|
18
18
|
)
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
end
|
21
|
+
def check_deadline_expiration!
|
22
|
+
expired? && raise(@raises || DeadlineExceeded)
|
23
23
|
end
|
24
24
|
|
25
25
|
def time_left
|
@@ -13,12 +13,9 @@ module ExecutionDeadline
|
|
13
13
|
raises: options[:raises]
|
14
14
|
)
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
else
|
21
|
-
send(options[:aliased_method_name], *args, &blk)
|
16
|
+
ExecutionDeadline.current_deadline&.require_seconds_left!(options[:runs_for]) if options[:runs_for]
|
17
|
+
send(options[:aliased_method_name], *args, &blk).tap do
|
18
|
+
ExecutionDeadline.current_deadline&.check_deadline_expiration!
|
22
19
|
end
|
23
20
|
ensure
|
24
21
|
ExecutionDeadline.clear_deadline! if set_deadline
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: execution_deadline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Malinconico
|
@@ -94,8 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
|
-
|
98
|
-
rubygems_version: 2.7.6
|
97
|
+
rubygems_version: 3.0.6
|
99
98
|
signing_key:
|
100
99
|
specification_version: 4
|
101
100
|
summary: Manage code deadlines without the hard termination of Timeout
|