dev_commands 0.0.9 → 0.0.10

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: 2a3c5c4222c71872efd5586899d6d4bc9f9af7fc
4
- data.tar.gz: 607a0fbc97a69060f05b870355b8883327f462bb
3
+ metadata.gz: 2bf6bd51e45b9c16b1389e81393dc5f7f3418936
4
+ data.tar.gz: 6629c5669dc7c52461e6be0836e729249d16819a
5
5
  SHA512:
6
- metadata.gz: c2de23d325e865182eb160044a356117e48c2e14f75008cb4231e9446af87bb714094b250da283b39bb129d554725ce4c109ddc1a6385de58942b34b6a2c0f97
7
- data.tar.gz: cc178efe00534258ef9bc2dd4b955a6dba615a82100978d20dfc8707618ba98175ed8e2386c7b323a7356f5ca8fc45e1795beef29cdec403935a0a941f05b969
6
+ metadata.gz: 9b406adf163157db56d19b808beb3ca512f2aceea9c763e6ac4b4c2b2dea29b6071a0b5cd876de2a052145a979e940a5920d6bc04ed3de2253deb4b427a41e83
7
+ data.tar.gz: ffdb1c0862886ce90d86299cc793b9b189737836c34f9e40513a56a1342a48041ef5df6ac3e6f524207fa6e0ff5a2c8b6b4f80a6211d54ef40bbed8d7a1d2525
data/lib/array.rb CHANGED
@@ -3,6 +3,7 @@ class Array
3
3
  i=0
4
4
  while i < self.length
5
5
  self[i]=Command.new(self[i]) if(self[i].is_a?(String))
6
+ self[i]=Command.new(self[i]) if(self[i].is_a?(Hash) && !self[i].is_a?(Command))
6
7
  self[i].execute if(self[i].is_a?(Command))
7
8
  i=i+1
8
9
  end
data/lib/command.rb CHANGED
@@ -6,17 +6,19 @@ require_relative('./timer.rb')
6
6
  class Command < Hash
7
7
  def initialize command
8
8
 
9
+ self[:input] = ''
10
+ self[:timeout] = 0
11
+ self[:directory] = ''
12
+ self[:exit_code] = 0
13
+ self[:output] = ''
14
+ self[:error] = ''
15
+ self[:machine] = ''
16
+ self[:user] = ''
17
+ self[:start_time] = nil
18
+ self[:end_time] = nil
19
+
9
20
  if(command.kind_of?(String))
10
21
  self[:input] = command
11
- self[:timeout] = 0
12
- self[:directory] = ''
13
- self[:exit_code] = 0
14
- self[:output] = ''
15
- self[:error] = ''
16
- self[:machine] = ''
17
- self[:user] = ''
18
- self[:start_time] = nil
19
- self[:end_time] = nil
20
22
  end
21
23
 
22
24
  if(command.kind_of?(Hash))
@@ -53,7 +55,8 @@ class Command < Hash
53
55
  self[:end_time] = Time.now
54
56
  else
55
57
  begin
56
- self[:output],self[:error],self[:exit_code]= Open3.capture3(self[:input])
58
+ self[:output],self[:error],status= Open3.capture3(self[:input])
59
+ self[:exit_code]=status.to_i
57
60
  self[:elapsed] = timer.elapsed_str
58
61
  self[:end_time] = Time.now
59
62
  #self[:exit_code]=$?.to_i
@@ -66,6 +69,16 @@ class Command < Hash
66
69
  end
67
70
 
68
71
  Dir.chdir(pwd) if pwd != Dir.pwd
72
+
73
+ if(self[:exit_code] != 0)
74
+ puts ' '
75
+ puts "exit_code=#{self[:exit_code]}"
76
+ puts ' '
77
+ puts self[:output]
78
+ puts self[:error]
79
+ puts ' '
80
+ raise "#{self[:input]} failed" unless self.has_key?(:ignore_failure) && self[:ignore_failure]
81
+ end
69
82
  end
70
83
 
71
84
  def self.machine
data/spec/command_spec.rb CHANGED
@@ -94,4 +94,8 @@ describe Command do
94
94
  commands.execute
95
95
  File.open('commands.html','w'){|f|f.write(commands.to_html)}
96
96
  end
97
+
98
+ #it "should fail this test" do
99
+ # expect(false).to eq(true)
100
+ #end
97
101
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dev_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lou Parslow