Class: Dir

Inherits:
Object
  • Object
show all
Defined in:
lib/xccache/core/system.rb

Class Method Summary collapse

Class Method Details

.create_tmpdirObject



25
26
27
28
29
30
# File 'lib/xccache/core/system.rb', line 25

def self.create_tmpdir
  dir = Pathname(Dir.mktmpdir("xccache"))
  res = block_given? ? (yield dir) : dir
  dir.rmtree if block_given?
  res
end

.git?(dir) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/xccache/core/system.rb', line 32

def self.git?(dir)
  XCCache::Sh.capture_output("git -C #{dir} rev-parse --git-dir") == ".git"
end

.prepare(dir, clean: false, expand: false) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/xccache/core/system.rb', line 17

def self.prepare(dir, clean: false, expand: false)
  dir = Pathname(dir)
  dir = dir.expand_path if expand
  dir.rmtree if clean && dir.exist?
  dir.mkpath
  dir
end