Class: Sprout::Platform
- Inherits:
-
Object
- Object
- Sprout::Platform
- Defined in:
- lib/sprout/platform.rb
Overview
Determine what environment we're in so that we can play nice with libraries, processes, executables, etc.
Instance Method Summary (collapse)
-
- (Boolean) java?
Returns true if the current platform is running in the JVM (JRuby).
-
- (Boolean) linux?
Returns true if the current platform is unix? and not mac?.
-
- (Boolean) mac?
Returns true if the current platform is some flash of OS X.
-
- (Object) ruby_platform
Instance wrapper for the global Ruby Constant, RUBY_PLATFORM.
-
- (Boolean) unix?
Returns true if the current platform is not windows? or java?.
-
- (Boolean) vista?
Returns true if the current platform is Vista.
-
- (Boolean) windows?
Returns true if the current platform is some flavor of Windows.
-
- (Boolean) windows_nix?
Returns true if the current platform is some flavor of Unix on Windows.
Instance Method Details
- (Boolean) java?
Returns true if the current platform is running in the JVM (JRuby).
56 57 58 |
# File 'lib/sprout/platform.rb', line 56 def java? (/java/ =~ ruby_platform) != nil end |
- (Boolean) linux?
Returns true if the current platform is unix? and not mac?.
49 50 51 |
# File 'lib/sprout/platform.rb', line 49 def linux? unix? and not mac? end |
- (Boolean) mac?
Returns true if the current platform is some flash of OS X.
35 36 37 |
# File 'lib/sprout/platform.rb', line 35 def mac? (/darwin/ =~ ruby_platform) != nil end |
- (Object) ruby_platform
Instance wrapper for the global Ruby Constant, RUBY_PLATFORM.
wrapping this global allows for much easier testing and environment simulation.
65 66 67 |
# File 'lib/sprout/platform.rb', line 65 def ruby_platform RUBY_PLATFORM end |
- (Boolean) unix?
Returns true if the current platform is not windows? or java?.
42 43 44 |
# File 'lib/sprout/platform.rb', line 42 def unix? not windows? and not java? end |
- (Boolean) vista?
Returns true if the current platform is Vista.
20 21 22 |
# File 'lib/sprout/platform.rb', line 20 def vista? (/vista/ =~ ruby_platform) != nil end |
- (Boolean) windows?
Returns true if the current platform is some flavor of Windows.
13 14 15 |
# File 'lib/sprout/platform.rb', line 13 def windows? (/cygwin|mswin|mingw|bccwin|wince|emx|vista/ =~ ruby_platform) != nil end |
- (Boolean) windows_nix?
Returns true if the current platform is some flavor of Unix on Windows. Recognized nix-ish systems are: Cygwin, Mingw and BCCWin.
28 29 30 |
# File 'lib/sprout/platform.rb', line 28 def windows_nix? (/cygwin|mingw|bccwin/ =~ ruby_platform) != nil end |