Class: RunLoop::Environment

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

Class Method Summary collapse

Class Method Details

.azurepipelines?Boolean

Returns:

  • (Boolean)


300
301
302
303
# File 'lib/run_loop/environment.rb', line 300

def self.azurepipelines?
  value = ENV["AGENT_VERSION"]
  !!value && value != ''
end

.bundle_idObject

Returns the value of BUNDLE_ID



138
139
140
141
142
143
144
145
# File 'lib/run_loop/environment.rb', line 138

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

.cbxdeviceObject

Returns the value of CBXDEVICE

Use this to specify a non-default CBX-Runner for physical devices.

The default CBX-Runner is bundled with this gem.



227
228
229
230
231
232
233
234
# File 'lib/run_loop/environment.rb', line 227

def self.cbxdevice
  value = ENV["CBXDEVICE"]
  if !value || value == ""
    nil
  else
    value
  end
end

.cbxsimObject

Returns the value of CBXSIM

Use this to specify a non-default CBX-Runner for simulators.

The default CBX-Runner is bundled with this gem.



241
242
243
244
245
246
247
248
# File 'lib/run_loop/environment.rb', line 241

def self.cbxsim
  value = ENV["CBXSIM"]
  if !value || value == ""
    nil
  else
    value
  end
end

.ci?Boolean

Returns true if running in a CI environment

Returns:

  • (Boolean)


306
307
308
309
310
311
312
313
314
315
316
# File 'lib/run_loop/environment.rb', line 306

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

.circle_ci?Boolean

Returns true if running in Circle CI

Checks the value of CIRCLECI

Returns:

  • (Boolean)


279
280
281
282
# File 'lib/run_loop/environment.rb', line 279

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

.code_sign_identityObject

Returns the value of CODE_SIGN_IDENTITY



175
176
177
178
179
180
181
182
# File 'lib/run_loop/environment.rb', line 175

def self.code_sign_identity
  value = ENV["CODE_SIGN_IDENTITY"]
  if !value || value == ""
    nil
  else
    value
  end
end

.debug?Boolean

Returns true if debugging is enabled.

Returns:

  • (Boolean)


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

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

.debug_read?Boolean

Returns true if read debugging is enabled.

Returns:

  • (Boolean)


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

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

.derived_dataObject

Returns the value of DERIVED_DATA which can be used to specify an alternative DerivedData directory.

The default is ~/Library/Xcode/DerivedData, but Xcode allows you to change this value.



94
95
96
97
98
99
100
101
# File 'lib/run_loop/environment.rb', line 94

def self.derived_data
  value = ENV["DERIVED_DATA"]
  if value.nil? || value == ""
    nil
  else
    File.expand_path(value)
  end
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



165
166
167
168
169
170
171
172
# File 'lib/run_loop/environment.rb', line 165

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

.device_agent_urlObject

Returns the value of DEVICE_ENDPOINT



251
252
253
254
255
256
257
258
# File 'lib/run_loop/environment.rb', line 251

def self.device_agent_url
  value = ENV["DEVICE_AGENT_URL"]
  if value.nil? || value == ""
    nil
  else
    value
  end
end

.device_endpointObject

Returns the value of DEVICE_ENDPOINT



51
52
53
54
55
56
57
58
# File 'lib/run_loop/environment.rb', line 51

def self.device_endpoint
  value = ENV["DEVICE_ENDPOINT"]
  if value.nil? || value == ""
    nil
  else
    value
  end
end

.device_targetObject

Returns the value of DEVICE_TARGET



41
42
43
44
45
46
47
48
# File 'lib/run_loop/environment.rb', line 41

def self.device_target
  value = ENV["DEVICE_TARGET"]
  if value.nil? || value == ""
    nil
  else
    value
  end
end

.gitlab?Boolean

Returns true if running in Teamcity

Checks the value of GITLAB_CI

Returns:

  • (Boolean)


295
296
297
298
# File 'lib/run_loop/environment.rb', line 295

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

.ios_device_managerObject

Returns the value of IOS_DEVICE_MANAGER

Use this to specify a non-default ios_device_manager binary.

The default ios_device_manager binary is bundled with this gem.



213
214
215
216
217
218
219
220
# File 'lib/run_loop/environment.rb', line 213

def self.ios_device_manager
  value = ENV["IOS_DEVICE_MANAGER"]
  if !value || value == ""
    nil
  else
    value
  end
end

.jenkins?Boolean

Returns true if running in Jenkins CI

Checks the value of JENKINS_HOME

Returns:

  • (Boolean)


263
264
265
266
# File 'lib/run_loop/environment.rb', line 263

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

.keychainObject

Returns the value of KEYCHAIN

Use this to specify a non-default KEYCHAIN for code signing.

The default KEYCHAIN is login.keychain.



199
200
201
202
203
204
205
206
# File 'lib/run_loop/environment.rb', line 199

def self.keychain
  value = ENV["KEYCHAIN"]
  if !value || value == ""
    nil
  else
    value
  end
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.



152
153
154
155
156
157
158
159
# File 'lib/run_loop/environment.rb', line 152

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

.portObject



60
61
62
63
64
65
66
67
# File 'lib/run_loop/environment.rb', line 60

def self.port
  value = ENV["CBX_SERVER_PORT"]
  if value.nil? || value == ""
    27753
  else
    value
  end
end

.provisioning_profileObject

Returns the value of PROVISIONING_PROFILE



185
186
187
188
189
190
191
192
# File 'lib/run_loop/environment.rb', line 185

def self.provisioning_profile
  value = ENV["PROVISIONING_PROFILE"]
  if !value || value == ""
    nil
  else
    value
  end
end

.reset_between_scenarios?Boolean

Should the app data be reset between Scenarios?

Returns:

  • (Boolean)


70
71
72
# File 'lib/run_loop/environment.rb', line 70

def self.reset_between_scenarios?
  ENV["RESET_BETWEEN_SCENARIOS"] == "1"
end

.solutionObject

Returns the value of SOLUTION which can be used to specify a Xamarin Studio .sln

This is useful if your project has multiple solutions (.sln) and Calabash cannot detect the correct one.



108
109
110
111
112
113
114
115
# File 'lib/run_loop/environment.rb', line 108

def self.solution
  value = ENV["SOLUTION"]
  if value.nil? || 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)


287
288
289
290
# File 'lib/run_loop/environment.rb', line 287

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.



119
120
121
122
123
124
125
126
# File 'lib/run_loop/environment.rb', line 119

def self.trace_template
  value = ENV['TRACE_TEMPLATE']
  if value.nil? || value == ""
    nil
  else
    File.expand_path(value)
  end
end

.travis?Boolean

Returns true if running in Travis CI

Checks the value of TRAVIS

Returns:

  • (Boolean)


271
272
273
274
# File 'lib/run_loop/environment.rb', line 271

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.



132
133
134
135
# File 'lib/run_loop/environment.rb', line 132

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

.windows_env?Boolean

Returns true if Windows environment

Returns:

  • (Boolean)


17
18
19
20
21
22
23
# File 'lib/run_loop/environment.rb', line 17

def self.windows_env?
  if @@windows_env.nil?
    @@windows_env = Environment.host_os_is_win?
  end

  @@windows_env
end

.with_debugging(debug, &block) ⇒ Object

!@visibility private



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/run_loop/environment.rb', line 319

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

.xcodeprojObject

Returns the value of XCODEPROJ which can be used to specify an Xcode project directory (my.xcodeproj).

This is useful if your project has multiple xcodeproj directories.

Most users should not set this variable.



80
81
82
83
84
85
86
87
# File 'lib/run_loop/environment.rb', line 80

def self.xcodeproj
  value = ENV["XCODEPROJ"]
  if value.nil? || value == ""
    nil
  else
    File.expand_path(value)
  end
end

.xtc?Boolean

Returns true if we are running on the XTC

Returns:

  • (Boolean)


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

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