frontkick 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6086b0058c21edf9586f841eef70e15a746dbbaf
4
- data.tar.gz: 0b1f63ed60327e2907dee507eaebe8ac9393df06
3
+ metadata.gz: 6bb5e819a8afaf32b404b81f3b4d0792aa90f7b9
4
+ data.tar.gz: 9a35e8fafa3cfecde913653eaf4611a9ace3b70a
5
5
  SHA512:
6
- metadata.gz: 170164a43b0a1a5175418a6c0216034a6b9d2e43637595699289bc9d100ef85767f466ef1dd2803eac27cd1c42cdbc825037ba807bab7fe3ab02bd3b70d48c5f
7
- data.tar.gz: 5631ed597d2e5134fc5ef914f2bf51275485635b9fe6f022e50a34c070fa88b6b7f4117bc0aa9fbd73eb90d68c0f5e2d7f768248a13ef0d6f222c0617ea578bf
6
+ metadata.gz: 628155e7ae55b811fee9f9727f429b5a6e8b50bf28d722618583b8d82627ce60640ac2263dda02d4c43d75ad03a9ac474483a5c0a170586b27c55e656321bfe8
7
+ data.tar.gz: 5baf25776ba2790a21c4f9156fdc78fe960fff48dee5357ad6b7e8e655b24549baff06f48c9be1ce66048ac7f0e6087f0e98dbc9aca9463b911480baf21f53dd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.5.3 (2017/01/12)
2
+
3
+ Fixes:
4
+
5
+ - Fix not to close given out and err IO objects
6
+
1
7
  # 0.5.2 (2016/03/18)
2
8
 
3
9
  Fixes:
data/README.md CHANGED
@@ -1,66 +1,121 @@
1
1
  # frontkick [![Build Status](https://secure.travis-ci.org/sonots/frontkick.png?branch=master)](http://travis-ci.org/sonots/frontkick) [![Dependency Status](https://gemnasium.com/sonots/frontkick.png)](https://gemnasium.com/sonots/frontkick)
2
2
 
3
- Frontkick is a gem to execute a command and obtain exit\_code, stdout, stderr simply.
3
+ Frontkick is a gem to execute a command and obtain exit\_code, stdout, stderr simply.
4
4
 
5
5
  ## What is This For?
6
6
 
7
- Ruby's `Kernel.#system` method does not return STDOUT and STDERR.
7
+ Ruby's `Kernel.#system` method does not return STDOUT and STDERR.
8
8
  Ruby's back quote (``) returns STDOUT, but does not return STDERR.
9
9
 
10
- With frontkick, you can easily get the exit code, STDOUT, and STDERR.
10
+ With frontkick, you can easily get the exit code, STDOUT, and STDERR.
11
11
 
12
12
  ## USAGE
13
13
 
14
- gem install frontkick
14
+ ```
15
+ gem install frontkick
16
+ ```
15
17
 
16
18
  ### Basic Usage
17
19
 
18
- result = Frontkick.exec("echo *")
19
- puts result.successful? #=> true if exit_code is 0
20
- puts result.success? #=> alias to successful?, for compatibility with Process::Status
21
- puts result.stdout #=> stdout output of the command
22
- puts result.stderr #=> stderr output of the command
23
- puts result.exit_code #=> exit_code of the command
24
- puts result.status #=> alias to exit_code
25
- puts result.exitstatus #=> alias to exit_code, for compatibility with Process::Status
26
- puts result.duration #=> the time used to execute the command
20
+ ```ruby
21
+ result = Frontkick.exec("echo *")
22
+ puts result.successful? #=> true if exit_code is 0
23
+ puts result.success? #=> alias to successful?, for compatibility with Process::Status
24
+ puts result.stdout #=> stdout output of the command
25
+ puts result.stderr #=> stderr output of the command
26
+ puts result.exit_code #=> exit_code of the command
27
+ puts result.status #=> alias to exit_code
28
+ puts result.exitstatus #=> alias to exit_code, for compatibility with Process::Status
29
+ puts result.duration #=> the time used to execute the command
30
+ ```
31
+
32
+ ### No Shell
33
+
34
+ **String argument**
35
+
36
+ When the first argument is a String, the command is executed via shell if the command string includes meta characters of shell such as:
37
+
38
+ ```
39
+ * ? {} [] <> () ~ & | \ $ ; ' ` " \n
40
+ ```
41
+
42
+ otherwise, the command is not executed via shell.
43
+
44
+ ```ruby
45
+ result = Frontkick.exec("echo foo") # no shell
46
+ result = Frontkick.exec("echo *") # with shell
47
+ ```
48
+
49
+ The process tree for the latter (with shell) will be like:
27
50
 
28
- ### Escape Command
51
+ ```
52
+ ruby
53
+ └─ sh -c
54
+   └── echo *
55
+ ```
56
+
57
+ **Array argument**
29
58
 
30
- result = Frontkick.exec(["echo", "*"]) #=> echo the asterisk character
59
+ When the first argument is an Array, The command is not executed via a shell.
60
+ Note that shell wildcards are not available with this way.
61
+
62
+ ```ruby
63
+ result = Frontkick.exec(["echo", "*"]) #=> echo the asterisk character
64
+ ```
65
+
66
+ The process tree will be like:
67
+
68
+ ```
69
+ ruby
70
+ └─ echo
71
+ ```
31
72
 
32
73
  ### Dry Run Option
33
74
 
34
- result = Frontkick.exec(["echo", "*"], :dry_run => true)
35
- puts result.stdout #=> echo \*
75
+ ```ruby
76
+ result = Frontkick.exec(["echo", "*"], :dry_run => true)
77
+ puts result.stdout #=> echo \*
78
+ ```
36
79
 
37
80
  ### Timeout Option
38
81
 
39
- Frontkick.exec("sleep 2 && ls /hoge", :timeout => 1) # raises Frontkick::Timeout
82
+ ```ruby
83
+ Frontkick.exec("sleep 2 && ls /hoge", :timeout => 1) # raises Frontkick::Timeout
84
+ ```
40
85
 
41
86
  not to kill timeouted process
42
87
 
43
- Frontkick.exec("sleep 2 && ls /hoge", :timeout => 1, :timeout_kill => false) # raises Frontkick::Timeout
88
+ ```ruby
89
+ Frontkick.exec("sleep 2 && ls /hoge", :timeout => 1, :timeout_kill => false) # raises Frontkick::Timeout
90
+ ```
44
91
 
45
92
  ### Exclusive Option
46
93
 
47
94
  Prohibit another process to run a command concurrently
48
95
 
49
- Frontkick.exec("sleep 2 && ls /hoge", :exclusive => "/tmp/frontkick.lock") # raises Fontkick::Locked if locked
96
+ ```ruby
97
+ Frontkick.exec("sleep 2 && ls /hoge", :exclusive => "/tmp/frontkick.lock") # raises Fontkick::Locked if locked
98
+ ```
50
99
 
51
100
  If you prefer to be blocked:
52
101
 
53
- Frontkick.exec("sleep 2 && ls /hoge", :exclusive => "/tmp/frontkick.lock", :exclusive_blocking => true)
102
+ ```ruby
103
+ Frontkick.exec("sleep 2 && ls /hoge", :exclusive => "/tmp/frontkick.lock", :exclusive_blocking => true)
104
+ ```
54
105
 
55
106
  ### Redirect Options (:out and :err)
56
107
 
57
- Frontkick.exec(["ls /something_not_found"], :out => 'stdout.txt', :err => 'stderr.txt')
108
+ ```ruby
109
+ Frontkick.exec(["ls /something_not_found"], :out => 'stdout.txt', :err => 'stderr.txt')
110
+ ```
58
111
 
59
112
  This redirects STDOUT and STDERR into files. In this case, result.stdout, and result.stderr are the given filename.
60
113
 
61
- out = File.open('stdout.txt', 'w').tap {|fp| fp.sync = true }
62
- err = File.open('stderr.txt', 'w').tap {|fp| fp.sync = true }
63
- Frontkick.exec(["ls /something_not_found"], :out => out, :err => err)
114
+ ```ruby
115
+ out = File.open('stdout.txt', 'w').tap {|fp| fp.sync = true }
116
+ err = File.open('stderr.txt', 'w').tap {|fp| fp.sync = true }
117
+ Frontkick.exec(["ls /something_not_found"], :out => out, :err => err)
118
+ ```
64
119
 
65
120
  You can also give IO objects. In this case, result.stdout, and result.stderr are the given IO objects.
66
121
 
@@ -70,8 +125,8 @@ Other options such as :chdir are treated as options of `Open3.#popen3`.
70
125
 
71
126
  ### Kill Child Process
72
127
 
73
- Sending a signal to a kicked child process is fine because a frontkick process can finish.
74
- But, sending a signal to a frontkick process is not fine because a child process would become an orphan process.
128
+ Although sending a signal to a kicked child process directly causes no problem (frontkick process can take care of it),
129
+ sending a signal to a frontkick process may cause a problem that a child process becomes an orphan process.
75
130
 
76
131
  To kill your frontkick process with its child process correctly, send a signal to their **process group** as
77
132
 
@@ -82,8 +82,8 @@ module Frontkick
82
82
  raise Frontkick::Timeout.new(pid, command, opts[:timeout_kill])
83
83
  ensure
84
84
  stdin.close if stdin and !stdin.closed?
85
- out.close if out and !out.closed?
86
- err.close if err and !err.closed?
85
+ stdout.close if stdout and !stdout.closed?
86
+ stderr.close if stderr and !stderr.closed?
87
87
  wait_thr.kill if wait_thr and !wait_thr.stop?
88
88
  lock_fd.flock(File::LOCK_UN) if lock_fd
89
89
  if opts[:out] and opts[:out].is_a?(String)
@@ -1,3 +1,3 @@
1
1
  module Frontkick
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frontkick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-18 00:00:00.000000000 Z
11
+ date: 2017-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake