Class: KeepYourHead::Resources

Inherits:
Object
  • Object
show all
Defined in:
lib/Keepyourhead/Resources.rb

Constant Summary collapse

PathSystem =
path
WorkDirectory =
user( "work/" )

Class Method Summary collapse

Class Method Details

.createWorkingDirectoryObject

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.expand_path("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.expand_path(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.expand_path("~/.KeepYourHead")
	::File.makedirs path unless ::File.directory? path
	path = ::File.expand_path( name, path )
	path
end