Sha256: 68f55849c8a591543dfe54d9d1d4a9f3455c8eabaf02ba18b4bc4aaf6b641912

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

$:.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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
BuildMaster-0.9.0 lib/buildmaster/cotta/physical_system.rb