roku_builder 3.3.3 → 3.3.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/.gitignore +1 -0
- data/.rubocop.yml +1158 -0
- data/.travis.yml +3 -0
- data/Gemfile.lock +19 -14
- data/README.md +5 -0
- data/bin/roku +32 -37
- data/config.json.example +2 -2
- data/lib/roku_builder/config_manager.rb +83 -118
- data/lib/roku_builder/config_parser.rb +192 -0
- data/lib/roku_builder/config_validator.rb +125 -0
- data/lib/roku_builder/controller.rb +97 -484
- data/lib/roku_builder/controller_commands.rb +112 -0
- data/lib/roku_builder/error_handler.rb +116 -0
- data/lib/roku_builder/inspector.rb +5 -18
- data/lib/roku_builder/keyer.rb +3 -11
- data/lib/roku_builder/linker.rb +3 -15
- data/lib/roku_builder/loader.rb +52 -89
- data/lib/roku_builder/manifest_manager.rb +2 -3
- data/lib/roku_builder/monitor.rb +15 -12
- data/lib/roku_builder/navigator.rb +2 -10
- data/lib/roku_builder/packager.rb +1 -7
- data/lib/roku_builder/tester.rb +1 -0
- data/lib/roku_builder/util.rb +39 -0
- data/lib/roku_builder/version.rb +1 -1
- data/lib/roku_builder.rb +96 -1
- data/roku_builder.gemspec +5 -4
- data/tests/roku_builder/config_manager_test.rb +80 -241
- data/tests/roku_builder/{controller_config_test.rb → config_parser_test.rb} +5 -5
- data/tests/roku_builder/config_validator_test.rb +158 -0
- data/tests/roku_builder/controller_commands_test.rb +304 -0
- data/tests/roku_builder/controller_test.rb +61 -620
- data/tests/roku_builder/error_handler_test.rb +76 -0
- data/tests/roku_builder/inspector_test.rb +3 -0
- data/tests/roku_builder/keyer_test.rb +3 -2
- data/tests/roku_builder/linker_test.rb +2 -1
- data/tests/roku_builder/loader_test.rb +2 -0
- data/tests/roku_builder/manifest_manager_test.rb +3 -6
- data/tests/roku_builder/monitor_test.rb +5 -13
- data/tests/roku_builder/navigator_test.rb +2 -0
- data/tests/roku_builder/test_helper.rb +38 -0
- metadata +34 -11
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
module RokuBuilder
|
|
2
|
+
|
|
3
|
+
MISSING_DEVICES = 1
|
|
4
|
+
MISSING_DEVICES_DEFAULT = 2
|
|
5
|
+
DEVICE_DEFAULT_BAD = 3
|
|
6
|
+
MISSING_PROJECTS = 4
|
|
7
|
+
MISSING_PROJECTS_DEFAULT = 5
|
|
8
|
+
PROJECTS_DEFAULT_BAD = 6
|
|
9
|
+
DEVICE_MISSING_IP = 7
|
|
10
|
+
DEVICE_MISSING_USER = 8
|
|
11
|
+
DEVICE_MISSING_PASSWORD = 9
|
|
12
|
+
PROJECT_MISSING_APP_NAME = 10
|
|
13
|
+
PROJECT_MISSING_DIRECTORY = 11
|
|
14
|
+
PROJECT_MISSING_FOLDERS = 12
|
|
15
|
+
PROJECT_FOLDERS_BAD = 13
|
|
16
|
+
PROJECT_MISSING_FILES = 14
|
|
17
|
+
PROJECT_FILES_BAD = 15
|
|
18
|
+
STAGE_MISSING_BRANCH = 16
|
|
19
|
+
|
|
20
|
+
# Validate Config File
|
|
21
|
+
class ConfigValidator
|
|
22
|
+
|
|
23
|
+
# Validates the roku config
|
|
24
|
+
# @param config [Hash] roku config object
|
|
25
|
+
# @return [Array] error codes for valid config (see self.error_codes)
|
|
26
|
+
def self.validate_config(config:)
|
|
27
|
+
codes = []
|
|
28
|
+
validate_device_structure(codes: codes, config: config)
|
|
29
|
+
validate_project_structure(codes: codes, config: config)
|
|
30
|
+
if config[:devices]
|
|
31
|
+
config[:devices].each {|k,v|
|
|
32
|
+
next if k == :default
|
|
33
|
+
validate_device(codes: codes, device: v)
|
|
34
|
+
}
|
|
35
|
+
end
|
|
36
|
+
if config[:projects]
|
|
37
|
+
config[:projects].each {|project,v|
|
|
38
|
+
next if project == :default
|
|
39
|
+
validate_project(codes: codes, project: v)
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
codes.push(0) if codes.empty?
|
|
43
|
+
codes
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Error code messages for config validation
|
|
47
|
+
# @return [Array] error code messages
|
|
48
|
+
def self.error_codes()
|
|
49
|
+
[
|
|
50
|
+
#===============FATAL ERRORS===============#
|
|
51
|
+
"Valid Config.",
|
|
52
|
+
"Devices config is missing.",
|
|
53
|
+
"Devices default is missing.",
|
|
54
|
+
"Devices default is not a hash.",
|
|
55
|
+
"Projects config is missing.",
|
|
56
|
+
"Projects default is missing.", #5
|
|
57
|
+
"Projects default is not a hash.",
|
|
58
|
+
"A device config is missing its IP address.",
|
|
59
|
+
"A device config is missing its username.",
|
|
60
|
+
"A device config is missing its password.",
|
|
61
|
+
"A project config is missing its app_name.", #10
|
|
62
|
+
"A project config is missing its directorty.",
|
|
63
|
+
"A project config is missing its folders.",
|
|
64
|
+
"A project config's folders is not an array.",
|
|
65
|
+
"A project config is missing its files.",
|
|
66
|
+
"A project config's files is not an array.", #15
|
|
67
|
+
"A project stage is missing its branch."
|
|
68
|
+
#===============WARNINGS===============#
|
|
69
|
+
]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Validates the roku config config structure
|
|
73
|
+
# @param codes [Array] array of error codes
|
|
74
|
+
# @param config [Hash] roku config object
|
|
75
|
+
def self.validate_device_structure(codes:, config:)
|
|
76
|
+
codes.push(MISSING_DEVICES) if not config[:devices]
|
|
77
|
+
codes.push(MISSING_DEVICES_DEFAULT) if config[:devices] and not config[:devices][:default]
|
|
78
|
+
codes.push(DEVICE_DEFAULT_BAD) if config[:devices] and config[:devices][:default] and not config[:devices][:default].is_a?(Symbol)
|
|
79
|
+
end
|
|
80
|
+
private_class_method :validate_device_structure
|
|
81
|
+
|
|
82
|
+
# Validates the roku config project structure
|
|
83
|
+
# @param codes [Array] array of error codes
|
|
84
|
+
# @param config [Hash] roku config object
|
|
85
|
+
def self.validate_project_structure(codes:, config:)
|
|
86
|
+
codes.push(MISSING_PROJECTS) if not config[:projects]
|
|
87
|
+
codes.push(MISSING_PROJECTS_DEFAULT) if config[:projects] and not config[:projects][:default]
|
|
88
|
+
codes.push(MISSING_PROJECTS_DEFAULT) if config[:projects] and config[:projects][:default] == "<project id>".to_sym
|
|
89
|
+
codes.push(PROJECTS_DEFAULT_BAD) if config[:projects] and config[:projects][:default] and not config[:projects][:default].is_a?(Symbol)
|
|
90
|
+
end
|
|
91
|
+
private_class_method :validate_project_structure
|
|
92
|
+
|
|
93
|
+
# Validates a roku config device
|
|
94
|
+
# @param codes [Array] array of error codes
|
|
95
|
+
# @param device [Hash] device config object
|
|
96
|
+
def self.validate_device(codes:, device:)
|
|
97
|
+
codes.push(DEVICE_MISSING_IP) if not device[:ip]
|
|
98
|
+
codes.push(DEVICE_MISSING_IP) if device[:ip] == "xxx.xxx.xxx.xxx"
|
|
99
|
+
codes.push(DEVICE_MISSING_IP) if device[:ip] == ""
|
|
100
|
+
codes.push(DEVICE_MISSING_USER) if not device[:user]
|
|
101
|
+
codes.push(DEVICE_MISSING_USER) if device[:user] == "<username>"
|
|
102
|
+
codes.push(DEVICE_MISSING_USER) if device[:user] == ""
|
|
103
|
+
codes.push(DEVICE_MISSING_PASSWORD) if not device[:password]
|
|
104
|
+
codes.push(DEVICE_MISSING_PASSWORD) if device[:password] == "<password>"
|
|
105
|
+
codes.push(DEVICE_MISSING_PASSWORD) if device[:password] == ""
|
|
106
|
+
end
|
|
107
|
+
private_class_method :validate_device
|
|
108
|
+
|
|
109
|
+
# Validates a roku config project
|
|
110
|
+
# @param codes [Array] array of error codes
|
|
111
|
+
# @param project [Hash] project config object
|
|
112
|
+
def self.validate_project(codes:, project:)
|
|
113
|
+
codes.push(PROJECT_MISSING_APP_NAME) if not project[:app_name]
|
|
114
|
+
codes.push(PROJECT_MISSING_DIRECTORY) if not project[:directory]
|
|
115
|
+
codes.push(PROJECT_MISSING_FOLDERS) if not project[:folders]
|
|
116
|
+
codes.push(PROJECT_FOLDERS_BAD) if project[:folders] and not project[:folders].is_a?(Array)
|
|
117
|
+
codes.push(PROJECT_MISSING_FILES) if not project[:files]
|
|
118
|
+
codes.push(PROJECT_FILES_BAD) if project[:files] and not project[:files].is_a?(Array)
|
|
119
|
+
project[:stages].each {|_stage,value|
|
|
120
|
+
codes.push(STAGE_MISSING_BRANCH) if not value[:branch]
|
|
121
|
+
}
|
|
122
|
+
end
|
|
123
|
+
private_class_method :validate_project
|
|
124
|
+
end
|
|
125
|
+
end
|