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

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



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

.in_build_dir(path = '', &block) ⇒ Object



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

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

.in_download_dir(path = '', &block) ⇒ Object



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

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