module U3dCore::Helper
Constants
- DEFAULT_LINUX_PATH
- DEFAULT_MAC_PATH
- DEFAULT_WINDOWS_PATH
Public Class Methods
backticks(command, print: true)
click to toggle source
Runs a given command using backticks (`) and prints them out using the UI.command method
# File lib/u3d_core/helper.rb, line 50 def self.backticks(command, print: true) UI.command(command) if print result = `#{command}` UI.command_output(result) if print return result end
bundler?()
click to toggle source
@return [boolean] true if executing with bundler (like 'bundle exec fastlane [action]')
# File lib/u3d_core/helper.rb, line 68 def self.bundler? # Bundler environment variable %w[BUNDLE_BIN_PATH BUNDLE_GEMFILE].each do |current| return true if ENV.key?(current) end return false end
ci?()
click to toggle source
@return [boolean] true if building in a known CI environment
# File lib/u3d_core/helper.rb, line 77 def self.ci? # Check for Jenkins, Travis CI, ... environment variables %w[JENKINS_HOME JENKINS_URL TRAVIS CIRCLECI CI TEAMCITY_VERSION GO_PIPELINE_NAME bamboo_buildKey GITLAB_CI XCS].each do |current| return true if ENV.key?(current) end return false end
colors_disabled?()
click to toggle source
Do we want to disable the colored output?
# File lib/u3d_core/helper.rb, line 137 def self.colors_disabled? ENV["U3D_DISABLE_COLORS"] end
data_path()
click to toggle source
# File lib/u3d_core/helper.rb, line 33 def self.data_path case operating_system when :linux DEFAULT_LINUX_PATH when :mac DEFAULT_MAC_PATH when :win DEFAULT_WINDOWS_PATH end end
iterm?()
click to toggle source
Does the user use iTerm?
# File lib/u3d_core/helper.rb, line 147 def self.iterm? !ENV["ITERM_SESSION_ID"].nil? end
linux?()
click to toggle source
# File lib/u3d_core/helper.rb, line 90 def self.linux? (/linux/ =~ RUBY_PLATFORM) != nil end
mac?()
click to toggle source
Is the currently running computer a Mac?
# File lib/u3d_core/helper.rb, line 104 def self.mac? (/darwin/ =~ RUBY_PLATFORM) != nil end
mac_stock_terminal?()
click to toggle source
Does the user use the Mac stock terminal
# File lib/u3d_core/helper.rb, line 142 def self.mac_stock_terminal? !ENV["TERM_PROGRAM_VERSION"].nil? end
operating_system()
click to toggle source
the current operating system
# File lib/u3d_core/helper.rb, line 114 def self.operating_system # rubocop:disable GuardClause if linux? return :linux elsif mac? return :mac elsif windows? return :win else raise 'Could not assume what OS you\'re running, please specify it as much as possible' end # rubocop:enable GuardClause end
operating_systems()
click to toggle source
the valid operating systems
# File lib/u3d_core/helper.rb, line 109 def self.operating_systems %i[linux mac win] end
strip_ansi_colors(str)
click to toggle source
removes ANSI colors from string
# File lib/u3d_core/helper.rb, line 63 def self.strip_ansi_colors(str) str.gsub(/\e\[([;\d]+)?m/, '') end
test?()
click to toggle source
@return true if the currently running program is a unit test
# File lib/u3d_core/helper.rb, line 58 def self.test? defined? SpecHelper end
ubuntu_on_windows?()
click to toggle source
# File lib/u3d_core/helper.rb, line 94 def self.ubuntu_on_windows? # taken from: https://github.com/Microsoft/BashOnWindows/issues/423#issuecomment-221627364 proc_version = '/proc/version' return false unless File.exist? proc_version File.open(proc_version, 'r') do |f| return !(/Microsof|WSL/ =~ f.read).nil? end end
win_32?()
click to toggle source
# File lib/u3d_core/helper.rb, line 132 def self.win_32? (/i386/ =~ RUBY_PLATFORM) != nil end
win_64?()
click to toggle source
# File lib/u3d_core/helper.rb, line 128 def self.win_64? (/x64/ =~ RUBY_PLATFORM) != nil end
windows?()
click to toggle source
# File lib/u3d_core/helper.rb, line 85 def self.windows? # taken from: http://stackoverflow.com/a/171011/1945875 (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil end
windows_path(path)
click to toggle source
# File lib/u3d_core/helper.rb, line 44 def self.windows_path(path) path.gsub(%r{\/(\d)}, '/\\\\\1').tr('/', '\\') end