class Serverspec::Type::File

Attributes

content[RW]

Public Instance Methods

contain(pattern, from, to) click to toggle source
# File lib/serverspec/type/file.rb, line 19
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 15
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 63
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
file?() click to toggle source
# File lib/serverspec/type/file.rb, line 7
def file?
  @runner.check_file_is_file(@name)
end
grouped_into?(group) click to toggle source
# File lib/serverspec/type/file.rb, line 39
def grouped_into?(group)
  @runner.check_file_is_grouped(@name, group)
end
immutable?() click to toggle source
# File lib/serverspec/type/file.rb, line 75
def immutable?
  @runner.check_file_is_immutable(@name)
end
linked_to?(target) click to toggle source
# File lib/serverspec/type/file.rb, line 43
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 79
def md5sum
  @runner.get_file_md5sum(@name).stdout.strip
end
mode?(mode) click to toggle source
# File lib/serverspec/type/file.rb, line 31
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 71
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 98
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 35
def owned_by?(owner)
  @runner.check_file_is_owned_by(@name, owner)
end
readable?(by_whom, by_user) click to toggle source
# File lib/serverspec/type/file.rb, line 47
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
sha256sum() click to toggle source
# File lib/serverspec/type/file.rb, line 83
def sha256sum
  @runner.get_file_sha256sum(@name).stdout.strip
end
size() click to toggle source
# File lib/serverspec/type/file.rb, line 103
def size
  @runner.get_file_size(@name).stdout.strip.to_i
end
socket?() click to toggle source
# File lib/serverspec/type/file.rb, line 11
def socket?
  @runner.check_file_is_socket(@name)
end
version?(version) click to toggle source
# File lib/serverspec/type/file.rb, line 94
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 55
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