Class: Siba::TmpDir
- Inherits:
-
Object
- Object
- Siba::TmpDir
- Extended by:
- FilePlug, LoggerPlug
- Includes:
- FilePlug, LoggerPlug
- Defined in:
- lib/siba/tmp_dir.rb
Constant Summary collapse
- TmpDirPrefix =
"siba-"
Class Method Summary collapse
Instance Method Summary collapse
- #cleanup ⇒ Object
- #get ⇒ Object
-
#initialize ⇒ TmpDir
constructor
A new instance of TmpDir.
Methods included from LoggerPlug
close, create, logger, logger, opened?
Methods included from FilePlug
siba_file, siba_file, siba_file=
Constructor Details
#initialize ⇒ TmpDir
Returns a new instance of TmpDir.
9 10 11 |
# File 'lib/siba/tmp_dir.rb', line 9 def initialize @tmp_dir = nil end |
Class Method Details
.test_access ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/siba/tmp_dir.rb', line 25 def test_access siba_file.run_this "test access" do begin tmp_dir_obj = TmpDir.new test_dir = tmp_dir_obj.get raise unless siba_file.file_directory? test_dir tmp_dir_obj.cleanup rescue Exception logger.error %q{Can not create temporary directory. Please make sure you have write permissions to the system temporary folder. You can also specify the alternative location for temporary folder in options: settings: tmp_dir: ~/your_tmp_dir } raise end logger.debug "Access to temporary directory verified" end end |
Instance Method Details
#cleanup ⇒ Object
17 18 19 20 |
# File 'lib/siba/tmp_dir.rb', line 17 def cleanup siba_file.file_utils_remove_entry_secure @tmp_dir unless @tmp_dir.nil? @tmp_dir = nil end |
#get ⇒ Object
13 14 15 |
# File 'lib/siba/tmp_dir.rb', line 13 def get @tmp_dir ||= create end |