Class: ConfUtils::Env

Inherits:
Object
  • Object
show all
Defined in:
lib/props/env.rb

Class Method Summary collapse

Class Method Details

.homeObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/props/env.rb', line 5

def self.home
  path = if( ENV['HOME'] || ENV['USERPROFILE'] )
           ENV['HOME'] || ENV['USERPROFILE']
         elsif( ENV['HOMEDRIVE'] && ENV['HOMEPATH'] )
           "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}"
         else
           begin
              File.expand_path('~')
           rescue
              if File::ALT_SEPARATOR
                 'C:/'
              else
                 '/'
              end
           end
         end
   
  # todo: use logger - how?
  ## puts "env home=>#{path}<"
  
  path
end

.parse_paths(paths) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/props/env.rb', line 33

def self.parse_paths( paths )
  if paths
    paths.split( File::PATH_SEPARATOR ) # e.g. UNIX-style => :  or Windows-style => ;
  else
    []
  end
end

.pathObject

returns array of paths (that is, path env gets split using PATH_SEPARATOR)



29
30
31
# File 'lib/props/env.rb', line 29

def self.path    # returns array of paths (that is, path env gets split using PATH_SEPARATOR)
  parse_paths( ENV['PATH'] )
end