Sha256: b4c9a0a5f27481c7d0b82024cf93a5f0e4fcc95545da76411e65f2547e3aa220

Contents?: true

Size: 1.32 KB

Versions: 9

Compression:

Stored size: 1.32 KB

Contents

module Pione
  module Location
    # MyFTPScheme is a special scheme for launching PIONE embedded ftp server.
    #
    # @example
    #   URI.parse("myftp:./output")
    # @example
    #   URI.parse("myftp://abc:123@192.168.0.32:45321/home/keita/pione/output")
    class MyFTPScheme < LocationScheme('myftp', :storage => true)
      PORT = 39123

      COMPONENT = [:scheme, :user, :password, :host, :port, :path]

      # Normalize the URI.
      #
      # @return [URI]
      #   normalized URI
      def normalize
        hash = {
          :scheme => "myftp",
          :userinfo => userinfo || Util::FTPServer.auth_info.to_userinfo,
          :host => (host == "myself" or host.nil?) ? Util::IPAddress.myself : host,
          :port => port || PORT,
          :path => File.expand_path(path, Global.pwd) + (directory? ? "/" : "")
        }
        MyFTPScheme.build(hash)
      end

      # Return ftp scheme that refers the ftp server.
      #
      # @return [URI]
      #   ftp scheme URI
      def to_ftp_scheme
        hash = {
          :scheme => "ftp",
          :userinfo => userinfo || Util::FTPServer.auth_info.to_userinfo,
          :host => (host == "myself" or host.nil?) ? Util::IPAddress.myself : host,
          :port => port || PORT,
          :path => "/"
        }
        URI::FTP.build(hash)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pione-0.5.0 lib/pione/location/myftp-scheme.rb
pione-0.5.0.alpha.2 lib/pione/location/myftp-scheme.rb
pione-0.5.0.alpha.1 lib/pione/location/myftp-scheme.rb
pione-0.4.2 lib/pione/location/myftp-scheme.rb
pione-0.4.1 lib/pione/location/myftp-scheme.rb
pione-0.4.0 lib/pione/location/myftp-scheme.rb
pione-0.3.2 lib/pione/location/myftp-scheme.rb
pione-0.3.1 lib/pione/location/myftp-scheme.rb
pione-0.3.0 lib/pione/location/myftp-scheme.rb