Sha256: 86209278df65b969cc7696e486e03a465fb26e1b2b599a8b6a58721576ba60b6

Contents?: true

Size: 1.03 KB

Versions: 17

Compression:

Stored size: 1.03 KB

Contents

# encoding: utf-8
module ProxyTester
  class RemoteRepository

    private

    attr_reader :repository

    public

    # Create Remote Repository
    def initialize(repository)
      @repository = parse(repository)
    end

    # source path of repository
    #
    # @return [String]
    #   base path to repository
    #
    # @example
    #   http://githost/repo.git => repo
    #   user@host:/githost/repo.git => repo
    def base
      ::File.basename(repository.path, '.*')
    end

    # source path of repository
    #
    # @return [String]
    #   path to repository
    def source
      repository.to_s
    end

    private

    def parse(repo_string)
      repo_string = ::File.expand_path(repo_string) if repo_string =~ %r{^(?:[^/@]+/)*[^/]+$}

      repo = Addressable::URI.heuristic_parse(repo_string)

      if repo.scheme.blank?
        repo.scheme    = 'file'
        repo.authority = ''
        repo.path      = repo_string
      elsif repo.scheme == 'ssh'
        repo.host = repo.host + ':'
      end

      repo
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
proxy_tester-0.1.10 lib/proxy_tester/remote_repository.rb
proxy_tester-0.1.8 lib/proxy_tester/remote_repository.rb
proxy_tester-0.1.6 lib/proxy_tester/remote_repository.rb
proxy_tester-0.1.5 lib/proxy_tester/remote_repository.rb
proxy_tester-0.1.4 lib/proxy_tester/remote_repository.rb
proxy_tester-0.1.3 lib/proxy_tester/remote_repository.rb
proxy_tester-0.1.2 lib/proxy_tester/remote_repository.rb
proxy_tester-0.1.1 lib/proxy_tester/remote_repository.rb
proxy_tester-0.1.0 lib/proxy_tester/remote_repository.rb
proxy_tester-0.0.9 lib/proxy_tester/remote_repository.rb
proxy_tester-0.0.8 lib/proxy_tester/remote_repository.rb
proxy_tester-0.0.7 lib/proxy_tester/remote_repository.rb
proxy_tester-0.0.6 lib/proxy_tester/remote_repository.rb
proxy_tester-0.0.5 lib/proxy_tester/remote_repository.rb
proxy_tester-0.0.4 lib/proxy_tester/remote_repository.rb
proxy_tester-0.0.3 lib/proxy_tester/remote_repository.rb
proxy_tester-0.0.2 lib/proxy_tester/remote_repository.rb