Class: Sprout::Platform

Inherits:
Object
  • Object
show all
Defined in:
sprout/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)

Instance Method Details

- (Boolean) java?

Returns true if the current platform is running in the JVM (JRuby).

Returns:

  • (Boolean)


56
57
58
# File 'sprout/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?.

Returns:

  • (Boolean)


49
50
51
# File 'sprout/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.

Returns:

  • (Boolean)


35
36
37
# File 'sprout/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 'sprout/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?.

Returns:

  • (Boolean)


42
43
44
# File 'sprout/lib/sprout/platform.rb', line 42

def unix?
  not windows? and not java?
end

- (Boolean) vista?

Returns true if the current platform is Vista.

Returns:

  • (Boolean)


20
21
22
# File 'sprout/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.

Returns:

  • (Boolean)


13
14
15
# File 'sprout/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.

Returns:

  • (Boolean)


28
29
30
# File 'sprout/lib/sprout/platform.rb', line 28

def windows_nix?
  (/cygwin|mingw|bccwin/ =~ ruby_platform) != nil
end