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, #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
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/serverspec/type/file.rb', line 19
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
15
16
17
|
# File 'lib/serverspec/type/file.rb', line 15
def directory?
@runner.check_file_is_directory(@name)
end
|
#executable?(by_whom, by_user) ⇒ Boolean
63
64
65
66
67
68
69
|
# File 'lib/serverspec/type/file.rb', line 63
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
|
# File 'lib/serverspec/type/file.rb', line 7
def file?
@runner.check_file_is_file(@name)
end
|
#grouped_into?(group) ⇒ Boolean
39
40
41
|
# File 'lib/serverspec/type/file.rb', line 39
def grouped_into?(group)
@runner.check_file_is_grouped(@name, group)
end
|
#immutable? ⇒ Boolean
75
76
77
|
# File 'lib/serverspec/type/file.rb', line 75
def immutable?
@runner.check_file_is_immutable(@name)
end
|
#linked_to?(target) ⇒ Boolean
43
44
45
|
# File 'lib/serverspec/type/file.rb', line 43
def linked_to?(target)
@runner.check_file_is_linked_to(@name, target)
end
|
#md5sum ⇒ Object
79
80
81
|
# File 'lib/serverspec/type/file.rb', line 79
def md5sum
@runner.get_file_md5sum(@name).stdout.strip
end
|
#mode?(mode) ⇒ Boolean
31
32
33
|
# File 'lib/serverspec/type/file.rb', line 31
def mode?(mode)
@runner.check_file_has_mode(@name, mode)
end
|
#mounted?(attr, only_with) ⇒ Boolean
71
72
73
|
# File 'lib/serverspec/type/file.rb', line 71
def mounted?(attr, only_with)
@runner.check_file_is_mounted(@name, attr, only_with)
end
|
#mtime ⇒ Object
98
99
100
101
|
# File 'lib/serverspec/type/file.rb', line 98
def mtime
d = @runner.get_file_mtime(@name).stdout.strip
DateTime.strptime(d, '%s').new_offset(DateTime.now.offset)
end
|
#owned_by?(owner) ⇒ Boolean
35
36
37
|
# File 'lib/serverspec/type/file.rb', line 35
def owned_by?(owner)
@runner.check_file_is_owned_by(@name, owner)
end
|
#readable?(by_whom, by_user) ⇒ Boolean
47
48
49
50
51
52
53
|
# File 'lib/serverspec/type/file.rb', line 47
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
83
84
85
|
# File 'lib/serverspec/type/file.rb', line 83
def sha256sum
@runner.get_file_sha256sum(@name).stdout.strip
end
|
#size ⇒ Object
103
104
105
|
# File 'lib/serverspec/type/file.rb', line 103
def size
@runner.get_file_size(@name).stdout.strip.to_i
end
|
#socket? ⇒ Boolean
11
12
13
|
# File 'lib/serverspec/type/file.rb', line 11
def socket?
@runner.check_file_is_socket(@name)
end
|
#version?(version) ⇒ Boolean
94
95
96
|
# File 'lib/serverspec/type/file.rb', line 94
def version?(version)
@runner.check_file_has_version(@name, version)
end
|
#writable?(by_whom, by_user) ⇒ Boolean
55
56
57
58
59
60
61
|
# File 'lib/serverspec/type/file.rb', line 55
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
|