lib/buildmaster/cotta/cotta.rb in BuildMaster-0.9.1 vs lib/buildmaster/cotta/cotta.rb in BuildMaster-1.0.6

- old
+ new

@@ -2,27 +2,64 @@ require 'physical_system' require 'cotta_dir' require 'cotta_file' require 'pathname' +require 'cotta_pathname' +require 'command_interface' module BuildMaster class Cotta + attr_accessor :command_interface + def initialize(system=PhysicalSystem.new) @system = system + @command_interface = CommandInterface.new end - def shell(command_line) - puts "$> #{command_line}" - @system.shell(command_line) + def shell(command_line, &block) + @system.shell(command_line, &block) end + def command_interface=(value) + if (value) + @command_interface = value + else + @command_interface = CommandInterface.new + end + end + def dir(path) + return nil unless path return CottaDir.new(@system, Pathname.new(path)) end + def Cotta::dir(path) + return nil unless path + return Cotta.new.dir(File.expand_path(path)) + end + def file(path) + return nil unless path return CottaFile.new(@system, Pathname.new(path)) + end + + def Cotta::file(path) + return nil unless path + return Cotta.new.file(File.expand_path(path)) + end + + def Cotta::parent_of(path) + return Cotta.file(path).parent + end + + def entry(path) + entry = file(path) + unless (entry.exists?) + entry = dir(path) + raise "#{path} exists as niether file nor directory" unless entry.exists? + end + return entry end def environment!(variable) @system.environment!(variable) end \ No newline at end of file