class XCListen
Constants
- IOS_DEVICES
- VERSION
Attributes
device[R]
scheme[R]
sdk[R]
workspace[R]
Public Class Methods
new(opts = {})
click to toggle source
# File lib/xclisten.rb, line 12 def initialize(opts = {}) @scheme = opts[:scheme] || project_name @sdk = opts[:sdk] || 'iphonesimulator' @workspace = opts[:workspace] || workspace_path @device = IOS_DEVICES[opts[:device]] || IOS_DEVICES['iphone5s'] end
Public Instance Methods
can_run?()
click to toggle source
# File lib/xclisten.rb, line 62 def can_run? project_name && !project_name.empty? end
install_pods()
click to toggle source
# File lib/xclisten.rb, line 42 def install_pods Dir.chdir(File.dirname(workspace)) do system 'pod install' puts 'Giving Xcode some time to index...' sleep 10 end end
listen()
click to toggle source
# File lib/xclisten.rb, line 66 def listen validate_run puts "Started xclistening to #{workspace}" ignored = [/.git/, /.xc(odeproj|workspace|userdata|scheme|config)/, /.lock$/, /\.txt$/, /\.log$/] listener = Listen.to(Dir.pwd, :ignore => ignored) do |modified, added, removed| system 'clear' if modified.first =~ /Podfile$/ install_pods else run_tests end end listener.start sleep end
project_name()
click to toggle source
# File lib/xclisten.rb, line 32 def project_name @project_name ||= File.basename(workspace_path, ".*") if workspace_path end
run_tests()
click to toggle source
# File lib/xclisten.rb, line 50 def run_tests ShellTask.run("#{xcodebuild} test 2> xcodebuild_error.log | xcpretty -tc") end
validate_run()
click to toggle source
TODO TEST THIS SPIKE
# File lib/xclisten.rb, line 55 def validate_run unless can_run? puts "[!] No xcworkspace found in this directory (or any child directories)" exit 1 end end
workspace_path()
click to toggle source
# File lib/xclisten.rb, line 28 def workspace_path @workspace_path ||= Dir.glob("**/*.xcworkspace").sort_by(&:length).first end
xcodebuild()
click to toggle source
# File lib/xclisten.rb, line 36 def xcodebuild cmd = "xcodebuild -workspace #{workspace} -scheme #{scheme} -sdk #{sdk}" cmd += " -destination 'name=#{device}'" unless @sdk == 'macosx' cmd end