Class: BarkestCore::WorkPath
- Inherits:
-
Object
- Object
- BarkestCore::WorkPath
- Defined in:
- app/models/barkest_core/work_path.rb
Overview
This class simply locates a temporary working directory for the application.
By default we shoot for shared memory such as /run/shm or /dev/shm. If those fail, we look to /tmp.
Class Method Summary collapse
-
.location ⇒ Object
Gets the temporary working directory location for the application.
-
.path_for(filename) ⇒ Object
Gets a path for a specific temporary file.
-
.system_status_file ⇒ Object
Gets the path to the system status file.
Class Method Details
.location ⇒ Object
Gets the temporary working directory location for the application.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/barkest_core/work_path.rb', line 15 def self.location @location ||= begin retval = nil %w(/run/shm /var/run/shm /dev/shm /tmp).each do |root| if Dir.exist?(root) retval = try_path(root) break if retval end end retval || try_path(Dir.tmpdir) end end |
.path_for(filename) ⇒ Object
Gets a path for a specific temporary file.
32 33 34 35 |
# File 'app/models/barkest_core/work_path.rb', line 32 def self.path_for(filename) raise StandardError.new('Cannot determine location.') unless location location + '/' + filename end |
.system_status_file ⇒ Object
Gets the path to the system status file.
This file is used by long running processes to log their progress.
42 43 44 |
# File 'app/models/barkest_core/work_path.rb', line 42 def self.system_status_file @system_status_file ||= path_for('system_status') end |