Module: DTR::Agent::WorkingEnvExt

Defined in:
lib/dtr/agent/working_env_ext.rb

Instance Method Summary collapse

Instance Method Details

#base_dirObject



18
19
20
21
22
23
# File 'lib/dtr/agent/working_env_ext.rb', line 18

def base_dir
  return @base_dir if defined?(@base_dir)
  project_specific_len = 20
  project_name = self[:pwd].length > project_specific_len ? self[:pwd][-project_specific_len..-1] : self[:pwd]
  @base_dir = File.expand_path FileUtils.mkdir_p(File.join(escape_dir(self[:host]), escape_dir(project_name)))
end

#load_environment(&block) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/dtr/agent/working_env_ext.rb', line 25

def load_environment(&block)
  working_dir = FileUtils.mkdir_p(File.join(base_dir, escape_dir(ENV['DTR_RUNNER_NAME'])))
  Dir.chdir(working_dir) do
    DTR.info "Loading environment at #{Dir.pwd}"

    ENV['DTR_MASTER_ENV'] = dtr_master_env

    setup_environment

    append_libs_to_load_path
    require_files

    block.call
  end
end