Sha256: d6b2032393afe1c7b0084d73c69f1b3c434c665444eae7293ec7845fc5e67b5f

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 Bytes

Contents

require 'gitable/uri'

module Gitable
  class ScpURI < Gitable::URI
    # Keep URIs like this relative:
    #
    #     git@github.com:martinemde/gitable.git
    #
    # Without breaking URIs like these:
    # 
    #     git@host.com:/home/martinemde/gitable.git
    #
    def path=(new_path)
      super
      if new_path[0..0] != "/"
        @path = path.sub(%r|^/|,'')
      end
      path
    end

    def to_s
      @uri_string ||= begin
                        uri_string = "#{authority}:#{path.to_s}"
                        if uri_string.respond_to?(:force_encoding)
                          uri_string.force_encoding(Encoding::UTF_8)
                        end
                        uri_string
                      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitable-0.0.1 lib/gitable/scp_uri.rb