Class: RokuBuilder::DeviceManager
- Inherits:
-
Object
- Object
- RokuBuilder::DeviceManager
- Defined in:
- lib/roku_builder/device_manager.rb
Instance Method Summary collapse
-
#initialize(options:, config:) ⇒ DeviceManager
constructor
A new instance of DeviceManager.
- #release_all ⇒ Object
- #release_device(device) ⇒ Object
- #reserve_device(no_lock: false) ⇒ Object
Constructor Details
#initialize(options:, config:) ⇒ DeviceManager
Returns a new instance of DeviceManager.
7 8 9 10 11 |
# File 'lib/roku_builder/device_manager.rb', line 7 def initialize(options:, config:) @config = config @options = @timeout_duration = 3600 end |
Instance Method Details
#release_all ⇒ Object
42 43 44 45 46 47 |
# File 'lib/roku_builder/device_manager.rb', line 42 def release_all all_devices.each do |device_name| device = Device.new(device_name, @config.devices[device_name]) release_device(device) end end |
#release_device(device) ⇒ Object
37 38 39 40 |
# File 'lib/roku_builder/device_manager.rb', line 37 def release_device(device) lock = lock_file(device) File.delete(lock) if File.exist?(lock) end |
#reserve_device(no_lock: false) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/roku_builder/device_manager.rb', line 13 def reserve_device(no_lock: false) = "No Devices Found" if @options[:device] device = Device.new(@options[:device], @config.raw[:devices][@options[:device].to_sym]) return device if device_available!(device: device, no_lock: no_lock) = "Device #{@options[:device]} not found" else begin Timeout::timeout(@timeout_duration) do loop do device = reserve_any(no_lock: no_lock) if device Logger.instance.info "Using Device: #{device.to_s}" return device end break unless @options[:device_blocking] end end rescue Timeout::Error end end raise DeviceError, end |