roku_builder 3.12.8 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/CHANGELOG +9 -0
- data/Gemfile.lock +17 -11
- data/bin/roku +4 -8
- data/lib/roku_builder.rb +16 -24
- data/lib/roku_builder/config.rb +213 -0
- data/lib/roku_builder/config_parser.rb +304 -267
- data/lib/roku_builder/config_validator.rb +149 -126
- data/lib/roku_builder/controller.rb +34 -184
- data/lib/roku_builder/controller_commands.rb +85 -79
- data/lib/roku_builder/error_handler.rb +0 -11
- data/lib/roku_builder/errors.rb +12 -0
- data/lib/roku_builder/inspector.rb +6 -4
- data/lib/roku_builder/keyer.rb +1 -1
- data/lib/roku_builder/loader.rb +1 -1
- data/lib/roku_builder/logger.rb +32 -0
- data/lib/roku_builder/manifest_manager.rb +2 -2
- data/lib/roku_builder/monitor.rb +1 -1
- data/lib/roku_builder/options.rb +113 -0
- data/lib/roku_builder/stager.rb +2 -2
- data/lib/roku_builder/tester.rb +57 -11
- data/lib/roku_builder/util.rb +3 -4
- data/lib/roku_builder/version.rb +1 -1
- data/roku_builder.gemspec +2 -1
- data/test/roku_builder/test_config.rb +168 -0
- data/test/roku_builder/test_config_parser.rb +347 -394
- data/test/roku_builder/test_config_validator.rb +193 -190
- data/test/roku_builder/test_controller.rb +59 -178
- data/test/roku_builder/test_controller_commands.rb +407 -394
- data/test/roku_builder/test_error_handler.rb +67 -69
- data/test/roku_builder/test_files/config_test/bad.json +2 -0
- data/test/roku_builder/test_files/config_test/child.json +11 -0
- data/test/roku_builder/test_files/config_test/config.json +29 -0
- data/test/roku_builder/test_files/config_test/non_json.json +1 -0
- data/test/roku_builder/test_files/config_test/parent.json +21 -0
- data/test/roku_builder/test_files/config_test/parent_projects.json +35 -0
- data/test/roku_builder/test_files/manifest_manager_test/manifest_template_2 +1 -1
- data/test/roku_builder/test_helper.rb +55 -45
- data/test/roku_builder/test_inspector.rb +278 -213
- data/test/roku_builder/test_keyer.rb +144 -147
- data/test/roku_builder/test_linker.rb +91 -95
- data/test/roku_builder/test_loader.rb +279 -289
- data/test/roku_builder/test_logger.rb +47 -0
- data/test/roku_builder/test_manifest_manager.rb +92 -94
- data/test/roku_builder/test_monitor.rb +101 -103
- data/test/roku_builder/test_navigator.rb +240 -245
- data/test/roku_builder/test_options.rb +156 -0
- data/test/roku_builder/test_packager.rb +108 -108
- data/test/roku_builder/test_profiler.rb +20 -19
- data/test/roku_builder/test_scripter.rb +83 -81
- data/test/roku_builder/test_stager.rb +299 -311
- data/test/roku_builder/test_tester.rb +112 -115
- data/test/roku_builder/test_util.rb +18 -17
- metadata +39 -6
- data/lib/roku_builder/config_manager.rb +0 -161
- data/test/roku_builder/test_config_manager.rb +0 -372
@@ -1,118 +1,125 @@
|
|
1
1
|
# ********** Copyright Viacom, Inc. Apache 2.0 **********
|
2
2
|
|
3
3
|
module RokuBuilder
|
4
|
-
|
5
|
-
MISSING_DEVICES = 1
|
6
|
-
MISSING_DEVICES_DEFAULT = 2
|
7
|
-
DEVICE_DEFAULT_BAD = 3
|
8
|
-
# = 4
|
9
|
-
MISSING_PROJECTS_DEFAULT = 5
|
10
|
-
PROJECTS_DEFAULT_BAD = 6
|
11
|
-
DEVICE_MISSING_IP = 7
|
12
|
-
DEVICE_MISSING_USER = 8
|
13
|
-
DEVICE_MISSING_PASSWORD = 9
|
14
|
-
PROJECT_MISSING_APP_NAME = 10
|
15
|
-
PROJECT_MISSING_DIRECTORY = 11
|
16
|
-
PROJECT_MISSING_FOLDERS = 12
|
17
|
-
PROJECT_FOLDERS_BAD = 13
|
18
|
-
PROJECT_MISSING_FILES = 14
|
19
|
-
PROJECT_FILES_BAD = 15
|
20
|
-
STAGE_MISSING_BRANCH = 16
|
21
|
-
STAGE_MISSING_SCRIPT = 17
|
22
|
-
PROJECT_STAGE_METHOD_BAD = 18
|
23
|
-
KEY_MISSING_PATH = 19
|
24
|
-
KEY_MISSING_PASSWORD = 20
|
25
|
-
INVALID_MAPPING_INFO = 21
|
26
|
-
MISSING_KEY = 22
|
27
|
-
|
28
|
-
MISSING_STAGE_METHOD = -1
|
29
|
-
|
30
|
-
# Validate Config File
|
31
4
|
class ConfigValidator
|
32
5
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
6
|
+
VALID_CONFIG = 0
|
7
|
+
MISSING_DEVICES = 1
|
8
|
+
MISSING_DEVICES_DEFAULT = 2
|
9
|
+
DEVICE_DEFAULT_BAD = 3
|
10
|
+
# = 4
|
11
|
+
MISSING_PROJECTS_DEFAULT = 5
|
12
|
+
PROJECTS_DEFAULT_BAD = 6
|
13
|
+
DEVICE_MISSING_IP = 7
|
14
|
+
DEVICE_MISSING_USER = 8
|
15
|
+
DEVICE_MISSING_PASSWORD = 9
|
16
|
+
PROJECT_MISSING_APP_NAME = 10
|
17
|
+
PROJECT_MISSING_DIRECTORY = 11
|
18
|
+
PROJECT_MISSING_FOLDERS = 12
|
19
|
+
PROJECT_FOLDERS_BAD = 13
|
20
|
+
PROJECT_MISSING_FILES = 14
|
21
|
+
PROJECT_FILES_BAD = 15
|
22
|
+
STAGE_MISSING_BRANCH = 16
|
23
|
+
STAGE_MISSING_SCRIPT = 17
|
24
|
+
PROJECT_STAGE_METHOD_BAD = 18
|
25
|
+
KEY_MISSING_PATH = 19
|
26
|
+
KEY_MISSING_PASSWORD = 20
|
27
|
+
INVALID_MAPPING_INFO = 21
|
28
|
+
MISSING_KEY = 22
|
29
|
+
MISSING_STAGE_METHOD = 23
|
30
|
+
|
31
|
+
def initialize(config:)
|
32
|
+
@logger = Logger.instance
|
33
|
+
@config = config
|
34
|
+
validate_config
|
35
|
+
end
|
36
|
+
|
37
|
+
def print_errors
|
38
|
+
@codes.each do |code|
|
39
|
+
if code > 0
|
40
|
+
@logger.fatal error_codes[code]
|
41
|
+
end
|
42
|
+
if code < 0
|
43
|
+
@logger.warn error_codes[code]
|
53
44
|
end
|
54
45
|
end
|
55
|
-
|
56
|
-
|
46
|
+
end
|
47
|
+
|
48
|
+
def is_fatal?
|
49
|
+
!@codes.select{|code| code > 0}.empty?
|
50
|
+
end
|
51
|
+
|
52
|
+
def is_depricated?
|
53
|
+
!@codes.select{|code| code < 0}.empty?
|
54
|
+
end
|
55
|
+
|
56
|
+
def is_valid?
|
57
|
+
@codes.select{|code| code > 0}.empty?
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def validate_config
|
63
|
+
@codes = []
|
64
|
+
validate_structure
|
65
|
+
[:projects, :devices, :keys, :input_mapping].each do |section|
|
66
|
+
validate_section(section: section) if @config[section]
|
57
67
|
end
|
58
|
-
codes.uniq!
|
59
|
-
codes.push(
|
60
|
-
codes
|
68
|
+
@codes.uniq!
|
69
|
+
@codes.push(VALID_CONFIG) if @codes.empty?
|
61
70
|
end
|
62
71
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
72
|
+
def validate_section(section:)
|
73
|
+
@config[section].each do |key, value|
|
74
|
+
next unless should_validate(key: key)
|
75
|
+
call_validate_method_for_section(section: section, content: value)
|
76
|
+
if has_stages(section_content: value)
|
77
|
+
validate_stages(project_content: value)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def should_validate(key:)
|
83
|
+
!([:default, :key_dir, :project_dir].include?(key))
|
84
|
+
end
|
85
|
+
|
86
|
+
def call_validate_method_for_section(section:, content:)
|
87
|
+
section_singular = singularize(section: section.to_s)
|
88
|
+
attrs = {}
|
89
|
+
attrs[section_singular] = content
|
90
|
+
method = "validate_#{section_singular}".to_sym
|
91
|
+
send(method, attrs)
|
92
|
+
end
|
93
|
+
|
94
|
+
def singularize(section:)
|
95
|
+
section = section[0..-2] if section.end_with?("s")
|
96
|
+
section.to_sym
|
97
|
+
end
|
98
|
+
|
99
|
+
def has_stages(section_content:)
|
100
|
+
section_content.class == Hash and section_content[:stages]
|
101
|
+
end
|
102
|
+
|
103
|
+
def validate_stages(project_content:)
|
104
|
+
project_content[:stages].each_value {|stage_config|
|
105
|
+
validate_stage(stage: stage_config, project: project_content)
|
106
|
+
}
|
94
107
|
end
|
95
108
|
|
96
|
-
|
97
|
-
|
98
|
-
# @param config [Hash] roku config object
|
99
|
-
def self.validate_structure(codes:, config:)
|
109
|
+
|
110
|
+
def validate_structure
|
100
111
|
errors = [
|
101
|
-
[MISSING_DEVICES,
|
102
|
-
[MISSING_DEVICES_DEFAULT, (config[:devices] and
|
103
|
-
[DEVICE_DEFAULT_BAD, (config[:devices] and config[:devices][:default] and
|
104
|
-
[MISSING_PROJECTS_DEFAULT, (config[:projects] and
|
105
|
-
[MISSING_PROJECTS_DEFAULT, (config[:projects] and config[:projects][:default] == "<project id>".to_sym)],
|
106
|
-
[PROJECTS_DEFAULT_BAD, (config[:projects] and config[:projects][:default] and
|
112
|
+
[MISSING_DEVICES, !@config[:devices]],
|
113
|
+
[MISSING_DEVICES_DEFAULT, (@config[:devices] and !@config[:devices][:default])],
|
114
|
+
[DEVICE_DEFAULT_BAD, (@config[:devices] and @config[:devices][:default] and !@config[:devices][:default].is_a?(Symbol))],
|
115
|
+
[MISSING_PROJECTS_DEFAULT, (@config[:projects] and !@config[:projects][:default])],
|
116
|
+
[MISSING_PROJECTS_DEFAULT, (@config[:projects] and @config[:projects][:default] == "<project id>".to_sym)],
|
117
|
+
[PROJECTS_DEFAULT_BAD, (@config[:projects] and @config[:projects][:default] and !@config[:projects][:default].is_a?(Symbol))]
|
107
118
|
]
|
108
|
-
process_errors(
|
119
|
+
process_errors(errors: errors)
|
109
120
|
end
|
110
|
-
private_class_method :validate_structure
|
111
121
|
|
112
|
-
|
113
|
-
# @param codes [Array] array of error codes
|
114
|
-
# @param device [Hash] device config object
|
115
|
-
def self.validate_device(codes:, device:)
|
122
|
+
def validate_device(device:)
|
116
123
|
errors = [
|
117
124
|
[DEVICE_MISSING_IP, (!device[:ip])],
|
118
125
|
[DEVICE_MISSING_IP, (device[:ip] == "xxx.xxx.xxx.xxx")],
|
@@ -124,14 +131,10 @@ module RokuBuilder
|
|
124
131
|
[DEVICE_MISSING_PASSWORD, (device[:password] == "<password>")],
|
125
132
|
[DEVICE_MISSING_PASSWORD, (device[:password] == "")]
|
126
133
|
]
|
127
|
-
process_errors(
|
134
|
+
process_errors(errors: errors)
|
128
135
|
end
|
129
|
-
private_class_method :validate_device
|
130
136
|
|
131
|
-
|
132
|
-
# @param codes [Array] array of error codes
|
133
|
-
# @param project [Hash] project config object
|
134
|
-
def self.validate_project(codes:, project:)
|
137
|
+
def validate_project(project:)
|
135
138
|
errors= [
|
136
139
|
[PROJECT_MISSING_APP_NAME, (!project[:app_name])],
|
137
140
|
[PROJECT_MISSING_DIRECTORY, (!project[:directory])],
|
@@ -142,49 +145,69 @@ module RokuBuilder
|
|
142
145
|
[MISSING_STAGE_METHOD, ( !project[:stage_method])],
|
143
146
|
[PROJECT_STAGE_METHOD_BAD, (![:git, :script, nil].include?(project[:stage_method]))]
|
144
147
|
]
|
145
|
-
process_errors(
|
148
|
+
process_errors(errors: errors)
|
146
149
|
end
|
147
|
-
private_class_method :validate_project
|
148
150
|
|
149
|
-
|
150
|
-
# @param codes [Array] array of error codes
|
151
|
-
# @param project [Hash] project config object
|
152
|
-
def self.validate_stage(codes:, stage:, project:, config:)
|
151
|
+
def validate_stage(stage:, project:)
|
153
152
|
errors= [
|
154
153
|
[STAGE_MISSING_BRANCH, (!stage[:branch] and project[:stage_method] == :git)],
|
155
154
|
[STAGE_MISSING_SCRIPT, (!stage[:script] and project[:stage_method] == :script)],
|
156
|
-
[MISSING_KEY, (!!stage[:key] and stage[:key].class == String and (
|
155
|
+
[MISSING_KEY, (!!stage[:key] and stage[:key].class == String and (!@config[:keys] or !@config[:keys][stage[:key].to_sym]))]
|
157
156
|
]
|
158
|
-
process_errors(
|
157
|
+
process_errors(errors: errors)
|
159
158
|
end
|
160
|
-
private_class_method :validate_stage
|
161
159
|
|
162
|
-
|
163
|
-
# @param codes [Array] array of error codes
|
164
|
-
# @param project [Hash] project config object
|
165
|
-
def self.validate_key(codes:, key:)
|
160
|
+
def validate_key(key:)
|
166
161
|
errors= [
|
167
162
|
[KEY_MISSING_PATH, (!key[:keyed_pkg])],
|
168
163
|
[KEY_MISSING_PATH, (key[:keyed_pkg] == "<path/to/signed/package>")],
|
169
164
|
[KEY_MISSING_PASSWORD, (!key[:password])],
|
170
165
|
[KEY_MISSING_PASSWORD, (key[:password] == "<password>")],
|
171
166
|
]
|
172
|
-
process_errors(
|
167
|
+
process_errors(errors: errors)
|
173
168
|
end
|
174
|
-
private_class_method :validate_key
|
175
169
|
|
176
|
-
def
|
170
|
+
def validate_input_mapping(input_mapping:)
|
177
171
|
errors=[
|
178
|
-
[INVALID_MAPPING_INFO, (
|
172
|
+
[INVALID_MAPPING_INFO, (input_mapping.count != 2)]
|
179
173
|
]
|
180
|
-
process_errors(
|
174
|
+
process_errors(errors: errors)
|
181
175
|
end
|
182
|
-
private_class_method :validate_mapping
|
183
176
|
|
184
|
-
def
|
177
|
+
def process_errors(errors:)
|
185
178
|
errors.each do |error|
|
186
|
-
codes.push(error[0]) if error[1]
|
179
|
+
@codes.push(error[0]) if error[1]
|
187
180
|
end
|
188
181
|
end
|
182
|
+
|
183
|
+
def error_codes
|
184
|
+
[
|
185
|
+
#===============FATAL ERRORS===============#
|
186
|
+
"Valid Config.",
|
187
|
+
"Devices config is missing.",
|
188
|
+
"Devices default is missing.",
|
189
|
+
"Devices default is not a hash.",
|
190
|
+
"",
|
191
|
+
"Projects default is missing.", #5
|
192
|
+
"Projects default is not a hash.",
|
193
|
+
"A device config is missing its IP address.",
|
194
|
+
"A device config is missing its username.",
|
195
|
+
"A device config is missing its password.",
|
196
|
+
"A project config is missing its app_name.", #10
|
197
|
+
"A project config is missing its directorty.",
|
198
|
+
"A project config is missing its folders.",
|
199
|
+
"A project config's folders is not an array.",
|
200
|
+
"A project config is missing its files.",
|
201
|
+
"A project config's files is not an array.", #15
|
202
|
+
"A project stage is missing its branch.",
|
203
|
+
"A project stage is missing its script.",
|
204
|
+
"A project as an invalid stage method.",
|
205
|
+
"A key is missing its keyed package path.",
|
206
|
+
"A key is missing its password.", #20
|
207
|
+
"A input mapping is invalid",
|
208
|
+
"A key is missing from the keys section",
|
209
|
+
"A project is missing its stage method."
|
210
|
+
]
|
211
|
+
end
|
189
212
|
end
|
190
213
|
end
|
@@ -7,126 +7,46 @@ module RokuBuilder
|
|
7
7
|
|
8
8
|
# Run the builder
|
9
9
|
# @param options [Hash] The options hash
|
10
|
-
def self.run(options
|
11
|
-
|
12
|
-
logger.level = Logger::DEBUG
|
13
|
-
elsif options[:verbose]
|
14
|
-
logger.level = Logger::INFO
|
15
|
-
else
|
16
|
-
logger.level = Logger::WARN
|
17
|
-
end
|
18
|
-
|
19
|
-
# Validate Options
|
20
|
-
options_code = validate_options(options: options)
|
21
|
-
ErrorHandler.handle_options_codes(options_code: options_code, options: options, logger: logger)
|
10
|
+
def self.run(options:)
|
11
|
+
options = Options.new(options: options)
|
22
12
|
|
23
|
-
|
24
|
-
configure_code = configure(options: options, logger: logger)
|
25
|
-
ErrorHandler.handle_configure_codes(configure_code: configure_code, logger: logger)
|
13
|
+
initialize_logger(options: options)
|
26
14
|
|
27
15
|
# Load Config
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
ErrorHandler.handle_configs_codes(configs_code: configs_code, logger: logger)
|
16
|
+
config = Config.new(options: options)
|
17
|
+
config.configure
|
18
|
+
config.load
|
19
|
+
config.validate
|
20
|
+
config.parse
|
34
21
|
|
35
22
|
# Check devices
|
36
|
-
device_code
|
37
|
-
ErrorHandler.handle_device_codes(device_code: device_code, logger:
|
23
|
+
device_code = check_devices(options: options, config: config)
|
24
|
+
ErrorHandler.handle_device_codes(device_code: device_code, logger: Logger.instance)
|
38
25
|
|
39
26
|
# Run Commands
|
40
|
-
command_code = execute_commands(options: options,
|
41
|
-
ErrorHandler.handle_command_codes(command_code: command_code, logger:
|
42
|
-
end
|
43
|
-
|
44
|
-
# Validates the user options
|
45
|
-
# @param options [Hash] The options hash
|
46
|
-
# @return [Integer] Status code for command validation
|
47
|
-
def self.validate_options(options:)
|
48
|
-
command_result = validate_command_options(options: options)
|
49
|
-
return command_result unless command_result == VALID
|
50
|
-
source_result = validate_source_options(options: options)
|
51
|
-
return source_result unless source_result == VALID
|
52
|
-
combination_result = validate_option_combinations(options: options)
|
53
|
-
return combination_result unless combination_result == VALID
|
54
|
-
return validate_depricated_commands(options: options)
|
55
|
-
end
|
56
|
-
private_class_method :validate_options
|
57
|
-
|
58
|
-
# Validates use of command options
|
59
|
-
# @param options [Hash] The options hash
|
60
|
-
# @return [Integer] Status code for command validation
|
61
|
-
def self.validate_command_options(options:)
|
62
|
-
all_commands = options.keys & commands
|
63
|
-
return EXTRA_COMMANDS if all_commands.count > 1
|
64
|
-
return NO_COMMANDS if all_commands.count < 1
|
65
|
-
VALID
|
66
|
-
end
|
67
|
-
private_class_method :validate_command_options
|
68
|
-
|
69
|
-
# Validates use of source options
|
70
|
-
# @param options [Hash] The options hash
|
71
|
-
# @return [Integer] Status code for command validation
|
72
|
-
def self.validate_source_options(options:)
|
73
|
-
all_sources = options.keys & sources
|
74
|
-
return EXTRA_SOURCES if all_sources.count > 1
|
75
|
-
if (options.keys & source_commands).count == 1
|
76
|
-
return NO_SOURCE unless all_sources.count == 1
|
77
|
-
end
|
78
|
-
VALID
|
79
|
-
end
|
80
|
-
private_class_method :validate_source_options
|
81
|
-
|
82
|
-
# Validates proper option combinations
|
83
|
-
# @param options [Hash] The options hash
|
84
|
-
# @return [Integer] Status code for command validation
|
85
|
-
def self.validate_option_combinations(options:)
|
86
|
-
all_sources = options.keys & sources
|
87
|
-
if all_sources.include?(:current)
|
88
|
-
return BAD_CURRENT unless options[:build] or options[:sideload]
|
89
|
-
end
|
90
|
-
if options[:in]
|
91
|
-
return BAD_IN_FILE unless options[:sideload]
|
92
|
-
end
|
93
|
-
VALID
|
94
|
-
end
|
95
|
-
private_class_method :validate_option_combinations
|
96
|
-
|
97
|
-
# Validate depricated options adn commands
|
98
|
-
# @param options [Hash] The Options hash
|
99
|
-
# @return [Integer] Status code for command validation
|
100
|
-
def self.validate_depricated_commands(options:)
|
101
|
-
depricated = options.keys & depricated_options.keys
|
102
|
-
if depricated.count > 0
|
103
|
-
return DEPRICATED
|
104
|
-
end
|
105
|
-
VALID
|
27
|
+
command_code = execute_commands(options: options, config: config)
|
28
|
+
ErrorHandler.handle_command_codes(command_code: command_code, logger: Logger.instance)
|
106
29
|
end
|
107
|
-
private_class_method :validate_depricated_commands
|
108
30
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
31
|
+
def self.initialize_logger(options:)
|
32
|
+
if options[:debug]
|
33
|
+
Logger.set_debug
|
34
|
+
elsif options[:verbose]
|
35
|
+
Logger.set_info
|
36
|
+
else
|
37
|
+
Logger.set_warn
|
115
38
|
end
|
116
|
-
VALID
|
117
39
|
end
|
118
|
-
private_class_method :validate_configs
|
119
40
|
|
120
41
|
# Run commands
|
121
42
|
# @param options [Hash] The options hash
|
122
43
|
# @return [Integer] Return code for options handeling
|
123
44
|
# @param logger [Logger] system logger
|
124
|
-
def self.execute_commands(options:,
|
125
|
-
command =
|
45
|
+
def self.execute_commands(options:, config:)
|
46
|
+
command = options.command
|
126
47
|
if ControllerCommands.simple_commands.keys.include?(command)
|
127
48
|
params = ControllerCommands.simple_commands[command]
|
128
|
-
params[:
|
129
|
-
params[:logger] = logger
|
49
|
+
params[:config] = config
|
130
50
|
ControllerCommands.simple_command(**params)
|
131
51
|
else
|
132
52
|
params = ControllerCommands.method(command.to_s).parameters.collect{|a|a[1]}
|
@@ -135,10 +55,8 @@ module RokuBuilder
|
|
135
55
|
case key
|
136
56
|
when :options
|
137
57
|
args[:options] = options
|
138
|
-
when :
|
139
|
-
args[:
|
140
|
-
when :logger
|
141
|
-
args[:logger] = logger
|
58
|
+
when :config
|
59
|
+
args[:config] = config
|
142
60
|
end
|
143
61
|
end
|
144
62
|
ControllerCommands.send(command, args)
|
@@ -149,95 +67,27 @@ module RokuBuilder
|
|
149
67
|
# Ensure that the selected device is accessable
|
150
68
|
# @param options [Hash] The options hash
|
151
69
|
# @param logger [Logger] system logger
|
152
|
-
def self.check_devices(options:, config
|
153
|
-
|
154
|
-
if device_commands.include?(command)
|
70
|
+
def self.check_devices(options:, config:)
|
71
|
+
if options.device_command?
|
155
72
|
ping = Net::Ping::External.new
|
156
|
-
host =
|
157
|
-
return
|
158
|
-
return
|
159
|
-
config[:devices].each_pair {|key, value|
|
73
|
+
host = config.parsed[:device_config][:ip]
|
74
|
+
return GOOD_DEVICE if ping.ping? host, 1, 0.2, 1
|
75
|
+
return BAD_DEVICE if options[:device_given]
|
76
|
+
config.raw[:devices].each_pair {|key, value|
|
160
77
|
unless key == :default
|
161
78
|
host = value[:ip]
|
162
79
|
if ping.ping? host, 1, 0.2, 1
|
163
|
-
|
164
|
-
|
165
|
-
return [CHANGED_DEVICE, configs]
|
80
|
+
config.parsed[:device_config] = value
|
81
|
+
return CHANGED_DEVICE
|
166
82
|
end
|
167
83
|
end
|
168
84
|
}
|
169
|
-
return
|
85
|
+
return NO_DEVICES
|
170
86
|
end
|
171
|
-
return
|
87
|
+
return GOOD_DEVICE
|
172
88
|
end
|
173
89
|
private_class_method :check_devices
|
174
90
|
|
175
|
-
# List of command options
|
176
|
-
# @return [Array<Symbol>] List of command symbols that can be used in the options hash
|
177
|
-
def self.commands
|
178
|
-
[:sideload, :package, :test, :deeplink,:configure, :validate, :delete,
|
179
|
-
:navigate, :navigator, :text, :build, :monitor, :update, :screencapture,
|
180
|
-
:key, :genkey, :screen, :screens, :applist, :print, :profile, :dostage,
|
181
|
-
:dounstage]
|
182
|
-
end
|
183
|
-
|
184
|
-
# List of depricated options
|
185
|
-
# @return [Hash] Hash of depricated options and the warning message for each
|
186
|
-
def self.depricated_options
|
187
|
-
{deeplink_depricated: "-L and --deeplink are depricated. Use -o or --deeplink-options." }
|
188
|
-
end
|
189
|
-
|
190
|
-
# List of source options
|
191
|
-
# @return [Array<Symbol>] List of source symbols that can be used in the options hash
|
192
|
-
def self.sources
|
193
|
-
[:ref, :set_stage, :working, :current, :in]
|
194
|
-
end
|
195
|
-
|
196
|
-
# List of commands requiring a source option
|
197
|
-
# @return [Array<Symbol>] List of command symbols that require a source in the options hash
|
198
|
-
def self.source_commands
|
199
|
-
[:sideload, :package, :test, :build, :key, :update, :print]
|
200
|
-
end
|
201
|
-
|
202
|
-
# List of commands the activate the exclude files
|
203
|
-
# @return [Array<Symbol] List of commands the will activate the exclude files lists
|
204
|
-
def self.exclude_commands
|
205
|
-
[:build, :package]
|
206
|
-
end
|
207
|
-
|
208
|
-
# List of commands that require a device
|
209
|
-
# @return [Array<Symbol>] List of commands that require a device
|
210
|
-
def self.device_commands
|
211
|
-
[:sideload, :package, :test, :deeplink, :delete, :navigate, :navigator,
|
212
|
-
:text, :monitor, :screencapture, :applist, :profile, :key, :genkey ]
|
213
|
-
end
|
214
|
-
|
215
|
-
|
216
|
-
# Configure the gem
|
217
|
-
# @param options [Hash] The options hash
|
218
|
-
# @return [Integer] Success or failure code
|
219
|
-
# @param logger [Logger] system logger
|
220
|
-
def self.configure(options:, logger:)
|
221
|
-
if options[:configure]
|
222
|
-
source_config = File.expand_path(File.join(File.dirname(__FILE__), "..", '..', 'config.json.example'))
|
223
|
-
target_config = File.expand_path(options[:config])
|
224
|
-
if File.exist?(target_config)
|
225
|
-
unless options[:edit_params]
|
226
|
-
return CONFIG_OVERWRITE
|
227
|
-
end
|
228
|
-
else
|
229
|
-
### Copy Config File ###
|
230
|
-
FileUtils.copy(source_config, target_config)
|
231
|
-
end
|
232
|
-
if options[:edit_params]
|
233
|
-
ConfigManager.edit_config(config: target_config, options: options, logger: logger)
|
234
|
-
end
|
235
|
-
return SUCCESS
|
236
|
-
end
|
237
|
-
nil
|
238
|
-
end
|
239
|
-
private_class_method :configure
|
240
|
-
|
241
91
|
# Run a system command
|
242
92
|
# @param command [String] The command to be run
|
243
93
|
# @return [String] The output of the command
|