Sha256: a172fbe5e64ae3defb2dde42ade7ef59edf0cb3386b2a7d8af3153b4458d6be1
Contents?: true
Size: 974 Bytes
Versions: 5
Compression:
Stored size: 974 Bytes
Contents
# encoding: utf-8 module TTY class Terminal # A class responsible for locating user home class Home # @api public def initialize(platform = nil) @platform = platform || TTY::Platform end # Find user home # # @api public def find_home path = @platform.windows? ? windows_home : unix_home File.expand_path(path) end def unix_home require 'etc' "~#{Etc.getlogin}" rescue ENV['HOME'] end def windows_home if (home = ENV['HOME']) home.tr('\\', '/') elsif ENV['HOMEDRIVE'] && ENV['HOMEPATH'] File.join(ENV['HOMEDRIVE'], ENV['HOMEPATH']) elsif ENV['USERPROFILE'] ENV['USERPROFILE'] elsif ENV['HOMEDRIVE'] || ENV['SystemDrive'] File.join(ENV['HOMEDRIVE'] || ENV['SystemDrive'], '/') else 'C:/' end end end # Home end # Terminal end # TTY
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
tty-0.5.0 | lib/tty/terminal/home.rb |
tty-0.4.0 | lib/tty/terminal/home.rb |
tty-0.3.2 | lib/tty/terminal/home.rb |
tty-0.3.1 | lib/tty/terminal/home.rb |
tty-0.3.0 | lib/tty/terminal/home.rb |