class Object
Constants
- FlavorArgumentMsg
- HELP
- INSPECT
- VALIDATE
Public Instance Methods
determine_os()
click to toggle source
# File lib/lace/utils.rb, line 91 def determine_os case RUBY_PLATFORM when /darwin/ then :mac when /linux/ then :linux else raise InvalidOSError end end
odie(error)
click to toggle source
# File lib/lace/utils.rb, line 86 def odie error onoe error exit 1 end
ofail(error)
click to toggle source
# File lib/lace/utils.rb, line 81 def ofail error onoe error Lace.failed = true end
oh1(title)
click to toggle source
# File lib/lace/utils.rb, line 66 def oh1 title title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose? puts "#{Tty.green}==>#{Tty.white} #{title}#{Tty.reset}" end
ohai(title, *sput)
click to toggle source
# File lib/lace/utils.rb, line 60 def ohai title, *sput title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose? puts "#{Tty.blue}==>#{Tty.white} #{title}#{Tty.reset}" puts sput unless sput.empty? end
onoe(error)
click to toggle source
# File lib/lace/utils.rb, line 75 def onoe error lines = error.to_s.split("\n") STDERR.puts "#{Tty.red}Error#{Tty.reset}: #{lines.shift}" STDERR.puts lines unless lines.empty? end
opoo(warning)
click to toggle source
# File lib/lace/utils.rb, line 71 def opoo warning STDERR.puts "#{Tty.red}Warning#{Tty.reset}: #{warning}" end
quiet_system(cmd, *args)
click to toggle source
prints no output
# File lib/lace/utils.rb, line 122 def quiet_system cmd, *args Lace.system(cmd, *args) do # Redirect output streams to `/dev/null` instead of closing as some programs # will fail to execute if they can't write to an open stream. $stdout.reopen('/dev/null') $stderr.reopen('/dev/null') end end
safe_system(cmd, *args)
click to toggle source
Kernel.system but with exceptions
# File lib/lace/utils.rb, line 114 def safe_system cmd, *args unless Lace.system cmd, *args args = args.map{ |arg| arg.to_s.gsub " ", "\\ " } * " " raise ErrorDuringExecution, "Failure while executing: #{cmd} #{args}" end end