Module: FastlaneCore::Helper
- Defined in:
- lib/fastlane_core/helper.rb
Class Method Summary collapse
- .fastlane_enabled? ⇒ Boolean
-
.gem_path(gem_name) ⇒ Object
Path to the installed gem to load resources (e.g. resign.sh).
-
.is_ci? ⇒ Boolean
True if building in a known CI environment.
-
.is_mac? ⇒ Boolean
Is the currently running computer a Mac?.
-
.is_test? ⇒ Boolean
Use Helper.test? instead.
-
.log ⇒ Object
Logging happens using this method.
-
.log_alert(text) ⇒ Object
This method can be used to add nice lines around the actual log Use this to log more important things The logs will be green automatically.
-
.test? ⇒ Boolean
True if the currently running program is a unit test.
-
.transporter_path ⇒ Object
The full path to the iTMSTransporter executable.
-
.xcode_path ⇒ Object
The full path to the Xcode developer tools of the currently running system.
Class Method Details
.fastlane_enabled? ⇒ Boolean
89 90 91 92 |
# File 'lib/fastlane_core/helper.rb', line 89 def self.fastlane_enabled? # This is called from the root context on the first start @@enabled ||= File.directory?"./fastlane" end |
.gem_path(gem_name) ⇒ Object
Path to the installed gem to load resources (e.g. resign.sh)
95 96 97 98 99 100 101 |
# File 'lib/fastlane_core/helper.rb', line 95 def self.gem_path(gem_name) if not Helper.is_test? and Gem::Specification::find_all_by_name(gem_name).any? return Gem::Specification.find_by_name(gem_name).gem_dir else return './' end end |
.is_ci? ⇒ Boolean
58 59 60 61 |
# File 'lib/fastlane_core/helper.rb', line 58 def self.is_ci? # Check for Jenkins, Travis CI, ... environment variables ENV.has_key?("JENKINS_URL") || ENV.has_key?("TRAVIS") || ENV.has_key?("CIRCLECI") || ENV.has_key?("CI") end |
.is_mac? ⇒ Boolean
Is the currently running computer a Mac?
71 72 73 |
# File 'lib/fastlane_core/helper.rb', line 71 def self.is_mac? (/darwin/ =~ RUBY_PLATFORM) != nil end |
.is_test? ⇒ Boolean
Use Helper.test? instead
53 54 55 |
# File 'lib/fastlane_core/helper.rb', line 53 def self.is_test? self.test? end |
.log ⇒ Object
Logging happens using this method
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fastlane_core/helper.rb', line 7 def self.log if is_test? @@log ||= Logger.new(nil) # don't show any logs when running tests else @@log ||= Logger.new(STDOUT) end @@log.formatter = proc do |severity, datetime, progname, msg| string = "#{severity} [#{datetime.strftime('%Y-%m-%d %H:%M:%S.%2N')}]: " if $verbose string = "[#{datetime.strftime('%H:%M:%S')}]: " unless $verbose second = "#{msg}\n" if severity == "DEBUG" string = string.magenta elsif severity == "INFO" string = string.white elsif severity == "WARN" string = string.yellow elsif severity == "ERROR" string = string.red elsif severity == "FATAL" string = string.red.bold end [string, second].join("") end @@log end |
.log_alert(text) ⇒ Object
This method can be used to add nice lines around the actual log Use this to log more important things The logs will be green automatically
40 41 42 43 44 45 |
# File 'lib/fastlane_core/helper.rb', line 40 def self.log_alert(text) i = text.length + 8 Helper.log.info(("-" * i).green) Helper.log.info("--- ".green + text.green + " ---".green) Helper.log.info(("-" * i).green) end |
.test? ⇒ Boolean
48 49 50 |
# File 'lib/fastlane_core/helper.rb', line 48 def self.test? defined?SpecHelper end |
.transporter_path ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/fastlane_core/helper.rb', line 76 def self.transporter_path return '' unless self.is_mac? # so tests work on Linx too [ "../Applications/Application Loader.app/Contents/MacOS/itms/bin/iTMSTransporter", "../Applications/Application Loader.app/Contents/itms/bin/iTMSTransporter" ].each do |path| result = File.join(self.xcode_path, path) return result if File.exists?(result) end raise "Could not find transporter at #{self.xcode_path}. Please make sure you set the correct path to your Xcode installation.".red end |
.xcode_path ⇒ Object
65 66 67 68 |
# File 'lib/fastlane_core/helper.rb', line 65 def self.xcode_path return "" if self.is_test? and not self.is_mac? `xcode-select -p`.gsub("\n", '') + "/" end |