roku_builder 3.9.0 → 3.10.0

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
  SHA1:
3
- metadata.gz: 3f57f3dc9e27633cf6455dd16f475e29c3ad4ac7
4
- data.tar.gz: 0d772e6d322cd620e17a6ad861ec6188a77fbaa6
3
+ metadata.gz: cafc0b0138dbfd81a85b39a01e42c997a475be97
4
+ data.tar.gz: a66b55d7ef11b635798337edc9596d260cc9af00
5
5
  SHA512:
6
- metadata.gz: 9e5f2ac10ed8c2788e5105b117db686cbedb628be12894b9a1867474dbeee934ff739359157ad471d34de1fb05d2c15a47e7460b9cce48daa7db40b74f7e5fe2
7
- data.tar.gz: 41774f8096866ae56473ad8d9bbd970ece9403728ac88e680d7558550c85adfdfcc51a458a7b4842bd625b9ec5c05b132bc913c946bdaf8762d702264a715074
6
+ metadata.gz: 1d27e06b83ead8167213f203a075526c4232a81d838df4cdb76e993b56d20532ed43442a4c21ad7dfd9b8400a546e9aeb0d4ba177610a5657aa2cc23bbf13b47
7
+ data.tar.gz: 8e0ea288ef29387ffaabcbba427ed034a7bab2b826d45c954fd81294fd48b1a4709e63bccc5992b8deb22a338a37095321f58d3bf064b0baaac6949b7ea789dd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roku_builder (3.9.0)
4
+ roku_builder (3.10.0)
5
5
  faraday (~> 0.9)
6
6
  faraday-digestauth (~> 0.2)
7
7
  git (~> 1.3)
@@ -13,7 +13,7 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- byebug (9.0.5)
16
+ byebug (9.0.6)
17
17
  coderay (1.1.1)
18
18
  coveralls (0.8.15)
19
19
  json (>= 1.8, < 3)
@@ -58,7 +58,7 @@ GEM
58
58
  lumberjack (1.0.10)
59
59
  method_source (0.8.2)
60
60
  mini_portile2 (2.1.0)
61
- minitest (5.9.0)
61
+ minitest (5.9.1)
62
62
  minitest-autotest (1.0.3)
63
63
  minitest-server (~> 1.0)
64
64
  minitest-server (1.0.4)
@@ -80,7 +80,7 @@ GEM
80
80
  coderay (~> 1.1.0)
81
81
  method_source (~> 0.8.1)
82
82
  slop (~> 3.4)
83
- rake (11.2.2)
83
+ rake (11.3.0)
84
84
  rb-fsevent (0.9.7)
85
85
  rb-inotify (0.9.7)
86
86
  ffi (>= 0.5.0)
@@ -93,7 +93,7 @@ GEM
93
93
  simplecov-html (~> 0.10.0)
94
94
  simplecov-html (0.10.0)
95
95
  slop (3.6.0)
96
- term-ansicolor (1.3.2)
96
+ term-ansicolor (1.4.0)
97
97
  tins (~> 1.0)
98
98
  thor (0.19.1)
99
99
  tins (1.12.0)
data/bin/roku CHANGED
@@ -52,10 +52,14 @@ parser = OptionParser.new do |opts|
52
52
  options[:delete] = true
53
53
  end
54
54
 
55
- opts.on("-N", "--navigate CMD", "Command: send the given command to the roku") do |n|
55
+ opts.on("-N", "--nav CMD", "Command: send the given command to the roku") do |n|
56
56
  options[:navigate] = n
57
57
  end
58
58
 
59
+ opts.on("--navigate", "Command: Run interactive navigator") do
60
+ options[:navigator] = true
61
+ end
62
+
59
63
  opts.on("-S", "--screencapture", "Command: save a screencapture to the output file/folder") do
60
64
  options[:screencapture] = true
61
65
  end
data/lib/roku_builder.rb CHANGED
@@ -18,6 +18,8 @@ require 'json'
18
18
  require 'pstore'
19
19
  #profiler
20
20
  require 'nokogiri'
21
+ #navigator
22
+ require 'io/console'
21
23
 
22
24
  require "roku_builder/controller"
23
25
  require "roku_builder/controller_commands"
@@ -228,7 +228,8 @@ module RokuBuilder
228
228
  end
229
229
  # Create Navigate Config
230
230
  if options[:navigate]
231
- configs[:navigate_config] = {command: options[:navigate].to_sym}
231
+ commands = options[:navigate].split(/, */).map{|c| c.to_sym}
232
+ configs[:navigate_config] = {commands: commands}
232
233
  end
233
234
  # Create Text Config
234
235
  configs[:text_config] = {text: options[:text]}
@@ -161,8 +161,9 @@ module RokuBuilder
161
161
  # @return [Array<Symbol>] List of command symbols that can be used in the options hash
162
162
  def self.commands
163
163
  [:sideload, :package, :test, :deeplink,:configure, :validate, :delete,
164
- :navigate, :text, :build, :monitor, :update, :screencapture, :key, :screen,
165
- :screens, :applist, :print, :profile, :dostage, :dounstage]
164
+ :navigate, :navigator, :text, :build, :monitor, :update, :screencapture,
165
+ :key, :screen, :screens, :applist, :print, :profile, :dostage,
166
+ :dounstage]
166
167
  end
167
168
 
168
169
  # List of depricated options
@@ -192,8 +193,8 @@ module RokuBuilder
192
193
  # List of commands that require a device
193
194
  # @return [Array<Symbol>] List of commands that require a device
194
195
  def self.device_commands
195
- [:sideload, :package, :test, :deeplink, :delete, :navigate, :text,
196
- :monitor, :screencapture, :applist, :profile ]
196
+ [:sideload, :package, :test, :deeplink, :delete, :navigate, :navigator,
197
+ :text, :monitor, :screencapture, :applist, :profile ]
197
198
  end
198
199
 
199
200
 
@@ -15,6 +15,7 @@ module RokuBuilder
15
15
  config_key: :monitor_config },
16
16
  navigate: { klass: Navigator, method: :nav, config_key: :navigate_config,
17
17
  failure: FAILED_NAVIGATING },
18
+ navigator: { klass: Navigator, method: :interactive },
18
19
  screen: { klass: Navigator, method: :screen, config_key: :screen_config,
19
20
  failure: FAILED_NAVIGATING },
20
21
  key: { klass: Keyer, method: :rekey, config_key: :key },
@@ -200,7 +201,7 @@ module RokuBuilder
200
201
  success = instance.send(method)
201
202
  end
202
203
  return failure unless failure.nil? or success
203
- logger.info "#{klass} call #{method} successfully"
204
+ logger.debug "#{klass} call #{method} successfully"
204
205
  SUCCESS
205
206
  end
206
207
  end
@@ -8,17 +8,91 @@ module RokuBuilder
8
8
  # Setup navigation commands
9
9
  def init
10
10
  @commands = {
11
- up: "Up",
12
- down: "Down",
13
- right: "Right",
14
- left: "Left",
15
- select: "Select",
16
- back: "Back",
17
11
  home: "Home",
18
12
  rew: "Rev",
19
13
  ff: "Fwd",
20
14
  play: "Play",
21
- replay: "InstantReplay"
15
+ select: "Select",
16
+ left: "Left",
17
+ right: "Right",
18
+ down: "Down",
19
+ up: "Up",
20
+ back: "Back",
21
+ replay: "InstantReplay",
22
+ info: "Info",
23
+ backspace: "Backspace",
24
+ search: "Search",
25
+ enter: "Enter",
26
+ volumedown: "VolumeDown",
27
+ volumeup: "VolumeUp",
28
+ mute: "VolumeMute",
29
+ channelup: "ChannelUp",
30
+ channeldown: "ChannelDown",
31
+ tuner: "InputTuner",
32
+ hdmi1: "InputHDMI1",
33
+ hdmi2: "InputHDMI2",
34
+ hdmi3: "InputHDMI3",
35
+ hdmi4: "InputHDMI4",
36
+ avi: "InputAVI"
37
+ }
38
+
39
+ @keys = {
40
+ "\e[1~": :home,
41
+ "<": :rew,
42
+ ">": :ff,
43
+ "=": :play,
44
+ "\\": :select,
45
+ "\e[D": :left,
46
+ "\e[C": :right,
47
+ "\e[B": :down,
48
+ "\e[A": :up,
49
+ "\t": :back,
50
+ "@": :replay,
51
+ "*": :info,
52
+ "\u007f": :backspace,
53
+ "?": :search,
54
+ "\r": :enter,
55
+ "\e[5~": :volumeup,
56
+ "\e[6~": :volumedown,
57
+ "\e[4~": :mute
58
+ #"": :channeldown,
59
+ #"": :channelup,
60
+ #"": :tuner,
61
+ #"": :hdmi1,
62
+ #"": :hdmi2,
63
+ #"": :hdmi3,
64
+ #"": :hdmi4,
65
+ #"": :avi,
66
+ }
67
+
68
+
69
+ @key_mappings = {
70
+ "Home": :home,
71
+ "<": :rew,
72
+ ">": :ff,
73
+ "=": :play,
74
+ "\\": :select,
75
+ "Left Arrow": :left,
76
+ "Right Arrow": :right,
77
+ "Down Arrow": :down,
78
+ "Up Arrow": :up,
79
+ "Tab": :back,
80
+ "@": :replay,
81
+ "*": :info,
82
+ "Backspace": :backspace,
83
+ "?": :search,
84
+ "Enter": :enter,
85
+ "Page Up": :volumeup,
86
+ "Page Down": :volumedown,
87
+ "End": :mute
88
+ #"": :channeldown,
89
+ #"": :channelup,
90
+ #"": :tuner,
91
+ #"": :hdmi1,
92
+ #"": :hdmi2,
93
+ #"": :hdmi3,
94
+ #"": :hdmi4,
95
+ #"": :avi,
22
96
  }
23
97
 
24
98
  @screens = {
@@ -33,21 +107,29 @@ module RokuBuilder
33
107
  network: [:home, :home, :home, :home, :home, :right, :left, :right, :left, :right],
34
108
  reboot: [:home, :home, :home, :home, :home, :up, :rew, :rew, :ff, :ff]
35
109
  }
110
+
111
+ @runable = [
112
+ :secret, :channels
113
+ ]
36
114
  end
37
115
 
38
116
  # Send a navigation command to the roku device
39
117
  # @param command [Symbol] The smbol of the command to send
40
118
  # @return [Boolean] Success
41
- def nav(command:)
42
- if @commands.has_key?(command)
43
- conn = multipart_connection(port: 8060)
119
+ def nav(commands:)
120
+ commands.each do |command|
121
+ if @commands.has_key?(command)
122
+ conn = multipart_connection(port: 8060)
44
123
 
45
- path = "/keypress/#{@commands[command]}"
46
- response = conn.post path
47
- return response.success?
48
- else
49
- return false
124
+ path = "/keypress/#{@commands[command]}"
125
+ @logger.debug("Send Command: "+path)
126
+ response = conn.post path
127
+ return false unless response.success?
128
+ else
129
+ return false
130
+ end
50
131
  end
132
+ return true
51
133
  end
52
134
 
53
135
  # Type text on the roku device
@@ -57,17 +139,47 @@ module RokuBuilder
57
139
  conn = multipart_connection(port: 8060)
58
140
  text.split(//).each do |c|
59
141
  path = "/keypress/LIT_#{CGI::escape(c)}"
142
+ @logger.debug("Send Letter: "+path)
60
143
  response = conn.post path
61
144
  return false unless response.success?
62
145
  end
63
146
  return true
64
147
  end
65
148
 
149
+ def interactive
150
+ running = true
151
+ @logger.info("Key Mappings:")
152
+ @key_mappings.each_pair {|key, command|
153
+ @logger.info("#{key} -> #{@commands[command]}")
154
+ }
155
+ @logger.info("Control-C -> Exit")
156
+ while running
157
+ char = read_char
158
+ @logger.debug("Char: #{char.inspect}")
159
+ if char == "\u0003"
160
+ running = false
161
+ else
162
+ Thread.new(char) {|char|
163
+ if @keys[char.to_sym] != nil
164
+ nav(commands:[@keys[char.to_sym]])
165
+ elsif char.inspect.force_encoding("UTF-8").ascii_only?
166
+ type(text: char)
167
+ end
168
+ }
169
+ end
170
+ end
171
+ end
172
+
66
173
  # Show the commands for one of the roku secret screens
67
174
  # @param type [Symbol] The type of screen to show
68
175
  # @return [Boolean] Screen found
69
176
  def screen(type:)
70
177
  if @screens.has_key?(type)
178
+ if @runable.include?(type)
179
+ nav(commands: @screens[type])
180
+ else
181
+ @logger.unknown("Cannot run command automatically")
182
+ end
71
183
  display = []
72
184
  count = []
73
185
  @screens[type].each do |command|
@@ -86,7 +198,12 @@ module RokuBuilder
86
198
  string = string + @commands[display[i]]+", "
87
199
  end
88
200
  end
89
- @logger.unknown(string.strip)
201
+
202
+ if @runable.include?(type)
203
+ @logger.info(string.strip)
204
+ else
205
+ @logger.unknown(string.strip)
206
+ end
90
207
  else
91
208
  return false
92
209
  end
@@ -97,5 +214,21 @@ module RokuBuilder
97
214
  def screens
98
215
  @screens.keys.each {|screen| @logger.unknown(screen)}
99
216
  end
217
+
218
+ def read_char
219
+ STDIN.echo = false
220
+ STDIN.raw!
221
+
222
+ input = STDIN.getc.chr
223
+ if input == "\e" then
224
+ input << STDIN.read_nonblock(3) rescue nil
225
+ input << STDIN.read_nonblock(2) rescue nil
226
+ end
227
+ ensure
228
+ STDIN.echo = true
229
+ STDIN.cooked!
230
+
231
+ return input
232
+ end
100
233
  end
101
234
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module RokuBuilder
4
4
  # Version of the RokuBuilder Gem
5
- VERSION = "3.9.0"
5
+ VERSION = "3.10.0"
6
6
  end
@@ -67,7 +67,7 @@ class NavigatorTest < Minitest::Test
67
67
  result = nil
68
68
  Faraday.stub(:new, connection, faraday) do
69
69
  if type == :nav
70
- result = navigator.nav(command: input)
70
+ result = navigator.nav(commands: [input])
71
71
  elsif type == :text
72
72
  result = navigator.type(text: input)
73
73
  end
@@ -91,11 +91,14 @@ class NavigatorTest < Minitest::Test
91
91
  }
92
92
  navigator = RokuBuilder::Navigator.new(**device_config)
93
93
 
94
- logger.expect(:unknown, nil, ["Home x 5, Fwd x 3, Rev x 2,"])
94
+ logger.expect(:info, nil, ["Home x 5, Fwd x 3, Rev x 2,"])
95
+ logger.expect(:unknown, nil, ["Cannot run command automatically"])
95
96
  logger.expect(:unknown, nil, ["Home x 5, Up, Rev x 2, Fwd x 2,"])
96
97
 
97
- navigator.screen(type: :secret)
98
- navigator.screen(type: :reboot)
98
+ navigator.stub(:nav, nil) do
99
+ navigator.screen(type: :secret)
100
+ navigator.screen(type: :reboot)
101
+ end
99
102
 
100
103
  logger.verify
101
104
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roku_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.0
4
+ version: 3.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - greeneca
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-08 00:00:00.000000000 Z
11
+ date: 2016-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip