lib/lxc.rb in lxc-0.0.2 vs lib/lxc.rb in lxc-0.0.3

- old
+ new

@@ -1,10 +1,10 @@ require 'ztk' require 'lxc/version' -# Main LXC (Linux Container) Class +# Top-Level LXC Class # # @author Zachary Patten <zachary@jovelabs.net> class LXC # Top-Level Error Class @@ -43,10 +43,15 @@ # RegEx pattern for extracting the LXC Version from the "lxc-version" command # output. REGEX_VERSION = /^lxc version:\s+([\w\W]+)$/ + # SED command for removing ANSI colors + # + # @see http://www.commandlinefu.com/commands/view/3584/remove-color-codes-special-characters-with-sed CommandLineFu - Remove Color Codes (Special Characters) with SED + SED_REMOVE_ANSI = %q(sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g") + def initialize @use_sudo = false @use_ssh = nil end @@ -120,12 +125,12 @@ # Linux container configuration check # # Runs the "lxc-checkconfig" command. # # @param [Array] args Additional command-line arguments. - # @return [Array<String>] Output text of the "lxc-ps" command. + # @return [Array<String>] Output text of the "lxc-checkconfig" command. def checkconfig(*args) - self.exec("checkconfig", *args).split("\n") + self.exec("checkconfig", *args, " | #{SED_REMOVE_ANSI}").split("\n") end # Linux container command execution wrapper # # Runs the supplied LXC command. The first element in the "args" splat is the