Sha256: 66f460a38dbca6687a85d9b2f5fdb6a5239dba62af19918c15fae1d0fc588be5

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

module OodAppkit
  module Urls
    # A class used to handle URLs for the system Shell app.
    class Shell < Url
      # @param (see Url#initialize)
      # @param ssh_url [#to_s] the ssh URL used to access the terminal
      def initialize(ssh_url: '/ssh', template: '{/url*}/{host}{+path}', **kwargs)
        super(template: template, **kwargs)
        @ssh_url = parse_url_segments(ssh_url.to_s)
      end

      # URL to access this app for a given host and absolute file path
      # @param opts [#to_h] the available options for this method
      # @option opts [#to_s, nil] :host ("default") The host the app will make
      #   an ssh connection to
      # @option opts [#to_s, nil] :path ("") The absolute path to the directory
      #   the ssh app opens up in
      # @return [Addressable::URI] the url used to access the app
      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
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ood_appkit-2.1.4 lib/ood_appkit/urls/shell.rb
ood_appkit-2.1.1 lib/ood_appkit/urls/shell.rb
ood_appkit-2.1.0 lib/ood_appkit/urls/shell.rb
ood_appkit-2.0.2 lib/ood_appkit/urls/shell.rb
ood_appkit-1.1.5 lib/ood_appkit/urls/shell.rb
ood_appkit-1.0.3 lib/ood_appkit/urls/shell.rb
ood_appkit-1.0.2 lib/ood_appkit/urls/shell.rb
ood_appkit-1.0.1 lib/ood_appkit/urls/shell.rb