roku-ecp 0.1.1 → 0.1.2

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: acb4cbf41e1b18efedf721b6f71f86a4a19269f96daa7488c9292e347ea73599
4
- data.tar.gz: 4249254d232d264bbfb61f4862b2baaccc0b74fac79040a3edfcbbf2225d9116
3
+ metadata.gz: c3880c57a9d8d5b4eafd4f7e44cdcf3127bc389546caab4d2ec3448bf79dbd5b
4
+ data.tar.gz: 4708afac1245ee982e6a67661816a5edea27bef24a568f5128c869a9ed088bbb
5
5
  SHA512:
6
- metadata.gz: 7b9dedf8f5a6341a6a5607c3f414a0490ceaaf7407246c8b1e2e486213b27a2a4c4c2d477714b39f03553977475c14a4c47fe10c94105a7273839bb34ed422dc
7
- data.tar.gz: 401e8af162143954e6eaeba630ef7e6e17db34e98a5182bd0360c499c4c8a7b3dab353b7d0ba4746f51ef75123fa52908f2baf29567f7b1d61bd3e6b83fc3a1c
6
+ metadata.gz: 8e260f6671001bf3b37cd4ea2819a2161e24bb14716d63cc120e65c2556b516d4ea2a420f7102b5195f89eaaf74a91a56ffd33321de26460862a08f79290cc7d
7
+ data.tar.gz: 2d3bb137fd4e569700afc078050a08631f8e4f18f6741791eb5f57c6856d94817ddd9c52cd24088f60f3e5d0a3a6ca53b73f68d098a780ab98df04f3c42c7113
@@ -0,0 +1 @@
1
+ *.gem
@@ -1,4 +1,5 @@
1
1
  require 'socket'
2
+ require 'ipaddr'
2
3
 
3
4
  module Roku
4
5
  module Discover
@@ -2,38 +2,27 @@ require 'io/console'
2
2
 
3
3
  module Roku
4
4
  class Input
5
+ BINDINGS = {
6
+ ' ' => :Play,
7
+ "\r" => :Select,
8
+ "\e[A" => :Up,
9
+ "\e[B" => :Down,
10
+ "\e[C" => :Right,
11
+ "\e[D" => :Left,
12
+ "\e[1;5A" => :VolumeUp,
13
+ "\e[1;5B" => :VolumeDown,
14
+ "\u007F" => :Back
15
+ }.freeze
16
+
5
17
  def run
6
18
  while (input = read_char)
7
19
  case input
8
- when ' '
9
- Roku::Client.keypress(:Play)
10
- when "\r"
11
- Roku::Client.keypress(:Select)
12
- when "\e[A"
13
- Roku::Client.keypress(:Up)
14
- when "\e[B"
15
- Roku::Client.keypress(:Down)
16
- when "\e[C"
17
- Roku::Client.keypress(:Right)
18
- when "\e[D"
19
- Roku::Client.keypress(:Left)
20
- when "\u007F"
21
- Roku::Client.keypress(:Back)
22
- when "\e[1;5A"
23
- Roku::Client.keypress(:VolumeUp)
24
- when "\e[1;5B"
25
- Roku::Client.keypress(:VolumeDown)
26
20
  when 'a'
27
- query = prompt('Launch: ')
28
- app = Roku::Client.apps.find { |a| a.name.casecmp(query) }
29
- if app.nil?
30
- print "\rNo app found."
31
- else
32
- print "\rLaunching #{app.name}."
33
- app.launch!
34
- end
35
- when 'q', "\u0003"
21
+ launch_app(prompt('Launch: '))
22
+ when 'q', "\u0003", "\e"
36
23
  break
24
+ when *BINDINGS.keys
25
+ Roku::Client.keypress(BINDINGS[input])
37
26
  else
38
27
  puts input.inspect
39
28
  end
@@ -57,5 +46,15 @@ module Roku
57
46
  print label
58
47
  $stdin.gets.chomp
59
48
  end
49
+
50
+ def launch_app(query)
51
+ app = Roku::Client.apps.find { |a| a.name.casecmp(query).zero? }
52
+ if app.nil?
53
+ print "\rNo app found."
54
+ else
55
+ print "\rLaunching #{app.name}."
56
+ app.launch!
57
+ end
58
+ end
60
59
  end
61
60
  end
data/readme.md CHANGED
@@ -14,6 +14,19 @@ for interacting.
14
14
 
15
15
  ## Usage
16
16
 
17
+ Use the included bin script to get started.
18
+
19
+ ```bash
20
+ $ roku
21
+ ```
22
+
23
+ It will find your device and tell you when you're ready to interact.
24
+
25
+ ### Programatic Usage
26
+
27
+ If you don't want to use the included remote program, you can use the source
28
+ library instead.
29
+
17
30
  Find your Roku device and automatically configure the client to use it.
18
31
 
19
32
  ```ruby
@@ -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.1'
6
+ spec.version = '0.1.2'
7
7
  spec.authors = ['Jacob Evan Shreve']
8
8
  spec.email = ['github@shreve.io']
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roku-ecp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Evan Shreve
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-08 00:00:00.000000000 Z
11
+ date: 2018-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -32,6 +32,7 @@ executables:
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
+ - ".gitignore"
35
36
  - Gemfile
36
37
  - Gemfile.lock
37
38
  - bin/console