yoshinon 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.idea/.gitignore +8 -0
- data/.idea/inspectionProfiles/Project_Default.xml +15 -0
- data/.idea/misc.xml +4 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vcs.xml +6 -0
- data/.idea/yoshinon.iml +54 -0
- data/.rubocop.yml +42 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +40 -0
- data/README.md +59 -0
- data/Rakefile +4 -0
- data/lib/yoshinon/deshite.rb +15 -0
- data/lib/yoshinon/sig/int.rb +5 -0
- data/lib/yoshinon/sig/term.rb +5 -0
- data/lib/yoshinon/version.rb +5 -0
- data/lib/yoshinon.rb +52 -0
- data/sig/yoshinon.rbs +4 -0
- data/yoshinon.gemspec +31 -0
- metadata +77 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cd77e4a657ce6d189f166c1876982ebc89abb17642ce27b3e3afb3d44b482169
|
4
|
+
data.tar.gz: c5616a11fac63c0d707870658961fa0a36b9d32e5fdf1095651c22fb74bdd315
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53aaef6f4dedc08e66276e9f240187056b6c3aa98c274456959c3da330ec45f7fd134c31206f79f133157bd756b183b453752c3db9dd7973fdb95e3b2301a0a0
|
7
|
+
data.tar.gz: d64bd704e9a9b3817bd77a7ef3da852effaf7b067d1ef9a69b7fa79695202bb6db45661bd0baef3bec76e4e58050ec833ca1ef9dacdcb82cb4268ba19263b159
|
data/.idea/.gitignore
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
<component name="InspectionProjectProfileManager">
|
2
|
+
<profile version="1.0">
|
3
|
+
<option name="myName" value="Project Default" />
|
4
|
+
<inspection_tool class="Rubocop" enabled="true" level="WARNING" enabled_by_default="true">
|
5
|
+
<option name="myRunRubocopOnSave" value="true" />
|
6
|
+
</inspection_tool>
|
7
|
+
<inspection_tool class="RubyConvertAllHashesInFileInspections" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
8
|
+
<inspection_tool class="RubyStringKeysInHashInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
9
|
+
<inspection_tool class="SpellCheckingInspection" enabled="true" level="INFORMATION" enabled_by_default="true">
|
10
|
+
<option name="processCode" value="true" />
|
11
|
+
<option name="processLiterals" value="true" />
|
12
|
+
<option name="processComments" value="true" />
|
13
|
+
</inspection_tool>
|
14
|
+
</profile>
|
15
|
+
</component>
|
data/.idea/misc.xml
ADDED
data/.idea/modules.xml
ADDED
data/.idea/vcs.xml
ADDED
data/.idea/yoshinon.iml
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
4
|
+
<shared />
|
5
|
+
</component>
|
6
|
+
<component name="NewModuleRootManager">
|
7
|
+
<content url="file://$MODULE_DIR$">
|
8
|
+
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
9
|
+
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
10
|
+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
11
|
+
</content>
|
12
|
+
<orderEntry type="inheritedJdk" />
|
13
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, rbenv: 2.7.2) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, rbenv: 2.7.2) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.22.1, rbenv: 2.7.2) [gem]" level="application" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="parser (v3.1.2.0, rbenv: 2.7.2) [gem]" level="application" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, rbenv: 2.7.2) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, rbenv: 2.7.2) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.5.0, rbenv: 2.7.2) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, rbenv: 2.7.2) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.30.1, rbenv: 2.7.2) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.18.0, rbenv: 2.7.2) [gem]" level="application" />
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, rbenv: 2.7.2) [gem]" level="application" />
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, rbenv: 2.7.2) [gem]" level="application" />
|
26
|
+
</component>
|
27
|
+
<component name="RakeTasksCache">
|
28
|
+
<option name="myRootTask">
|
29
|
+
<RakeTaskImpl id="rake">
|
30
|
+
<subtasks>
|
31
|
+
<RakeTaskImpl description="Build yoshinon-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
|
32
|
+
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
33
|
+
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
34
|
+
<RakeTaskImpl description="Build and install yoshinon-0.1.0.gem into system gems" fullCommand="install" id="install" />
|
35
|
+
<RakeTaskImpl id="install">
|
36
|
+
<subtasks>
|
37
|
+
<RakeTaskImpl description="Build and install yoshinon-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
|
38
|
+
</subtasks>
|
39
|
+
</RakeTaskImpl>
|
40
|
+
<RakeTaskImpl description="Create tag v0.1.0 and build and push yoshinon-0.1.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
41
|
+
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
42
|
+
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
43
|
+
<RakeTaskImpl id="release">
|
44
|
+
<subtasks>
|
45
|
+
<RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
|
46
|
+
<RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
|
47
|
+
<RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
|
48
|
+
</subtasks>
|
49
|
+
</RakeTaskImpl>
|
50
|
+
</subtasks>
|
51
|
+
</RakeTaskImpl>
|
52
|
+
</option>
|
53
|
+
</component>
|
54
|
+
</module>
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
|
4
|
+
Metrics/AbcSize:
|
5
|
+
Max: 170
|
6
|
+
|
7
|
+
Metrics/BlockLength:
|
8
|
+
Max: 250
|
9
|
+
|
10
|
+
Metrics/ClassLength:
|
11
|
+
Max: 1000
|
12
|
+
|
13
|
+
Metrics/CyclomaticComplexity:
|
14
|
+
Max: 70
|
15
|
+
|
16
|
+
Metrics/MethodLength:
|
17
|
+
Max: 100
|
18
|
+
|
19
|
+
Metrics/ModuleLength:
|
20
|
+
Max: 1000
|
21
|
+
|
22
|
+
Metrics/ParameterLists:
|
23
|
+
Max: 50
|
24
|
+
|
25
|
+
Metrics/PerceivedComplexity:
|
26
|
+
Max: 80
|
27
|
+
|
28
|
+
Layout/SpaceInsideBlockBraces:
|
29
|
+
EnforcedStyle: no_space
|
30
|
+
SpaceBeforeBlockParameters: false
|
31
|
+
|
32
|
+
Style/Documentation:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Style/NumericPredicate:
|
36
|
+
EnforcedStyle: comparison
|
37
|
+
|
38
|
+
Style/MultilineBlockChain:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
Style/SpecialGlobalVars:
|
42
|
+
EnforcedStyle: use_perl_names
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
yoshinon (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
parallel (1.22.1)
|
11
|
+
parser (3.1.2.0)
|
12
|
+
ast (~> 2.4.1)
|
13
|
+
rainbow (3.1.1)
|
14
|
+
rake (13.0.6)
|
15
|
+
regexp_parser (2.5.0)
|
16
|
+
rexml (3.2.5)
|
17
|
+
rubocop (1.30.1)
|
18
|
+
parallel (~> 1.10)
|
19
|
+
parser (>= 3.1.0.0)
|
20
|
+
rainbow (>= 2.2.2, < 4.0)
|
21
|
+
regexp_parser (>= 1.8, < 3.0)
|
22
|
+
rexml (>= 3.2.5, < 4.0)
|
23
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
24
|
+
ruby-progressbar (~> 1.7)
|
25
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
26
|
+
rubocop-ast (1.18.0)
|
27
|
+
parser (>= 3.1.1.0)
|
28
|
+
ruby-progressbar (1.11.0)
|
29
|
+
unicode-display_width (2.1.0)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
rake (~> 13.0)
|
36
|
+
rubocop
|
37
|
+
yoshinon!
|
38
|
+
|
39
|
+
BUNDLED WITH
|
40
|
+
2.1.4
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Yoshinon
|
2
|
+
|
3
|
+
Yoshinon is a gem to guard processes from signals such as SIGTERM and SIGINT.
|
4
|
+
|
5
|
+
The name comes from [Yoshino Yorita](https://project-imas.wiki/Yoshino_Yorita).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install the gem and add to the application's Gemfile by executing:
|
10
|
+
|
11
|
+
$ bundle add yoshinon
|
12
|
+
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
|
+
|
15
|
+
$ gem install yoshinon
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require 'yoshinon/sig/int'
|
21
|
+
|
22
|
+
Yoshinon.on_trap do
|
23
|
+
puts 'Signal received!'
|
24
|
+
end
|
25
|
+
|
26
|
+
Yoshinon.lock do
|
27
|
+
10.times do
|
28
|
+
sleep 0.2
|
29
|
+
puts 'running...'
|
30
|
+
end
|
31
|
+
puts 'end!'
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
```
|
36
|
+
$ bundle exec ruby test/sample.rb
|
37
|
+
running...
|
38
|
+
running...
|
39
|
+
^CSignal received!
|
40
|
+
running...
|
41
|
+
running...
|
42
|
+
running...
|
43
|
+
running...
|
44
|
+
running...
|
45
|
+
running...
|
46
|
+
running...
|
47
|
+
running...
|
48
|
+
end!
|
49
|
+
```
|
50
|
+
|
51
|
+
## Development
|
52
|
+
|
53
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
54
|
+
|
55
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Ishotihadus/yoshinon.
|
data/Rakefile
ADDED
data/lib/yoshinon.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'set'
|
4
|
+
require_relative 'yoshinon/deshite'
|
5
|
+
require_relative 'yoshinon/version'
|
6
|
+
|
7
|
+
module Yoshinon
|
8
|
+
@mutex = Mutex.new
|
9
|
+
@cv = ConditionVariable.new
|
10
|
+
@deshite_set = Set.new
|
11
|
+
@on_trap = []
|
12
|
+
|
13
|
+
def self.on_trap(&block)
|
14
|
+
@on_trap << block
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.define_trap(signal)
|
18
|
+
Signal.trap(signal) do |value|
|
19
|
+
@on_trap.each{|e| e.call(value)}
|
20
|
+
Thread.new do
|
21
|
+
@mutex.synchronize do
|
22
|
+
@cv.wait(@mutex) until @deshite_set.empty?
|
23
|
+
end
|
24
|
+
exit 130
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.lock
|
30
|
+
if block_given?
|
31
|
+
deshite = lock
|
32
|
+
begin
|
33
|
+
yield
|
34
|
+
ensure
|
35
|
+
unlock(deshite)
|
36
|
+
end
|
37
|
+
else
|
38
|
+
deshite = Deshite.new
|
39
|
+
@mutex.synchronize do
|
40
|
+
@deshite_set << deshite
|
41
|
+
end
|
42
|
+
deshite
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.unlock(deshite)
|
47
|
+
@mutex.synchronize do
|
48
|
+
@deshite_set.delete(deshite)
|
49
|
+
@cv.broadcast
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/sig/yoshinon.rbs
ADDED
data/yoshinon.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/yoshinon/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'yoshinon'
|
7
|
+
spec.version = Yoshinon::VERSION
|
8
|
+
spec.authors = ['Ishotihadus']
|
9
|
+
spec.email = ['hanachan.pao@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'Yoshinon is a gem to guard processes from signals such as SIGTERM and SIGINT.'
|
12
|
+
spec.description = 'Yoshinon is a gem to guard processes from signals such as SIGTERM and SIGINT.'
|
13
|
+
spec.homepage = 'https://github.com/Ishotihadus/yoshinon'
|
14
|
+
spec.required_ruby_version = '>= 2.6.0'
|
15
|
+
|
16
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
+
spec.metadata['source_code_uri'] = 'https://github.com/Ishotihadus/yoshinon'
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(__dir__) do
|
22
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
23
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
spec.bindir = 'exe'
|
27
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) {|f| File.basename(f)}
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
|
30
|
+
spec.add_development_dependency 'rubocop'
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yoshinon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ishotihadus
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-06-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Yoshinon is a gem to guard processes from signals such as SIGTERM and
|
28
|
+
SIGINT.
|
29
|
+
email:
|
30
|
+
- hanachan.pao@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".idea/.gitignore"
|
36
|
+
- ".idea/inspectionProfiles/Project_Default.xml"
|
37
|
+
- ".idea/misc.xml"
|
38
|
+
- ".idea/modules.xml"
|
39
|
+
- ".idea/vcs.xml"
|
40
|
+
- ".idea/yoshinon.iml"
|
41
|
+
- ".rubocop.yml"
|
42
|
+
- Gemfile
|
43
|
+
- Gemfile.lock
|
44
|
+
- README.md
|
45
|
+
- Rakefile
|
46
|
+
- lib/yoshinon.rb
|
47
|
+
- lib/yoshinon/deshite.rb
|
48
|
+
- lib/yoshinon/sig/int.rb
|
49
|
+
- lib/yoshinon/sig/term.rb
|
50
|
+
- lib/yoshinon/version.rb
|
51
|
+
- sig/yoshinon.rbs
|
52
|
+
- yoshinon.gemspec
|
53
|
+
homepage: https://github.com/Ishotihadus/yoshinon
|
54
|
+
licenses: []
|
55
|
+
metadata:
|
56
|
+
homepage_uri: https://github.com/Ishotihadus/yoshinon
|
57
|
+
source_code_uri: https://github.com/Ishotihadus/yoshinon
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.6.0
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubygems_version: 3.1.4
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: Yoshinon is a gem to guard processes from signals such as SIGTERM and SIGINT.
|
77
|
+
test_files: []
|