Class: Swineherd::LocalFileSystem

Inherits:
Object
  • Object
show all
Includes:
BaseFileSystem
Defined in:
lib/swineherd/filesystem/localfilesystem.rb

Defined Under Namespace

Classes: LocalFile

Instance Method Summary collapse

Methods included from BaseFileSystem

#check_paths, #close

Constructor Details

#initialize(*args) ⇒ LocalFileSystem

Returns a new instance of LocalFileSystem.



8
9
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 8

def initialize *args
end

Instance Method Details

#cp(srcpath, dstpath) ⇒ Object



27
28
29
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 27

def cp srcpath, dstpath
  FileUtils.cp_r(srcpath,dstpath)
end

#entries(dirpath) ⇒ Object



47
48
49
50
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 47

def entries dirpath
  return unless (type(dirpath) == "directory")
  Dir.entries(dirpath)
end

#exists?(path) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 19

def exists? path
  File.exists?(path)
end

#mkpath(path) ⇒ Object



31
32
33
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 31

def mkpath path
  FileUtils.mkpath path
end

#mv(srcpath, dstpath) ⇒ Object



23
24
25
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 23

def mv srcpath, dstpath
  FileUtils.mv(srcpath,dstpath)
end

#open(path, mode = "r", &blk) ⇒ Object



11
12
13
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 11

def open path, mode="r", &blk
  return LocalFile.new path, mode, &blk
end

#rm(path) ⇒ Object



15
16
17
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 15

def rm path
  FileUtils.rm_r path
end

#type(path) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 35

def type path
  case
  when File.symlink?(path) then
    return "symlink"
  when File.directory?(path) then
    return "directory"
  when File.file?(path) then
      return "file"
  end
  "unknown"
end