Class: Monkey::FilePaths

Inherits:
Object
  • Object
show all
Defined in:
lib/helpers/file_paths.rb

Class Method Summary collapse

Class Method Details

.global_appsObject



28
29
30
# File 'lib/helpers/file_paths.rb', line 28

def self.global_apps
  global_bit64_apps || global_bit32_apps
end

.global_bit32_appsObject



18
19
20
21
22
23
24
25
26
# File 'lib/helpers/file_paths.rb', line 18

def self.global_bit32_apps
  if Computer.windows?
    path = ENV['programfiles(x86)'] if Computer.bit64?
    path = ENV['programfiles'] if Computer.bit32?
    return path.gsub(File::ALT_SEPARATOR, File::SEPARATOR)
  elsif Computer.mac?
    return File.join(root, '/Applications')
  end
end

.global_bit64_appsObject



12
13
14
15
16
# File 'lib/helpers/file_paths.rb', line 12

def self.global_bit64_apps
  return nil if Computer.bit32?
  return ENV['programfiles'].gsub(File::ALT_SEPARATOR, File::SEPARATOR) if Computer.windows?
  return File.join(root, '/Applications') if Computer.mac?
end

.hosts_fileObject



32
33
34
35
# File 'lib/helpers/file_paths.rb', line 32

def self.hosts_file
  return File.join(root, 'windows/system32/drivers/etc/hosts') if Computer.windows?
  return File.join(root, '/private/etc/hosts') if Computer.mac?
end

.rootObject



4
5
6
7
8
9
10
# File 'lib/helpers/file_paths.rb', line 4

def self.root
  if Computer.windows?
    Dir.pwd.scan(/\w:\//).first
  else
    '/'
  end
end