lib/ass_launcher/support/platforms.rb in ass_launcher-0.1.1.alpha vs lib/ass_launcher/support/platforms.rb in ass_launcher-0.2.0
- old
+ new
@@ -1,25 +1,57 @@
# encoding: utf-8
-require 'ffi'
-
-module FFI
- # Monkey patch of [FFI::Platform]
+module AssLauncher
+ # Code partly copied from sources [FFI::Platform] module
+ # Module provides some functional like [FFI::Platform]
+ # Gem +ffi+ builds binary extension and decided don't use it
module Platform
- IS_CYGWIN = is_os('cygwin')
+ # :nocov:
+ OS = case RbConfig::CONFIG['host_os'].downcase
+ when /linux/
+ 'linux'
+ when /darwin/
+ 'darwin'
+ when /freebsd/
+ 'freebsd'
+ when /netbsd/
+ 'netbsd'
+ when /openbsd/
+ 'openbsd'
+ when /sunos|solaris/
+ 'solaris'
+ when /mingw|mswin/
+ 'windows'
+ else
+ RbConfig::CONFIG['host_os'].downcase
+ end
+ # :nocov:
+ # @param [String) os
+ # @return [Boolean]
+ # Test if current OS is +os+.
+ def self.os?(os)
+ OS == os
+ end
+
+ IS_CYGWIN = os?('cygwin')
+ IS_WINDOWS = os?('windows')
+ IS_LINUX = os?('linux')
+
def self.cygwin?
IS_CYGWIN
end
def self.linux?
IS_LINUX
end
+
+ def self.windows?
+ IS_WINDOWS
+ end
end
-end
-module AssLauncher
module Support
# OS-specific things
# Mixin module help work with things as paths and env in other plases
# @example
# include AssLauncher::Support::Platforms
@@ -48,22 +80,22 @@
#
#
module Platforms
# True if run in Cygwin
def cygwin?
- FFI::Platform.cygwin?
+ Platform.cygwin?
end
module_function :cygwin?
# True if run in MinGW
def windows?
- FFI::Platform.windows?
+ Platform.windows?
end
module_function :windows?
# True if run in Linux
def linux?
- FFI::Platform.linux?
+ Platform.linux?
end
module_function :linux?
# Return module [Platforms] as helper
# @return [Platforms]