Class: GithubCLI::System
- Inherits:
-
Object
- Object
- GithubCLI::System
- Defined in:
- lib/github_cli/system.rb
Overview
This class provides methods for reading system settings.
Class Method Summary collapse
-
.command?(name) ⇒ Boolean
Checks if command exists.
-
.which(command) ⇒ Object
Finds executable in $PATH.
-
.windows? ⇒ Boolean
Checks if windows platform.
Class Method Details
.command?(name) ⇒ Boolean
Checks if command exists.
27 28 29 |
# File 'lib/github_cli/system.rb', line 27 def command?(name) !which(name).nil? end |
.which(command) ⇒ Object
Finds executable in $PATH.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/github_cli/system.rb', line 15 def which(command) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each do |ext| exe = "#{path}/#{command}#{ext}" return exe if File.executable? exe end end return nil end |
.windows? ⇒ Boolean
Checks if windows platform.
9 10 11 12 |
# File 'lib/github_cli/system.rb', line 9 def windows? require 'rbconfig' RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw|windows/ end |