Sha256: de63c3b91b864df465c2549562fdc6257cfe15a892d1f17dc6ec1653f91a9253
Contents?: true
Size: 747 Bytes
Versions: 12
Compression:
Stored size: 747 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 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 Server.working_dir.join('dependent_vms').tap(&:mkpath) end end end
Version data entries
12 entries across 12 versions & 1 rubygems