roku-ecp 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4596a3e8de44cf9e2828527b7c1db97b868226df2c142a939a673f6954bbeb5a
4
- data.tar.gz: 445dd74fd2fea0890730b4daec31ce60ce0ec6eff4fa84a785b4a25ab0835a19
3
+ metadata.gz: acb4cbf41e1b18efedf721b6f71f86a4a19269f96daa7488c9292e347ea73599
4
+ data.tar.gz: 4249254d232d264bbfb61f4862b2baaccc0b74fac79040a3edfcbbf2225d9116
5
5
  SHA512:
6
- metadata.gz: e3870be57187c600a341aac7d53598c4981f31156e7b7a1230cbac3534f7daa9ffe8c388f0e0053df0295e74d35e27a42dd194a54aa95808af6b816e9a3a0b4b
7
- data.tar.gz: f88c5ff06c91c9e0ec8cc093b86b874b453d042507999c0c2cd033e7cc50da59c2af1064c881a30e94c6827e4b9dcf975fd827bc4dbd6280b7742d47e9e06a95
6
+ metadata.gz: 7b9dedf8f5a6341a6a5607c3f414a0490ceaaf7407246c8b1e2e486213b27a2a4c4c2d477714b39f03553977475c14a4c47fe10c94105a7273839bb34ed422dc
7
+ data.tar.gz: 401e8af162143954e6eaeba630ef7e6e17db34e98a5182bd0360c499c4c8a7b3dab353b7d0ba4746f51ef75123fa52908f2baf29567f7b1d61bd3e6b83fc3a1c
data/bin/roku CHANGED
@@ -2,4 +2,8 @@
2
2
 
3
3
  require_relative '../lib/roku'
4
4
 
5
+ puts 'Finding device'
6
+ Roku::Client.find_device!
7
+
8
+ puts 'Ready'
5
9
  Roku::Input.new.run
@@ -36,7 +36,7 @@ module Roku
36
36
 
37
37
  class << self
38
38
  def find_device!
39
- address = Roku::Discover.search
39
+ address = ENV.fetch('ROKU_HOST') { Roku::Discover.search }
40
40
  base_uri(address)
41
41
  end
42
42
 
@@ -10,15 +10,28 @@ module Roku
10
10
  "Man: \"ssdp:discover\"\n" \
11
11
  "ST: roku:ecp\n\n".freeze
12
12
 
13
+ class DeviceNotFound < StandardError
14
+ end
15
+
13
16
  class << self
14
17
  def search
15
18
  bind
16
19
  socket.send(REQUEST, 0, MULTICAST_ADDR, PORT)
17
- parse_address(await_response)
20
+ begin
21
+ parse_address(await_response)
22
+ rescue Timeout::Error
23
+ raise DeviceNotFound,
24
+ "Roku's automatic device discovery failed. If you continue " \
25
+ "to receive this message, you should try restarting your " \
26
+ "router, and you may want to manually configure this. You " \
27
+ "can do this by finding the device's IP via your router " \
28
+ "and setting the ROKU_HOST environment variable to " \
29
+ "\"http://{{device-ip}}:8060\"."
30
+ end
18
31
  end
19
32
 
20
33
  def await_response
21
- Timeout.timeout(5) do
34
+ Timeout.timeout(10) do
22
35
  loop do
23
36
  response, = socket.recvfrom(1024)
24
37
  if response.include?('LOCATION') && response.include?('200 OK')
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'roku-ecp'
6
- spec.version = '0.1.0'
6
+ spec.version = '0.1.1'
7
7
  spec.authors = ['Jacob Evan Shreve']
8
8
  spec.email = ['github@shreve.io']
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roku-ecp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Evan Shreve