Class: KeepYourHead::Resources
- Inherits:
-
Object
- Object
- KeepYourHead::Resources
- Defined in:
- lib/Keepyourhead/Resources.rb
Constant Summary collapse
- PathSystem =
path
- WorkDirectory =
user( "work/" )
Class Method Summary collapse
-
.createWorkingDirectory ⇒ Object
creates a new working directory in the user folder that must be deleted afterwards.
-
.system(name) ⇒ Object
returns a folder or file from the gem, that is same for all the system.
-
.user(name) ⇒ Object
returns a file or folder in the storage for the actual user.
Class Method Details
.createWorkingDirectory ⇒ Object
creates a new working directory in the user folder that must be deleted afterwards
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/Keepyourhead/Resources.rb', line 27 def self.createWorkingDirectory directory = nil @monitorDirectory ||= Monitor.new @monitorDirectory.mon_synchronize { begin val = rand(3000000) directory = ::File.("tmp_#{val}/", WorkDirectory ) end while ::File.directory?(directory) or ::File.exist?(directory) ::File.makedirs directory unless ::File.directory? directory } directory end |
.system(name) ⇒ Object
returns a folder or file from the gem, that is same for all the system
19 20 21 22 |
# File 'lib/Keepyourhead/Resources.rb', line 19 def self.system(name) path = ::File.(name, PathSystem) path end |
.user(name) ⇒ Object
returns a file or folder in the storage for the actual user
11 12 13 14 15 16 |
# File 'lib/Keepyourhead/Resources.rb', line 11 def self.user(name) path = ::File.("~/.KeepYourHead") ::File.makedirs path unless ::File.directory? path path = ::File.( name, path ) path end |