File: scp.rb

package info (click to toggle)
ruby-net-scp 1.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 216 kB
  • sloc: ruby: 1,913; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 755 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'uri/generic'

module URI
  class SCP < Generic
    DEFAULT_PORT = 22

    COMPONENT = [
      :scheme,
      :userinfo,
      :host, :port, :path,
      :query  
    ].freeze

    attr_reader :options

    def self.new2(user, password, host, port, path, query)
      new('scp', [user, password], host, port, nil, path, nil, query)
    end

    def initialize(*args)
      super(*args)

      @options = Hash.new
      (query || "").split(/&/).each do |pair|
        name, value = pair.split(/=/, 2)
        opt_name = name.to_sym
        values = value.split(/,/).map { |v| v.to_i.to_s == v ? v.to_i : v }
        values = values.first if values.length == 1
        options[opt_name] = values
      end
    end
  end

  @@schemes['SCP'] = SCP
end