Module: Utils

Defined in:
lib/phtools/utils/os.rb,
lib/phtools/utils/dir.rb,
lib/phtools/utils/os_win.rb,
lib/phtools/utils/os_unix.rb

Overview

© ANB Andrew Bizyaev

Defined Under Namespace

Classes: OS, OSUnix, OSWin

Class Method Summary collapse

Class Method Details

.dir_empty?(dir) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/phtools/utils/dir.rb', line 6

def self.dir_empty?(dir)
  (Dir.entries(dir) - ['.', '..']).empty?
end

.os(os_string = RbConfig::CONFIG['host_os']) ⇒ Object

determine OS



10
11
12
13
14
15
16
17
# File 'lib/phtools/utils/os.rb', line 10

def self.os(os_string = RbConfig::CONFIG['host_os'])
  case os_string
  when /darwin/i then :macosx
  when /linux/i then :linux
  when /mswin|mingw|w32/i then :windows
  else :unknown
  end
end