Class: Itamae::Resource::Directory
- Inherits:
-
Base
- Object
- Base
- Itamae::Resource::Directory
show all
- Defined in:
- lib/itamae/resource/directory.rb
Instance Attribute Summary
Attributes inherited from Base
#attributes, #current_attributes, #notifications, #recipe, #resource_name, #subscriptions, #updated
Instance Method Summary
collapse
Methods inherited from Base
#action_nothing, define_attribute, #do_not_run_because_of_not_if?, #do_not_run_because_of_only_if?, inherited, #initialize, #resource_type, #run
Instance Method Details
#action_create(options) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/itamae/resource/directory.rb', line 41
def action_create(options)
if !run_specinfra(:check_file_is_directory, attributes.path)
run_specinfra(:create_file_as_directory, attributes.path)
end
if attributes.mode
run_specinfra(:change_file_mode, attributes.path, attributes.mode)
end
if attributes.owner || attributes.group
run_specinfra(:change_file_owner, attributes.path, attributes.owner, attributes.group)
end
end
|
#action_delete(options) ⇒ Object
53
54
55
56
57
|
# File 'lib/itamae/resource/directory.rb', line 53
def action_delete(options)
if run_specinfra(:check_file_is_directory, attributes.path)
run_specinfra(:remove_file, attributes.path)
end
end
|
#pre_action ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/itamae/resource/directory.rb', line 10
def pre_action
case @current_action
when :create
attributes.exist = true
when :delete
attributes.exist = false
end
end
|
#set_current_attributes ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/itamae/resource/directory.rb', line 26
def set_current_attributes
exist = run_specinfra(:check_file_is_directory, attributes.path)
current.exist = exist
if exist
current.mode = run_specinfra(:get_file_mode, attributes.path).stdout.chomp
current.owner = run_specinfra(:get_file_owner_user, attributes.path).stdout.chomp
current.group = run_specinfra(:get_file_owner_group, attributes.path).stdout.chomp
else
current.mode = nil
current.owner = nil
current.group = nil
end
end
|
#show_differences ⇒ Object
19
20
21
22
23
24
|
# File 'lib/itamae/resource/directory.rb', line 19
def show_differences
current.mode = current.mode.rjust(4, '0') if current.mode
attributes.mode = attributes.mode.rjust(4, '0') if attributes.mode
super
end
|