Files

Class/Module Index [+]

Quicksearch

Construct::PathExtensions

Attributes

construct__chdir_default[RW]

Public Instance Methods

chdir(&block) click to toggle source

Note: Pathname implements chdir directly, but it is deprecated in favor of Dir.chdir

# File lib/construct/path_extensions.rb, line 43
def chdir(&block)
  Dir.chdir(self, &block)
end
destroy!() click to toggle source
# File lib/construct/path_extensions.rb, line 47
def destroy!
  rmtree
end
directory(path,chdir=construct__chdir_default) click to toggle source
# File lib/construct/path_extensions.rb, line 6
def directory(path,chdir=construct__chdir_default)
  subdir = (self + path)
  subdir.mkpath
  subdir.extend(PathExtensions)
  subdir.maybe_change_dir(chdir) do
    yield(subdir) if block_given?
  end
  subdir
end
file(filepath,contents=nil,&block) click to toggle source
# File lib/construct/path_extensions.rb, line 16
def file(filepath,contents=nil,&block)
  path = (self+filepath)
  path.dirname.mkpath
  File.open(path,'w') do |f|
    if(block)
      if(block.arity==1)
        block.call(f)
      else
        f << block.call
      end
    else
      f << contents
    end
  end
  path
end
maybe_change_dir(chdir, &block) click to toggle source
# File lib/construct/path_extensions.rb, line 33
def maybe_change_dir(chdir, &block)
  if(chdir)
    self.chdir(&block)
  else
    block.call
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.