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



166
167
168
169
170
# File 'lib/roku_builder/controller.rb', line 166

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

.depricated_optionsHash

List of depricated options

Returns:

  • (Hash)

    Hash of depricated options and the warning message for each



174
175
176
# File 'lib/roku_builder/controller.rb', line 174

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

.device_commandsArray<Symbol>

List of commands that require a device

Returns:

  • (Array<Symbol>)

    List of commands that require a device



198
199
200
201
# File 'lib/roku_builder/controller.rb', line 198

def self.device_commands
  [:sideload, :package, :test, :deeplink, :delete, :navigate, :text,
    :monitor, :screencapture, :applist, :print ]
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



192
193
194
# File 'lib/roku_builder/controller.rb', line 192

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

.run(options:) ⇒ Object

Run the builder

Parameters:

  • options (Hash)

    The options hash



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
41
42
# File 'lib/roku_builder/controller.rb', line 10

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



186
187
188
# File 'lib/roku_builder/controller.rb', line 186

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



180
181
182
# File 'lib/roku_builder/controller.rb', line 180

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



232
233
234
# File 'lib/roku_builder/controller.rb', line 232

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