Class: Serverspec::Type::File

Inherits:
Base
  • Object
show all
Defined in:
lib/serverspec/type/file.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #to_s

Constructor Details

This class inherits a constructor from Serverspec::Type::Base

Instance Method Details

#contain(pattern, from, to) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/serverspec/type/file.rb', line 16

def contain(pattern, from, to)
  if (@from || @to).nil?
    cmd = backend.check_file_contain(@name, pattern)
  else
    cmd = backend.check_file_contain_within(@name, pattern, from, to)
  end
end

#directory?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/serverspec/type/file.rb', line 12

def directory?
  backend.check_directory(@name)
end

#executable?(by_whom, by_user) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
59
60
61
62
# File 'lib/serverspec/type/file.rb', line 56

def executable?(by_whom, by_user)
  if by_user != nil
    backend.check_access_by_user(@name, by_user, 'x')
  else
    backend.check_executable(@name, by_whom)
  end
end

#file?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/serverspec/type/file.rb', line 4

def file?
  backend.check_file(@name)
end

#grouped_into?(group) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/serverspec/type/file.rb', line 32

def grouped_into?(group)
  backend.check_grouped(@name, group)
end

#linked_to?(target) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/serverspec/type/file.rb', line 36

def linked_to?(target)
  backend.check_link(@name, target)
end

#match_md5checksum(md5sum) ⇒ Object



68
69
70
# File 'lib/serverspec/type/file.rb', line 68

def match_md5checksum(md5sum)
  backend.check_file_md5checksum(@name, md5sum)
end

#mode?(mode) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/serverspec/type/file.rb', line 24

def mode?(mode)
  backend.check_mode(@name, mode)
end

#mounted?(attr, only_with) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/serverspec/type/file.rb', line 64

def mounted?(attr, only_with)
  backend.check_mounted(@name, attr, only_with)
end

#owned_by?(owner) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/serverspec/type/file.rb', line 28

def owned_by?(owner)
  backend.check_owner(@name, owner)
end

#readable?(by_whom, by_user) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
44
45
46
# File 'lib/serverspec/type/file.rb', line 40

def readable?(by_whom, by_user)
  if by_user != nil
    backend.check_access_by_user(@name, by_user, 'r')
  else
    backend.check_readable(@name, by_whom)
  end
end

#socket?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/serverspec/type/file.rb', line 8

def socket?
  backend.check_socket(@name)
end

#writable?(by_whom, by_user) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
52
53
54
# File 'lib/serverspec/type/file.rb', line 48

def writable?(by_whom, by_user)
  if by_user != nil
    backend.check_access_by_user(@name, by_user, 'w')
  else
    backend.check_writable(@name, by_whom)
  end
end