Module: Babushka::PathHelpers

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

Class Method Summary (collapse)

Class Method Details

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



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

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

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



24
25
26
# File 'lib/babushka/helpers/path_helpers.rb', line 24

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

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



28
29
30
# File 'lib/babushka/helpers/path_helpers.rb', line 28

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