Class: Ftpmock::NetSftpProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/ftpmock/proxies/net_sftp_proxy.rb

Constant Summary collapse

Real =

Stubbers

begin
  Net::SFTP
rescue NameError
  nil
end

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration: Ftpmock.configuration) ⇒ NetSftpProxy

Instance Methods



37
38
39
# File 'lib/ftpmock/proxies/net_sftp_proxy.rb', line 37

def initialize(configuration: Ftpmock.configuration)
  @configuration = configuration
end

Class Method Details

.off!Object



28
29
30
31
32
33
# File 'lib/ftpmock/proxies/net_sftp_proxy.rb', line 28

def self.off!
  return unless Real

  Net.send(:remove_const, :SFTP)
  Net.const_set(:SFTP, Real)
end

.on!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ftpmock/proxies/net_sftp_proxy.rb', line 14

def self.on!
  unless Real
    yield
    return
  end

  Net.send(:remove_const, :SFTP)
  Net.const_set(:SFTP, self)
  if block_given?
    yield
    off!
  end
end

Instance Method Details

#realObject

def self.start(*)

i = new
yield i

end



46
47
48
# File 'lib/ftpmock/proxies/net_sftp_proxy.rb', line 46

def real
  @real ||= Real.new
end