Module: U3dCore::Helper
- Defined in:
- lib/u3d_core/helper.rb
Class Method Summary collapse
-
.backticks(command, print: true) ⇒ Object
Runs a given command using backticks (‘) and prints them out using the UI.command method.
-
.bundler? ⇒ boolean
True if executing with bundler (like ‘bundle exec fastlane [action]’).
-
.ci? ⇒ boolean
True if building in a known CI environment.
-
.colors_disabled? ⇒ Boolean
Do we want to disable the colored output?.
-
.contained_fastlane? ⇒ Boolean
Do we run from a bundled fastlane, which contains Ruby and OpenSSL? Usually this means the fastlane directory is ~/.fastlane/bin/ We set this value via the environment variable ‘FASTLANE_SELF_CONTAINED`.
-
.homebrew? ⇒ Boolean
returns true if fastlane was installed via Homebrew.
-
.is_test? ⇒ Boolean
True if the currently running program is a unit test.
-
.iterm? ⇒ Boolean
Does the user use iTerm?.
- .linux? ⇒ Boolean
-
.mac? ⇒ Boolean
Is the currently running computer a Mac?.
-
.mac_app? ⇒ Boolean
returns true if fastlane was installed from the Fabric Mac app.
-
.mac_stock_terminal? ⇒ Boolean
Does the user use the Mac stock terminal.
-
.operating_system ⇒ Object
the current operating system.
-
.operating_systems ⇒ Object
the valid operating systems.
-
.rubygems? ⇒ Boolean
returns true if fastlane was installed via RubyGems.
-
.strip_ansi_colors(str) ⇒ Object
removes ANSI colors from string.
- .win_32? ⇒ Boolean
- .win_64? ⇒ Boolean
- .windows? ⇒ Boolean
Class Method Details
.backticks(command, print: true) ⇒ Object
Runs a given command using backticks (‘) and prints them out using the UI.command method
31 32 33 34 35 36 |
# File 'lib/u3d_core/helper.rb', line 31 def self.backticks(command, print: true) UI.command(command) if print result = `#{command}` UI.command_output(result) if print return result end |
.bundler? ⇒ boolean
Returns true if executing with bundler (like ‘bundle exec fastlane [action]’).
49 50 51 52 53 54 55 |
# File 'lib/u3d_core/helper.rb', line 49 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? ⇒ boolean
Returns true if building in a known CI environment.
80 81 82 83 84 85 86 |
# File 'lib/u3d_core/helper.rb', line 80 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? ⇒ Boolean
Do we want to disable the colored output?
129 130 131 |
# File 'lib/u3d_core/helper.rb', line 129 def self.colors_disabled? ENV["U3D_DISABLE_COLORS"] end |
.contained_fastlane? ⇒ Boolean
Do we run from a bundled fastlane, which contains Ruby and OpenSSL? Usually this means the fastlane directory is ~/.fastlane/bin/ We set this value via the environment variable ‘FASTLANE_SELF_CONTAINED`
60 61 62 |
# File 'lib/u3d_core/helper.rb', line 60 def self.contained_fastlane? ENV["FASTLANE_SELF_CONTAINED"].to_s == "true" && !homebrew? end |
.homebrew? ⇒ Boolean
returns true if fastlane was installed via Homebrew
70 71 72 |
# File 'lib/u3d_core/helper.rb', line 70 def self.homebrew? ENV["FASTLANE_INSTALLED_VIA_HOMEBREW"].to_s == "true" end |
.is_test? ⇒ Boolean
Returns true if the currently running program is a unit test.
39 40 41 |
# File 'lib/u3d_core/helper.rb', line 39 def self.is_test? defined? SpecHelper end |
.iterm? ⇒ Boolean
Does the user use iTerm?
139 140 141 |
# File 'lib/u3d_core/helper.rb', line 139 def self.iterm? !!ENV["ITERM_SESSION_ID"] end |
.linux? ⇒ Boolean
93 94 95 |
# File 'lib/u3d_core/helper.rb', line 93 def self.linux? (/linux/ =~ RUBY_PLATFORM) != nil end |
.mac? ⇒ Boolean
Is the currently running computer a Mac?
98 99 100 |
# File 'lib/u3d_core/helper.rb', line 98 def self.mac? (/darwin/ =~ RUBY_PLATFORM) != nil end |
.mac_app? ⇒ Boolean
returns true if fastlane was installed from the Fabric Mac app
65 66 67 |
# File 'lib/u3d_core/helper.rb', line 65 def self.mac_app? ENV["FASTLANE_SELF_CONTAINED"].to_s == "false" end |
.mac_stock_terminal? ⇒ Boolean
Does the user use the Mac stock terminal
134 135 136 |
# File 'lib/u3d_core/helper.rb', line 134 def self.mac_stock_terminal? !!ENV["TERM_PROGRAM_VERSION"] end |
.operating_system ⇒ Object
the current operating system
108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/u3d_core/helper.rb', line 108 def self. 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 end |
.operating_systems ⇒ Object
the valid operating systems
103 104 105 |
# File 'lib/u3d_core/helper.rb', line 103 def self. [:linux, :mac, :win] end |
.rubygems? ⇒ Boolean
returns true if fastlane was installed via RubyGems
75 76 77 |
# File 'lib/u3d_core/helper.rb', line 75 def self.rubygems? !bundler? && !contained_fastlane? && !homebrew? && !mac_app? end |
.strip_ansi_colors(str) ⇒ Object
removes ANSI colors from string
44 45 46 |
# File 'lib/u3d_core/helper.rb', line 44 def self.strip_ansi_colors(str) str.gsub(/\e\[([;\d]+)?m/, '') end |
.win_32? ⇒ Boolean
124 125 126 |
# File 'lib/u3d_core/helper.rb', line 124 def self.win_32? (/i386/ =~ RUBY_PLATFORM) != nil end |
.win_64? ⇒ Boolean
120 121 122 |
# File 'lib/u3d_core/helper.rb', line 120 def self.win_64? (/x64/ =~ RUBY_PLATFORM) != nil end |
.windows? ⇒ Boolean
88 89 90 91 |
# File 'lib/u3d_core/helper.rb', line 88 def self.windows? # taken from: http://stackoverflow.com/a/171011/1945875 (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil end |