Class: Pwrake::SharedDirectory
- Inherits:
-
Object
- Object
- Pwrake::SharedDirectory
- Defined in:
- lib/pwrake/worker/shared_directory.rb
Direct Known Subclasses
Constant Summary collapse
- @@prefix =
nil
- @@work_dir =
nil
- @@log_dir =
nil
Class Method Summary collapse
Instance Method Summary collapse
- #cd(d = '') ⇒ Object
- #check_mountpoint ⇒ Object
- #close ⇒ Object
- #close_messages ⇒ Object
- #current ⇒ Object
- #home_path ⇒ Object
-
#initialize ⇒ SharedDirectory
constructor
instance methods.
- #log_path ⇒ Object
- #open ⇒ Object
- #open_messages ⇒ Object
- #work_dir ⇒ Object
- #work_path ⇒ Object
Constructor Details
#initialize ⇒ SharedDirectory
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_mountpoint ⇒ Object
73 74 |
# File 'lib/pwrake/worker/shared_directory.rb', line 73 def check_mountpoint end |
#close ⇒ Object
35 36 |
# File 'lib/pwrake/worker/shared_directory.rb', line 35 def close end |
#close_messages ⇒ Object
38 39 40 |
# File 'lib/pwrake/worker/shared_directory.rb', line 38 def ["leave workdir: #{work_path}"] end |
#current ⇒ Object
57 58 59 |
# File 'lib/pwrake/worker/shared_directory.rb', line 57 def current @current_path.to_s end |
#home_path ⇒ Object
23 24 25 |
# File 'lib/pwrake/worker/shared_directory.rb', line 23 def home_path Pathname.new(ENV['HOME']) end |
#log_path ⇒ Object
69 70 71 |
# File 'lib/pwrake/worker/shared_directory.rb', line 69 def log_path work_path + @@log_dir end |
#open ⇒ Object
27 28 29 |
# File 'lib/pwrake/worker/shared_directory.rb', line 27 def open @current_path = work_path end |
#open_messages ⇒ Object
31 32 33 |
# File 'lib/pwrake/worker/shared_directory.rb', line 31 def ["enter workdir: #{work_path}"] end |
#work_dir ⇒ Object
65 66 67 |
# File 'lib/pwrake/worker/shared_directory.rb', line 65 def work_dir work_path.to_s end |
#work_path ⇒ Object
61 62 63 |
# File 'lib/pwrake/worker/shared_directory.rb', line 61 def work_path home_path + @@work_dir end |