roku_builder 3.6.1 → 3.6.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
  SHA1:
3
- metadata.gz: 5fd419ef8714c1ee725684939cff69165e1daac9
4
- data.tar.gz: 6fc59c0b8453ee8ea26f765b493892044faacf68
3
+ metadata.gz: cda87c8c79464c6cbaadc76552d553d1d4f992f8
4
+ data.tar.gz: b2f72f1595cb30bc54ba7fabde915ff1f5761454
5
5
  SHA512:
6
- metadata.gz: 601f919047c348e2511456e37c5a5810df71f273fbc9005671cd1af815e251546ff4939334473e7a1010c84e2d23fce68ad4f0c7c5936584d15a95816e37772a
7
- data.tar.gz: a015de3a94792cfa7d8051f305834cb3c99f1139f2be004ce519cdd6213e870cf51525233a99005cca4a1edf8026fb8bcb712cb1f47bb827a75ccb5d7c40eaff
6
+ metadata.gz: f4bc039de589e530c0424df8067bc0985d54ce37ef356cd212a7d668a4934391ca41490d83d5af0710b291edf7a274b7a7787fb080275b43350a47cdacf7e5a8
7
+ data.tar.gz: f7470fa07bb4bb460ffc011d71a58bc278414674b0718b286cc4b1844a9f93bee3a441dc00912cef2aa3fec905be71258eb4ed72da065f9d04924574fe1dee09
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roku_builder (3.6.1)
4
+ roku_builder (3.6.2)
5
5
  faraday (~> 0.9)
6
6
  faraday-digestauth (~> 0.2)
7
7
  git (~> 1.3)
data/bin/roku CHANGED
@@ -83,6 +83,10 @@ OptionParser.new do |opts|
83
83
  options[:update] = true
84
84
  end
85
85
 
86
+ opts.on("-A", "--app-list", "Command: List currently installed apps") do
87
+ options[:applist] = true
88
+ end
89
+
86
90
  opts.on("-r", "--ref REF", "Git referance to use for sideloading") do |r|
87
91
  options[:ref] = r
88
92
  end
@@ -125,6 +129,10 @@ OptionParser.new do |opts|
125
129
  options[:project] = p
126
130
  end
127
131
 
132
+ opts.on("-a", "--app ID", "Send App id for deeplinking") do |a|
133
+ options[:app_id] = a
134
+ end
135
+
128
136
  opts.on("-O", "--out PATH", "Output file/folder. If PATH ends in .pkg/.zip/.jpg, file is assumed, otherwise folder is assumed") do |o|
129
137
  options[:out] = o
130
138
  end
@@ -202,7 +202,10 @@ module RokuBuilder
202
202
  root_dir: configs[:project_config][:directory]
203
203
  }
204
204
  # Create Deeplink Config
205
- configs[:deeplink_config] ={options: options[:deeplink]}
205
+ configs[:deeplink_config] = {options: options[:deeplink]}
206
+ if options[:app_id]
207
+ configs[:deeplink_config][:app_id] = options[:app_id]
208
+ end
206
209
  # Create Monitor Config
207
210
  if options[:monitor]
208
211
  configs[:monitor_config] = {type: options[:monitor].to_sym}
@@ -160,7 +160,7 @@ module RokuBuilder
160
160
  def self.commands
161
161
  [:sideload, :package, :test, :deeplink,:configure, :validate, :delete,
162
162
  :navigate, :text, :build, :monitor, :update, :screencapture, :key, :screen,
163
- :screens]
163
+ :screens, :applist]
164
164
  end
165
165
 
166
166
  # List of depricated options
@@ -20,7 +20,8 @@ module RokuBuilder
20
20
  text: { klass: Navigator, method: :type, config_key: :text_config },
21
21
  test: { klass: Tester, method: :run_tests, config_key: :test_config },
22
22
  screencapture: { klass: Inspector, method: :screencapture, config_key: :screencapture_config,
23
- failure: FAILED_SCREENCAPTURE }
23
+ failure: FAILED_SCREENCAPTURE },
24
+ applist: {klass: Linker, method: :list}
24
25
  }
25
26
  end
26
27
  # Validate Config
@@ -139,7 +140,7 @@ module RokuBuilder
139
140
  end
140
141
 
141
142
  linker = Linker.new(configs[:device_config])
142
- if linker.link(configs[:deeplink_config])
143
+ if linker.launch(configs[:deeplink_config])
143
144
  logger.info "Deeplinked into app"
144
145
  return SUCCESS
145
146
  else
@@ -2,26 +2,46 @@ module RokuBuilder
2
2
 
3
3
  # Launch application, sending parameters
4
4
  class Linker < Util
5
- # Deeplink to the currently sideloaded app
5
+ # Deeplink to an app
6
6
  # @param options [String] Options string
7
+ # @param app_id [String] Id of the app to launch (defaults to dev)
8
+ # @param logger [Logger] System Logger
7
9
  # @note Options string should be formated like the following: "<key>:<value>[, <key>:<value>]*"
8
10
  # @note Any options will be accepted and sent to the app
9
- def link(options:)
10
- path = "/launch/dev"
11
- return false unless options
11
+ def launch(options: nil, app_id: "dev")
12
+ path = "/launch/#{app_id}"
12
13
  payload = Util.options_parse(options: options)
13
14
 
14
15
  unless payload.keys.count > 0
15
- return false
16
+ @logger.warn "No options sent to launched app"
17
+ else
18
+ path = "#{path}?#{parameterize(payload)}"
16
19
  end
17
20
 
18
- path = "#{path}?#{parameterize(payload)}"
19
21
  conn = multipart_connection(port: 8060)
20
22
 
21
23
  response = conn.post path
22
24
  return response.success?
23
25
  end
24
26
 
27
+ # List currently installed apps
28
+ # @param logger [Logger] System Logger
29
+ def list()
30
+ path = "/query/apps"
31
+ conn = multipart_connection(port: 8060)
32
+ response = conn.get path
33
+
34
+ if response.success?
35
+ regexp = /id="([^"]*)"\stype="([^"]*)"\sversion="([^"]*)">([^<]*)</
36
+ apps = response.body.scan(regexp)
37
+ printf("%30s | %10s | %10s | %10s\n", "title", "id", "type", "version")
38
+ printf("---------------------------------------------------------------------\n")
39
+ apps.each do |app|
40
+ printf("%30s | %10s | %10s | %10s\n", app[3], app[0], app[1], app[2])
41
+ end
42
+ end
43
+ end
44
+
25
45
  private
26
46
 
27
47
  # Parameterize options to be sent to the app
@@ -1,4 +1,4 @@
1
1
  module RokuBuilder
2
2
  # Version of the RokuBuilder Gem
3
- VERSION = "3.6.1"
3
+ VERSION = "3.6.2"
4
4
  end
@@ -189,7 +189,7 @@ class ControllerCommandsTest < Minitest::Test
189
189
  options = {deeplink: true, stage: 'production', deeplink_options: "a:b", config: "~/.roku_config.json"}
190
190
  config = good_config
191
191
  code, configs = RokuBuilder::ConfigParser.parse_config(options: options, config: config, logger: logger)
192
- mock.expect(:link, "true", [configs[:deeplink_config]])
192
+ mock.expect(:launch, "true", [configs[:deeplink_config]])
193
193
  RokuBuilder::Linker.stub(:new, mock) do
194
194
  code = RokuBuilder::Controller.send(:execute_commands, {options: options, config: config, configs: configs, logger: logger})
195
195
  end
@@ -208,7 +208,7 @@ class ControllerCommandsTest < Minitest::Test
208
208
  options = {deeplink: true, set_stage: true, stage: 'production', deeplink_options: "a:b", config: "~/.roku_config.json"}
209
209
  config = good_config
210
210
  code, configs = RokuBuilder::ConfigParser.parse_config(options: options, config: config, logger: logger)
211
- mock.expect(:link, "true", [configs[:deeplink_config]])
211
+ mock.expect(:launch, "true", [configs[:deeplink_config]])
212
212
  RokuBuilder::Linker.stub(:new, mock) do
213
213
  RokuBuilder::ControllerCommands.stub(:sideload, sideload) do
214
214
  code = RokuBuilder::Controller.send(:execute_commands, {options: options, config: config, configs: configs, logger: logger})
@@ -226,7 +226,7 @@ class ControllerCommandsTest < Minitest::Test
226
226
  options = {deeplink: true, stage: 'production', deeplink_options: "a:b", config: "~/.roku_config.json"}
227
227
  config = good_config
228
228
  code, configs = RokuBuilder::ConfigParser.parse_config(options: options, config: config, logger: logger)
229
- mock.expect(:link, false, [configs[:deeplink_config]])
229
+ mock.expect(:launch, false, [configs[:deeplink_config]])
230
230
  RokuBuilder::Linker.stub(:new, mock) do
231
231
  code = RokuBuilder::Controller.send(:execute_commands, {options: options, config: config, configs: configs, logger: logger})
232
232
  end
@@ -26,7 +26,7 @@ class LinkerTest < Minitest::Test
26
26
  linker = RokuBuilder::Linker.new(**device_config)
27
27
  success = nil
28
28
  Faraday.stub(:new, connection, faraday) do
29
- success = linker.link(options: options)
29
+ success = linker.launch(options: options)
30
30
  end
31
31
 
32
32
  assert success
@@ -36,18 +36,77 @@ class LinkerTest < Minitest::Test
36
36
  response.verify
37
37
  end
38
38
  def test_linker_link_nothing
39
+ logger = Minitest::Mock.new
40
+ connection = Minitest::Mock.new
41
+ faraday = Minitest::Mock.new
42
+ response = Minitest::Mock.new
43
+
39
44
  device_config = {
40
45
  ip: "111.222.333",
41
46
  user: "user",
42
47
  password: "password",
43
- logger: Logger.new("/dev/null")
48
+ logger: logger
44
49
  }
50
+ path = "/launch/dev"
45
51
  options = ''
52
+ logger.expect(:warn, nil, ["No options sent to launched app"])
53
+ connection.expect(:post, response, [path])
54
+ faraday.expect(:headers, {})
55
+ faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
56
+ faraday.expect(:request, nil, [:multipart])
57
+ faraday.expect(:request, nil, [:url_encoded])
58
+ faraday.expect(:adapter, nil, [Faraday.default_adapter])
59
+ response.expect(:success?, true)
46
60
  linker = RokuBuilder::Linker.new(**device_config)
47
61
  success = nil
48
- success = linker.link(options: options)
62
+ Faraday.stub(:new, connection, faraday) do
63
+ success = linker.launch(options: options)
64
+ end
65
+
66
+ assert success
67
+ logger.verify
68
+ connection.verify
69
+ faraday.verify
70
+ response.verify
71
+ end
49
72
 
50
- assert !success
73
+ def test_linker_list
74
+ connection = Minitest::Mock.new
75
+ faraday = Minitest::Mock.new
76
+ response = Minitest::Mock.new
77
+
78
+ device_config = {
79
+ ip: "111.222.333",
80
+ user: "user",
81
+ password: "password",
82
+ logger: Logger.new("/dev/null")
83
+ }
84
+ path = "/query/apps"
85
+ body = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<apps>\n\t
86
+ <app id=\"31012\" type=\"menu\" version=\"1.6.3\">Movie Store and TV Store</app>\n\t
87
+ <app id=\"31863\" type=\"menu\" version=\"1.2.6\">Roku Home News</app>\n\t
88
+ <app id=\"65066\" type=\"appl\" version=\"1.3.0\">Nick</app>\n\t
89
+ <app id=\"68161\" type=\"appl\" version=\"1.3.0\">Nick</app>\n\t
90
+ </apps>\n"
91
+ connection.expect(:get, response, [path])
92
+ faraday.expect(:headers, {})
93
+ faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
94
+ faraday.expect(:request, nil, [:multipart])
95
+ faraday.expect(:request, nil, [:url_encoded])
96
+ faraday.expect(:adapter, nil, [Faraday.default_adapter])
97
+ response.expect(:success?, true)
98
+ response.expect(:body, body)
99
+ linker = RokuBuilder::Linker.new(**device_config)
100
+
101
+ print_count = 0
102
+ did_print = Proc.new { |msg| print_count+=1 }
103
+
104
+ Faraday.stub(:new, connection, faraday) do
105
+ linker.stub(:printf, did_print) do
106
+ linker.list
107
+ end
108
+ end
51
109
 
110
+ assert_equal 6, print_count
52
111
  end
53
112
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roku_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.1
4
+ version: 3.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - greeneca