Sha256: 797764d46f65cc5ee8fd2e4d410cb7f24702b1c1a2b6367a3bcb3f97080508df
Contents?: true
Size: 754 Bytes
Versions: 21
Compression:
Stored size: 754 Bytes
Contents
require 'fileutils' # # Keep track of dependent VMs. # # Poor man's race condition defense - touch and rm files in a directory and count them. # module Landrush class DependentVMs extend Enumerable def self.each(&block) (dir.directory? ? dir.children : []).each(&block) end def self.add(hostname) FileUtils.touch(file_for(hostname)) end def self.remove(hostname) file_for(hostname).tap { |f| f.delete if f.exist? } end def self.list self.map { |path| path.basename.to_s } end def self.clear! dir.rmtree end def self.file_for(hostname) dir.join(hostname) end def self.dir Landrush.working_dir.join('dependent_vms').tap(&:mkpath) end end end
Version data entries
21 entries across 21 versions & 1 rubygems