Module: Capistrano::Ops::Logrotate::Helpers

Defined in:
lib/capistrano/ops/logrotate/helpers.rb

Instance Method Summary collapse

Instance Method Details

#config_templateObject



7
8
9
10
11
# File 'lib/capistrano/ops/logrotate/helpers.rb', line 7

def config_template
  return nil unless File.exist?(File.expand_path(logrotate_config_file_template, __dir__))

  ERB.new(File.read(File.expand_path(logrotate_config_file_template, __dir__))).result(binding)
end

#delete_filesObject



31
32
33
# File 'lib/capistrano/ops/logrotate/helpers.rb', line 31

def delete_files
  puts capture "rm -rfv #{logrotate_basepath}"
end

#logrotate_disabledObject



23
24
25
# File 'lib/capistrano/ops/logrotate/helpers.rb', line 23

def logrotate_disabled
  !(test("[ -f #{logrotate_config_file_path} ]") && test("[ -f #{logrotate_schedule_file_path} ]"))
end

#logrotate_enabledObject



19
20
21
# File 'lib/capistrano/ops/logrotate/helpers.rb', line 19

def logrotate_enabled
  test("[ -f #{logrotate_config_file_path} ]") && test("[ -f #{logrotate_schedule_file_path} ]")
end

#make_basepathObject



27
28
29
# File 'lib/capistrano/ops/logrotate/helpers.rb', line 27

def make_basepath
  puts capture "mkdir -pv #{logrotate_basepath}"
end

#schedule_templateObject



13
14
15
16
17
# File 'lib/capistrano/ops/logrotate/helpers.rb', line 13

def schedule_template
  return nil unless File.exist?(File.expand_path(logrotate_schedule_file_template, __dir__))

  ERB.new(File.read(File.expand_path(logrotate_schedule_file_template, __dir__))).result(binding)
end

#whenever(type) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/capistrano/ops/logrotate/helpers.rb', line 35

def whenever(type)
  case type
  when 'clear'
    puts capture :bundle, :exec, :whenever, '--clear-crontab',
                 "-f #{logrotate_schedule_file_path} #{fetch(:whenever_identifier)}_logrotate"
  when 'update'
    puts capture :bundle, :exec, :whenever, '--update-crontab', "-f #{logrotate_schedule_file_path}",
                 "-i #{fetch(:whenever_identifier)}_logrotate"
  else
    puts 'type not found'
  end
end