Class: SimulatorRecorder
- Defined in:
- lib/capa/simulator_recorder.rb
Instance Method Summary collapse
- #can_record? ⇒ Boolean
- #cancel ⇒ Object
-
#initialize(filename: '') ⇒ SimulatorRecorder
constructor
A new instance of SimulatorRecorder.
- #record ⇒ Object
Constructor Details
#initialize(filename: '') ⇒ SimulatorRecorder
Returns a new instance of SimulatorRecorder.
5 6 7 8 |
# File 'lib/capa/simulator_recorder.rb', line 5 def initialize(filename: '') abort('Please provide a name for the video') if filename.blank? @filename = filename end |
Instance Method Details
#can_record? ⇒ Boolean
31 32 33 34 35 36 |
# File 'lib/capa/simulator_recorder.rb', line 31 def can_record? return false if command?('xcrun') == false # Will output 'No devices are booted.' if Simulator.app is closed `xcrun simctl io booted enumerate > /dev/null 2>&1` $?.exitstatus == 0 end |
#cancel ⇒ Object
25 26 27 28 29 |
# File 'lib/capa/simulator_recorder.rb', line 25 def cancel if system('pgrep simctl > /dev/null') `killall simctl` end end |
#record ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/capa/simulator_recorder.rb', line 10 def record abort("You need to open the iOS Simulator") unless can_record? Signal.trap("SIGINT") { raise Capa::UserAbort } Signal.trap("SIGTSTP") { raise Capa::UserAbort } Thread.new do `xcrun simctl io booted recordVideo #{@filename}` end puts 'Capturing video from the iOS Simulator... Press ENTER to save' p = gets.chomp `killall -SIGINT simctl` end |