Class: Serverspec::Type::File
- Inherits:
-
Base
- Object
- Base
- Serverspec::Type::File
show all
- Defined in:
- lib/serverspec/type/file.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#name
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
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/serverspec/type/file.rb', line 29
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
73
74
75
76
77
78
79
|
# File 'lib/serverspec/type/file.rb', line 73
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? ⇒ Boolean
89
90
91
|
# File 'lib/serverspec/type/file.rb', line 89
def exists?
@runner.check_file_exists(@name)
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
49
50
51
|
# File 'lib/serverspec/type/file.rb', line 49
def grouped_into?(group)
@runner.check_file_is_grouped(@name, group)
end
|
#immutable? ⇒ Boolean
85
86
87
|
# File 'lib/serverspec/type/file.rb', line 85
def immutable?
@runner.check_file_is_immutable(@name)
end
|
#linked_to?(target) ⇒ Boolean
53
54
55
|
# File 'lib/serverspec/type/file.rb', line 53
def linked_to?(target)
@runner.check_file_is_linked_to(@name, target)
end
|
#md5sum ⇒ Object
93
94
95
|
# File 'lib/serverspec/type/file.rb', line 93
def md5sum
@runner.get_file_md5sum(@name).stdout.strip
end
|
#mode?(mode) ⇒ Boolean
41
42
43
|
# File 'lib/serverspec/type/file.rb', line 41
def mode?(mode)
@runner.check_file_has_mode(@name, mode)
end
|
#mounted?(attr, only_with) ⇒ Boolean
81
82
83
|
# File 'lib/serverspec/type/file.rb', line 81
def mounted?(attr, only_with)
@runner.check_file_is_mounted(@name, attr, only_with)
end
|
#mtime ⇒ Object
112
113
114
115
|
# File 'lib/serverspec/type/file.rb', line 112
def mtime
d = @runner.get_file_mtime(@name).stdout.strip
DateTime.strptime(d, '%s').new_offset(DateTime.now.offset)
end
|
#owned_by?(owner) ⇒ Boolean
45
46
47
|
# File 'lib/serverspec/type/file.rb', line 45
def owned_by?(owner)
@runner.check_file_is_owned_by(@name, owner)
end
|
#pipe? ⇒ Boolean
25
26
27
|
# File 'lib/serverspec/type/file.rb', line 25
def pipe?
@runner.check_file_is_pipe(@name)
end
|
#readable?(by_whom, by_user) ⇒ Boolean
57
58
59
60
61
62
63
|
# File 'lib/serverspec/type/file.rb', line 57
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 ⇒ Object
121
122
123
|
# File 'lib/serverspec/type/file.rb', line 121
def selinux_label
@runner.get_file_selinuxlabel(@name).stdout.strip
end
|
#sha256sum ⇒ Object
97
98
99
|
# File 'lib/serverspec/type/file.rb', line 97
def sha256sum
@runner.get_file_sha256sum(@name).stdout.strip
end
|
#size ⇒ Object
117
118
119
|
# File 'lib/serverspec/type/file.rb', line 117
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
|
#symlink? ⇒ Boolean
21
22
23
|
# File 'lib/serverspec/type/file.rb', line 21
def symlink?
@runner.check_file_is_symlink(@name)
end
|
#version?(version) ⇒ Boolean
108
109
110
|
# File 'lib/serverspec/type/file.rb', line 108
def version?(version)
@runner.check_file_has_version(@name, version)
end
|
#writable?(by_whom, by_user) ⇒ Boolean
65
66
67
68
69
70
71
|
# File 'lib/serverspec/type/file.rb', line 65
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
|