lib/sct/config.rb in sct-0.1.11 vs lib/sct/config.rb in sct-0.1.12
- old
+ new
@@ -1,22 +1,10 @@
module Sct
class Config
- WINDOWS = "Windows"
- MAC_OS = "MacOS"
- UBUNTU = "Ubuntu"
-
def self.dir
- user = ENV["SUDO_USER"] || ENV["USER"]
-
- if self.operatingSystem == MAC_OS
- home = "/Users"
- else
- home = "/home"
- end
-
- return "#{home}/#{user}/.config/sct"
+ return "#{Sct::Helpers.homePath}/.config/sct"
end
def self.path
return File.expand_path(File.join(self.dir, 'config'))
end
@@ -41,51 +29,8 @@
end
contents = File.read(self.path)
return Sct::Helpers.to_hash(contents)
- end
-
- def self.operatingSystem
- proc = `uname -a`
-
- case proc
- when /Microsoft/
- os = WINDOWS
- when /Darwin/
- os = MAC_OS
- else
- os = UBUNTU
- end
-
- return os
- end
-
- ###
- # Get the actual home path of the user. This may be different depending on the operating system
- ###
- def self.getTrueHomePath
- home_path = `echo ~`
- if self.operatingSystem == WINDOWS
- home_path = self.convertWindowsToWSLPath(`cmd.exe /c echo %userprofile%`)
- end
-
- return home_path
- end
-
- def self.convertWindowsToWSLPath(path)
- if self.operatingSystem == WINDOWS
- return path.gsub(/C:\\/, '/mnt/c/').gsub(/\\\\/, "/").gsub(/\\/, '/').gsub(/\r\n?/, '')
- end
-
- return path
- end
-
- def self.convertWSLToWindowsPath(path)
- if self.operatingSystem == WINDOWS
- return path.gsub(/\/mnt\/c/, 'C:/').gsub(/\/\//, '/').gsub(/\\\\/, "/").gsub(/\r\n?/, '')
- end
-
- return path
end
end
end