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.


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

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


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

def current_resource
  @current_resource
end

#new_resourceObject (readonly)

Returns the value of attribute new_resource


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

def new_resource
  @new_resource
end

#uriObject (readonly)

Returns the value of attribute uri


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

def uri
  @uri
end

Instance Method Details

#directoriesObject


77
78
79
80
# File 'lib/chef/provider/remote_file/ftp.rb', line 77

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

#fetchObject


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

def fetch
  with_connection do
    get
  end
end

#filenameObject


82
83
84
85
# File 'lib/chef/provider/remote_file/ftp.rb', line 82

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

#ftpObject


93
94
95
# File 'lib/chef/provider/remote_file/ftp.rb', line 93

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

#hostnameObject


45
46
47
# File 'lib/chef/provider/remote_file/ftp.rb', line 45

def hostname
  @uri.host
end

#passObject


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

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

#portObject


49
50
51
# File 'lib/chef/provider/remote_file/ftp.rb', line 49

def port
  @uri.port
end

#typecodeObject


57
58
59
# File 'lib/chef/provider/remote_file/ftp.rb', line 57

def typecode
  uri.typecode
end

#use_passive_mode?Boolean

Returns:

  • (Boolean)

53
54
55
# File 'lib/chef/provider/remote_file/ftp.rb', line 53

def use_passive_mode?
  ! new_resource.ftp_active_mode
end

#userObject


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

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