execute 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cmd.rb +7 -8
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84f0a6fd837ea755821d7fcc1996514836aa634a
4
- data.tar.gz: 602134c00f98ba12e785d36f4eb9e8c078ec708c
3
+ metadata.gz: 136de8d8682549cc6430b228c3fe34e3bd646b33
4
+ data.tar.gz: 17ddeb504dc69715e9b9c7421f04175b41d692fe
5
5
  SHA512:
6
- metadata.gz: 97a73d99ffa910a6aa647f437db2f017854a4172a2ab6c1aca7ddb43d839da23fe0d11e82f8d96032cb2b53e9a200d8ad412430536ec62829afdb8642cd705be
7
- data.tar.gz: 90a3f8ac78dcaebe49238234a9e3a51a67663d0ea32c29a657aa87ead4b6d9b95a9f3f3179c6f85a09bb78312eb3345b7f02d4cd0f2ef075cb8d8ec769738135
6
+ metadata.gz: ed7933e383171891718afadc1714df073eced3a477cd1fb72ca091fe2fd1b46568399468e01bba032a5e34e06fe33cc35d6aa006336edf5848cd67922fb7bb50
7
+ data.tar.gz: afafb75f9ce9204fc9740fe2ef83c2bfc6b82c1c5c9eec441418eee3ceb60184248551f77211580de75f168cfa983b88fc28dc77049d419d2374ee8cb733b8cd
data/lib/cmd.rb CHANGED
@@ -4,12 +4,8 @@ require_relative 'IOAdapter.rb'
4
4
 
5
5
  class CMD < Hash
6
6
  private
7
- @@default_options = nil
7
+ @@default_options = { echo_command: true, echo_output: true, ignore_exit_code: false, debug: false }
8
8
 
9
- def initialize_defaults
10
- @@default_options = { echo_command: true, echo_output: true, ignore_exit_code: false, debug: false }
11
- end
12
-
13
9
  public
14
10
  def initialize(cmd, options=nil)
15
11
  initialize_defaults if(@@default_options.nil?)
@@ -23,12 +19,11 @@ class CMD < Hash
23
19
 
24
20
  public
25
21
  def self.default_options(hash)
26
- initialize_defaults
27
22
  hash.each { |key, value| @@default_options[key] = value}
28
23
  end
29
24
 
30
25
  def execute
31
- #begin
26
+ begin
32
27
  puts self[:command] if(self[:echo_command])
33
28
 
34
29
  output = {output: [], error: [] }
@@ -46,7 +41,11 @@ class CMD < Hash
46
41
  self[:error] = output[:error].join
47
42
  self[:exit_code] = wait_thr.value.to_i
48
43
  end
49
-
44
+ rescue Excpetion => e
45
+ self[:error] = "#{self[:error]}\nException: #{e.to_s}"
46
+ self[:exit_code]=1 unless(self[:exit_code].nil? || (self[:exit_code] == 0))
47
+ end
48
+
50
49
  if(self[:debug])
51
50
  puts "command: #{self[:command]}" if(self[:quiet])
52
51
  puts "output: #{self[:output]}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: execute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Marshall