Module: Luffa
- Defined in:
- lib/luffa/gem.rb,
lib/luffa/retry.rb,
lib/luffa/cli/cli.rb,
lib/luffa/logging.rb,
lib/luffa/version.rb,
lib/luffa/ios/xcode.rb,
lib/luffa/environment.rb,
lib/luffa/unix_command.rb,
lib/luffa/ios/simulator.rb,
lib/luffa/with_debugging.rb,
lib/luffa/patches/retriable.rb,
lib/luffa/ios/ideviceinstaller.rb
Defined Under Namespace
Modules: Debug, Environment
Classes: CLI, Gem, IDeviceInstaller, Retry, RetryOpts, Simulator, ValidationError, Version, Xcode, XcodeInstall
Constant Summary
collapse
- VERSION =
'1.0.6'
Class Method Summary
collapse
Class Method Details
.log_fail(msg) ⇒ Object
14
15
16
|
# File 'lib/luffa/logging.rb', line 14
def self.log_fail(msg)
puts "\033[31mFAIL: #{msg}\033[0m" if msg
end
|
.log_info(msg) ⇒ Object
18
19
20
|
# File 'lib/luffa/logging.rb', line 18
def self.log_info(msg)
puts "\033[35mINFO: #{msg}\033[0m" if msg
end
|
.log_pass(msg) ⇒ Object
6
7
8
|
# File 'lib/luffa/logging.rb', line 6
def self.log_pass(msg)
puts "\033[32mPASS: #{msg}\033[0m" if msg
end
|
.log_unix_cmd(msg) ⇒ Object
2
3
4
|
# File 'lib/luffa/logging.rb', line 2
def self.log_unix_cmd(msg)
puts "\033[36mEXEC: #{msg}\033[0m" if msg
end
|
.log_warn(msg) ⇒ Object
10
11
12
|
# File 'lib/luffa/logging.rb', line 10
def self.log_warn(msg)
puts "\033[34mWARN: #{msg}\033[0m"
end
|
.unix_command(cmd, opts = {}) ⇒ Object
2
3
4
5
6
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
36
37
38
39
40
41
42
|
# File 'lib/luffa/unix_command.rb', line 2
def self.unix_command(cmd, opts={})
default_opts = {:pass_msg => nil,
:fail_msg => nil,
:exit_on_nonzero_status => true,
:env_vars => {},
:log_cmd => true,
:obscure_fields => []}
merged_opts = default_opts.merge(opts)
obscure_fields = merged_opts[:obscure_fields]
if not obscure_fields.empty? and merged_opts[:log_cmd]
obscured = cmd.split(' ').map do |token|
if obscure_fields.include? token
"#{token[0,1]}***#{token[token.length-1,1]}"
else
token
end
end
Luffa.log_unix_cmd obscured.join(' ')
elsif merged_opts[:log_cmd]
Luffa.log_unix_cmd cmd
end
exit_on_err = merged_opts[:exit_on_nonzero_status]
unless exit_on_err
system 'set +e'
end
env_vars = merged_opts[:env_vars]
res = system(env_vars, cmd)
exit_code = $?.exitstatus
if res
Luffa.log_pass merged_opts[:pass_msg]
else
Luffa.log_fail merged_opts[:fail_msg]
exit exit_code if exit_on_err
end
system 'set -e'
exit_code
end
|