dropkick 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,26 +1,23 @@
1
1
  require 'benchmark'
2
2
  require 'open3'
3
- class Command
4
- def self.secure_exec(command, arguments = [])
5
- stdout = nil
6
- stderr = nil
7
- exit_code = 100
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
- command_array = arguments.unshift(command)
10
+ command_array = arguments.unshift(command)
10
11
 
11
- duration = Benchmark.realtime do
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
- class CommandResult
2
- attr_accessor :stdout, :stderr, :duration
1
+ module Dropkick
2
+ class CommandResult
3
+ attr_accessor :stdout, :stderr, :duration
3
4
 
4
- def initialize(stdout, stderr, exit_code, duration)
5
- @stdout = stdout
6
- @stderr = stderr
7
- @exit_code = exit_code
8
- @duration = duration
9
- end
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
- def output
12
- @stdout
13
- end
12
+ def output
13
+ @stdout
14
+ end
14
15
 
15
- def errors
16
- @stderr
17
- end
16
+ def errors
17
+ @stderr
18
+ end
18
19
 
19
- def successful?
20
- @exit_code == 0
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.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-12 00:00:00.000000000 Z
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: jesse@techno-geek.sorg
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/jesseadams/dropkick
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: