Module: Babushka::PathHelpers

Included in:
Dep, DepDefiner, DepDefiner, Resource, Resource, RunHelpers, Source, Source, Task
Defined in:
lib/babushka/helpers/path_helpers.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) cd(dir, opts = {}, &block)



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/babushka/helpers/path_helpers.rb', line 3

def cd dir, opts = {}, &block
  if dir.nil?
    yield Dir.pwd.p
  else
    path = dir.p
    shell("mkdir -p '#{path}'", :sudo => opts[:sudo]) if opts[:create] unless path.exists?
    if Dir.pwd == path
      yield path
    else
      Dir.chdir path do
        debug "in dir #{dir} (#{path})" do
          yield path
        end
      end
    end
  end
end

- (Object) in_build_dir(path = '', &block)



26
27
28
# File 'lib/babushka/helpers/path_helpers.rb', line 26

def in_build_dir path = '', &block
  cd Babushka::BuildPrefix / path, :create => true, &block
end

- (Object) in_dir(dir, opts = {}, &block)



21
22
23
24
# File 'lib/babushka/helpers/path_helpers.rb', line 21

def in_dir dir, opts = {}, &block
  log_error "#{caller.first}: #in_dir has been renamed to #cd." # deprecated
  cd dir, opts, &block
end

- (Object) in_download_dir(path = '', &block)



30
31
32
# File 'lib/babushka/helpers/path_helpers.rb', line 30

def in_download_dir path = '', &block
  cd Babushka::DownloadPrefix / path, :create => true, &block
end