Class: RokuBuilder::Linker

Inherits:
Util
  • Object
show all
Defined in:
lib/roku_builder/linker.rb

Overview

Launch application, sending parameters

Instance Method Summary collapse

Methods inherited from Util

#init, #initialize, #multipart_connection, options_parse, #simple_connection

Constructor Details

This class inherits a constructor from RokuBuilder::Util

Instance Method Details

#launch(options: nil, app_id: "dev") ⇒ Object

Note:

Options string should be formated like the following: “<key>:<value>[, <key>:<value>]*”

Note:

Any options will be accepted and sent to the app

Deeplink to an app

Parameters:

  • options (String) (defaults to: nil)

    Options string

  • app_id (String) (defaults to: "dev")

    Id of the app to launch (defaults to dev)

  • logger (Logger)

    System Logger



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/roku_builder/linker.rb', line 13

def launch(options: nil, app_id: "dev")
  path = "/launch/#{app_id}"
  payload = Util.options_parse(options: options)

  unless payload.keys.count > 0
    @logger.warn "No options sent to launched app"
  else
    path = "#{path}?#{parameterize(payload)}"
  end

  conn = multipart_connection(port: 8060)

  response = conn.post path
  return response.success?
end

#listObject

List currently installed apps

Parameters:

  • logger (Logger)

    System Logger



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/roku_builder/linker.rb', line 31

def list()
  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