Class: RokuBuilder::Loader

Inherits:
Util
  • Object
show all
Extended by:
Plugin
Defined in:
lib/roku_builder/plugins/loader.rb

Overview

Load/Unload/Build roku applications

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Plugin

commands, dependencies, parse_options, validate

Methods inherited from Util

#initialize

Constructor Details

This class inherits a constructor from RokuBuilder::Util

Class Method Details

.commandsObject



13
14
15
16
17
18
19
20
# File 'lib/roku_builder/plugins/loader.rb', line 13

def self.commands
  {
    sideload: {source: true, device: true, stage: true},
    build: {source: true, stage: true, exclude: true},
    delete: {device: true},
    squash: {device: true}
  }
end

.dependenciesObject



45
46
47
# File 'lib/roku_builder/plugins/loader.rb', line 45

def self.dependencies
  [Navigator]
end

.parse_options(parser:, options:) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/roku_builder/plugins/loader.rb', line 22

def self.parse_options(parser:, options:)
  parser.separator "Commands:"
  parser.on("-l", "--sideload", "Sideload an app") do
    options[:sideload] = true
  end
  parser.on("-d", "--delete", "Delete the currently sideloaded app") do
    options[:delete] = true
  end
  parser.on("-b", "--build", "Build a zip to be sideloaded") do
    options[:build] = true
  end
  parser.on("--squash", "Convert currently sideloaded application to squashfs") do
    options[:squash] = true
  end
  parser.separator "Options:"
  parser.on("-x", "--exclude", "Apply exclude config to sideload") do
    options[:exclude] = true
  end
  parser.on("--remote-debug", "Sideload will enable remote debug") do
    options[:remoteDebug] = true
  end
end

Instance Method Details

#build(options:) ⇒ Object

Build an app to sideload later



65
66
67
68
69
70
71
72
73
# File 'lib/roku_builder/plugins/loader.rb', line 65

def build(options:)
  @options = options
  build_zip(setup_build_content)
  if options.command == :build or (options.command == :sideload and options[:out])
    @logger.info "File Path: "+file_path(:out)
  end
  @config.in = @config.out #setting in path for possible sideload
  file_path(:out)
end

#copy(options:, path:) ⇒ Object



93
94
95
96
97
# File 'lib/roku_builder/plugins/loader.rb', line 93

def copy(options:, path:)
  @options = options
  @target = path
  copy_channel_files(setup_build_content)
end

#delete(options:, ignoreFailure: false) ⇒ Object

Remove the currently sideloaded app



76
77
78
79
80
81
82
# File 'lib/roku_builder/plugins/loader.rb', line 76

def delete(options:, ignoreFailure: false)
  payload =  {mysubmit: "Delete", archive: ""}
  response  = multipart_connection.post "/plugin_install", payload
  unless response.status == 200 and response.body =~ /Delete Succeeded/ or ignoreFailure
    raise ExecutionError, "Failed Unloading"
  end
end

#initObject



9
10
11
# File 'lib/roku_builder/plugins/loader.rb', line 9

def init
  @warningFileSize = 500 * 1024
end

#sideload(options:) ⇒ Object

Sideload an app onto a roku device



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/roku_builder/plugins/loader.rb', line 50

def sideload(options:)
  delete(options: options, ignoreFailure: true)
  did_build = false
  unless options[:in]
    did_build = true
    build(options: options)
  end
  keep_build_file = is_build_command(options) and options[:out]
  upload(options)
  # Cleanup
  File.delete(file_path(:in)) if did_build and not keep_build_file
end

#squash(options:, ignoreFailure: false) ⇒ Object

Convert sideloaded app to squashfs



85
86
87
88
89
90
91
# File 'lib/roku_builder/plugins/loader.rb', line 85

def squash(options:, ignoreFailure: false)
  payload =  {mysubmit: "Convert to squashfs", archive: ""}
  response  = multipart_connection.post "/plugin_install", payload
  unless response.status == 200 and response.body =~ /Conversion succeeded/ or ignoreFailure
    raise ExecutionError, "Failed Converting to Squashfs"
  end
end