Sha256: b1d1842d0a492c9a68dfda7adc40f4af464ca94f6cf771b63f7a25da3c3eb311
Contents?: true
Size: 717 Bytes
Versions: 2
Compression:
Stored size: 717 Bytes
Contents
module Ramdo class DiskInstance NAME_PATTERN = /^ramdo_disk_([a-z0-9]+)$/ def self.list disks = [] Dir.glob('/tmp/*').each do |dir| if (dir.split(File::SEPARATOR).last =~ NAME_PATTERN) && File.writable?(dir) disks << self.new(dir) end end disks end def self.create path = File.join('/tmp', self.generate_name) Dir.mkdir(path) self.new(path) end def self.generate_name "ramdo_disk_#{SecureRandom.hex(4)}" end attr_accessor :path def initialize(path) @path = path end def destroy! return false unless Dir.exist? @path FileUtils.rm_r @path, :force => true end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ramdo-0.3.2 | lib/ramdo/disk_instance.rb |
ramdo-0.3.1 | lib/ramdo/disk_instance.rb |