Sha256: bef07836d4d643bfd822ec9e25bda18bf59457a88dde1fd3b4c7c61acc3a4861
Contents?: true
Size: 1.46 KB
Versions: 25
Compression:
Stored size: 1.46 KB
Contents
module FakeFS # Fake Dir class class FakeDir attr_accessor :name, :parent, :mode, :uid, :gid, :mtime, :atime attr_reader :ctime, :content def initialize(name = nil, parent = nil) @name = name @parent = parent @ctime = Time.now @mtime = @ctime @atime = @ctime @mode = 0100000 + (0777 - File.umask) @uid = Process.uid @gid = Process.gid @content = '' @entries = {} end def entry self end def inspect "(FakeDir name:#{name.inspect} " \ "parent:#{parent.to_s.inspect} size:#{@entries.size})" end def clone(parent = nil) clone = Marshal.load(Marshal.dump(self)) clone.entries.each do |value| value.parent = clone end clone.parent = parent if parent clone end def to_s if parent && parent.to_s != '.' File.join(parent.to_s, name) elsif parent && parent.to_s == '.' "#{File::PATH_SEPARATOR}#{name}" else name end end def empty? @entries.empty? end def entries @entries.values end def matches(pattern) @entries.reject { |k, _v| pattern !~ k }.values end def [](name) @entries[name] end def []=(name, value) @entries[name] = value end def delete(node = self) if node == self parent.delete(self) else @entries.delete(node.name) end end end end
Version data entries
25 entries across 25 versions & 1 rubygems
Version | Path |
---|---|
fakefs-0.6.5 | lib/fakefs/fake/dir.rb |
fakefs-0.6.4 | lib/fakefs/fake/dir.rb |
fakefs-0.6.3 | lib/fakefs/fake/dir.rb |
fakefs-0.6.1 | lib/fakefs/fake/dir.rb |
fakefs-0.6.0 | lib/fakefs/fake/dir.rb |