dropkick 0.1.1 → 0.1.2
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.
- data/lib/dropkick/command.rb +10 -13
- data/lib/dropkick/command_result.rb +18 -16
- metadata +7 -5
data/lib/dropkick/command.rb
CHANGED
@@ -1,26 +1,23 @@
|
|
1
1
|
require 'benchmark'
|
2
2
|
require 'open3'
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module Dropkick
|
4
|
+
class Command
|
5
|
+
def self.secure_exec(command, arguments = [])
|
6
|
+
stdout = nil
|
7
|
+
stderr = nil
|
8
|
+
exit_code = nil
|
8
9
|
|
9
|
-
|
10
|
+
command_array = arguments.unshift(command)
|
10
11
|
|
11
|
-
|
12
|
-
begin
|
12
|
+
duration = Benchmark.realtime do
|
13
13
|
Open3.popen3(*command_array) do |stdin, out, err, wait_thr|
|
14
14
|
stdout = out.read
|
15
15
|
stderr = err.read
|
16
16
|
exit_code = wait_thr.value.exitstatus
|
17
17
|
end
|
18
|
-
rescue Exception => error
|
19
|
-
stdout = '' if stdout.nil?
|
20
|
-
stderr = error.message
|
21
18
|
end
|
19
|
+
|
20
|
+
CommandResult.new(stdout, stderr, exit_code, duration)
|
22
21
|
end
|
23
|
-
|
24
|
-
CommandResult.new(stdout, stderr, exit_code, duration)
|
25
22
|
end
|
26
23
|
end
|
@@ -1,22 +1,24 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Dropkick
|
2
|
+
class CommandResult
|
3
|
+
attr_accessor :stdout, :stderr, :duration
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
def initialize(stdout, stderr, exit_code, duration)
|
6
|
+
@stdout = stdout
|
7
|
+
@stderr = stderr
|
8
|
+
@exit_code = exit_code
|
9
|
+
@duration = duration
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
def output
|
13
|
+
@stdout
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
def errors
|
17
|
+
@stderr
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
def successful?
|
21
|
+
@exit_code == 0
|
22
|
+
end
|
21
23
|
end
|
22
24
|
end
|
metadata
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dropkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
+
- Sleepy Giant Entertainment
|
8
9
|
- Jesse R. Adams
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
13
|
+
date: 2012-10-15 00:00:00.000000000 Z
|
13
14
|
dependencies: []
|
14
15
|
description: Friendly wrappers to Open3#popen3 aiming for secure command execution
|
15
|
-
email:
|
16
|
+
email: info@sleepgiant.com
|
16
17
|
executables: []
|
17
18
|
extensions: []
|
18
19
|
extra_rdoc_files: []
|
@@ -20,8 +21,9 @@ files:
|
|
20
21
|
- lib/dropkick/command.rb
|
21
22
|
- lib/dropkick/command_result.rb
|
22
23
|
- lib/dropkick.rb
|
23
|
-
homepage: https://github.com/
|
24
|
-
licenses:
|
24
|
+
homepage: https://github.com/sge/dropkick
|
25
|
+
licenses:
|
26
|
+
- MIT
|
25
27
|
post_install_message:
|
26
28
|
rdoc_options: []
|
27
29
|
require_paths:
|