Class: MobyUtil::EnvironmentHelper
- Defined in:
- lib/tdriver/util/common/environment.rb
Constant Summary collapse
- LINUX =
:linux
- SOLARIS =
:solaris
- WINDOWS =
:windows
- OSX =
:osx
- CYGWIN =
:cygwin
- UNKNOWN =
keep this as last constant
:unknown
Class Method Summary collapse
- .change_file_ownership!(target, user_name, user_group, recursively = true) ⇒ Object
- .cygwin? ⇒ Boolean
- .java? ⇒ Boolean
- .linux? ⇒ Boolean
- .osx? ⇒ Boolean
-
.platform ⇒ Object
- Function to retrieve platform type == returns Integer
-
LINUX.
- .posix? ⇒ Boolean
-
.ruby_platform ⇒ Object
Function to retrieve platform type == returns String::.
- .solaris? ⇒ Boolean
- .unknown_os? ⇒ Boolean
-
.user_group(name = nil) ⇒ Object
linux.
-
.user_name ⇒ Object
linux.
- .windows? ⇒ Boolean
Class Method Details
.change_file_ownership!(target, user_name, user_group, recursively = true) ⇒ Object
125 126 127 128 129 |
# File 'lib/tdriver/util/common/environment.rb', line 125 def self.change_file_ownership!( target, user_name, user_group, recursively = true ) `chown -h #{ recursively ? '-R' : '' } #{ user_name }:#{ user_group } #{ target }` if MobyUtil::EnvironmentHelper.posix? end |
.cygwin? ⇒ Boolean
45 46 47 48 49 |
# File 'lib/tdriver/util/common/environment.rb', line 45 def self.cygwin? platform == CYGWIN end |
.java? ⇒ Boolean
33 34 35 36 37 |
# File 'lib/tdriver/util/common/environment.rb', line 33 def self.java? RUBY_PLATFORM == "java" end |
.linux? ⇒ Boolean
57 58 59 60 61 |
# File 'lib/tdriver/util/common/environment.rb', line 57 def self.linux? platform == LINUX end |
.osx? ⇒ Boolean
69 70 71 72 73 |
# File 'lib/tdriver/util/common/environment.rb', line 69 def self.osx? platform == OSX end |
.platform ⇒ Object
Function to retrieve platform type
returns
- Integer
-
LINUX
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/tdriver/util/common/environment.rb', line 84 def self.platform case RbConfig::CONFIG[ 'host_os' ] when /mswin|mingw|windows/i WINDOWS when /cygwin/i CYGWIN when /linux/i LINUX when /sunos|solaris/i SOLARIS when /darwin/ OSX else OTHER end end |
.posix? ⇒ Boolean
39 40 41 42 43 |
# File 'lib/tdriver/util/common/environment.rb', line 39 def self.posix? ( platform == LINUX || platform == OSX || platform == CYGWIN || platform == SOLARIS ) end |
.ruby_platform ⇒ Object
Function to retrieve platform type
returns
- String
119 120 121 122 123 |
# File 'lib/tdriver/util/common/environment.rb', line 119 def self.ruby_platform RbConfig::CONFIG[ 'target_os' ] end |
.solaris? ⇒ Boolean
51 52 53 54 55 |
# File 'lib/tdriver/util/common/environment.rb', line 51 def self.solaris? platform == SOLARIS end |
.unknown_os? ⇒ Boolean
75 76 77 78 79 |
# File 'lib/tdriver/util/common/environment.rb', line 75 def self.unknown_os? platform == UNKNOWN end |
.user_group(name = nil) ⇒ Object
linux
132 133 134 135 136 |
# File 'lib/tdriver/util/common/environment.rb', line 132 def self.user_group( name = nil ) `id -g -n #{ name }`.chomp if MobyUtil::EnvironmentHelper.posix? end |
.user_name ⇒ Object
linux
139 140 141 142 143 144 145 146 147 |
# File 'lib/tdriver/util/common/environment.rb', line 139 def self.user_name result = ENV[ 'LOGNAME' ] result = ENV[ 'SUDO_USER' ] if result == "root" || result == "" result = ENV[ 'USER' ] if result == "root" || result == "" result end |
.windows? ⇒ Boolean
63 64 65 66 67 |
# File 'lib/tdriver/util/common/environment.rb', line 63 def self.windows? platform == WINDOWS end |