10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/itamae/plugin/resource/rvm_config.rb', line 10
def pre_action
user = attributes.user
unless user
user = run_command('id -un').stdout.strip
end
::Itamae.logger.debug "user: #{user}"
if rvm_path == '/usr/local/rvm'
attributes.path = '/etc/rvmrc'
else
attributes.path = '.rvmrc'
end
::Itamae.logger.debug "attributes.path: #{attributes.path}"
case @current_action
when :create
attributes.exist = true
when :delete
attributes.exist = false
when :edit
attributes.exist = true
content = backend.receive_file(attributes.path)
%w(rvm_install_on_use_flag rvm_project_rvmrc rvm_gemset_create_on_use_flag rvm_auto_reload_flag rvm_autoinstall_bundler_flag).each do |key|
content.gsub!(/[ \t]*#{key}[ \t]*=[ \t]*\w+[ \t]*\n?/,'')
end
content.gsub!(/\s*\z/,'')
content.concat(<<-"EOS".gsub(/^\s+\|/, ''))
|
|rvm_install_on_use_flag=#{attributes.install_on_use_flag || 1}
|rvm_project_rvmrc=#{attributes.project_rvmrc || 1}
|rvm_gemset_create_on_use_flag=#{attributes.gemset_create_on_use_flag || 1}
|rvm_auto_reload_flag=#{attributes.auto_reload_flag || 2}
|rvm_autoinstall_bundler_flag=#{attributes.autoinstall_bundler_flag || 1}
EOS
attributes.content = content
end
send_tempfile
end
|