Class: RokuBuilder::Linker
- Extended by:
- Plugin
- Defined in:
- lib/roku_builder/plugins/linker.rb
Overview
Launch application, sending parameters
Class Method Summary collapse
Instance Method Summary collapse
-
#applist(options:) ⇒ Object
List currently installed apps.
-
#deeplink(options:, device: nil) ⇒ Object
Deeplink to an app.
- #input(options:) ⇒ Object
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
9 10 11 12 13 14 15 |
# File 'lib/roku_builder/plugins/linker.rb', line 9 def self.commands { deeplink: {device: true, stage: true}, input: {device: true}, applist: {device: true} } end |
.dependencies ⇒ Object
34 35 36 |
# File 'lib/roku_builder/plugins/linker.rb', line 34 def self.dependencies [Loader] end |
.parse_options(parser:, options:) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/roku_builder/plugins/linker.rb', line 17 def self.(parser:, options:) parser.separator "Commands:" parser.on("-o", "--deeplink OPTIONS", "Launch and Deeplink into app. Define options as keypairs (eg. \"a:b, c:d,e:f\") or name (eg. \"name\"). To use named deeplinks, including them in your config file: \"deeplinks\": { \"name\": \"a:b, c:d, e:f\" }") do |o| [:deeplink] = o end parser.on("-i", "--input OPTIONS", "Deeplink into app. Define options as keypairs (eg. \"a:b, c:d,e:f\") or name (eg. \"name\"). To use named deeplinks, including them in your config file: \"deeplinks\": { \"name\": \"a:b, c:d, e:f\" }") do |o| [:input] = o end parser.on("-A", "--app-list", "List currently installed apps") do [:applist] = true end parser.separator "Options:" parser.on("-a", "--app ID", "Send App id for deeplinking") do |a| [:app_id] = a end end |
Instance Method Details
#applist(options:) ⇒ Object
List currently installed apps
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/roku_builder/plugins/linker.rb', line 57 def applist(options:) path = "/query/apps" response = nil multipart_connection(port: 8060) do |conn| response = conn.get path end if response.success? regexp = /id="([^"]*)"\stype="([^"]*)"\sversion="([^"]*)">([^<]*)</ apps = response.body.scan(regexp) printf("%30s | %10s | %10s | %10s\n", "title", "id", "type", "version") printf("---------------------------------------------------------------------\n") apps.each do |app| printf("%30s | %10s | %10s | %10s\n", app[3], app[0], app[1], app[2]) end end end |
#deeplink(options:, device: nil) ⇒ Object
Deeplink to an app
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/roku_builder/plugins/linker.rb', line 39 def deeplink(options:, device: nil) get_device(device: device) do |device| if .has_source? Loader.new(config: @config).sideload(options: , device: device) end app_id = [:app_id] app_id ||= "dev" path = "/launch/#{app_id}" (path: path, options: [:deeplink], device: device) end end |
#input(options:) ⇒ Object
51 52 53 |
# File 'lib/roku_builder/plugins/linker.rb', line 51 def input(options:) (path: "/input", options: [:input]) end |