Module: FastlaneCore::Helper

Defined in:
lib/fastlane_core/helper.rb

Class Method Summary collapse

Class Method Details

.fastlane_enabled?Boolean

Returns:

  • (Boolean)


58
59
60
61
# File 'lib/fastlane_core/helper.rb', line 58

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)



64
65
66
67
68
69
70
# File 'lib/fastlane_core/helper.rb', line 64

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_test?Boolean

Use Helper.test? instead

Returns:

  • (Boolean)


42
43
44
# File 'lib/fastlane_core/helper.rb', line 42

def self.is_test?
  self.test?
end

.logObject

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
# 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')}]: "
    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

.test?Boolean

Returns true if the currently running program is a unit test.

Returns:

  • (Boolean)

    true if the currently running program is a unit test



37
38
39
# File 'lib/fastlane_core/helper.rb', line 37

def self.test?
  defined?SpecHelper
end

.transporter_pathObject

Returns the full path to the iTMSTransporter executable.

Returns:

  • the full path to the iTMSTransporter executable



54
55
56
# File 'lib/fastlane_core/helper.rb', line 54

def self.transporter_path
  self.xcode_path + '../Applications/Application\ Loader.app/Contents/MacOS/itms/bin/iTMSTransporter'
end

.xcode_pathObject

Returns the full path to the Xcode developer tools of the currently running system.

Returns:

  • the full path to the Xcode developer tools of the currently running system



48
49
50
51
# File 'lib/fastlane_core/helper.rb', line 48

def self.xcode_path
  return "" if self.is_test? and not OS.mac?
  `xcode-select -p`.gsub("\n", '') + "/"
end