Class: Chef::Provider::RemoteFile::FTP

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/provider/remote_file/ftp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, new_resource, current_resource) ⇒ FTP

Returns a new instance of FTP.



35
36
37
38
39
40
41
# File 'lib/chef/provider/remote_file/ftp.rb', line 35

def initialize(uri, new_resource, current_resource)
  @uri = uri
  @new_resource = new_resource
  @current_resource = current_resource
  validate_typecode!
  validate_path!
end

Instance Attribute Details

#current_resourceObject (readonly)

Returns the value of attribute current_resource.



33
34
35
# File 'lib/chef/provider/remote_file/ftp.rb', line 33

def current_resource
  @current_resource
end

#new_resourceObject (readonly)

Returns the value of attribute new_resource.



32
33
34
# File 'lib/chef/provider/remote_file/ftp.rb', line 32

def new_resource
  @new_resource
end

#uriObject (readonly)

Returns the value of attribute uri.



31
32
33
# File 'lib/chef/provider/remote_file/ftp.rb', line 31

def uri
  @uri
end

Instance Method Details

#directoriesObject



75
76
77
78
# File 'lib/chef/provider/remote_file/ftp.rb', line 75

def directories
  parse_path if @directories.nil?
  @directories
end

#fetchObject



85
86
87
88
89
# File 'lib/chef/provider/remote_file/ftp.rb', line 85

def fetch
  with_connection do
    get
  end
end

#filenameObject



80
81
82
83
# File 'lib/chef/provider/remote_file/ftp.rb', line 80

def filename
  parse_path if @filename.nil?
  @filename
end

#ftpObject



91
92
93
# File 'lib/chef/provider/remote_file/ftp.rb', line 91

def ftp
  @ftp ||= Net::FTP.new
end

#hostnameObject



43
44
45
# File 'lib/chef/provider/remote_file/ftp.rb', line 43

def hostname
  @uri.host
end

#passObject



67
68
69
70
71
72
73
# File 'lib/chef/provider/remote_file/ftp.rb', line 67

def pass
  if uri.userinfo
    CGI.unescape(uri.password)
  else
    nil
  end
end

#portObject



47
48
49
# File 'lib/chef/provider/remote_file/ftp.rb', line 47

def port
  @uri.port
end

#typecodeObject



55
56
57
# File 'lib/chef/provider/remote_file/ftp.rb', line 55

def typecode
  uri.typecode
end

#use_passive_mode?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/chef/provider/remote_file/ftp.rb', line 51

def use_passive_mode?
  ! new_resource.ftp_active_mode
end

#userObject



59
60
61
62
63
64
65
# File 'lib/chef/provider/remote_file/ftp.rb', line 59

def user
  if uri.userinfo
    CGI.unescape(uri.user)
  else
    "anonymous"
  end
end