lib/rubu.rb in rubu-0.0.3 vs lib/rubu.rb in rubu-0.0.4
- old
+ new
@@ -1,10 +1,9 @@
require 'open3'
require 'yaml'
require 'digest/md5'
-
module Rubu
# Persistent state of Rubu.
#
# State maintains YAML based state file (if in use). The file
@@ -57,10 +56,11 @@
# Move is the action in Step.
class Move
@@host = []
+ @@show_shell_warning = true
# Status after execution.
attr_reader :status
# Storage for error message.
@@ -105,16 +105,25 @@
def error( msg )
@errmsg = msg
STDERR.puts "Rubu Error: #{@errmsg}"
end
+ # Report warning.
+ def warn( msg )
+ STDERR.puts "Rubu Warning: #{msg}"
+ end
+
# Display command output.
def display( msg )
@output = msg
STDOUT.puts @output
end
+ def set_show_shell_warning( value = true )
+ @@show_shell_warning = value
+ end
+
end
# Shell based command.
class ShellCommand < Move
@@ -132,10 +141,13 @@
if Order[ :verbose ]
STDOUT.puts @cmd
end
if status.exitstatus == 0
+ if @@show_shell_warning && not( stderr.empty? )
+ warn( stderr )
+ end
@status = :success
else
@status = :error
error( stderr )
end
@@ -523,9 +535,14 @@
# Setup variables for Step. Should be defined again in derived
# classes.
def setup
+ end
+
+
+ # Default to no action. Typically this method is redefined.
+ def step
end
# Run Step and capture status.
def run