Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
152 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# ********** Copyright Viacom, Inc. Apache 2.0 ********** | ||
|
||
module RokuBuilder | ||
|
||
# Helper for extending for scripting | ||
class Scripter | ||
|
||
# Prints attributes from config or project to allow scripting | ||
# @param attribute [Symbol] attribute to print | ||
# @param configs [Hash] Parsed config hash | ||
def self.print(attribute:, configs:) | ||
attributes = [ | ||
:title, :build_version, :app_version, :root_dir | ||
] | ||
|
||
unless attributes.include? attribute | ||
return BAD_PRINT_ATTRIBUTE | ||
end | ||
|
||
read_config = {root_dir: configs[:project_config][:directory]} | ||
|
||
case attribute | ||
when :root_dir | ||
printf "%s", configs[:project_config][:directory] | ||
when :title | ||
printf "%s", ManifestManager.read_manifest(**read_config)[:title] | ||
when :build_version | ||
printf "%s", ManifestManager.read_manifest(**read_config)[:build_version] | ||
when :app_version | ||
major = ManifestManager.read_manifest(**read_config)[:major_version] | ||
minor = ManifestManager.read_manifest(**read_config)[:minor_version] | ||
printf "%s.%s", major, minor | ||
end | ||
SUCCESS | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
|
||
module RokuBuilder | ||
# Version of the RokuBuilder Gem | ||
VERSION = "3.6.3" | ||
VERSION = "3.6.4" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# ********** Copyright Viacom, Inc. Apache 2.0 ********** | ||
|
||
require_relative "test_helper.rb" | ||
|
||
class Scriptertest < Minitest::Test | ||
|
||
def test_scripter_print_bad_attr | ||
code = RokuBuilder::Scripter.print(attribute: :bad, configs: {}) | ||
assert_equal RokuBuilder::BAD_PRINT_ATTRIBUTE, code | ||
end | ||
|
||
def test_scripter_print_config_values | ||
call_count = 0 | ||
code = nil | ||
fake_print = lambda { |message, path| | ||
assert_equal "%s", message | ||
assert_equal "/dev/null", path | ||
call_count+=1 | ||
} | ||
configs = {project_config: {directory: "/dev/null"}} | ||
RokuBuilder::Scripter.stub(:printf, fake_print) do | ||
code = RokuBuilder::Scripter.print(attribute: :root_dir, configs: configs) | ||
end | ||
assert_equal 1, call_count | ||
assert_equal RokuBuilder::SUCCESS, code | ||
end | ||
|
||
def test_scripter_print_manifest_title | ||
call_count = 0 | ||
code = nil | ||
fake_print = lambda { |message, title| | ||
assert_equal "%s", message | ||
assert_equal "title", title | ||
call_count+=1 | ||
} | ||
manifest = {title: "title"} | ||
configs = {project_config: {directory: "/dev/null"}} | ||
RokuBuilder::Scripter.stub(:printf, fake_print) do | ||
RokuBuilder::ManifestManager.stub(:read_manifest, manifest) do | ||
code = RokuBuilder::Scripter.print(attribute: :title, configs: configs) | ||
end | ||
end | ||
assert_equal 1, call_count | ||
assert_equal RokuBuilder::SUCCESS, code | ||
end | ||
|
||
def test_scripter_print_manifest_build_version | ||
call_count = 0 | ||
code = nil | ||
fake_print = lambda { |message, build| | ||
assert_equal "%s", message | ||
assert_equal "010101.0001", build | ||
call_count+=1 | ||
} | ||
manifest = {build_version: "010101.0001"} | ||
configs = {project_config: {directory: "/dev/null"}} | ||
RokuBuilder::Scripter.stub(:printf, fake_print) do | ||
RokuBuilder::ManifestManager.stub(:read_manifest, manifest) do | ||
code = RokuBuilder::Scripter.print(attribute: :build_version, configs: configs) | ||
end | ||
end | ||
assert_equal 1, call_count | ||
assert_equal RokuBuilder::SUCCESS, code | ||
end | ||
|
||
def test_scripter_print_manifest_app_version | ||
call_count = 0 | ||
code = nil | ||
fake_print = lambda { |message, major, minor| | ||
assert_equal "%s.%s", message | ||
assert_equal "1", major | ||
assert_equal "0", minor | ||
call_count+=1 | ||
} | ||
manifest = {major_version: "1", minor_version: "0"} | ||
configs = {project_config: {directory: "/dev/null"}} | ||
RokuBuilder::Scripter.stub(:printf, fake_print) do | ||
RokuBuilder::ManifestManager.stub(:read_manifest, manifest) do | ||
code = RokuBuilder::Scripter.print(attribute: :app_version, configs: configs) | ||
end | ||
end | ||
assert_equal 1, call_count | ||
assert_equal RokuBuilder::SUCCESS, code | ||
end | ||
end |
34 changes: 0 additions & 34 deletions
34
tests/roku_builder/test_files/controller_test/configure_test.json
This file was deleted.
Oops, something went wrong.