Class: Serverspec::Type::File
- Inherits:
-
Base
- Object
- Base
- Serverspec::Type::File
show all
- Defined in:
- lib/serverspec/type/file.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #inspect, #to_ary, #to_s
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
5
6
7
|
# File 'lib/serverspec/type/file.rb', line 5
def content
@content
end
|
Instance Method Details
#contain(pattern, from, to) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/serverspec/type/file.rb', line 21
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? ⇒ Boolean
17
18
19
|
# File 'lib/serverspec/type/file.rb', line 17
def directory?
@runner.check_file_is_directory(@name)
end
|
#executable?(by_whom, by_user) ⇒ Boolean
65
66
67
68
69
70
71
|
# File 'lib/serverspec/type/file.rb', line 65
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? ⇒ Boolean
7
8
9
10
11
|
# 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) ⇒ Boolean
41
42
43
|
# File 'lib/serverspec/type/file.rb', line 41
def grouped_into?(group)
@runner.check_file_is_grouped(@name, group)
end
|
#immutable? ⇒ Boolean
77
78
79
|
# File 'lib/serverspec/type/file.rb', line 77
def immutable?
@runner.check_file_is_immutable(@name)
end
|
#linked_to?(target) ⇒ Boolean
45
46
47
|
# File 'lib/serverspec/type/file.rb', line 45
def linked_to?(target)
@runner.check_file_is_linked_to(@name, target)
end
|
#md5sum ⇒ Object
81
82
83
|
# File 'lib/serverspec/type/file.rb', line 81
def md5sum
@runner.get_file_md5sum(@name).stdout.strip
end
|
#mode?(mode) ⇒ Boolean
33
34
35
|
# File 'lib/serverspec/type/file.rb', line 33
def mode?(mode)
@runner.check_file_has_mode(@name, mode)
end
|
#mounted?(attr, only_with) ⇒ Boolean
73
74
75
|
# File 'lib/serverspec/type/file.rb', line 73
def mounted?(attr, only_with)
@runner.check_file_is_mounted(@name, attr, only_with)
end
|
#mtime ⇒ Object
100
101
102
103
|
# File 'lib/serverspec/type/file.rb', line 100
def mtime
d = @runner.get_file_mtime(@name).stdout.strip
DateTime.strptime(d, '%s').new_offset(DateTime.now.offset)
end
|
#owned_by?(owner) ⇒ Boolean
37
38
39
|
# File 'lib/serverspec/type/file.rb', line 37
def owned_by?(owner)
@runner.check_file_is_owned_by(@name, owner)
end
|
#readable?(by_whom, by_user) ⇒ Boolean
49
50
51
52
53
54
55
|
# File 'lib/serverspec/type/file.rb', line 49
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 ⇒ Object
85
86
87
|
# File 'lib/serverspec/type/file.rb', line 85
def sha256sum
@runner.get_file_sha256sum(@name).stdout.strip
end
|
#size ⇒ Object
105
106
107
|
# File 'lib/serverspec/type/file.rb', line 105
def size
@runner.get_file_size(@name).stdout.strip.to_i
end
|
#socket? ⇒ Boolean
13
14
15
|
# File 'lib/serverspec/type/file.rb', line 13
def socket?
@runner.check_file_is_socket(@name)
end
|
#version?(version) ⇒ Boolean
96
97
98
|
# File 'lib/serverspec/type/file.rb', line 96
def version?(version)
@runner.check_file_has_version(@name, version)
end
|
#writable?(by_whom, by_user) ⇒ Boolean
57
58
59
60
61
62
63
|
# File 'lib/serverspec/type/file.rb', line 57
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
|