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
#block_device? ⇒ Boolean
13
14
15
|
# File 'lib/serverspec/type/file.rb', line 13
def block_device?
@runner.check_file_is_block_device(@name)
end
|
#character_device? ⇒ Boolean
17
18
19
|
# File 'lib/serverspec/type/file.rb', line 17
def character_device?
@runner.check_file_is_character_device(@name)
end
|
#contain(pattern, from, to) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/serverspec/type/file.rb', line 37
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
25
26
27
|
# File 'lib/serverspec/type/file.rb', line 25
def directory?
@runner.check_file_is_directory(@name)
end
|
#executable?(by_whom, by_user) ⇒ Boolean
81
82
83
84
85
86
87
|
# File 'lib/serverspec/type/file.rb', line 81
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
97
98
99
|
# File 'lib/serverspec/type/file.rb', line 97
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
|
#group ⇒ Object
116
117
118
|
# File 'lib/serverspec/type/file.rb', line 116
def group
@runner.get_file_owner_group(@name).stdout.strip
end
|
#grouped_into?(group) ⇒ Boolean
57
58
59
|
# File 'lib/serverspec/type/file.rb', line 57
def grouped_into?(group)
@runner.check_file_is_grouped(@name, group)
end
|
#immutable? ⇒ Boolean
93
94
95
|
# File 'lib/serverspec/type/file.rb', line 93
def immutable?
@runner.check_file_is_immutable(@name)
end
|
#link_target ⇒ Object
124
125
126
|
# File 'lib/serverspec/type/file.rb', line 124
def link_target
@runner.get_file_link_target(@name).stdout.strip
end
|
#linked_to?(target) ⇒ Boolean
61
62
63
|
# File 'lib/serverspec/type/file.rb', line 61
def linked_to?(target)
@runner.check_file_is_linked_to(@name, target)
end
|
#md5sum ⇒ Object
101
102
103
|
# File 'lib/serverspec/type/file.rb', line 101
def md5sum
@runner.get_file_md5sum(@name).stdout.strip
end
|
#mode ⇒ Object
128
129
130
|
# File 'lib/serverspec/type/file.rb', line 128
def mode
@runner.get_file_mode(@name).stdout.strip
end
|
#mode?(mode) ⇒ Boolean
49
50
51
|
# File 'lib/serverspec/type/file.rb', line 49
def mode?(mode)
@runner.check_file_has_mode(@name, mode)
end
|
#mounted?(attr, only_with) ⇒ Boolean
89
90
91
|
# File 'lib/serverspec/type/file.rb', line 89
def mounted?(attr, only_with)
@runner.check_file_is_mounted(@name, attr, only_with)
end
|
#mtime ⇒ Object
132
133
134
135
|
# File 'lib/serverspec/type/file.rb', line 132
def mtime
d = @runner.get_file_mtime(@name).stdout.strip
DateTime.strptime(d, '%s').new_offset(DateTime.now.offset)
end
|
#owned_by?(owner) ⇒ Boolean
53
54
55
|
# File 'lib/serverspec/type/file.rb', line 53
def owned_by?(owner)
@runner.check_file_is_owned_by(@name, owner)
end
|
#owner ⇒ Object
137
138
139
|
# File 'lib/serverspec/type/file.rb', line 137
def owner
@runner.get_file_owner_user(@name).stdout.strip
end
|
#pipe? ⇒ Boolean
33
34
35
|
# File 'lib/serverspec/type/file.rb', line 33
def pipe?
@runner.check_file_is_pipe(@name)
end
|
#readable?(by_whom, by_user) ⇒ Boolean
65
66
67
68
69
70
71
|
# File 'lib/serverspec/type/file.rb', line 65
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
145
146
147
|
# File 'lib/serverspec/type/file.rb', line 145
def selinux_label
@runner.get_file_selinuxlabel(@name).stdout.strip
end
|
#sha256sum ⇒ Object
105
106
107
|
# File 'lib/serverspec/type/file.rb', line 105
def sha256sum
@runner.get_file_sha256sum(@name).stdout.strip
end
|
#size ⇒ Object
141
142
143
|
# File 'lib/serverspec/type/file.rb', line 141
def size
@runner.get_file_size(@name).stdout.strip.to_i
end
|
#socket? ⇒ Boolean
21
22
23
|
# File 'lib/serverspec/type/file.rb', line 21
def socket?
@runner.check_file_is_socket(@name)
end
|
#symlink? ⇒ Boolean
29
30
31
|
# File 'lib/serverspec/type/file.rb', line 29
def symlink?
@runner.check_file_is_symlink(@name)
end
|
#version?(version) ⇒ Boolean
120
121
122
|
# File 'lib/serverspec/type/file.rb', line 120
def version?(version)
@runner.check_file_has_version(@name, version)
end
|
#writable?(by_whom, by_user) ⇒ Boolean
73
74
75
76
77
78
79
|
# File 'lib/serverspec/type/file.rb', line 73
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
|