Class: RunLoop::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/run_loop/environment.rb

Class Method Summary collapse

Class Method Details

.bundle_idObject

Returns the value of BUNDLE_ID



57
58
59
60
61
62
63
64
# File 'lib/run_loop/environment.rb', line 57

def self.bundle_id
  value = ENV['BUNDLE_ID']
  if !value || value == ''
    nil
  else
    value
  end
end

.ci?Boolean

Returns true if running in a CI environment

Returns:

  • (Boolean)


134
135
136
137
138
139
140
141
142
143
# File 'lib/run_loop/environment.rb', line 134

def self.ci?
  [
    self.ci_var_defined?,
    self.travis?,
    self.jenkins?,
    self.circle_ci?,
    self.teamcity?,
    self.gitlab?
  ].any?
end

.circle_ci?Boolean

Returns true if running in Circle CI

Checks the value of CIRCLECI

Returns:

  • (Boolean)


112
113
114
115
# File 'lib/run_loop/environment.rb', line 112

def self.circle_ci?
  value = ENV["CIRCLECI"]
  !!value && value != ''
end

.debug?Boolean

Returns true if debugging is enabled.

Returns:

  • (Boolean)


17
18
19
# File 'lib/run_loop/environment.rb', line 17

def self.debug?
  ENV['DEBUG'] == '1'
end

.debug_read?Boolean

Returns true if read debugging is enabled.

Returns:

  • (Boolean)


22
23
24
# File 'lib/run_loop/environment.rb', line 22

def self.debug_read?
  ENV['DEBUG_READ'] == '1'
end

.developer_dirObject

Note:

Never call this directly. Always create an Xcode instance and allow it to derive the path to the Xcode toolchain.

Returns the value of DEVELOPER_DIR



84
85
86
87
88
89
90
91
# File 'lib/run_loop/environment.rb', line 84

def self.developer_dir
  value = ENV['DEVELOPER_DIR']
  if !value || value == ''
    nil
  else
    value
  end
end

.device_endpointObject

Returns the value of DEVICE_ENDPOINT



37
38
39
# File 'lib/run_loop/environment.rb', line 37

def self.device_endpoint
  ENV["DEVICE_ENDPOINT"]
end

.device_targetObject

Returns the value of DEVICE_TARGET



32
33
34
# File 'lib/run_loop/environment.rb', line 32

def self.device_target
  ENV["DEVICE_TARGET"]
end

.gitlab?Boolean

Returns true if running in Teamcity

Checks the value of GITLAB_CI

Returns:

  • (Boolean)


128
129
130
131
# File 'lib/run_loop/environment.rb', line 128

def self.gitlab?
  value = ENV["GITLAB_CI"]
  !!value && value != ''
end

.jenkins?Boolean

Returns true if running in Jenkins CI

Checks the value of JENKINS_HOME

Returns:

  • (Boolean)


96
97
98
99
# File 'lib/run_loop/environment.rb', line 96

def self.jenkins?
  value = ENV["JENKINS_HOME"]
  !!value && value != ''
end

.path_to_app_bundleObject

Returns to the path to the app bundle (simulator builds).

Both APP_BUNDLE_PATH and APP are checked and in that order.

Use of APP_BUNDLE_PATH is deprecated and will be removed.



71
72
73
74
75
76
77
78
# File 'lib/run_loop/environment.rb', line 71

def self.path_to_app_bundle
  value = ENV['APP_BUNDLE_PATH'] || ENV['APP']
  if !value || value == ''
    nil
  else
    File.expand_path(value)
  end
end

.teamcity?Boolean

Returns true if running in Teamcity

Checks the value of TEAMCITY_PROJECT_NAME

Returns:

  • (Boolean)


120
121
122
123
# File 'lib/run_loop/environment.rb', line 120

def self.teamcity?
  value = ENV["TEAMCITY_PROJECT_NAME"]
  !!value && value != ''
end

.trace_templateObject

Returns the value of TRACE_TEMPLATE; the Instruments template to use during testing.



43
44
45
# File 'lib/run_loop/environment.rb', line 43

def self.trace_template
  ENV['TRACE_TEMPLATE']
end

.travis?Boolean

Returns true if running in Travis CI

Checks the value of TRAVIS

Returns:

  • (Boolean)


104
105
106
107
# File 'lib/run_loop/environment.rb', line 104

def self.travis?
  value = ENV["TRAVIS"]
  !!value && value != ''
end

.uia_timeoutObject

Returns the value of UIA_TIMEOUT. Use this control how long to wait for instruments to launch and attach to your application.

Non-empty values are converted to a float.



51
52
53
54
# File 'lib/run_loop/environment.rb', line 51

def self.uia_timeout
  timeout = ENV['UIA_TIMEOUT']
  timeout ? timeout.to_f : nil
end

.user_home_directoryObject

Returns the user home directory



5
6
7
8
9
10
11
12
13
14
# File 'lib/run_loop/environment.rb', line 5

def self.user_home_directory
  if self.xtc?
     home = File.join("./", "tmp", "home")
     FileUtils.mkdir_p(home)
     home
  else
    require 'etc'
    Etc.getpwuid.dir
  end
end

.with_debugging(debug, &block) ⇒ Object

!@visibility private



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/run_loop/environment.rb', line 146

def self.with_debugging(debug, &block)
  if debug
    original_value = ENV['DEBUG']

    begin
      ENV['DEBUG'] = '1'
      block.call
    ensure
      ENV['DEBUG'] = original_value
    end

  else
    block.call
  end
end

.xtc?Boolean

Returns true if we are running on the XTC

Returns:

  • (Boolean)


27
28
29
# File 'lib/run_loop/environment.rb', line 27

def self.xtc?
  ENV['XAMARIN_TEST_CLOUD'] == '1'
end