Module: Bnicovideo::OsDetector

Defined in:
lib/bnicovideo/os_detector.rb

Class Method Summary collapse

Class Method Details

.detectObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bnicovideo/os_detector.rb', line 6

def self.detect
  if /mswin(?!ce)|mingw|cygwin|bccwin/ =~ RUBY_PLATFORM
    # Windows
    return Bnicovideo::WindowsDetector.check
  elsif /darwin/ =~ RUBY_PLATFORM
    return 'macosx'
  elsif /java/ =~ RUBY_PLATFORM
    # JRuby
    os_name = Java::JavaLang::System.getProperty('os.name')
    if /Windows/ =~ os_name
      os_version = Java::JavaLang::System.getProperty('os.version')
      mj = os_version.split('.')[0]
      if mj == '6'
        return 'winvista'
      elsif mj == '5'
        return 'winxp'
      else
        return 'win95'
      end
    elsif /Mac OS X/ =~ os_name
      return 'macosx'
    else
      return 'unix'
    end
  else
    return 'unix'
  end
end