Method: RokuBuilder.check_devices

Defined in:
lib/roku_builder.rb

.check_devicesObject



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/roku_builder.rb', line 166

def self.check_devices
  if @@options.device_command?
    ping = Net::Ping::External.new
    host = @@config.parsed[:device_config][:ip]
    return if ping.ping? host, 1, 0.2, 1
    raise DeviceError, "Device not online" if @@options[:device_given]
    @@config.raw[:devices].each_pair {|key, value|
      unless key == :default
        host = value[:ip]
        if ping.ping? host, 1, 0.2, 1
          @@config.parsed[:device_config] = value
          Logger.instance.warn("Default device offline, choosing Alternate")
          return
        end
      end
    }
    raise DeviceError, "No devices found"
  end
end