Sha256: 64a248a5e0168fb29327080d7511c58f88a445256a2054254bfb34218d825def

Contents?: true

Size: 634 Bytes

Versions: 2

Compression:

Stored size: 634 Bytes

Contents

module Bolt
  class NodeURI
    def initialize(string)
      @uri = parse(string)
    end

    def parse(string)
      case string
      when %r{^(ssh|winrm|pcp)://.*:\d+$}
        URI(string)
      when %r{^pcp://}
        URI(string)
      when %r{^(ssh|winrm)://}
        uri = URI(string)
        uri.port = 5985 if uri.scheme == 'winrm'
        uri
      else
        URI("ssh://#{string}")
      end
    end

    def hostname
      @uri.hostname
    end

    def port
      @uri.port
    end

    def user
      @uri.user
    end

    def password
      @uri.password
    end

    def scheme
      @uri.scheme
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bolt-0.5.1 lib/bolt/node_uri.rb
bolt-0.5.0 lib/bolt/node_uri.rb