$:.unshift File.dirname(__FILE__) require 'file_not_found_error' require 'command_error' require 'fileutils' module BuildMaster class PhysicalSystem def initialize end def shell(command) raise CommandError.new, command, caller unless system(command) end def environment!(variable) value = ENV[variable] raise "#{variable} environment variable not found" unless value return value end def environment(variable, default) value = ENV[variable] value = default unless value return value end def dir_exists?(dir_path) return FileTest.directory?(dir_path) end def file_exists?(file_path) return FileTest.file?(file_path) end def list(dir_path) Dir.entries(dir_path).find_all {|item| item != '.' && item != '..'} end def mkdir(dir_path) Dir.mkdir(dir_path) end def io(file_path, argument) return File.open(file_path, argument) end def delete_file(file_path) return File.delete(file_path) end def delete_dir(dir_path) return Dir.delete(dir_path) end def copy(source, target) FileUtils.copy(source, target) end def move(source, target) FileUtils.move(source, target) end end end