Module: DamageControl::Directories

Includes:
FileUtils
Defined in:
lib/damagecontrol/directories.rb

Overview

This class knows about locations of various files and directories.

TODO: Add templates, logs(global)

Class Method Summary collapse

Class Method Details

.basedirObject



114
115
116
117
118
119
120
121
122
# File 'lib/damagecontrol/directories.rb', line 114

def basedir
  if(ENV['DAMAGECONTROL_HOME'])
    ENV['DAMAGECONTROL_HOME']
  elsif(WINDOWS)
    RSCM::PathConverter.nativepath_to_filepath("#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}/.damagecontrol").gsub(/\\/, "/")
  else
    "#{ENV['HOME']}/.damagecontrol"
  end
end

.build_command_file(project_name, changeset_identifier, time) ⇒ Object

File containing the build command for a build created at time time



84
85
86
# File 'lib/damagecontrol/directories.rb', line 84

def build_command_file(project_name, changeset_identifier, time)
  "#{build_dir(project_name, changeset_identifier, time)}/command"
end

.build_dir(project_name, changeset_identifier, time) ⇒ Object

Dir for a build created at time time



54
55
56
# File 'lib/damagecontrol/directories.rb', line 54

def build_dir(project_name, changeset_identifier, time)
  "#{builds_dir(project_name, changeset_identifier)}/#{time.to_s}"
end

.build_dirs(project_name, changeset_identifier) ⇒ Object



48
49
50
# File 'lib/damagecontrol/directories.rb', line 48

def build_dirs(project_name, changeset_identifier)
  Dir["#{builds_dir(project_name, changeset_identifier)}/*"]
end

.build_exit_code_file(project_name, changeset_identifier, time) ⇒ Object

File where the exit code for the build command execution is stored



72
73
74
# File 'lib/damagecontrol/directories.rb', line 72

def build_exit_code_file(project_name, changeset_identifier, time)
  "#{build_dir(project_name, changeset_identifier, time)}/exit_code"
end

.build_pid_file(project_name, changeset_identifier, time) ⇒ Object

File where the pid for the build command execution is stored



78
79
80
# File 'lib/damagecontrol/directories.rb', line 78

def build_pid_file(project_name, changeset_identifier, time)
  "#{build_dir(project_name, changeset_identifier, time)}/pid"
end

.builds_dir(project_name, changeset_identifier) ⇒ Object



43
44
45
# File 'lib/damagecontrol/directories.rb', line 43

def builds_dir(project_name, changeset_identifier)
  "#{changeset_dir(project_name, changeset_identifier)}/builds"
end

.changeset_dir(project_name, changeset_identifier) ⇒ Object



38
39
40
# File 'lib/damagecontrol/directories.rb', line 38

def changeset_dir(project_name, changeset_identifier)
  "#{changesets_dir(project_name)}/#{changeset_identifier.to_s}"
end

.changesets_dir(project_name) ⇒ Object



89
90
91
# File 'lib/damagecontrol/directories.rb', line 89

def changesets_dir(project_name)
  "#{project_dir(project_name)}/changesets"
end

.changesets_rss_file(project_name) ⇒ Object



94
95
96
# File 'lib/damagecontrol/directories.rb', line 94

def changesets_rss_file(project_name)
  "#{changesets_dir(project_name)}/changesets.xml"
end

.checkout_dir(project_name) ⇒ Object



26
27
28
# File 'lib/damagecontrol/directories.rb', line 26

def checkout_dir(project_name)
  "#{project_dir(project_name)}/checkout"
end

.checkout_list_file(project_name) ⇒ Object

File containing list of files currently being checked out.



33
34
35
# File 'lib/damagecontrol/directories.rb', line 33

def checkout_list_file(project_name)
  "#{project_dir(project_name)}/checkout_list.txt"
end

.diff_file(project_name, changeset, change) ⇒ Object



99
100
101
# File 'lib/damagecontrol/directories.rb', line 99

def diff_file(project_name, changeset, change)
  "#{changesets_dir(project_name)}/#{changeset.identifier.to_s}/diffs/#{change.path}.diff"
end

.project_config_file(project_name) ⇒ Object



109
110
111
# File 'lib/damagecontrol/directories.rb', line 109

def project_config_file(project_name)
  "#{project_dir(project_name)}/project.yaml"
end

.project_dir(project_name) ⇒ Object



21
22
23
# File 'lib/damagecontrol/directories.rb', line 21

def project_dir(project_name)
  "#{basedir}/projects/#{project_name}"
end

.project_namesObject



13
14
15
16
17
18
# File 'lib/damagecontrol/directories.rb', line 13

def project_names
  result = Dir["#{basedir}/projects/*/project.yaml"].collect do |f| 
    File.basename(File.dirname(f))
  end
  result.sort
end

.stderr(project_name, changeset_identifier, time) ⇒ Object

File where stderr for the build command is written



66
67
68
# File 'lib/damagecontrol/directories.rb', line 66

def stderr(project_name, changeset_identifier, time)
  "#{build_dir(project_name, changeset_identifier, time)}/stderr.log"
end

.stdout(project_name, changeset_identifier, time) ⇒ Object

File where stdout for the build command is written



60
61
62
# File 'lib/damagecontrol/directories.rb', line 60

def stdout(project_name, changeset_identifier, time)
  "#{build_dir(project_name, changeset_identifier, time)}/stdout.log"
end

.trigger_checkout_dir(project_name) ⇒ Object



104
105
106
# File 'lib/damagecontrol/directories.rb', line 104

def trigger_checkout_dir(project_name)
  "#{project_dir(project_name)}/trigger_checkout"
end