Class: Serverspec::Type::File

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #to_ary, #to_s

Constructor Details

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

Instance Attribute Details

#contentObject

Returns the value of attribute content


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

def content
  @content
end

Instance Method Details

#contain(pattern, from, to) ⇒ Object


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

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)

14
15
16
# File 'lib/serverspec/type/file.rb', line 14

def directory?
  backend.check_directory(@name)
end

#executable?(by_whom, by_user) ⇒ Boolean

Returns:

  • (Boolean)

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

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)

6
7
8
# File 'lib/serverspec/type/file.rb', line 6

def file?
  backend.check_file(@name)
end

#grouped_into?(group) ⇒ Boolean

Returns:

  • (Boolean)

34
35
36
# File 'lib/serverspec/type/file.rb', line 34

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

#linked_to?(target) ⇒ Boolean

Returns:

  • (Boolean)

38
39
40
# File 'lib/serverspec/type/file.rb', line 38

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

#match_md5checksum(md5sum) ⇒ Object


70
71
72
# File 'lib/serverspec/type/file.rb', line 70

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

#match_sha256checksum(sha256sum) ⇒ Object


74
75
76
# File 'lib/serverspec/type/file.rb', line 74

def match_sha256checksum(sha256sum)
  backend.check_file_sha256checksum(@name, sha256sum)
end

#mode?(mode) ⇒ Boolean

Returns:

  • (Boolean)

26
27
28
# File 'lib/serverspec/type/file.rb', line 26

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

#mounted?(attr, only_with) ⇒ Boolean

Returns:

  • (Boolean)

66
67
68
# File 'lib/serverspec/type/file.rb', line 66

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

#owned_by?(owner) ⇒ Boolean

Returns:

  • (Boolean)

30
31
32
# File 'lib/serverspec/type/file.rb', line 30

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

#readable?(by_whom, by_user) ⇒ Boolean

Returns:

  • (Boolean)

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

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)

10
11
12
# File 'lib/serverspec/type/file.rb', line 10

def socket?
  backend.check_socket(@name)
end

#writable?(by_whom, by_user) ⇒ Boolean

Returns:

  • (Boolean)

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

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