Class: Ftpspec::Commands
- Inherits:
-
Object
- Object
- Ftpspec::Commands
- Defined in:
- lib/ftpspec/commands.rb
Class Method Summary collapse
- .check_directory(target) ⇒ Object
- .check_file(target) ⇒ Object
- .check_group(target, expected) ⇒ Object
- .check_mode(target, expected) ⇒ Object
- .check_owner(target, expected) ⇒ Object
Class Method Details
.check_directory(target) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ftpspec/commands.rb', line 50 def self.check_directory(target) ftp = Ftpspec.get_ftp ftp.chdir File.dirname(target) ftp.list.each do |file| part = file.split(" ") if part[8] != "." && part[8] != ".." then current_path = ftp.pwd filemode = part[0] if current_path == "/" then filename = "/" + part[8] else filename = current_path + "/" + part[8] end if filename == target then return filemode[0] == "d" end end end return false end |
.check_file(target) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ftpspec/commands.rb', line 27 def self.check_file(target) ftp = Ftpspec.get_ftp ftp.chdir File.dirname(target) ftp.list.each do |file| part = file.split(" ") if part[8] != "." && part[8] != ".." then current_path = ftp.pwd filemode = part[0] if current_path == "/" then filename = "/" + part[8] else filename = current_path + "/" + part[8] end if filename == target then return filemode[0] == "-" end end end return false end |
.check_group(target, expected) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/ftpspec/commands.rb', line 97 def self.check_group(target, expected) ftp = Ftpspec.get_ftp ftp.chdir File.dirname(target) ftp.list.each do |file| part = file.split(" ") if part[8] != "." && part[8] != ".." then current_path = ftp.pwd filemode = part[0] group = part[3] if current_path == "/" then filename = "/" + part[8] else filename = current_path + "/" + part[8] end if filename == target then return group == expected end end end return false end |
.check_mode(target, expected) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ftpspec/commands.rb', line 4 def self.check_mode(target, expected) ftp = Ftpspec.get_ftp ftp.chdir File.dirname(target) ftp.list.each do |file| part = file.split(" ") if part[8] != "." && part[8] != ".." then current_path = ftp.pwd filemode = part[0] if current_path == "/" then filename = "/" + part[8] else filename = current_path + "/" + part[8] end if filename == target then return Ftpspec::Utils.convert_to_octal(filemode) == expected end end end return false end |
.check_owner(target, expected) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/ftpspec/commands.rb', line 73 def self.check_owner(target, expected) ftp = Ftpspec.get_ftp ftp.chdir File.dirname(target) ftp.list.each do |file| part = file.split(" ") if part[8] != "." && part[8] != ".." then current_path = ftp.pwd filemode = part[0] owner = part[2] if current_path == "/" then filename = "/" + part[8] else filename = current_path + "/" + part[8] end if filename == target then return owner == expected end end end return false end |