Module: Clacky::Utils::EnvironmentDetector
- Defined in:
- lib/clacky/utils/environment_detector.rb
Overview
Detects the current operating system environment and desktop path.
Class Method Summary collapse
-
.desktop_path ⇒ String?
Detect the desktop directory path for the current environment.
-
.os_label ⇒ Object
Human-readable OS label for injection into session context.
-
.os_type ⇒ Symbol
Detect OS type.
- .wsl? ⇒ Boolean
Class Method Details
.desktop_path ⇒ String?
Detect the desktop directory path for the current environment.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/clacky/utils/environment_detector.rb', line 35 def self.desktop_path return @desktop_path if defined?(@desktop_path) @desktop_path = case os_type when :wsl wsl_desktop_path when :macos macos_desktop_path when :linux linux_desktop_path else fallback_desktop_path end end |
.os_label ⇒ Object
Human-readable OS label for injection into session context.
24 25 26 27 28 29 30 31 |
# File 'lib/clacky/utils/environment_detector.rb', line 24 def self.os_label case os_type when :wsl then "WSL/Windows" when :macos then "macOS" when :linux then "Linux" else "Unknown" end end |
.os_type ⇒ Symbol
Detect OS type.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/clacky/utils/environment_detector.rb', line 9 def self.os_type return @os_type if defined?(@os_type) @os_type = if wsl? :wsl elsif RUBY_PLATFORM.include?("darwin") :macos elsif RUBY_PLATFORM.include?("linux") :linux else :unknown end end |
.wsl? ⇒ Boolean
50 51 52 53 54 55 |
# File 'lib/clacky/utils/environment_detector.rb', line 50 def self.wsl? File.exist?("/proc/version") && File.read("/proc/version").downcase.include?("microsoft") rescue false end |