Class: RokuBuilder::Loader
- 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
-
#build(options:) ⇒ Object
Build an app to sideload later.
- #copy(options:, path:) ⇒ Object
-
#delete(options:, ignoreFailure: false) ⇒ Object
Remove the currently sideloaded app.
- #init ⇒ Object
-
#sideload(options:, device: nil) ⇒ Object
Sideload an app onto a roku device.
-
#squash(options:, device: nil, ignoreFailure: false) ⇒ Object
Convert sideloaded app to squashfs.
Methods included from Plugin
commands, dependencies, parse_options, validate
Methods inherited from Util
Constructor Details
This class inherits a constructor from RokuBuilder::Util
Class Method Details
.commands ⇒ Object
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 |
.dependencies ⇒ Object
48 49 50 |
# File 'lib/roku_builder/plugins/loader.rb', line 48 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 44 45 46 |
# File 'lib/roku_builder/plugins/loader.rb', line 22 def self.(parser:, options:) parser.separator "Commands:" parser.on("-l", "--sideload", "Sideload an app") do [:sideload] = true end parser.on("-d", "--delete", "Delete the currently sideloaded app") do [:delete] = true end parser.on("-b", "--build", "Build a zip to be sideloaded") do [:build] = true end parser.on("--squash", "Convert currently sideloaded application to squashfs") do [:squash] = true end parser.separator "Options:" parser.on("-x", "--exclude", "Apply exclude config to sideload") do [:exclude] = true end parser.on("--remote-debug", "Sideload will enable remote debug") do [:remoteDebug] = true end parser.on("--build-dir DIR", "The directory to load files from when building the app") do |dir| [:build_dir] = dir end end |
Instance Method Details
#build(options:) ⇒ Object
Build an app to sideload later
83 84 85 86 87 88 89 90 91 |
# File 'lib/roku_builder/plugins/loader.rb', line 83 def build(options:) @options = build_zip(setup_build_content) if .command == :build or (.command == :sideload and [: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
123 124 125 126 127 |
# File 'lib/roku_builder/plugins/loader.rb', line 123 def copy(options:, path:) @options = @target = path copy_channel_files(setup_build_content) end |
#delete(options:, ignoreFailure: false) ⇒ Object
Remove the currently sideloaded app
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/roku_builder/plugins/loader.rb', line 94 def delete(options:, ignoreFailure: false) payload = { mysubmit: make_param("Delete"), archive: make_param("", "application/octet-stream") } response = nil multipart_connection do |conn| response = conn.post "/plugin_install", payload end unless response.status == 200 and response.body =~ /Delete Succeeded/ or ignoreFailure raise ExecutionError, "Failed Unloading" end end |
#init ⇒ Object
9 10 11 |
# File 'lib/roku_builder/plugins/loader.rb', line 9 def init @warningFileSize = 500 * 1024 end |
#sideload(options:, device: nil) ⇒ Object
Sideload an app onto a roku device
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/roku_builder/plugins/loader.rb', line 53 def sideload(options:, device: nil) if ![:logfile].nil? if [:logfile].match("config") [:logfile] = @config.console_log end if [:clearfile] if ![:logfile].nil? File.delete([:logfile]) if File.exist?([:logfile]) else @logger.unknown "Cannot clear, console_log file not set." end end end did_build = false unless [:in] did_build = true build(options: ) end keep_build_file = is_build_command() and [:out] upload(options: , device: device) # Cleanup begin File.delete(file_path(:in)) if did_build and not keep_build_file rescue Errno::EACCES @logger.warn "Unable to delete: " + file_path(:in) end end |
#squash(options:, device: nil, ignoreFailure: false) ⇒ Object
Convert sideloaded app to squashfs
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/roku_builder/plugins/loader.rb', line 109 def squash(options:, device: nil, ignoreFailure: false) payload = { mysubmit: "Convert to squashfs", archive: make_param("", "application/octet-stream") } response = nil multipart_connection(device: device) do |conn| response = conn.post "/plugin_install", payload end unless response.status == 200 and response.body =~ /Conversion succeeded/ or ignoreFailure raise ExecutionError, "Failed Converting to Squashfs" end end |