-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
70 lines (56 loc) · 1.37 KB
/
Rakefile
1
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#
# Rakefile
#
# Created by Natalia Osiecka on 29.3.2015.
# Copyright (c) 2015 iOskApps. All rights reserved.
#
require "json"
require "net/http"
require "uri"
### TASKS
desc "Install project dependencies"
task "install" do
sh "pod install --no-integrate"
end
desc "Run the unit tests"
task "test-unit" do
xcode_run "clean test", ENV["XCODE_SCHEME"]
end
### BUILD AND RUN
def scheme_config scheme
{
"workspace" => ENV["XCODE_WORKSPACE"],
"scheme" => scheme,
"destination" => "'platform=iOS Simulator,name=iPhone 5s,OS=8.1'",
"sdk" => ENV["XCODE_SDK"]
}
end
def xcodebuild_flags hash
hash.map do |key, value|
"-#{key} #{value}"
end.join " "
end
def xcode_run (action, scheme)
flags = xcodebuild_flags(scheme_config(scheme))
sh "xcodebuild #{flags} #{action} | xcpretty -c ; exit ${PIPESTATUS[0]}" rescue nil
report_failure "Scheme '#{scheme}' failed to '#{action}'.", $?.exitstatus unless $?.success?
end
### REPORTING
def report_success(message)
report_common message, 2
end
def report_info(message)
report_common message, 3
end
def report_error(message)
report_common message, 1
end
def report_failure(message, status = 1)
report_error message
exit status
end
def report_common(message, color)
color_formatter = `tput setaf #{color}`
reset_formatter = `tput sgr 0`
puts "#{color_formatter}#{message}#{reset_formatter}\n"
end