lib/roku_builder/controller.rb in roku_builder-3.4.4 vs lib/roku_builder/controller.rb in roku_builder-3.5.0
- old
+ new
@@ -18,11 +18,11 @@
logger.level = Logger::WARN
end
# Validate Options
options_code = validate_options(options: options)
- ErrorHandler.handle_options_codes(options_code: options_code, logger: logger)
+ ErrorHandler.handle_options_codes(options_code: options_code, options: options, logger: logger)
# Configure Gem
configure_code = configure(options: options, logger: logger)
ErrorHandler.handle_configure_codes(configure_code: configure_code, logger: logger)
@@ -46,11 +46,12 @@
command_result = validate_command_options(options: options)
return command_result unless command_result == VALID
source_result = validate_source_options(options: options)
return source_result unless source_result == VALID
combination_result = validate_option_combinations(options: options)
- return combination_result
+ return combination_result unless combination_result == VALID
+ return validate_depricated_commands(options: options)
end
private_class_method :validate_options
# Validates use of command options
# @param options [Hash] The options hash
@@ -85,26 +86,36 @@
return BAD_CURRENT unless options[:build] or options[:sideload]
end
if options[:in]
return BAD_IN_FILE unless options[:sideload]
end
- if options[:deeplink]
- return BAD_DEEPLINK if options[:deeplink_options].to_s.empty?
- end
VALID
end
private_class_method :validate_option_combinations
+ # Validate depricated options adn commands
+ # @param options [Hash] The Options hash
+ # @return [Integer] Status code for command validation
+ def self.validate_depricated_commands(options:)
+ depricated = options.keys & depricated_options.keys
+ if depricated.count > 0
+ return DEPRICATED
+ end
+ VALID
+ end
+ private_class_method :validate_depricated_commands
+
# Run commands
# @param options [Hash] The options hash
# @return [Integer] Return code for options handeling
# @param logger [Logger] system logger
def self.execute_commands(options:, config:, configs:, logger:)
command = (commands & options.keys).first
if ControllerCommands.simple_commands.keys.include?(command)
params = ControllerCommands.simple_commands[command]
params[:configs] = configs
+ params[:logger] = logger
ControllerCommands.simple_command(**params)
else
params = ControllerCommands.method(command.to_s).parameters.collect{|a|a[1]}
args = {}
params.each do |key|
@@ -153,15 +164,20 @@
:navigate, :text, :build, :monitor, :update, :screencapture, :key, :screen,
:screens]
end
private_class_method :commands
+ # List of depricated options
+ # @return [Hash] Hash of depricated options and the warning message for each
+ def self.depricated_options
+ {deeplink_depricated: "-L and --deeplink are depricated. Use -o -r --deeplink-options." }
+ end
+
# List of source options
# @return [Array<Symbol>] List of source symbols that can be used in the options hash
def self.sources
[:ref, :set_stage, :working, :current]
end
- private_class_method :sources
# List of commands requiring a source option
# @return [Array<Symbol>] List of command symbols that require a source in the options hash
def self.source_commands
[:sideload, :package, :test, :build, :key]