restartable 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YzVlYTM0OTk0MDIzZjFmODU5NjVmOWNkOTk2ZjBhNzA3ZDMzZjY0Zg==
5
- data.tar.gz: !binary |-
6
- NzcxMzhiM2E5YzY3ZWE0ZDMzOGRlZTVhMmI0MzIzODIwOTUzOGQxMw==
2
+ SHA256:
3
+ metadata.gz: a28dc12572eb0bea21b5092610bc37735f80895e6cbf118dcdaf768afbb56b57
4
+ data.tar.gz: ab8a55f71bc27b21888d034fc242407358ab42145b644c4b54d7d94fc37da980
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- N2UwMTYxOGE1OTQ2Nzk5ZTMyMjRjNjAxOThiOWYxM2U5OTlkNGMzMzUzMDIw
10
- ZGI3OTRlMzNhZjBmNmQzN2VjZDgzMmYxMTA2NDlmNzZlNjBmNDMxY2Q0MzM1
11
- MzkzMzM1MDAwNTE3NTE1YWY3ZjdlZDc3ZmI1MmNlOGVmY2ZiMjE=
12
- data.tar.gz: !binary |-
13
- MzZiZDZkNDVhYjgyMTdkZDg2Mjg4MzY0Yjg1ODVkMjEyYzUxMTU5YmE5MjU0
14
- MjFmN2FmNGM0Mzk3MzdiOTg2ZWIyNjEyMjA3OTI4NjJmNjFkYWE2ZDA3YjU3
15
- OTk3MzI5M2Y1OWZhOGI5ZTAyYzk4N2Q0OWUwMDFkOTY5MGVjMDM=
6
+ metadata.gz: 4847e349cece0182822cc5282c6ad128b71b377d33e576fd12e43bf2dc18d546f946e55bb55e12c07c91612536717eb7844e6fe505310ad6a845cdf783e27874
7
+ data.tar.gz: 63c21a956b21f73d45a32067903434656edae876ffb51f35be7d8551aeeb9406196856cb02991fe1ab76df00ff3a2cc865fc2437be410213c4c4bea954be30c0
data/.rubocop.yml CHANGED
@@ -2,58 +2,72 @@ AllCops:
2
2
  Exclude:
3
3
  - '*.gemspec'
4
4
 
5
+ Layout/AccessModifierIndentation:
6
+ EnforcedStyle: outdent
7
+
8
+ Layout/CaseIndentation:
9
+ EnforcedStyle: end
10
+
11
+ Layout/IndentHash:
12
+ EnforcedStyle: consistent
13
+
14
+ Layout/IndentHeredoc:
15
+ Enabled: false
16
+
17
+ Layout/SpaceBeforeBlockBraces:
18
+ EnforcedStyle: no_space
19
+
20
+ Layout/SpaceInsideHashLiteralBraces:
21
+ EnforcedStyle: no_space
22
+
5
23
  Lint/EndAlignment:
6
- AlignWith: variable
24
+ EnforcedStyleAlignWith: variable
7
25
 
8
- Lint/Eval:
26
+ Lint/UnneededRequireStatement:
9
27
  Enabled: false
10
28
 
11
29
  Metrics/AbcSize:
12
30
  Max: 20
13
31
 
32
+ Metrics/LineLength:
33
+ Max: 120
34
+
14
35
  Metrics/MethodLength:
15
36
  Max: 20
16
37
 
17
- Style/AccessModifierIndentation:
18
- EnforcedStyle: outdent
38
+ Security/Eval:
39
+ Exclude:
40
+ - 'features/**/*_steps.rb'
19
41
 
20
42
  Style/BracesAroundHashParameters:
21
43
  Enabled: false
22
44
 
23
- Style/CaseIndentation:
24
- IndentWhenRelativeTo: end
25
-
26
- Style/DotPosition:
27
- EnforcedStyle: trailing
28
-
29
45
  Style/DoubleNegation:
30
46
  Enabled: false
31
47
 
32
- Style/Encoding:
33
- EnforcedStyle: when_needed
48
+ Style/EmptyCaseCondition:
49
+ Enabled: false
34
50
 
35
- Style/HashSyntax:
36
- EnforcedStyle: hash_rockets
51
+ Style/Encoding:
52
+ Enabled: false
37
53
 
38
54
  Style/IfUnlessModifier:
39
- MaxLineLength: 40
40
-
41
- Style/IndentHash:
42
- EnforcedStyle: consistent
55
+ Enabled: false
43
56
 
44
- Style/PercentLiteralDelimiters:
45
- PreferredDelimiters:
46
- '%w': '[]'
47
- '%W': '[]'
57
+ Style/RescueStandardError:
58
+ EnforcedStyle: implicit
48
59
 
49
60
  Style/Semicolon:
50
61
  AllowAsExpressionSeparator: true
51
62
 
52
- Style/SpaceBeforeBlockBraces:
53
- EnforcedStyle: no_space
63
+ Style/SignalException:
64
+ EnforcedStyle: semantic
54
65
 
55
- Style/SpaceInsideHashLiteralBraces:
56
- EnforcedStyle: no_space
66
+ Style/TrailingCommaInArguments:
67
+ EnforcedStyleForMultiline: no_comma
68
+
69
+ Style/TrailingCommaInArrayLiteral:
70
+ EnforcedStyleForMultiline: comma
57
71
 
58
- Style/TrailingComma:
72
+ Style/TrailingCommaInHashLiteral:
59
73
  EnforcedStyleForMultiline: comma
data/.travis.yml CHANGED
@@ -1,17 +1,23 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
- - 1.8.7
4
- - 1.9.3
5
- - '2.0'
6
- - '2.1'
7
- script:
8
- if [ -n "$RUBOCOP" ]; then
9
- bundle exec rubocop
10
- ; else
11
- bundle exec cucumber
12
- ; fi
4
+ - '2.0.0-p648'
5
+ - '2.1.10'
6
+ - '2.2.10'
7
+ - '2.3.8'
8
+ - '2.4.5'
9
+ - '2.5.3'
10
+ before_install:
11
+ - gem update --system
12
+ - gem update bundler
13
+ script: bundle exec cucumber --expand
13
14
  matrix:
14
- fast_finish: true
15
15
  include:
16
- - env: RUBOCOP=true
16
+ - os: osx
17
17
  rvm: default
18
+ - env: RUBOCOP=✓
19
+ rvm: '2.5.3'
20
+ script: bundle exec rubocop
21
+ - env: CHECK_RUBIES=✓
22
+ rvm: '2.5.3'
23
+ script: bundle exec travis_check_rubies
data/Gemfile CHANGED
@@ -1,3 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ if ENV['CHECK_RUBIES']
6
+ gem 'travis_check_rubies', '~> 0.2'
7
+ end
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2014 Ivan Kuchin
1
+ Copyright (c) 2013-2018 Ivan Kuchin
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.markdown CHANGED
@@ -1,7 +1,7 @@
1
1
  [![Gem Version](https://img.shields.io/gem/v/restartable.svg?style=flat)](https://rubygems.org/gems/restartable)
2
2
  [![Build Status](https://img.shields.io/travis/toy/restartable/master.svg?style=flat)](https://travis-ci.org/toy/restartable)
3
- [![Code Climate](https://img.shields.io/codeclimate/github/toy/restartable.svg?style=flat)](https://codeclimate.com/github/toy/restartable)
4
- [![Dependency Status](https://img.shields.io/gemnasium/toy/restartable.svg?style=flat)](https://gemnasium.com/toy/restartable)
3
+ [![Code Climate](https://img.shields.io/codeclimate/maintainability/toy/restartable.svg?style=flat)](https://codeclimate.com/github/toy/restartable)
4
+ [![Depfu](https://badges.depfu.com/badges/726b551145c58c3fed9076c2c06361fa/overview.svg)](https://depfu.com/github/toy/restartable)
5
5
 
6
6
  # restartable
7
7
 
@@ -9,4 +9,4 @@ Run code, Ctrl-C to restart, two Ctrl-C to stop.
9
9
 
10
10
  ## Copyright
11
11
 
12
- Copyright (c) 2012-2014 Ivan Kuchin. See LICENSE.txt for details.
12
+ Copyright (c) 2012-2018 Ivan Kuchin. See LICENSE.txt for details.
@@ -9,7 +9,6 @@ Feature: Restarting
9
9
  And I should see "Hello world!" in stdout
10
10
  And there should be a child process
11
11
  When I interrupt restartable
12
- Then I should see "Killing children…" in stderr
13
12
  And I should see "Waiting ^C 0.5 second than restart…" in stderr within <timeout> seconds
14
13
  And child process should terminate
15
14
 
@@ -19,7 +18,7 @@ Feature: Restarting
19
18
  And I should see "Hello world!" in stdout
20
19
  And there should be a child process
21
20
  When I interrupt restartable twice
22
- Then I should see "Killing children…" and "Don't restart!" in stderr
21
+ Then I should see "Don't restart!" in stderr
23
22
  And child process should terminate within <timeout> seconds
24
23
  And restartable should finish
25
24
  And I should not see "Waiting ^C 0.5 second than restart…" in stderr
@@ -27,7 +26,7 @@ Feature: Restarting
27
26
 
28
27
  Examples:
29
28
  | code | timeout |
30
- | $stdout.puts "Hello world!" | 5 |
29
+ | $stdout.puts "Hello world!"; sleep 100 | 5 |
31
30
  | $stdout.puts "Hello world!"; 100.times{ sleep 1 } | 5 |
32
31
  | exec 'echo "Hello world!"; sleep 100' | 5 |
33
32
  | system 'echo "Hello world!"; sleep 100' | 5 |
@@ -1,10 +1,23 @@
1
1
  require 'restartable'
2
2
 
3
- Given(/^I have set on restart to `(.*?)`$/) do |command|
3
+ def children
4
+ Sys::ProcTable.ps.select do |pe|
5
+ next if pe.pid == @pid
6
+
7
+ @pid == case
8
+ when pe.respond_to?(:pgid) then pe.pgid
9
+ when pe.respond_to?(:pgrp) then pe.pgrp
10
+ when pe.respond_to?(:ppid) then pe.ppid
11
+ else fail 'Can\'t find process group id'
12
+ end
13
+ end
14
+ end
15
+
16
+ Given(/^I have set on restart to `(.+)`$/) do |command|
4
17
  (@on_restart ||= []) << proc{ eval(command) }
5
18
  end
6
19
 
7
- Given(/^I have invoked restartable with `(.*?)`$/) do |command|
20
+ Given(/^I have invoked restartable with `(.+)`$/) do |command|
8
21
  @stdout = IO.pipe
9
22
  @stderr = IO.pipe
10
23
 
@@ -17,7 +30,7 @@ Given(/^I have invoked restartable with `(.*?)`$/) do |command|
17
30
  @stderr[0].close
18
31
  STDERR.reopen(@stderr[1])
19
32
 
20
- Restartable.new(:on_restart => @on_restart) do
33
+ Restartable.new(on_restart: @on_restart) do
21
34
  Signal.trap('INT', 'EXIT')
22
35
  eval(command)
23
36
  end
@@ -31,14 +44,13 @@ When(/^I have waited for (\d+) second$/) do |seconds|
31
44
  sleep seconds.to_i
32
45
  end
33
46
 
34
- Then(/^
35
- I\ should\ see\ "(.*?)"
36
- \ in\ std(out|err)
37
- (?:\ within\ (\d+)\ seconds)?
38
- $/x) do |arg, io_name, timeout|
47
+ Then(/^I should see "(.+)" in std(out|err)$/) do |arg, io_name|
48
+ step %(I should see "#{arg}" in std#{io_name} within 5 seconds)
49
+ end
50
+ Then(/^I should see "(.+)" in std(out|err) within (\d+) seconds$/) do |arg, io_name, timeout|
39
51
  io = (io_name == 'out' ? @stdout : @stderr)[0]
40
- Timeout.timeout(timeout ? timeout.to_i : 5) do
41
- strings = arg.split(/".*?"/)
52
+ Timeout.timeout(timeout.to_i) do
53
+ strings = arg.split(/".+?"/)
42
54
  until strings.empty?
43
55
  line = io.gets
44
56
  strings.reject! do |string|
@@ -48,9 +60,9 @@ $/x) do |arg, io_name, timeout|
48
60
  end
49
61
  end
50
62
 
51
- Then(/^I should not see "(.*?)" in std(out|err)$/) do |arg, io_name|
63
+ Then(/^I should not see "(.+)" in std(out|err)$/) do |arg, io_name|
52
64
  io = (io_name == 'out' ? @stdout : @stderr)[0]
53
- strings = arg.split(/".*?"/)
65
+ strings = arg.split(/".+?"/)
54
66
  while (line = io.gets)
55
67
  if strings.any?{ |string| line.include?(string) }
56
68
  fail "Got #{line}"
@@ -70,13 +82,16 @@ end
70
82
 
71
83
  Then(/^there should be a child process$/) do
72
84
  Timeout.timeout(5) do
73
- sleep 1 until Sys::ProcTable.ps.any?{ |pe| pe.ppid == @pid }
85
+ sleep 0.3 while children.empty?
74
86
  end
75
87
  end
76
88
 
77
- Then(/^child process should terminate(?: within (\d+) seconds)?$/) do |timeout|
78
- Timeout.timeout(timeout ? timeout.to_i : 5) do
79
- sleep 1 until Sys::ProcTable.ps.none?{ |pe| pe.ppid == @pid }
89
+ Then(/^child process should terminate$/) do
90
+ step %(child process should terminate within 5 seconds)
91
+ end
92
+ Then(/^child process should terminate within (\d+) seconds$/) do |timeout|
93
+ Timeout.timeout(timeout.to_i) do
94
+ sleep 0.3 until children.empty?
80
95
  end
81
96
  end
82
97
 
data/lib/restartable.rb CHANGED
@@ -9,7 +9,9 @@ require 'English'
9
9
  # Main interface
10
10
  class Restartable
11
11
  def self.version
12
- Gem.loaded_specs['restartable'].version.to_s rescue 'DEV'
12
+ Gem.loaded_specs['restartable'].version.to_s
13
+ rescue
14
+ 'DEV'
13
15
  end
14
16
 
15
17
  def initialize(options = {}, &block)
@@ -35,9 +37,11 @@ private
35
37
  sleep 0.1 until @interrupted
36
38
  kill_children!
37
39
  break if @stop
40
+
38
41
  $stderr << "Waiting ^C 0.5 second than restart…\n".yellow.bold
39
42
  sleep 0.5
40
43
  break if @stop
44
+
41
45
  @on_restart.each(&:call)
42
46
  end
43
47
  end
@@ -56,7 +60,13 @@ private
56
60
  interrupt!
57
61
  end
58
62
 
59
- WAIT_SIGNALS = [[5, 'INT'], [3, 'INT'], [1, 'INT'], [3, 'TERM'], [5, 'KILL']]
63
+ WAIT_SIGNALS = [
64
+ [5, 'INT'],
65
+ [3, 'INT'],
66
+ [1, 'INT'],
67
+ [3, 'TERM'],
68
+ [5, 'KILL'],
69
+ ].freeze
60
70
 
61
71
  def kill_children!
62
72
  until children_pids.empty?
data/restartable.gemspec CHANGED
@@ -2,24 +2,31 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'restartable'
5
- s.version = '1.0.1'
5
+ s.version = '1.1.0'
6
6
  s.summary = %q{Run code, Ctrl-C to restart, once more Ctrl-C to stop}
7
7
  s.homepage = "http://github.com/toy/#{s.name}"
8
8
  s.authors = ['Ivan Kuchin']
9
9
  s.license = 'MIT'
10
10
 
11
+ s.required_ruby_version = '>= 2.0'
12
+
11
13
  s.rubyforge_project = s.name
12
14
 
15
+ s.metadata = {
16
+ 'bug_tracker_uri' => "https://github.com/toy/#{s.name}/issues",
17
+ 'documentation_uri' => "https://www.rubydoc.info/gems/#{s.name}/#{s.version}",
18
+ 'source_code_uri' => "https://github.com/toy/#{s.name}",
19
+ }
20
+
13
21
  s.files = `git ls-files`.split("\n")
14
22
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
23
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
24
  s.require_paths = %w[lib]
17
25
 
18
26
  s.add_dependency 'colored', '~> 1.2'
19
- s.add_dependency 'sys-proctable', '~> 0.9.3'
27
+ s.add_dependency 'sys-proctable', '>= 0.9.3', '<= 2.0'
20
28
  s.add_development_dependency 'cucumber'
21
- s.add_development_dependency 'rspec', '~> 3.0'
22
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('1.9.3')
23
- s.add_development_dependency 'rubocop', '~> 0.27'
29
+ if RUBY_VERSION >= '2.1'
30
+ s.add_development_dependency 'rubocop', '~> 0.53'
24
31
  end
25
32
  end
metadata CHANGED
@@ -1,85 +1,77 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restartable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Kuchin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-20 00:00:00.000000000 Z
11
+ date: 2018-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sys-proctable
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.9.3
34
+ - - "<="
35
+ - !ruby/object:Gem::Version
36
+ version: '2.0'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - ~>
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: 0.9.3
44
+ - - "<="
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: cucumber
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ! '>='
51
+ - - ">="
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ! '>='
58
+ - - ">="
53
59
  - !ruby/object:Gem::Version
54
60
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '3.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ~>
67
- - !ruby/object:Gem::Version
68
- version: '3.0'
69
61
  - !ruby/object:Gem::Dependency
70
62
  name: rubocop
71
63
  requirement: !ruby/object:Gem::Requirement
72
64
  requirements:
73
- - - ~>
65
+ - - "~>"
74
66
  - !ruby/object:Gem::Version
75
- version: '0.27'
67
+ version: '0.53'
76
68
  type: :development
77
69
  prerelease: false
78
70
  version_requirements: !ruby/object:Gem::Requirement
79
71
  requirements:
80
- - - ~>
72
+ - - "~>"
81
73
  - !ruby/object:Gem::Version
82
- version: '0.27'
74
+ version: '0.53'
83
75
  description:
84
76
  email:
85
77
  executables:
@@ -87,9 +79,9 @@ executables:
87
79
  extensions: []
88
80
  extra_rdoc_files: []
89
81
  files:
90
- - .gitignore
91
- - .rubocop.yml
92
- - .travis.yml
82
+ - ".gitignore"
83
+ - ".rubocop.yml"
84
+ - ".travis.yml"
93
85
  - Gemfile
94
86
  - LICENSE.txt
95
87
  - README.markdown
@@ -101,28 +93,30 @@ files:
101
93
  homepage: http://github.com/toy/restartable
102
94
  licenses:
103
95
  - MIT
104
- metadata: {}
96
+ metadata:
97
+ bug_tracker_uri: https://github.com/toy/restartable/issues
98
+ documentation_uri: https://www.rubydoc.info/gems/restartable/1.1.0
99
+ source_code_uri: https://github.com/toy/restartable
105
100
  post_install_message:
106
101
  rdoc_options: []
107
102
  require_paths:
108
103
  - lib
109
104
  required_ruby_version: !ruby/object:Gem::Requirement
110
105
  requirements:
111
- - - ! '>='
106
+ - - ">="
112
107
  - !ruby/object:Gem::Version
113
- version: '0'
108
+ version: '2.0'
114
109
  required_rubygems_version: !ruby/object:Gem::Requirement
115
110
  requirements:
116
- - - ! '>='
111
+ - - ">="
117
112
  - !ruby/object:Gem::Version
118
113
  version: '0'
119
114
  requirements: []
120
115
  rubyforge_project: restartable
121
- rubygems_version: 2.4.5
116
+ rubygems_version: 2.7.8
122
117
  signing_key:
123
118
  specification_version: 4
124
119
  summary: Run code, Ctrl-C to restart, once more Ctrl-C to stop
125
120
  test_files:
126
121
  - features/restarting.feature
127
122
  - features/step_definitions/restartable_steps.rb
128
- has_rdoc: