Sha256: e34e85f642b1a85d9ee2a77d8939c6f3b4c5da71a87264f7a01778a8d80f32ad

Contents?: true

Size: 771 Bytes

Versions: 3

Compression:

Stored size: 771 Bytes

Contents

require 'addressable'

module Bolt
  class NodeURI
    def initialize(string, transport = 'ssh')
      @uri = parse(string, transport)
    end

    def parse(string, transport)
      uri = if string =~ %r{^[^:]+://}
              Addressable::URI.parse(string)
            else
              Addressable::URI.parse("#{transport}://#{string}")
            end
      uri.port ||= 5985 if uri.scheme == 'winrm'
      uri
    end
    private :parse

    def hostname
      @uri.hostname
    end

    def port
      @uri.port
    end

    def user
      Addressable::URI.unencode_component(
        @uri.user
      )
    end

    def password
      Addressable::URI.unencode_component(
        @uri.password
      )
    end

    def scheme
      @uri.scheme
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bolt-0.9.0 lib/bolt/node_uri.rb
bolt-0.8.0 lib/bolt/node_uri.rb
bolt-0.7.0 lib/bolt/node_uri.rb