class Serverspec::Type::File
Attributes
content[RW]
Public Instance Methods
block_device?()
click to toggle source
# File lib/serverspec/type/file.rb, line 13 def block_device? @runner.check_file_is_block_device(@name) end
character_device?()
click to toggle source
# File lib/serverspec/type/file.rb, line 17 def character_device? @runner.check_file_is_character_device(@name) end
contain(pattern, from, to)
click to toggle source
# File lib/serverspec/type/file.rb, line 37 def contain(pattern, from, to) if pattern.is_a?(Array) @runner.check_file_contains_lines(@name, pattern, from, to) else if (from || to).nil? @runner.check_file_contains(@name, pattern) else @runner.check_file_contains_within(@name, pattern, from, to) end end end
directory?()
click to toggle source
# File lib/serverspec/type/file.rb, line 25 def directory? @runner.check_file_is_directory(@name) end
executable?(by_whom, by_user)
click to toggle source
# File lib/serverspec/type/file.rb, line 81 def executable?(by_whom, by_user) if by_user != nil @runner.check_file_is_accessible_by_user(@name, by_user, 'x') else @runner.check_file_is_executable(@name, by_whom) end end
exists?()
click to toggle source
# File lib/serverspec/type/file.rb, line 97 def exists? @runner.check_file_exists(@name) end
file?()
click to toggle source
# File lib/serverspec/type/file.rb, line 7 def file? cmd = Specinfra.command.get(:check_file_is_file, @name) @inspection = Specinfra.backend.build_command(cmd) @runner.check_file_is_file(@name) end
grouped_into?(group)
click to toggle source
# File lib/serverspec/type/file.rb, line 57 def grouped_into?(group) @runner.check_file_is_grouped(@name, group) end
immutable?()
click to toggle source
# File lib/serverspec/type/file.rb, line 93 def immutable? @runner.check_file_is_immutable(@name) end
linked_to?(target)
click to toggle source
# File lib/serverspec/type/file.rb, line 61 def linked_to?(target) @runner.check_file_is_linked_to(@name, target) end
md5sum()
click to toggle source
# File lib/serverspec/type/file.rb, line 101 def md5sum @runner.get_file_md5sum(@name).stdout.strip end
mode?(mode)
click to toggle source
# File lib/serverspec/type/file.rb, line 49 def mode?(mode) @runner.check_file_has_mode(@name, mode) end
mounted?(attr, only_with)
click to toggle source
# File lib/serverspec/type/file.rb, line 89 def mounted?(attr, only_with) @runner.check_file_is_mounted(@name, attr, only_with) end
mtime()
click to toggle source
# File lib/serverspec/type/file.rb, line 120 def mtime d = @runner.get_file_mtime(@name).stdout.strip DateTime.strptime(d, '%s').new_offset(DateTime.now.offset) end
owned_by?(owner)
click to toggle source
# File lib/serverspec/type/file.rb, line 53 def owned_by?(owner) @runner.check_file_is_owned_by(@name, owner) end
pipe?()
click to toggle source
# File lib/serverspec/type/file.rb, line 33 def pipe? @runner.check_file_is_pipe(@name) end
readable?(by_whom, by_user)
click to toggle source
# File lib/serverspec/type/file.rb, line 65 def readable?(by_whom, by_user) if by_user != nil @runner.check_file_is_accessible_by_user(@name, by_user, 'r') else @runner.check_file_is_readable(@name, by_whom) end end
selinux_label()
click to toggle source
# File lib/serverspec/type/file.rb, line 129 def selinux_label @runner.get_file_selinuxlabel(@name).stdout.strip end
sha256sum()
click to toggle source
# File lib/serverspec/type/file.rb, line 105 def sha256sum @runner.get_file_sha256sum(@name).stdout.strip end
size()
click to toggle source
# File lib/serverspec/type/file.rb, line 125 def size @runner.get_file_size(@name).stdout.strip.to_i end
socket?()
click to toggle source
# File lib/serverspec/type/file.rb, line 21 def socket? @runner.check_file_is_socket(@name) end
symlink?()
click to toggle source
# File lib/serverspec/type/file.rb, line 29 def symlink? @runner.check_file_is_symlink(@name) end
version?(version)
click to toggle source
# File lib/serverspec/type/file.rb, line 116 def version?(version) @runner.check_file_has_version(@name, version) end
writable?(by_whom, by_user)
click to toggle source
# File lib/serverspec/type/file.rb, line 73 def writable?(by_whom, by_user) if by_user != nil @runner.check_file_is_accessible_by_user(@name, by_user, 'w') else @runner.check_file_is_writable(@name, by_whom) end end