Class: Fourflusher::SimControl
- Inherits:
-
Object
- Object
- Fourflusher::SimControl
show all
- Extended by:
- Executable
- Defined in:
- lib/fourflusher/find.rb,
lib/fourflusher/simctl.rb,
lib/fourflusher/xcodebuild.rb
Overview
Instance Method Summary
collapse
Methods included from Executable
capture_command, executable, execute_command, which
Constructor Details
Returns a new instance of SimControl.
62
63
64
|
# File 'lib/fourflusher/find.rb', line 62
def initialize
@os_regex = /^-- (?<os_name>.*?) (?<os_version>[0-9][0-9]?\.[0-9]) --$/
end
|
Instance Method Details
#destination(filter, os = :ios, minimum_version = '1.0') ⇒ Object
6
7
8
9
10
|
# File 'lib/fourflusher/xcodebuild.rb', line 6
def destination(filter, os = :ios, minimum_version = '1.0')
sim = simulator(filter, os, minimum_version)
fail "Simulator #{filter} is not available." if sim.nil?
['-destination', "id=#{sim.id}"]
end
|
#list(args) ⇒ Object
9
10
11
|
# File 'lib/fourflusher/simctl.rb', line 9
def list(args)
simctl!(['list'] + args)
end
|
#simulator(filter, os_name = :ios, minimum_version = '1.0') ⇒ Object
66
67
68
|
# File 'lib/fourflusher/find.rb', line 66
def simulator(filter, os_name = :ios, minimum_version = '1.0')
usable_simulators(filter, os_name, minimum_version).first
end
|
#usable_simulators(filter = nil, os = :ios, minimum_version = '1.0') ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/fourflusher/find.rb', line 70
def usable_simulators(filter = nil, os = :ios, minimum_version = '1.0')
os_name = ''
os_version = ''
sims = []
list(['devices']).lines.each do |line|
@os_regex.match(line) do |m|
os_name = m['os_name']
os_version = m['os_version']
end
sims += Simulator.match(line, os_name, os_version)
end
oses = sims.map(&:os_name).uniq
os = os.downcase.to_sym
fail "Invalid OS `#{os}`, valid values are #{oses.join(', ')}" unless oses.include?(os)
return sims if filter.nil?
minimum_version = Gem::Version.new(minimum_version)
sims = sims.select { |sim| sim.os_name == os && sim.compatible?(minimum_version) }
return [sims.first] if filter == :oldest
found_sims = sims.select { |sim| sim.name == filter }
return found_sims if found_sims.count > 0
sims.select { |sim| sim.name.start_with?(filter) }
end
|