class Object
Constants
- COMMON_CONFIG_FOLDERS
- Diff
- FlavorArgumentMsg
- HELP
- INSPECT
- VALIDATE
Public Instance Methods
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
Source
# File lib/lace/utils.rb, line 81 def ofail error onoe error Lace.failed = true end
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
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
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
Source
# File lib/lace/utils.rb, line 71 def opoo warning STDERR.puts "#{Tty.red}Warning#{Tty.reset}: #{warning}" end
Source
# 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
prints no output
Source
# 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
Kernel.system but with exceptions
Source
# File lib/lace/package/utils.rb, line 86 def traverse_directory(directory, package, &block) package_path = package.path whitelisted_folders = package.facts.globbed_folder + COMMON_CONFIG_FOLDERS Dir.foreach(directory) do |entry| next if ['.', '..'].include?(entry) entry_path = File.join(directory, entry) if File.symlink?(entry_path) && File.readlink(entry_path).include?(package_path) block.call(entry_path) elsif File.directory?(entry_path) && whitelisted_folders.any? { |f| entry_path.include?(f) } traverse_directory(entry_path, package, &block) end end end