roku_builder 4.29.1 → 4.29.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a74435c26dad5e136130516be10f397638bb374f4f105a8ca25c438193b39151
4
- data.tar.gz: 1fa12ee0b271ae1506b5d3ffe028da016fbafa208eee996b6f9fbedd5dbb3a0e
3
+ metadata.gz: 81cf2f851953864be0d4dd66937daf9e00386eabcd13b70afd4168dbd3b7b473
4
+ data.tar.gz: 8d58024ade2b9f3cc786f4f7ebb29b47884da7d1d7794becb631f977054dd492
5
5
  SHA512:
6
- metadata.gz: a7a74b63df763ff355473e8f1d5e90c80ea0805c8539edf43d189199876ebf7fd801322e45020ae9192c888c53e9de39f2e23d2ebe95ce581a4e0016fb2db493
7
- data.tar.gz: 202e8b749f4b0aa46d6a0ebd18aabae4a3c486214d5945b823e1cc897b0a36a1ed3d351c07f0e49bf89e612df92bed68d860d3b1797ff89a92af63a9c3bd8313
6
+ metadata.gz: '060098efb871fc1e846634331e8b69d0738ba8ade3dda92da6ae931c9c7d5b595b37d8d35ce329832a05224ffa852f7990bad7605ad490d6d2b0504333e79e0a'
7
+ data.tar.gz: 6cb5e1aee0f27363a0021feb135a5675083916cb9f73670a2273968047cc3175034f5828bc528d0874492a26bf40cb770c61adb626badbf77a06e9a35a59f06d
@@ -39,12 +39,23 @@ module RokuBuilder
39
39
  File.delete(lock) if File.exist?(lock)
40
40
  end
41
41
 
42
+ def release_all
43
+ all_devices.each do |device_name|
44
+ device = Device.new(device_name, @config.devices[device_name])
45
+ release_device(device)
46
+ end
47
+ end
48
+
42
49
  private
43
50
 
44
- def reserve_any(no_lock: false)
51
+ def all_devices
45
52
  default = @config.device_default
46
- all_devices = @config.devices.keys.reject{|key, value| default == key}
47
- all_devices.unshift(default)
53
+ devices = @config.devices.keys.reject{|key, value| default == key}
54
+ devices.unshift(default)
55
+ devices
56
+ end
57
+
58
+ def reserve_any(no_lock: false)
48
59
  all_devices.each do |device_name|
49
60
  device = Device.new(device_name, @config.devices[device_name])
50
61
  if device_available!(device: device, no_lock: no_lock)
@@ -11,7 +11,8 @@ module RokuBuilder
11
11
  validate: {keyed: true},
12
12
  increment: {source: true, stage: true},
13
13
  dostage: {source: true},
14
- dounstage: {source: true}
14
+ dounstage: {source: true},
15
+ release_all_devices: {},
15
16
  }
16
17
  end
17
18
 
@@ -32,6 +33,9 @@ module RokuBuilder
32
33
  parser.on("--do-unstage", "Run the unstager. Used for scripting. Always run --do-script first") do
33
34
  options[:dounstage] = true
34
35
  end
36
+ parser.on("--release-all-devices", "Releases all devices, deleting lock files") do
37
+ options[:release_all_devices] = true
38
+ end
35
39
  parser.separator ""
36
40
  parser.separator "Config Options:"
37
41
  parser.on("-e", "--edit PARAMS", "Edit config params when configuring. (eg. a:b, c:d,e:f)") do |p|
@@ -123,6 +127,11 @@ module RokuBuilder
123
127
  def dounstage(options:)
124
128
  Stager.new(config: @config, options: options).unstage
125
129
  end
130
+ def release_all_devices(options:)
131
+ manager = DeviceManager.new(config: @config, options: @options)
132
+ manager.release_all
133
+ Logger.instance.info "All devices unlocked"
134
+ end
126
135
 
127
136
  def self.get_help_text(parser:, options:, plugin_name:)
128
137
  plugin = self.get_plugin_by_name(plugin_name)
@@ -139,8 +139,8 @@ module RokuBuilder
139
139
 
140
140
  # Print the node stats
141
141
  def get_stats
142
- end_reg = /<\/All_Nodes>/
143
- start_reg = /<All_Nodes>/
142
+ end_reg = /<\/All_Nodes/
143
+ start_reg = /<All_Nodes/
144
144
  lines = get_command_response(command: "sgnodes all", start_reg: start_reg, end_reg: end_reg)
145
145
  xml_string = lines.join("\n")
146
146
  stats = {"Total" => {count: 0}}
@@ -211,14 +211,14 @@ module RokuBuilder
211
211
  end
212
212
 
213
213
  def print_all_nodes
214
- start_reg = /<All_Nodes>/
215
- end_reg = /<\/All_Nodes>/
214
+ start_reg = /<All_Nodes/
215
+ end_reg = /<\/All_Nodes/
216
216
  lines = get_command_response(command: "sgnodes all", start_reg: start_reg, end_reg: end_reg)
217
217
  lines.each {|line| print line}
218
218
  end
219
219
  def print_root_nodes
220
- start_reg = /<Root_Nodes>/
221
- end_reg = /<\/Root_Nodes>/
220
+ start_reg = /<Root_Nodes/
221
+ end_reg = /<\/Root_Nodes/
222
222
  lines = get_command_response(command: "sgnodes roots", start_reg: start_reg, end_reg: end_reg)
223
223
  lines.each {|line| print line}
224
224
  end
@@ -230,14 +230,14 @@ module RokuBuilder
230
230
  end
231
231
  def print_image_information
232
232
  start_reg = /RoGraphics instance/
233
- end_reg = /Available memory/
233
+ end_reg = /Available texture memory/
234
234
  lines = get_command_response(command: "r2d2_bitmaps", start_reg: start_reg, end_reg: end_reg)
235
235
  lines = sort_image_lines(lines, /0x[^\s]+\s+\d+\s+\d+\s+\d+\s+\d+/, 4)
236
236
  lines.each {|line| print line}
237
237
  end
238
238
  def print_memmory_usage
239
239
  start_reg = /RoGraphics instance/
240
- end_reg = /Available memory/
240
+ end_reg = /Available texture memory/
241
241
  begin
242
242
  while true
243
243
  lines = get_command_response(command: "r2d2_bitmaps", start_reg: start_reg, end_reg: end_reg, ignore_warnings: true)
@@ -338,7 +338,7 @@ module RokuBuilder
338
338
  first_match = /RoGraphics instance (0x.*)/.match(line)
339
339
  if first_match
340
340
  while line != nil
341
- usage_match = /Available memory (\d*) used (\d*) max (\d*)/.match(line)
341
+ usage_match = /Available texture memory (\d*) used (\d*) max (\d*)/.match(line)
342
342
  if usage_match
343
343
  data[first_match[1]] = [usage_match[1].to_i, usage_match[2].to_i, usage_match[3].to_i]
344
344
  break
@@ -86,10 +86,7 @@ module RokuBuilder
86
86
 
87
87
  def sorted_versions(versions)
88
88
  sorted = versions.sort do |a, b|
89
- aa, ab = a["version"].split(".").map{|i| i.to_i}
90
- ba, bb = b["version"].split(".").map{|i| i.to_i}
91
- value = (aa == ba ? bb <=> ab : ba <=> aa)
92
- value
89
+ DateTime.parse(b["createdDate"]) <=> DateTime.parse(a["createdDate"])
93
90
  end
94
91
  sorted
95
92
  end
@@ -98,7 +95,7 @@ module RokuBuilder
98
95
  path = "/external/channels/#{channel}/versions"
99
96
  params = nil
100
97
  unless @no_publish
101
- params = {"channelState" => "Published"}
98
+ params = {"state" => "Published"}
102
99
  end
103
100
  api_post(path, path, package, params)
104
101
  end
@@ -127,7 +124,7 @@ module RokuBuilder
127
124
  "appFileBase64Encoded" => Base64.encode64(package.read)
128
125
  }.to_json
129
126
  end
130
- connection('POST', token_path, body).post(api_path+path) do |request|
127
+ connection('POST', token_path, body, params).post(api_path+path) do |request|
131
128
  if params
132
129
  request.params = params
133
130
  end if
@@ -146,10 +143,10 @@ module RokuBuilder
146
143
  end
147
144
  end
148
145
 
149
- def connection(method, path, body)
146
+ def connection(method, path, body, params = nil)
150
147
  service_urn = "urn:roku:cloud-services:chanprovsvc"
151
148
  connection = Faraday.new(url: HOST, headers: {
152
- 'Authorization' => "Bearer "+get_jwt_token(@api_key, service_urn, method, path, body),
149
+ 'Authorization' => "Bearer "+get_jwt_token(@api_key, service_urn, method, path, body, params),
153
150
  'Content-Type' => 'application/json',
154
151
  'Accept' => 'application/json',
155
152
  }) do |f|
@@ -157,10 +154,11 @@ module RokuBuilder
157
154
  end
158
155
  end
159
156
 
160
- def get_jwt_token(api_key, service_urn, method, path, body = nil)
157
+ def get_jwt_token(api_key, service_urn, method, path, body = nil, params = nil)
161
158
  key_file = File.expand_path(@config.api_keys[api_key.to_sym])
162
159
  raise InvalidOptions "Missing api key" unless key_file
163
160
  jwk = JWT::JWK.new(JSON.parse(File.read(key_file)))
161
+ path += "?" + URI.encode_www_form(params) if params
164
162
  header = {
165
163
  "typ" => "JWT",
166
164
  "kid" => jwk.export[:kid]
@@ -2,5 +2,5 @@
2
2
 
3
3
  module RokuBuilder
4
4
  # Version of the RokuBuilder Gem
5
- VERSION = "4.29.1"
5
+ VERSION = "4.29.4"
6
6
  end
@@ -63,13 +63,21 @@ module RokuBuilder
63
63
 
64
64
  def test_sorted_versions
65
65
  api = RokuAPI.new(config: @config)
66
- versions = [{"version" => "1.9"}, {"version" => "1.11"}, {"version" => "2.3"}, {"version" => "2.4"}]
66
+ versions = [
67
+ {"version" => "1.9", "createdDate" => (DateTime.now - 30).to_s},
68
+ {"version" => "1.11", "createdDate" => (DateTime.now - 20).to_s},
69
+ {"version" => "2.3", "createdDate" => (DateTime.now - 10).to_s},
70
+ {"version" => "2.4", "createdDate" => (DateTime.now).to_s}
71
+ ]
67
72
  sorted = api.send(:sorted_versions, versions)
68
73
  assert_equal "2.4", sorted[0]["version"]
69
74
  assert_equal "2.3", sorted[1]["version"]
70
75
  assert_equal "1.11", sorted[2]["version"]
71
76
  assert_equal "1.9", sorted[3]["version"]
72
- versions = [{"version" => "1.4"}, {"version" => "1.3"}]
77
+ versions = [
78
+ {"version" => "1.4", "createdDate" => (DateTime.now).to_s},
79
+ {"version" => "1.3", "createdDate" => (DateTime.now - 10).to_s}
80
+ ]
73
81
  sorted = api.send(:sorted_versions, versions)
74
82
  assert_equal "1.4", sorted[0]["version"]
75
83
  assert_equal "1.3", sorted[1]["version"]
@@ -95,16 +103,17 @@ module RokuBuilder
95
103
  assert_equal spec["path"], path
96
104
  end
97
105
 
98
- def test_get_jwt_token_with_body
106
+ def test_get_jwt_token_with_body_and_params
99
107
  api = RokuAPI.new(config: @config)
100
108
  urn = "test:urn"
101
109
  method = "GET"
102
110
  path = "/test/path"
111
+ params = {"param" => "value"}
103
112
  body = {
104
113
  "appFileBase64Encoded" => Base64.encode64(File.open(File.join(test_files_path(RokuAPITest), "test.pkg")).read)
105
114
  }
106
115
  sha256 = Digest::SHA256.base64digest(body.to_json)
107
- token = api.send(:get_jwt_token, @options[:api_key], urn, method, path, body.to_json)
116
+ token = api.send(:get_jwt_token, @options[:api_key], urn, method, path, body.to_json, params)
108
117
  jwk = JWT::JWK.new(JSON.parse(File.read(@config.api_keys[:key1])))
109
118
  decoded = JWT.decode(token, jwk.public_key, true, {algorithm: 'RS256'})
110
119
  assert_equal decoded[1]["typ"], "JWT"
@@ -116,7 +125,7 @@ module RokuBuilder
116
125
  refute_nil spec
117
126
  assert_equal spec["serviceUrn"], urn
118
127
  assert_equal spec["httpMethod"], method
119
- assert_equal spec["path"], path
128
+ assert_equal spec["path"], path+"?"+URI.encode_www_form(params)
120
129
  assert_equal spec["bodySha256Base64"], sha256
121
130
  end
122
131
 
@@ -280,6 +289,7 @@ module RokuBuilder
280
289
  body.push(api_versions.first)
281
290
  body[1]["version"] = "1.3"
282
291
  body[1]["channelState"] = "Unpublished"
292
+ body[1]["createdDate"] = (DateTime.now -10).to_s
283
293
  response = Minitest::Mock.new
284
294
  response.expect(:success?, true)
285
295
  response.expect(:body, body[0].to_json)
@@ -337,7 +347,7 @@ module RokuBuilder
337
347
  called = true
338
348
  assert_equal path, "/external/channels/#{channel}/versions"
339
349
  assert_equal token_path, "/external/channels/#{channel}/versions"
340
- assert_equal "Published", params["channelState"]
350
+ assert_equal "Published", params["state"]
341
351
  assert_kind_of File, package
342
352
  end
343
353
  api.stub(:api_post, post_proc) do
@@ -143,7 +143,8 @@ def api_versions
143
143
  "channelId" => 722085,
144
144
  "version" => "1.4",
145
145
  "minFirmwareVersion" => 0,
146
- "minimumFirmwareVersionTextShort" => "v2.5 b388"
146
+ "minimumFirmwareVersionTextShort" => "v2.5 b388",
147
+ "createdDate" => DateTime.now.to_s
147
148
  }
148
149
  ]
149
150
  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: 4.29.1
4
+ version: 4.29.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - greeneca
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-25 00:00:00.000000000 Z
11
+ date: 2024-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip