Sha256: 62127763421c2a07b859095737479ba2b085a1a7c643553f4a6871fbbd0847a3
Contents?: true
Size: 1.94 KB
Versions: 1
Compression:
Stored size: 1.94 KB
Contents
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved. # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. # License:: Gnu General Public License. # Revision:: $Id$ require 'uri_ex' module URI class Ssh < Generic SCHEME = 'ssh'.freeze DEFAULT_HOST = 'localhost'.freeze DEFAULT_PORT = 22 DEFAULT_QUERY = ''.freeze COMPONENT = [ :scheme, :userinfo, :host, :path, :query ].freeze def self.build ( args ) tmp = Util::make_components_hash(self, args) return super(tmp) end def get_opts opts = [] opts << '-q' << '-P' << @port return opts if @query.nil? @query.split(/,/).map do |x| k, v = x.split(/=/) if k.size == 1 opts << "-#{k}" else opts << "--#{k}" end opts << v unless v.nil? end opts end def mk_opts get_opts.join(' ') end def mk_arg "#@user@#@host:#{@path.gsub(/^\//, '')}" end def checkout out = TempPath.new('checkout', pathname.basename.to_s) cmd = "scp #{mk_opts} #{mk_arg} #{out}" puts cmd raise CheckoutError, to_s unless system cmd out end def save checkout.save end def commit ( aPath ) cmd = "scp #{mk_opts} #{aPath} #{mk_arg}" puts cmd raise CommitError, to_s unless system cmd end end # class Ssh @@schemes[Ssh::SCHEME.upcase] = Ssh if $0 == __FILE__ require 'test/unit' class SshTest < Test::Unit::TestCase def test_basic assert_nothing_raised { @uri = URI.parse('ssh://foo@bar') } assert_equal('-q -P 22', @uri.mk_opts) end def test_with_query assert_nothing_raised do @uri = URI.parse('ssh://foo@bar/qux?a=b,c,d=e,f,ghi,jkl=mno') end assert_equal('-q -P 22 -a b -c -d e -f --ghi --jkl mno', @uri.mk_opts) end end # class SshTest end end # module URI
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vcs-0.2.148 | ruby_ex/uri/ssh.rb |