Class: RokuBuilder::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/roku_builder/controller.rb

Overview

Controls all interaction with other classes

Class Method Summary collapse

Class Method Details

.commandsArray<Symbol>

List of command options

Returns:

  • (Array<Symbol>)

    List of command symbols that can be used in the options hash



162
163
164
165
166
# File 'lib/roku_builder/controller.rb', line 162

def self.commands
  [:sideload, :package, :test, :deeplink,:configure, :validate, :delete,
    :navigate, :text, :build, :monitor, :update, :screencapture, :key, :screen,
    :screens]
end

.depricated_optionsHash

List of depricated options

Returns:

  • (Hash)

    Hash of depricated options and the warning message for each



170
171
172
# File 'lib/roku_builder/controller.rb', line 170

def self.depricated_options
  {deeplink_depricated: "-L and --deeplink are depricated. Use -o -r --deeplink-options." }
end

.exclude_commandsArray<Symbol] List of commands the will activate the exclude files lists

List of commands the activate the exclude files

Returns:

  • (Array<Symbol] List of commands the will activate the exclude files lists)

    Array<Symbol] List of commands the will activate the exclude files lists



188
189
190
# File 'lib/roku_builder/controller.rb', line 188

def self.exclude_commands
  [:build, :package]
end

.run(options:) ⇒ Object

Run the builder

Parameters:

  • options (Hash)

    The options hash



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/roku_builder/controller.rb', line 8

def self.run(options:)
  logger = Logger.new(STDOUT)
  logger.formatter = proc {|severity, datetime, _progname, msg|
    "[%s #%s] %5s: %s\n\r" % [datetime.strftime("%Y-%m-%d %H:%M:%S.%4N"), $$, severity, msg]
  }
  if options[:debug]
    logger.level = Logger::DEBUG
  elsif options[:verbose]
    logger.level = Logger::INFO
  else
    logger.level = Logger::WARN
  end

  # Validate Options
  options_code = validate_options(options: options)
  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)

  # Load Config
  load_code, config, configs = ConfigManager.load_config(options: options, logger: logger)
  ErrorHandler.handle_load_codes(options: options, load_code: load_code, logger: logger)

  # Check devices
  device_code, configs = check_devices(options: options, config: config, configs: configs, logger: logger)
  ErrorHandler.handle_device_codes(device_code: device_code, logger: logger)

  # Run Commands
  command_code = execute_commands(options: options, config: config, configs: configs, logger: logger)
  ErrorHandler.handle_command_codes(command_code: command_code, logger: logger)
end

.source_commandsArray<Symbol>

List of commands requiring a source option

Returns:

  • (Array<Symbol>)

    List of command symbols that require a source in the options hash



182
183
184
# File 'lib/roku_builder/controller.rb', line 182

def self.source_commands
  [:sideload, :package, :test, :build, :key]
end

.sourcesArray<Symbol>

List of source options

Returns:

  • (Array<Symbol>)

    List of source symbols that can be used in the options hash



176
177
178
# File 'lib/roku_builder/controller.rb', line 176

def self.sources
  [:ref, :set_stage, :working, :current, :in]
end

.system(command:) ⇒ String

Run a system command

Parameters:

  • command (String)

    The command to be run

Returns:

  • (String)

    The output of the command



221
222
223
# File 'lib/roku_builder/controller.rb', line 221

def self.system(command:)
  `#{command}`.chomp
end