- #
- C
- D
- E
- F
- G
- M
- N
- O
- P
- R
- S
- T
- Enumerable START:includes
Source: show
# File lib/fakefs/dir.rb, line 55 def self.[](pattern) glob(pattern) end
Source: show
# File lib/fakefs/dir.rb, line 59 def self.chdir(dir, &blk) FileSystem.chdir(dir, &blk) end
Source: show
# File lib/fakefs/dir.rb, line 63 def self.chroot(string) # Not implemented yet end
Source: show
# File lib/fakefs/dir.rb, line 67 def self.delete(string) raise SystemCallError, "No such file or directory - #{string}" unless FileSystem.find(string).values.empty? FileSystem.delete(string) end
Source: show
# File lib/fakefs/dir.rb, line 72 def self.entries(dirname) raise SystemCallError, dirname unless FileSystem.find(dirname) Dir.new(dirname).map { |file| File.basename(file) } end
Source: show
# File lib/fakefs/dir.rb, line 77 def self.foreach(dirname, &block) Dir.open(dirname) { |file| yield file } end
Source: show
# File lib/fakefs/dir.rb, line 81 def self.glob(pattern) [FileSystem.find(pattern) || []].flatten.map{|e| e.to_s}.sort end
Source: show
# File lib/fakefs/dir.rb, line 85 def self.mkdir(string, integer = 0) parent = string.split('/') parent.pop raise Errno::ENOENT, "No such file or directory - #{string}" unless parent.join == "" || FileSystem.find(parent.join('/')) raise Errno::EEXIST, "File exists - #{string}" if File.exists?(string) FileUtils.mkdir_p(string) end
Source: show
# File lib/fakefs/dir.rb, line 5 def initialize(string) raise Errno::ENOENT, string unless FileSystem.find(string) @path = string @open = true @pointer = 0 @contents = [ '.', '..', ] + FileSystem.find(@path).values end
Source: show
# File lib/fakefs/dir.rb, line 93 def self.open(string, &block) if block_given? Dir.new(string).each { |file| yield(file) } else Dir.new(string) end end
Source: show
# File lib/fakefs/dir.rb, line 105 def self.pwd FileSystem.current_dir.to_s end
Source: show
# File lib/fakefs/dir.rb, line 101 def self.tmpdir '/tmp' end
Source: show
# File lib/fakefs/dir.rb, line 13 def close @open = false @pointer = nil @contents = nil nil end
Source: show
# File lib/fakefs/dir.rb, line 20 def each(&block) while f = read yield f end end
Source: show
# File lib/fakefs/dir.rb, line 26 def path @path end
Source: show
# File lib/fakefs/dir.rb, line 30 def pos @pointer end
Source: show
# File lib/fakefs/dir.rb, line 34 def pos=(integer) @pointer = integer end
Source: show
# File lib/fakefs/dir.rb, line 38 def read raise IOError, "closed directory" if @pointer == nil n = @contents[@pointer] @pointer += 1 n.to_s.gsub(path + '/', '') if n end
Source: show
# File lib/fakefs/dir.rb, line 45 def rewind @pointer = 0 end
Source: show
# File lib/fakefs/dir.rb, line 49 def seek(integer) raise IOError, "closed directory" if @pointer == nil @pointer = integer @contents[integer] end