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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8db051c4e993ec213f306abdbd5bc2b040ee54a1deaf2dd3e792499bd7df2281
4
- data.tar.gz: 51f845449e648ff5194b80e03c99e38678c483da9b3f7768d3c839010870034a
3
+ metadata.gz: ab73aac3e9d983dcbeae9b4ecfee3260588c84a73bc5371168f49702e54f9f01
4
+ data.tar.gz: f9b60401c580d89763e9e56be22494169d8706056b4b0a8300fb482b3c9f4390
5
5
  SHA512:
6
- metadata.gz: 557fcc632853b4d9f36ade03025724900060e2c6a2469f0d53f71f5f1184d455a87f21d77bd7409577c265ebe0349ff83e2826dcbe8c3849a5cb1943eb003101
7
- data.tar.gz: d8daf31b451a24e88a69854a32fb29a852932cba06a191ab98c03cd3e539145f238a4a2823e90d1a9ef400678cd3fd9358abbffdbd6b962ffc9783a2895dbbe3
6
+ metadata.gz: 877beba2aab5d7e4098dd574cd5fd1fa8a666e01263657c20bf90ef2a5c6a6505d1404ff82404e3e614296e91283a7b8afdd4e94d9aff4aa6630d00b1015f5ff
7
+ data.tar.gz: 40a4e52623b308287683dbe5a58901bd252ba2ed13ac0e5c11259abf91353231e1d32a761e9cb783e1a0ca5bae0a07bc9cdcf5bcc3a0e1942aeafc44b66cc0af
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in execution_deadline.gemspec
4
6
  gemspec
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "execution_deadline"
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 "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1,28 +1,29 @@
1
+ # frozen_string_literal: true
1
2
 
2
- lib = File.expand_path("../lib", __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "execution_deadline/version"
5
+ require 'execution_deadline/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "execution_deadline"
8
+ spec.name = 'execution_deadline'
8
9
  spec.version = ExecutionDeadline::VERSION
9
- spec.authors = ["Brian Malinconico"]
10
+ spec.authors = ['Brian Malinconico']
10
11
 
11
- spec.summary = %q{Manage code deadlines without the hard termination of Timeout}
12
- spec.description = %q{Easily create and enforce deadline timings for code without the harsh termination of the Timeout module.}
13
- spec.homepage = "https://github.com/arjes/execution_deadline"
14
- spec.license = "MIT"
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('..', __FILE__)) do
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 = "exe"
22
+ spec.bindir = 'exe'
22
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
- spec.require_paths = ["lib"]
24
+ spec.require_paths = ['lib']
24
25
 
25
- spec.add_development_dependency "bundler", "~> 2.0"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "rspec", "~> 3.0"
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 runs_for(duration)
13
- time_left < duration &&
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 #{duration} " \
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
- yield.tap do
21
- expired? && raise(@raises || DeadlineExceeded)
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
- if ExecutionDeadline.current_deadline && options[:runs_for]
17
- ExecutionDeadline.current_deadline.runs_for(options[:runs_for]) do
18
- send(options[:aliased_method_name], *args, &blk)
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ExecutionDeadline
2
- VERSION = "0.1.0"
4
+ VERSION = '0.1.1'
3
5
  end
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.0
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
- rubyforge_project:
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