Module: ConfCtl::GCRoot

Extended by:
Utils::File
Defined in:
lib/confctl/gcroot.rb

Class Method Summary collapse

Methods included from Utils::File

replace_symlink, unlink_if_exists

Class Method Details

.add(name, path) ⇒ Object



21
22
23
24
# File 'lib/confctl/gcroot.rb', line 21

def self.add(name, path)
  FileUtils.mkdir_p(dir)
  File.symlink(path, File.join(dir, name))
end

.dirObject



9
10
11
12
13
14
15
# File 'lib/confctl/gcroot.rb', line 9

def self.dir
  File.join(
    '/nix/var/nix/gcroots/per-user',
    Etc.getlogin,
    "confctl-#{ConfDir.short_hash}"
  )
end

.exist?(name) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/confctl/gcroot.rb', line 17

def self.exist?(name)
  File.symlink?(File.join(dir, name))
end

.remove(name) ⇒ Object



26
27
28
# File 'lib/confctl/gcroot.rb', line 26

def self.remove(name)
  unlink_if_exists(File.join(dir, name))
end