roku_builder 3.6.3 → 3.6.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 +4 -4
- data/Gemfile.lock +1 -1
- data/bin/roku +4 -0
- data/lib/roku_builder.rb +4 -0
- data/lib/roku_builder/controller.rb +1 -1
- data/lib/roku_builder/controller_commands.rb +13 -0
- data/lib/roku_builder/error_handler.rb +2 -0
- data/lib/roku_builder/manifest_manager.rb +22 -41
- data/lib/roku_builder/scripter.rb +37 -0
- data/lib/roku_builder/version.rb +1 -1
- data/tests/roku_builder/keyer_test.rb +4 -2
- data/tests/roku_builder/manifest_manager_test.rb +1 -1
- data/tests/roku_builder/scripter_test.rb +85 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5491a8115dec46aaf4d5aa694bc5d32b66ac39bf
|
4
|
+
data.tar.gz: 01a9774a5829a0966e6d05dd9187141d00bba712
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 387ce09f99b318904e27b96a8c698f3dd357242e68d3422802306beb5daafb415dea3d69bf92cab81e1c7cd0130a07c9d21585dcca33b157f19dfbd7d4ae2438
|
7
|
+
data.tar.gz: 3c141ea7b5f3f83c886fc70a905c683e4d229aed277499ec7f4311a8aae24a81ba0a8cedbed15820d19f6704a505f2f4bf4b221c7b4a22be818d9a32f9e51af1
|
data/Gemfile.lock
CHANGED
data/bin/roku
CHANGED
@@ -68,6 +68,10 @@ OptionParser.new do |opts|
|
|
68
68
|
options[:key] = true
|
69
69
|
end
|
70
70
|
|
71
|
+
opts.on("--print ATTRIBUTE", "Command: Print attribute for scripting") do |a|
|
72
|
+
options[:print] = a
|
73
|
+
end
|
74
|
+
|
71
75
|
opts.on("--screen SCREEN", "Command: show a screen") do |s|
|
72
76
|
options[:screen] = s
|
73
77
|
end
|
data/lib/roku_builder.rb
CHANGED
@@ -25,6 +25,7 @@ require "roku_builder/loader"
|
|
25
25
|
require "roku_builder/packager"
|
26
26
|
require "roku_builder/linker"
|
27
27
|
require "roku_builder/tester"
|
28
|
+
require "roku_builder/scripter"
|
28
29
|
require "roku_builder/manifest_manager"
|
29
30
|
require "roku_builder/config_manager"
|
30
31
|
require "roku_builder/config_validator"
|
@@ -134,6 +135,9 @@ module RokuBuilder
|
|
134
135
|
|
135
136
|
# Did not sideload as content is identical
|
136
137
|
IDENTICAL_SIDELOAD = 13
|
138
|
+
|
139
|
+
# Bad print attribute
|
140
|
+
BAD_PRINT_ATTRIBUTE = 14
|
137
141
|
end
|
138
142
|
|
139
143
|
class ::String
|
@@ -162,7 +162,7 @@ module RokuBuilder
|
|
162
162
|
def self.commands
|
163
163
|
[:sideload, :package, :test, :deeplink,:configure, :validate, :delete,
|
164
164
|
:navigate, :text, :build, :monitor, :update, :screencapture, :key, :screen,
|
165
|
-
:screens, :applist]
|
165
|
+
:screens, :applist, :print]
|
166
166
|
end
|
167
167
|
|
168
168
|
# List of depricated options
|
@@ -150,6 +150,19 @@ module RokuBuilder
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
+
# Run Print
|
154
|
+
# @param options [Hash] user options
|
155
|
+
# @param configs [Hash] parsed configs
|
156
|
+
def self.print(options:, configs:)
|
157
|
+
stager = Stager.new(**configs[:stage_config])
|
158
|
+
code = nil
|
159
|
+
if stager.stage
|
160
|
+
code = Scripter.print(attribute: options[:print].to_sym, configs: configs)
|
161
|
+
end
|
162
|
+
stager.unstage
|
163
|
+
code
|
164
|
+
end
|
165
|
+
|
153
166
|
# Run a simple command
|
154
167
|
# @param klass [Class] class of object to create
|
155
168
|
# @param method [Symbol] methog to run on klass
|
@@ -10,64 +10,45 @@ module RokuBuilder
|
|
10
10
|
# @return [String] Build version on success, empty string otherwise
|
11
11
|
def self.update_build(root_dir:)
|
12
12
|
|
13
|
-
build_version = ""
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
#Update build version.
|
23
|
-
build_version = line.split(".")
|
24
|
-
if 2 == build_version.length
|
25
|
-
iteration = build_version[1].to_i + 1
|
26
|
-
build_version[0] = Time.now.strftime("%m%d%y")
|
27
|
-
build_version[1] = iteration
|
28
|
-
build_version = build_version.join(".")
|
29
|
-
else
|
30
|
-
#Use current date.
|
31
|
-
build_version = Time.now.strftime("%m%d%y")+".1"
|
32
|
-
end
|
33
|
-
temp_file.puts "build_version=#{build_version}"
|
34
|
-
else
|
35
|
-
temp_file.puts line
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
temp_file.rewind
|
40
|
-
FileUtils.cp(temp_file.path, path)
|
41
|
-
ensure
|
42
|
-
temp_file.close
|
43
|
-
temp_file.unlink
|
13
|
+
build_version = self.build_version(root_dir: root_dir).split(".")
|
14
|
+
if 2 == build_version.length
|
15
|
+
iteration = build_version[1].to_i + 1
|
16
|
+
build_version[0] = Time.now.strftime("%m%d%y")
|
17
|
+
build_version[1] = iteration
|
18
|
+
build_version = build_version.join(".")
|
19
|
+
else
|
20
|
+
#Use current date.
|
21
|
+
build_version = Time.now.strftime("%m%d%y")+".0001"
|
44
22
|
end
|
45
|
-
build_version
|
23
|
+
self.update_manifest(root_dir: root_dir, attributes: {build_version: build_version})
|
24
|
+
self.build_version(root_dir: root_dir)
|
46
25
|
end
|
47
26
|
|
48
27
|
# Retrive the build version from the manifest file
|
49
28
|
# @param root_dir [String] Path to the root directory for the app
|
50
29
|
# @return [String] Build version on success, empty string otherwise
|
51
30
|
def self.build_version(root_dir:)
|
52
|
-
build_version
|
53
|
-
|
31
|
+
read_manifest(root_dir: root_dir)[:build_version]
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.read_manifest(root_dir:)
|
35
|
+
attrs = {}
|
36
|
+
get_attrs = lambda { |file|
|
54
37
|
file.each_line do |line|
|
55
|
-
|
56
|
-
|
57
|
-
end
|
38
|
+
key, value = line.split("=")
|
39
|
+
attrs[key.chomp.to_sym]= value.chomp
|
58
40
|
end
|
59
41
|
}
|
60
42
|
if File.directory?(root_dir)
|
61
43
|
path = File.join(root_dir, 'manifest')
|
62
|
-
|
63
|
-
File.open(path, 'r', &get_version)
|
44
|
+
File.open(path, 'r', &get_attrs)
|
64
45
|
elsif File.extname(root_dir) == ".zip"
|
65
46
|
Zip::File.open(root_dir) do |zip_file|
|
66
47
|
entry = zip_file.glob("manifest").first
|
67
|
-
entry.get_input_stream(&
|
48
|
+
entry.get_input_stream(&get_attrs)
|
68
49
|
end
|
69
50
|
end
|
70
|
-
|
51
|
+
attrs
|
71
52
|
end
|
72
53
|
|
73
54
|
# Update attributes in the app manifest
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# ********** Copyright Viacom, Inc. Apache 2.0 **********
|
2
|
+
|
3
|
+
module RokuBuilder
|
4
|
+
|
5
|
+
# Helper for extending for scripting
|
6
|
+
class Scripter
|
7
|
+
|
8
|
+
# Prints attributes from config or project to allow scripting
|
9
|
+
# @param attribute [Symbol] attribute to print
|
10
|
+
# @param configs [Hash] Parsed config hash
|
11
|
+
def self.print(attribute:, configs:)
|
12
|
+
attributes = [
|
13
|
+
:title, :build_version, :app_version, :root_dir
|
14
|
+
]
|
15
|
+
|
16
|
+
unless attributes.include? attribute
|
17
|
+
return BAD_PRINT_ATTRIBUTE
|
18
|
+
end
|
19
|
+
|
20
|
+
read_config = {root_dir: configs[:project_config][:directory]}
|
21
|
+
|
22
|
+
case attribute
|
23
|
+
when :root_dir
|
24
|
+
printf "%s", configs[:project_config][:directory]
|
25
|
+
when :title
|
26
|
+
printf "%s", ManifestManager.read_manifest(**read_config)[:title]
|
27
|
+
when :build_version
|
28
|
+
printf "%s", ManifestManager.read_manifest(**read_config)[:build_version]
|
29
|
+
when :app_version
|
30
|
+
major = ManifestManager.read_manifest(**read_config)[:major_version]
|
31
|
+
minor = ManifestManager.read_manifest(**read_config)[:minor_version]
|
32
|
+
printf "%s.%s", major, minor
|
33
|
+
end
|
34
|
+
SUCCESS
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/roku_builder/version.rb
CHANGED
@@ -101,8 +101,10 @@ class KeyerTest < Minitest::Test
|
|
101
101
|
faraday.expect(:request, nil, [:url_encoded])
|
102
102
|
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
103
103
|
|
104
|
-
# This test fails with
|
105
|
-
# spitting out the same number twice
|
104
|
+
# This test fails with the following seeds due to the random number
|
105
|
+
# generator spitting out the same number twice
|
106
|
+
# SEED=21894
|
107
|
+
# SEED=31813
|
106
108
|
dev_id = Proc.new { Random.rand(100) }
|
107
109
|
keyer = RokuBuilder::Keyer.new(**device_config)
|
108
110
|
key_changed = nil
|
@@ -21,7 +21,7 @@ class ManifestManagerTest < Minitest::Test
|
|
21
21
|
Time.stub(:now, Time.new(2001, 02, 01)) do
|
22
22
|
build_version = RokuBuilder::ManifestManager.update_build(root_dir: root_dir)
|
23
23
|
end
|
24
|
-
assert_equal "020101.
|
24
|
+
assert_equal "020101.0001", build_version
|
25
25
|
FileUtils.rm(File.join(root_dir, "manifest"))
|
26
26
|
end
|
27
27
|
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# ********** Copyright Viacom, Inc. Apache 2.0 **********
|
2
|
+
|
3
|
+
require_relative "test_helper.rb"
|
4
|
+
|
5
|
+
class Scriptertest < Minitest::Test
|
6
|
+
|
7
|
+
def test_scripter_print_bad_attr
|
8
|
+
code = RokuBuilder::Scripter.print(attribute: :bad, configs: {})
|
9
|
+
assert_equal RokuBuilder::BAD_PRINT_ATTRIBUTE, code
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_scripter_print_config_values
|
13
|
+
call_count = 0
|
14
|
+
code = nil
|
15
|
+
fake_print = lambda { |message, path|
|
16
|
+
assert_equal "%s", message
|
17
|
+
assert_equal "/dev/null", path
|
18
|
+
call_count+=1
|
19
|
+
}
|
20
|
+
configs = {project_config: {directory: "/dev/null"}}
|
21
|
+
RokuBuilder::Scripter.stub(:printf, fake_print) do
|
22
|
+
code = RokuBuilder::Scripter.print(attribute: :root_dir, configs: configs)
|
23
|
+
end
|
24
|
+
assert_equal 1, call_count
|
25
|
+
assert_equal RokuBuilder::SUCCESS, code
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_scripter_print_manifest_title
|
29
|
+
call_count = 0
|
30
|
+
code = nil
|
31
|
+
fake_print = lambda { |message, title|
|
32
|
+
assert_equal "%s", message
|
33
|
+
assert_equal "title", title
|
34
|
+
call_count+=1
|
35
|
+
}
|
36
|
+
manifest = {title: "title"}
|
37
|
+
configs = {project_config: {directory: "/dev/null"}}
|
38
|
+
RokuBuilder::Scripter.stub(:printf, fake_print) do
|
39
|
+
RokuBuilder::ManifestManager.stub(:read_manifest, manifest) do
|
40
|
+
code = RokuBuilder::Scripter.print(attribute: :title, configs: configs)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
assert_equal 1, call_count
|
44
|
+
assert_equal RokuBuilder::SUCCESS, code
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_scripter_print_manifest_build_version
|
48
|
+
call_count = 0
|
49
|
+
code = nil
|
50
|
+
fake_print = lambda { |message, build|
|
51
|
+
assert_equal "%s", message
|
52
|
+
assert_equal "010101.0001", build
|
53
|
+
call_count+=1
|
54
|
+
}
|
55
|
+
manifest = {build_version: "010101.0001"}
|
56
|
+
configs = {project_config: {directory: "/dev/null"}}
|
57
|
+
RokuBuilder::Scripter.stub(:printf, fake_print) do
|
58
|
+
RokuBuilder::ManifestManager.stub(:read_manifest, manifest) do
|
59
|
+
code = RokuBuilder::Scripter.print(attribute: :build_version, configs: configs)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
assert_equal 1, call_count
|
63
|
+
assert_equal RokuBuilder::SUCCESS, code
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_scripter_print_manifest_app_version
|
67
|
+
call_count = 0
|
68
|
+
code = nil
|
69
|
+
fake_print = lambda { |message, major, minor|
|
70
|
+
assert_equal "%s.%s", message
|
71
|
+
assert_equal "1", major
|
72
|
+
assert_equal "0", minor
|
73
|
+
call_count+=1
|
74
|
+
}
|
75
|
+
manifest = {major_version: "1", minor_version: "0"}
|
76
|
+
configs = {project_config: {directory: "/dev/null"}}
|
77
|
+
RokuBuilder::Scripter.stub(:printf, fake_print) do
|
78
|
+
RokuBuilder::ManifestManager.stub(:read_manifest, manifest) do
|
79
|
+
code = RokuBuilder::Scripter.print(attribute: :app_version, configs: configs)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
assert_equal 1, call_count
|
83
|
+
assert_equal RokuBuilder::SUCCESS, code
|
84
|
+
end
|
85
|
+
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.6.
|
4
|
+
version: 3.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- greeneca
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -267,6 +267,7 @@ files:
|
|
267
267
|
- lib/roku_builder/monitor.rb
|
268
268
|
- lib/roku_builder/navigator.rb
|
269
269
|
- lib/roku_builder/packager.rb
|
270
|
+
- lib/roku_builder/scripter.rb
|
270
271
|
- lib/roku_builder/stager.rb
|
271
272
|
- lib/roku_builder/tester.rb
|
272
273
|
- lib/roku_builder/util.rb
|
@@ -287,6 +288,7 @@ files:
|
|
287
288
|
- tests/roku_builder/monitor_test.rb
|
288
289
|
- tests/roku_builder/navigator_test.rb
|
289
290
|
- tests/roku_builder/packager_test.rb
|
291
|
+
- tests/roku_builder/scripter_test.rb
|
290
292
|
- tests/roku_builder/stager_test.rb
|
291
293
|
- tests/roku_builder/test_files/controller_config_test/valid_config.json
|
292
294
|
- tests/roku_builder/test_files/controller_test/load_config_test.json
|