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:) ⇒ Object
Deeplink to an app.
Methods included from Plugin
commands, dependencies, parse_options
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 |
# File 'lib/roku_builder/plugins/linker.rb', line 9 def self.commands { deeplink: {device: true, stage: true}, applist: {device: true} } end |
.dependencies ⇒ Object
30 31 32 |
# File 'lib/roku_builder/plugins/linker.rb', line 30 def self.dependencies [Loader] end |
.parse_options(parser:, options:) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/roku_builder/plugins/linker.rb', line 16 def self.(parser:, options:) parser.separator "Commands:" parser.on("-o", "--deeplink OPTIONS", "Deeplink into app. Define options as keypairs. (eg. a:b, c:d,e:f)") do |o| [:deeplink] = 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
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/roku_builder/plugins/linker.rb', line 61 def applist(options:) path = "/query/apps" conn = multipart_connection(port: 8060) response = conn.get path 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:) ⇒ Object
Deeplink to an app
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/roku_builder/plugins/linker.rb', line 35 def deeplink(options:) if .has_source? Loader.new(config: @config).sideload(options: ) end app_id = [:app_id] app_id ||= "dev" path = "/launch/#{app_id}" payload = RokuBuilder.(options: [:deeplink]) unless payload.keys.count > 0 @logger.warn "No options sent to launched app" else payload = parameterize(payload) path = "#{path}?#{payload}" @logger.info "Deeplink:" @logger.info payload @logger.info "CURL:" @logger.info "curl -d '' '#{@url}:8060#{path}'" end response = multipart_connection(port: 8060).post path @logger.fatal("Failed Deeplinking") unless response.success? end |