lib/kafo/kafo_configure.rb in kafo-0.5.1 vs lib/kafo/kafo_configure.rb in kafo-0.5.2
- old
+ new
@@ -23,16 +23,19 @@
module Kafo
class KafoConfigure < Clamp::Command
include StringHelper
-
class << self
attr_accessor :config, :root_dir, :config_file, :gem_root, :temp_config_file,
:modules_dir, :kafo_modules_dir, :verbose, :app_options, :logger
attr_writer :hooking
+ def cleanup_paths
+ @cleanup_paths ||= []
+ end
+
def hooking
@hooking ||= Hooking.new
end
end
@@ -119,10 +122,11 @@
def exit_code
self.class.exit_code
end
def self.exit(code)
+ cleanup
@exit_code = translate_exit_code(code)
throw :exit
end
def self.exit_code
@@ -140,9 +144,29 @@
if error_codes.has_key? code
return error_codes[code]
else
raise "Unknown code #{code}"
end
+ end
+
+ def self.cleanup
+ # make sure default values are removed from /tmp
+ (self.cleanup_paths + ['/tmp/default_values.yaml']).each do |file|
+ logger.debug "Cleaning #{file}"
+ FileUtils.rm_rf(file)
+ end
+ end
+
+ def self.register_cleanup_path(path)
+ self.cleanup_paths<< path
+ end
+
+ def register_cleanup_path(path)
+ self.class.register_cleanup_path(path)
+ end
+
+ def cleanup_paths
+ self.class.cleanup_paths
end
def help
self.class.help(invocation_path, self)
end