Class: OodAppkit::Urls::Shell

Inherits:
OodAppkit::Url show all
Defined in:
lib/ood_appkit/urls/shell.rb

Overview

A class used to handle URLs for the system Shell app.

Instance Attribute Summary

Attributes inherited from OodAppkit::Url

#title

Instance Method Summary collapse

Constructor Details

#initialize(ssh_url: '/ssh', template: '{/url*}/{host}{+path}', **kwargs) ⇒ Shell

Returns a new instance of Shell.

Parameters:

  • ssh_url (#to_s) (defaults to: '/ssh')

    the ssh URL used to access the terminal

  • title (#to_s)

    the title of the URL

  • base_url (#to_s)

    the base URL used to access this app

  • template (#to_s) (defaults to: '{/url*}/{host}{+path}')

    the template used to generate URLs for this app



7
8
9
10
# File 'lib/ood_appkit/urls/shell.rb', line 7

def initialize(ssh_url: '/ssh', template: '{/url*}/{host}{+path}', **kwargs)
  super(template: template, **kwargs)
  @ssh_url = parse_url_segments(ssh_url.to_s)
end

Instance Method Details

#url(opts = {}) ⇒ Addressable::URI

URL to access this app for a given host and absolute file path

Parameters:

  • opts (#to_h) (defaults to: {})

    the available options for this method

Options Hash (opts):

  • :host (#to_s, nil) — default: "default"

    The host the app will make an ssh connection to

  • :path (#to_s, nil) — default: ""

    The absolute path to the directory the ssh app opens up in

Returns:

  • (Addressable::URI)

    the url used to access the app



19
20
21
22
23
24
25
# File 'lib/ood_appkit/urls/shell.rb', line 19

def url(opts = {})
  opts = opts.to_h.compact.symbolize_keys

  host = opts.fetch(:host, "default").to_s
  path = opts.fetch(:path, "").to_s
  @template.expand url: @base_url + @ssh_url, host: host, path: path
end