Class: Cotta::PhysicalSystem

Inherits:
Object
  • Object
show all
Defined in:
lib/cotta/impl/physical_system.rb

Instance Method Summary collapse

Constructor Details

#initializePhysicalSystem

Returns a new instance of PhysicalSystem.



3
4
# File 'lib/cotta/impl/physical_system.rb', line 3

def initialize
end

Instance Method Details

#==(other) ⇒ Object



85
86
87
# File 'lib/cotta/impl/physical_system.rb', line 85

def ==(other)
  other.class == PhysicalSystem
end

#chdir(target, &block) ⇒ Object



77
78
79
# File 'lib/cotta/impl/physical_system.rb', line 77

def chdir(target, &block)
  Dir.chdir(target, &block)
end

#copy_dir(source, target) ⇒ Object



69
70
71
# File 'lib/cotta/impl/physical_system.rb', line 69

def copy_dir(source, target)
  FileUtils.copy_entry(source, target)
end

#copy_file(source, target) ⇒ Object



61
62
63
# File 'lib/cotta/impl/physical_system.rb', line 61

def copy_file(source, target)
  FileUtils.copy(source, target)
end

#delete_dir(dir_path) ⇒ Object



57
58
59
# File 'lib/cotta/impl/physical_system.rb', line 57

def delete_dir(dir_path)
  return Dir.delete(dir_path)
end

#delete_file(file_path) ⇒ Object



53
54
55
# File 'lib/cotta/impl/physical_system.rb', line 53

def delete_file(file_path)
  return File.delete(file_path)
end

#dir_exists?(dir_path) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/cotta/impl/physical_system.rb', line 25

def dir_exists?(dir_path)
  return FileTest.directory?(dir_path)
end

#dir_stat(path) ⇒ Object



33
34
35
# File 'lib/cotta/impl/physical_system.rb', line 33

def dir_stat(path)
  File.stat(path)
end

#environment(variable, default) ⇒ Object



19
20
21
22
23
# File 'lib/cotta/impl/physical_system.rb', line 19

def environment(variable, default)
  value = ENV[variable]
  value = default unless value
  return value
end

#environment!(variable) ⇒ Object



13
14
15
16
17
# File 'lib/cotta/impl/physical_system.rb', line 13

def environment!(variable)
  value = ENV[variable]
  raise "#{variable} environment variable not found" unless value
  return value
end

#file_exists?(file_path) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/cotta/impl/physical_system.rb', line 29

def file_exists?(file_path)
  return FileTest.file?(file_path)
end

#file_stat(path) ⇒ Object



37
38
39
# File 'lib/cotta/impl/physical_system.rb', line 37

def file_stat(path)
  File.stat(path)
end

#io(file_path, argument) ⇒ Object



49
50
51
# File 'lib/cotta/impl/physical_system.rb', line 49

def io(file_path, argument)
  return File.open(file_path, argument)
end

#list(dir_path) ⇒ Object



41
42
43
# File 'lib/cotta/impl/physical_system.rb', line 41

def list(dir_path)
  Dir.entries(dir_path).find_all {|item| item != '.' && item != '..'}
end

#mkdir(dir_path) ⇒ Object



45
46
47
# File 'lib/cotta/impl/physical_system.rb', line 45

def mkdir(dir_path)
  Dir.mkdir(dir_path)
end

#move_dir(source, target) ⇒ Object



73
74
75
# File 'lib/cotta/impl/physical_system.rb', line 73

def move_dir(source, target)
  FileUtils.mv(source, target)
end

#move_file(source, target) ⇒ Object



65
66
67
# File 'lib/cotta/impl/physical_system.rb', line 65

def move_file(source, target)
  FileUtils.move(source, target)
end

#pwdObject



81
82
83
# File 'lib/cotta/impl/physical_system.rb', line 81

def pwd
  Dir.pwd
end

#shell(command, &block) ⇒ Object

Invoke the command passed in through the CommandRunner and pass in the closure.



8
9
10
11
# File 'lib/cotta/impl/physical_system.rb', line 8

def shell(command, &block)
  runner = CommandRunner.new(command)
  runner.execute(&block)
end