Class: Pwrake::SharedDirectory

Inherits:
Object
  • Object
show all
Defined in:
lib/pwrake/worker/shared_directory.rb

Direct Known Subclasses

GfarmDirectory

Constant Summary collapse

@@prefix =
nil
@@work_dir =
nil
@@log_dir =
nil

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSharedDirectory

instance methods



19
20
21
# File 'lib/pwrake/worker/shared_directory.rb', line 19

def initialize
  @log = LogExecutor.instance
end

Class Method Details

.init(opts) ⇒ Object



11
12
13
14
15
# File 'lib/pwrake/worker/shared_directory.rb', line 11

def self.init(opts)
  @@prefix   = opts[:base_dir]
  @@work_dir = opts[:work_dir]
  @@log_dir  = opts[:log_dir]
end

Instance Method Details

#cd(d = '') ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/pwrake/worker/shared_directory.rb', line 42

def cd(d='')
  if d==''
    @current_path = home_path
  else
    pn = Pathname(d.sub(/^\$HOME\b/,ENV['HOME']))
    if pn.relative?
      pn = @current_path + pn
    end
    if !Dir.exist?(pn)
      raise "Cannot chdir to #{pn}"
    end
    @current_path = pn.realpath
  end
end

#check_mountpointObject



73
74
# File 'lib/pwrake/worker/shared_directory.rb', line 73

def check_mountpoint
end

#closeObject



35
36
# File 'lib/pwrake/worker/shared_directory.rb', line 35

def close
end

#close_messagesObject



38
39
40
# File 'lib/pwrake/worker/shared_directory.rb', line 38

def close_messages
  ["leave workdir: #{work_path}"]
end

#currentObject



57
58
59
# File 'lib/pwrake/worker/shared_directory.rb', line 57

def current
  @current_path.to_s
end

#home_pathObject



23
24
25
# File 'lib/pwrake/worker/shared_directory.rb', line 23

def home_path
  Pathname.new(ENV['HOME'])
end

#log_pathObject



69
70
71
# File 'lib/pwrake/worker/shared_directory.rb', line 69

def log_path
  work_path + @@log_dir
end

#openObject



27
28
29
# File 'lib/pwrake/worker/shared_directory.rb', line 27

def open
  @current_path = work_path
end

#open_messagesObject



31
32
33
# File 'lib/pwrake/worker/shared_directory.rb', line 31

def open_messages
  ["enter workdir: #{work_path}"]
end

#work_dirObject



65
66
67
# File 'lib/pwrake/worker/shared_directory.rb', line 65

def work_dir
  work_path.to_s
end

#work_pathObject



61
62
63
# File 'lib/pwrake/worker/shared_directory.rb', line 61

def work_path
  home_path + @@work_dir
end