Sha256: 9b0212b50c95a5d936d140b313e5d17c8a5e42b57ea032d5fc1dc8a2def84fc8

Contents?: true

Size: 1.04 KB

Versions: 20

Compression:

Stored size: 1.04 KB

Contents

require 'fileutils'
require 'forwardable'
require File.expand_path('test_server_files',
                         File.dirname(__FILE__))

class ExampleServer

  extend Forwardable
  include FileUtils
  include TestServerFiles

  def initialize(args = nil)
    command = [
      File.expand_path('../../examples/example.rb',
                       File.dirname(__FILE__)),
      args,
    ].join(' ')
    @io = IO.popen(command, 'r+')
    @output = read_output
  end

  def stop 
    @io.close
  end

  def host
    @output[/Host: (.*)$/, 1]
  end

  def port
    @output[/Port: (.*)$/, 1].to_i
  end

  def user
    @output[/User: "(.*)"$/, 1]
  end

  def password
    @output[/Pass: "(.*)"$/, 1]
  end

  def account
    @output[/Account: "(.*)"$/, 1]
  end

  def auth_level
    Ftpd::AUTH_PASSWORD
  end

  private

  def read_output
    output = ''
    loop do
      line = @io.gets
      break if line.nil?
      output << line
      break if line =~ /FTP server started/
    end
    output
  end

  def temp_dir
    @output[/Directory: (.*)$/, 1]
  end

end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
ftpd-1.1.1 features/support/example_server.rb
ftpd-1.1.0 features/support/example_server.rb
investtools-ftpd-1.0.1 features/support/example_server.rb
ftpd-1.0.1 features/support/example_server.rb
ftpd-1.0.0 features/support/example_server.rb
ftpd-0.17.0 features/support/example_server.rb
ftpd-0.16.0 features/support/example_server.rb
ftpd-0.15.0 features/support/example_server.rb
ftpd-0.14.0 features/support/example_server.rb
ftpd-0.13.0 features/support/example_server.rb
ftpd-0.12.0 features/support/example_server.rb
ftpd-0.11.0 features/support/example_server.rb
ftpd-0.10.0 features/support/example_server.rb
ftpd-0.9.0 features/support/example_server.rb
ftpd-0.7.1 features/support/example_server.rb
ftpd-0.8.0 features/support/example_server.rb
ftpd-0.7.0 features/support/example_server.rb
ftpd-0.6.0 features/support/example_server.rb
ftpd-0.5.0 features/support/example_server.rb
ftpd-0.4.0 features/support/example_server.rb