lib/calabash-cucumber/utils/xctools.rb in calabash-cucumber-0.10.0 vs lib/calabash-cucumber/utils/xctools.rb in calabash-cucumber-0.10.1
- old
+ new
@@ -1,6 +1,7 @@
require 'open3'
+require 'run_loop'
module Calabash
module Cucumber
# @!visibility private
@@ -19,14 +20,11 @@
# directory.
#```
#
# @return [String] path to current developer directory
def xcode_developer_dir
- # respect DEVELOPER_DIR
- return ENV['DEVELOPER_DIR'] if ENV['DEVELOPER_DIR']
- # fall back to xcode-select
- `xcode-select --print-path`.chomp
+ RunLoop::XCTools.new.xcode_developer_dir
end
# @deprecated 0.10.0 not replaced
# Returns the path to the current developer `usr/bin` directory.
# @return [String] path to the current xcode binaries
@@ -52,21 +50,15 @@
# simulators, or the path to the instruments binary
# @raise [ArgumentError] if invalid +cmd+ is passed
def instruments(cmd=nil)
instruments = 'xcrun instruments'
return instruments if cmd == nil
-
case cmd
when :version
- # instruments, version 5.1.1 (55045)
- # noinspection RubyUnusedLocalVariable
- Open3.popen3("#{instruments}") do |stdin, stdout, stderr, wait_thr|
- stderr.read.chomp.split(' ')[2]
- end
+ RunLoop::XCTools.new.instruments(cmd).to_s
when :sims
- devices = `#{instruments} -s devices`.chomp.split("\n")
- devices.select { |device| device.downcase.include?('simulator') }
+ RunLoop::XCTools.new.instruments(cmd)
else
candidates = [:version, :sims]
raise(ArgumentError, "expected '#{cmd}' to be one of '#{candidates}'")
end
end
@@ -80,28 +72,21 @@
#
# @param [String] version (instruments(:version))
# a major.minor[.patch] version string
#
# @return [Boolean] true if the version is >= 5.*
- def instruments_supports_hyphen_s?(version=instruments(:version))
- tokens = version.split('.')
- return false if tokens[0].to_i < 5
- return false if tokens[1].to_i < 1
- true
+ def instruments_supports_hyphen_s?(version)
+ RunLoop::XCTools.new.instruments_supports_hyphen_s?(version)
end
# Returns a list of installed simulators by calling `$ instruments -s devices`.
# and parsing the output
# @return [Array<String>] an array of simulator names suitable for passing
# to instruments or xcodebuild
# @raise [RuntimeError] if the currently active instruments version does
# not support the -s flag
def installed_simulators
- unless instruments_supports_hyphen_s?
- raise(RuntimeError, "instruments '#{instruments(:version)}' does not support '-s devices' arguments")
- end
instruments(:sims)
end
-
end
end
-end
\ No newline at end of file
+end