ftp_paradise 1.4.5 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +155 -28
- data/bin/{iftp → ftp_paradise_shell} +1 -1
- data/doc/README.gen +97 -15
- data/doc/todo/{TODO_FOR_FTP_PARADISE_PROJECT.md → todo_for_the_ftp_paradise_project.md} +11 -1
- data/ftp_paradise.gemspec +30 -39
- data/lib/ftp_paradise/base/base.rb +375 -0
- data/lib/ftp_paradise/colours/colours.rb +27 -27
- data/lib/ftp_paradise/colours/use_colours.rb +6 -1
- data/lib/ftp_paradise/configuration/configuration.rb +7 -4
- data/lib/ftp_paradise/connection/README.md +0 -0
- data/lib/ftp_paradise/connection/connection.rb +2782 -15
- data/lib/ftp_paradise/constants/constants.rb +91 -5
- data/lib/ftp_paradise/entry/entry.rb +42 -5
- data/lib/ftp_paradise/{connection → gui/gtk3/ftp_client}/constants.rb +33 -21
- data/lib/ftp_paradise/gui/{shared_code/ftp_paradise/ftp_paradise_module.rb → gtk3/ftp_client/ftp_client.rb} +658 -170
- data/lib/ftp_paradise/gui/gtk3/ftp_client/misc.rb +27 -0
- data/lib/ftp_paradise/project/project.rb +11 -15
- data/lib/ftp_paradise/requires/require_class_connection.rb +7 -0
- data/lib/ftp_paradise/requires/require_net_ftp.rb +7 -0
- data/lib/ftp_paradise/requires/require_the_ftp_paradise_project.rb +4 -3
- data/lib/ftp_paradise/requires/require_the_ftp_paradise_project_with_the_GUI_bindings.rb +1 -1
- data/lib/ftp_paradise/requires/require_the_toplevel_methods.rb +1 -0
- data/lib/ftp_paradise/{interactive_ftp → shell}/menu.rb +564 -449
- data/lib/ftp_paradise/shell/shell.rb +2321 -0
- data/lib/ftp_paradise/toplevel_methods/connect.rb +3 -0
- data/lib/ftp_paradise/toplevel_methods/dataset.rb +111 -0
- data/lib/ftp_paradise/toplevel_methods/file_related_actions.rb +4 -3
- data/lib/ftp_paradise/toplevel_methods/ftp_object.rb +6 -5
- data/lib/ftp_paradise/toplevel_methods/login_name.rb +6 -4
- data/lib/ftp_paradise/toplevel_methods/misc.rb +19 -0
- data/lib/ftp_paradise/toplevel_methods/opn.rb +1 -1
- data/lib/ftp_paradise/toplevel_methods/password.rb +4 -2
- data/lib/ftp_paradise/toplevel_methods/port.rb +4 -1
- data/lib/ftp_paradise/toplevel_methods/remote_url.rb +11 -5
- data/lib/ftp_paradise/toplevel_methods/upload_and_download.rb +1 -0
- data/lib/ftp_paradise/version/version.rb +6 -1
- data/lib/ftp_paradise/www/web_interface.cgi +1 -1
- data/lib/ftp_paradise/yaml/automatically_connect_on_startup_of_the_interactive_ftp_shell.yml +0 -0
- data/lib/ftp_paradise/yaml/debug.yml +0 -0
- data/lib/ftp_paradise/yaml/open_in_default_editor.yml +0 -0
- data/lib/ftp_paradise/yaml/show_full_names.yml +0 -0
- data/lib/ftp_paradise/yaml/use_colours.yml +0 -0
- data/test/testing_minimal_pure_net_ftp_example_to_connect.rb +13 -3
- metadata +52 -126
- data/lib/ftp_paradise/base/cliner.rb +0 -23
- data/lib/ftp_paradise/base/colours.rb +0 -83
- data/lib/ftp_paradise/base/prototype.rb +0 -171
- data/lib/ftp_paradise/base/reset.rb +0 -29
- data/lib/ftp_paradise/connection/data.rb +0 -164
- data/lib/ftp_paradise/connection/debug.rb +0 -78
- data/lib/ftp_paradise/connection/directory_handling.rb +0 -271
- data/lib/ftp_paradise/connection/do_login.rb +0 -108
- data/lib/ftp_paradise/connection/download.rb +0 -86
- data/lib/ftp_paradise/connection/file_handling.rb +0 -174
- data/lib/ftp_paradise/connection/ftp_object.rb +0 -21
- data/lib/ftp_paradise/connection/initialize.rb +0 -88
- data/lib/ftp_paradise/connection/initialize_a_new_net_ftp_object_with_this_url.rb +0 -20
- data/lib/ftp_paradise/connection/is_connected.rb +0 -46
- data/lib/ftp_paradise/connection/misc.rb +0 -474
- data/lib/ftp_paradise/connection/notify.rb +0 -71
- data/lib/ftp_paradise/connection/password.rb +0 -47
- data/lib/ftp_paradise/connection/port.rb +0 -33
- data/lib/ftp_paradise/connection/remote_pwd.rb +0 -72
- data/lib/ftp_paradise/connection/remote_url.rb +0 -164
- data/lib/ftp_paradise/connection/remove.rb +0 -143
- data/lib/ftp_paradise/connection/reset.rb +0 -78
- data/lib/ftp_paradise/connection/run.rb +0 -18
- data/lib/ftp_paradise/connection/set_array_available_hosts.rb +0 -27
- data/lib/ftp_paradise/connection/set_input.rb +0 -18
- data/lib/ftp_paradise/connection/show.rb +0 -153
- data/lib/ftp_paradise/connection/sync_ftp_object_onto_the_main_namespace.rb +0 -24
- data/lib/ftp_paradise/connection/transfer_mode.rb +0 -163
- data/lib/ftp_paradise/connection/upload.rb +0 -253
- data/lib/ftp_paradise/connection/use_default_dataset.rb +0 -40
- data/lib/ftp_paradise/connection/username.rb +0 -42
- data/lib/ftp_paradise/constants/misc.rb +0 -57
- data/lib/ftp_paradise/constants/namespace.rb +0 -14
- data/lib/ftp_paradise/constants/newline.rb +0 -14
- data/lib/ftp_paradise/constants/roebe.rb +0 -31
- data/lib/ftp_paradise/constants/roebe_ftp_constants.rb +0 -233
- data/lib/ftp_paradise/gui/gtk2/ftp_paradise.rb +0 -34
- data/lib/ftp_paradise/gui/gtk3/ftp_paradise.rb +0 -34
- data/lib/ftp_paradise/interactive_ftp/constants.rb +0 -103
- data/lib/ftp_paradise/interactive_ftp/directory_handling.rb +0 -216
- data/lib/ftp_paradise/interactive_ftp/help.rb +0 -50
- data/lib/ftp_paradise/interactive_ftp/initialize.rb +0 -27
- data/lib/ftp_paradise/interactive_ftp/interactive_ftp.rb +0 -998
- data/lib/ftp_paradise/interactive_ftp/main_loop.rb +0 -51
- data/lib/ftp_paradise/interactive_ftp/misc.rb +0 -208
- data/lib/ftp_paradise/interactive_ftp/mode.rb +0 -124
- data/lib/ftp_paradise/interactive_ftp/readline.rb +0 -113
- data/lib/ftp_paradise/interactive_ftp/remove.rb +0 -97
- data/lib/ftp_paradise/interactive_ftp/reset.rb +0 -90
- data/lib/ftp_paradise/interactive_ftp/run.rb +0 -22
- data/lib/ftp_paradise/interactive_ftp/show.rb +0 -184
- data/lib/ftp_paradise/interactive_ftp/upload.rb +0 -90
- data/lib/ftp_paradise/interactive_ftp/user_input.rb +0 -53
- data/lib/ftp_paradise/toplevel_methods/can_connect_to_remote_site.rb +0 -28
- data/lib/ftp_paradise/toplevel_methods/clear_user_dataset.rb +0 -28
- data/lib/ftp_paradise/toplevel_methods/data.rb +0 -31
- data/lib/ftp_paradise/toplevel_methods/determine_user_dataset_from_this_hash.rb +0 -37
@@ -1,164 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/connection/remote_url.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
class Connection
|
10
|
-
|
11
|
-
require 'ftp_paradise/toplevel_methods/remote_url.rb'
|
12
|
-
|
13
|
-
# ========================================================================= #
|
14
|
-
# === remote_url?
|
15
|
-
#
|
16
|
-
# This method is guaranteed to return a String.
|
17
|
-
# ========================================================================= #
|
18
|
-
def remote_url?
|
19
|
-
begin
|
20
|
-
return FtpParadise.remote_url?.to_s
|
21
|
-
rescue Interrupt
|
22
|
-
exit # User interrupted, so we exit as requested.
|
23
|
-
rescue Exception => error
|
24
|
-
opnn; e 'We did encounter an error in the method '+
|
25
|
-
simp(__method__.to_s)
|
26
|
-
opnn; pp error
|
27
|
-
return error.to_s # Return that exception.
|
28
|
-
end
|
29
|
-
end; alias remote_host? remote_url? # === remote_host?
|
30
|
-
alias remote_url remote_url? # === remote_url
|
31
|
-
alias url? remote_url? # === url?
|
32
|
-
alias host? remote_url? # === host?
|
33
|
-
alias host remote_url? # === host
|
34
|
-
|
35
|
-
# ========================================================================= #
|
36
|
-
# === set_remote_url
|
37
|
-
#
|
38
|
-
# This method will do some sanitizing before it sets a proper and
|
39
|
-
# valid hostname. Remember to keep the 'default' entry at the
|
40
|
-
# current main FTP host you use.
|
41
|
-
# ========================================================================= #
|
42
|
-
def set_remote_url(
|
43
|
-
i = :default,
|
44
|
-
be_verbose = true
|
45
|
-
)
|
46
|
-
i = :default? if i.nil?
|
47
|
-
if i.is_a? Hash # Handle Hash as input here.
|
48
|
-
if i.has_key?(:to)
|
49
|
-
i = i[:to]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
# ======================================================================= #
|
53
|
-
# The next block is mostly for my custom constants.
|
54
|
-
# You can simply pass in your own Hash.
|
55
|
-
# ======================================================================= #
|
56
|
-
case i # Do some sanitizing. This is a String here. (case tag)
|
57
|
-
# ======================================================================= #
|
58
|
-
# === shevy
|
59
|
-
# ======================================================================= #
|
60
|
-
when /^-?-?shevy$/i,
|
61
|
-
'default'
|
62
|
-
set_data(PODSERVER)
|
63
|
-
i = PODSERVER.first
|
64
|
-
# ======================================================================= #
|
65
|
-
# === bplaced
|
66
|
-
# ======================================================================= #
|
67
|
-
when /^-?-?bplaced$/i
|
68
|
-
set_data(BPLACED)
|
69
|
-
i = BPLACED.first
|
70
|
-
# ======================================================================= #
|
71
|
-
# === ?
|
72
|
-
# ======================================================================= #
|
73
|
-
when '?'
|
74
|
-
feedback_login_hosts
|
75
|
-
# ======================================================================= #
|
76
|
-
# === uniwien_homepage
|
77
|
-
# ======================================================================= #
|
78
|
-
when /^uniwien_?homepage/
|
79
|
-
set_data(UNIWIEN_HOMEPAGE)
|
80
|
-
i = UNIWIEN_HOMEPAGE.first
|
81
|
-
# ======================================================================= #
|
82
|
-
# === unet
|
83
|
-
# ======================================================================= #
|
84
|
-
when 'unet','uni',
|
85
|
-
'uniftp'
|
86
|
-
set_data(UNIVIE)
|
87
|
-
i = UNIVIE.first
|
88
|
-
# ======================================================================= #
|
89
|
-
# === a1
|
90
|
-
# ======================================================================= #
|
91
|
-
when /^a1/
|
92
|
-
set_data(A1)
|
93
|
-
i = A1.first
|
94
|
-
# ======================================================================= #
|
95
|
-
# === byte
|
96
|
-
# ======================================================================= #
|
97
|
-
when /^byte/ # This also includese bytehost.
|
98
|
-
set_data(BYTEHOST)
|
99
|
-
i = BYTEHOST.first
|
100
|
-
# ======================================================================= #
|
101
|
-
# === zerofees
|
102
|
-
# ======================================================================= #
|
103
|
-
when 'ZEROFEES','zero','ZERO'
|
104
|
-
set_data(ZEROFEES)
|
105
|
-
i = ZEROFEES.first
|
106
|
-
# ======================================================================= #
|
107
|
-
# === ucoz
|
108
|
-
# ======================================================================= #
|
109
|
-
when 'ucoz','UCOZ','LAST',/tanriel/i,
|
110
|
-
'last'
|
111
|
-
set_data(UCOZ)
|
112
|
-
i = UCOZ.first
|
113
|
-
end
|
114
|
-
case i.to_s
|
115
|
-
# ======================================================================= #
|
116
|
-
# === shevy
|
117
|
-
# ======================================================================= #
|
118
|
-
when 'shevy','5','default' # Current default entry.
|
119
|
-
i = SQUARE7.first
|
120
|
-
# ======================================================================= #
|
121
|
-
# === a1
|
122
|
-
# ======================================================================= #
|
123
|
-
when '1','a1'
|
124
|
-
i = A1.first
|
125
|
-
# ======================================================================= #
|
126
|
-
# === unet
|
127
|
-
# ======================================================================= #
|
128
|
-
when '2','unet','uni','uniftp'
|
129
|
-
i = UNIVIE.first
|
130
|
-
# ======================================================================= #
|
131
|
-
# === geas
|
132
|
-
# ======================================================================= #
|
133
|
-
when '3','geas'
|
134
|
-
i = GEAS.first
|
135
|
-
# ======================================================================= #
|
136
|
-
# === byte
|
137
|
-
# ======================================================================= #
|
138
|
-
when '4','byte'
|
139
|
-
i = BYTEHOST.first
|
140
|
-
end
|
141
|
-
i = i.to_s # Need a String here.
|
142
|
-
# ======================================================================= #
|
143
|
-
# === Provide more information to the user
|
144
|
-
# ======================================================================= #
|
145
|
-
if debug?
|
146
|
-
opnn; e "The remote URL was set to: #{sfancy(i)}"
|
147
|
-
end
|
148
|
-
if be_verbose
|
149
|
-
e "Setting url to #{sfancy(i)} now."
|
150
|
-
end
|
151
|
-
FtpParadise.set_remote_url(i)
|
152
|
-
# ======================================================================= #
|
153
|
-
# And we will always initialize a new ftp-object as well, whenever
|
154
|
-
# we call this method:
|
155
|
-
# ======================================================================= #
|
156
|
-
initialize_a_new_net_ftp_object_with_this_remote_url(i)
|
157
|
-
end; alias set_this_host set_remote_url # === set_this_host
|
158
|
-
alias set_host set_remote_url # === set_host
|
159
|
-
alias set_url set_remote_url # === set_url
|
160
|
-
alias host= set_remote_url # === host=
|
161
|
-
alias url= set_remote_url # === url=
|
162
|
-
alias set_remote_host set_remote_url # === set_remote_host
|
163
|
-
|
164
|
-
end; end
|
@@ -1,143 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/connection/remove.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
class Connection
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === remove (remove tag)
|
13
|
-
# ========================================================================= #
|
14
|
-
def remove(i)
|
15
|
-
if i.is_a? Array
|
16
|
-
i.each {|entry| remove(entry) }
|
17
|
-
else
|
18
|
-
if is_a_directory?(i)
|
19
|
-
remove_remote_directory(i)
|
20
|
-
elsif is_a_file?(i)
|
21
|
-
remove_remote_file(i, be_verbose?)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# ========================================================================= #
|
27
|
-
# === remove_remote_file
|
28
|
-
#
|
29
|
-
# Remove a (remote) file, via the delete() method of the FTP protocol.
|
30
|
-
#
|
31
|
-
# Note that this method will only delete files.
|
32
|
-
#
|
33
|
-
# The official documentation for the Ruby-FTP delete() method can be
|
34
|
-
# found here:
|
35
|
-
#
|
36
|
-
# https://www.ruby-doc.org/stdlib/libdoc/net/ftp/rdoc/Net/FTP.html#method-i-delete
|
37
|
-
#
|
38
|
-
# ========================================================================= #
|
39
|
-
def remove_remote_file(
|
40
|
-
i,
|
41
|
-
be_verbose = be_verbose?
|
42
|
-
)
|
43
|
-
case be_verbose
|
44
|
-
when :be_verbose
|
45
|
-
be_verbose = true
|
46
|
-
end
|
47
|
-
if i.is_a? Array
|
48
|
-
i.each {|entry| remove_remote_file(entry, be_verbose) }
|
49
|
-
else
|
50
|
-
if does_this_remote_file_exist?(File.basename(i))
|
51
|
-
i = File.basename(i)
|
52
|
-
if i =~ /^\d+$/ # if is a number
|
53
|
-
update_file_listing
|
54
|
-
_ = return_remote_file_listing[i.to_i - 1].first
|
55
|
-
_ = File.basename(_)
|
56
|
-
e "Performing a substitution of #{sfancy(i)}"\
|
57
|
-
" to #{simp(_)}."
|
58
|
-
i = _
|
59
|
-
end
|
60
|
-
if be_verbose
|
61
|
-
notify_the_user_about(i, __method__)
|
62
|
-
end
|
63
|
-
ftp_object?.delete(i)
|
64
|
-
update_file_listing
|
65
|
-
return i # Also return the file that was deleted.
|
66
|
-
else
|
67
|
-
opnn; e "No remote file called `#{sfile(i)}` was "\
|
68
|
-
"found at `#{sfancy(remote_pwd)}`."
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end; alias remote_remove remove_remote_file # === remote_remove
|
72
|
-
alias remote_remove_files remove_remote_file # === remote_remove_files
|
73
|
-
alias remote_remove_file remove_remote_file # === remote_remove_files
|
74
|
-
alias delete remove_remote_file # === delete
|
75
|
-
alias remove_file remove_remote_file # === remove_file
|
76
|
-
alias rm_file remove_remote_file # === rm_file
|
77
|
-
alias rmfile remove_remote_file # === rmfile
|
78
|
-
|
79
|
-
# ========================================================================= #
|
80
|
-
# === original_delete
|
81
|
-
#
|
82
|
-
# This method will remove the file, without doing any additional
|
83
|
-
# checks.
|
84
|
-
# ========================================================================= #
|
85
|
-
def original_delete(i)
|
86
|
-
ftp_object?.delete(i)
|
87
|
-
end
|
88
|
-
|
89
|
-
# ========================================================================= #
|
90
|
-
# === remove_remote_directory
|
91
|
-
#
|
92
|
-
# This method will remove a remote directory. For this to work, as
|
93
|
-
# operation, the remote directory has to exist.
|
94
|
-
#
|
95
|
-
# This operation may fail e. g. when the remote directory is not empty.
|
96
|
-
# This explains why we attempt to rescue some errors.
|
97
|
-
# ========================================================================= #
|
98
|
-
def remove_remote_directory(
|
99
|
-
i,
|
100
|
-
be_verbose = be_verbose?,
|
101
|
-
force_remove = false
|
102
|
-
)
|
103
|
-
case force_remove
|
104
|
-
when :force_remove
|
105
|
-
force_remove = true
|
106
|
-
when :do_not_force_remove
|
107
|
-
force_remove = false
|
108
|
-
end
|
109
|
-
if i.is_a? Array
|
110
|
-
i.each {|entry| remove_remote_directory(entry, be_verbose) }
|
111
|
-
else
|
112
|
-
if be_verbose
|
113
|
-
notify_the_user_about(i, __method__)
|
114
|
-
end
|
115
|
-
if is_a_directory? i
|
116
|
-
begin
|
117
|
-
ftp_object?.rmdir(i)
|
118
|
-
rescue Net::FTPPermError => error
|
119
|
-
opnn; e swarn('We could not remove the remote directory at ')+
|
120
|
-
sdir(i)+swarn(' as it is not empty.')
|
121
|
-
pp error
|
122
|
-
if force_remove
|
123
|
-
opnn; e 'We will now try to enter into this directory'
|
124
|
-
opnn; e 'and then remove all files of that directory.'
|
125
|
-
rcd(this_dir)
|
126
|
-
update_file_listing
|
127
|
-
all_remote_files?.each {|file| remove(file) } # Now it should be removed.
|
128
|
-
rcd('..') # Go back again.
|
129
|
-
rmdir(i, be_verbose, :do_not_force_remove) # But we won't force again, to avoid recursive loops.
|
130
|
-
opnn; e "The remote directory at #{sdir(i)} has been removed."
|
131
|
-
end
|
132
|
-
end
|
133
|
-
else
|
134
|
-
if be_verbose
|
135
|
-
opnn; e "The given input #{sfancy(i)} is not a directory."
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end; alias rmdir remove_remote_directory # === rmdir
|
140
|
-
alias remove_these_remote_directories remove_remote_directory # === remove_these_remote_directories
|
141
|
-
alias remove_directory remove_remote_directory # === remove_directory
|
142
|
-
|
143
|
-
end; end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/connection/reset.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
class Connection
|
10
|
-
|
11
|
-
require 'ftp_paradise/connection/port.rb'
|
12
|
-
require 'ftp_paradise/connection/set_array_available_hosts.rb'
|
13
|
-
require 'ftp_paradise/connection/transfer_mode.rb'
|
14
|
-
require 'ftp_paradise/connection/username.rb'
|
15
|
-
|
16
|
-
# ========================================================================= #
|
17
|
-
# === reset
|
18
|
-
# ========================================================================= #
|
19
|
-
def reset
|
20
|
-
super()
|
21
|
-
# ======================================================================= #
|
22
|
-
# === @input
|
23
|
-
# ======================================================================= #
|
24
|
-
@input = nil
|
25
|
-
# ======================================================================= #
|
26
|
-
# === @ftp_object
|
27
|
-
# ======================================================================= #
|
28
|
-
@ftp_object = nil
|
29
|
-
populate_internal_hash_with_default_values
|
30
|
-
# ======================================================================= #
|
31
|
-
# The next method-call must come after
|
32
|
-
# populate_internal_hash_with_default_values().
|
33
|
-
# ======================================================================= #
|
34
|
-
set_be_verbose if BE_VERBOSE
|
35
|
-
set_port
|
36
|
-
set_array_available_hosts
|
37
|
-
set_default_transfer_mode :be_quiet
|
38
|
-
set_username
|
39
|
-
end
|
40
|
-
|
41
|
-
# ========================================================================= #
|
42
|
-
# === populate_internal_hash_with_default_values
|
43
|
-
# ========================================================================= #
|
44
|
-
def populate_internal_hash_with_default_values
|
45
|
-
# ======================================================================= #
|
46
|
-
# === @internal_hash
|
47
|
-
# ======================================================================= #
|
48
|
-
@internal_hash = {}
|
49
|
-
# ======================================================================= #
|
50
|
-
# === :port
|
51
|
-
#
|
52
|
-
# The internal Hash keeps track of some configure-settings and slots
|
53
|
-
# to be used that are of relevance to this class.
|
54
|
-
# ======================================================================= #
|
55
|
-
@internal_hash[:port] = nil # Has to be nil initially.
|
56
|
-
@internal_hash[:be_verbose] = nil
|
57
|
-
@internal_hash[:raw_entries] = nil
|
58
|
-
@internal_hash[:file] = nil
|
59
|
-
@internal_hash[:transfer_mode] = :binary
|
60
|
-
@internal_hash[:show_full_names] = false # Is false on startup.
|
61
|
-
@internal_hash[:debug] = false
|
62
|
-
# ======================================================================= #
|
63
|
-
# === :array_available_hosts
|
64
|
-
# ======================================================================= #
|
65
|
-
@internal_hash[:array_available_hosts] = []
|
66
|
-
# ======================================================================= #
|
67
|
-
# === :padding
|
68
|
-
# ======================================================================= #
|
69
|
-
@internal_hash[:padding] = ' ' # This padding value is used for remote directory listing.
|
70
|
-
# ======================================================================= #
|
71
|
-
# The following Array keeps track over the files that were uploaded
|
72
|
-
# successfully. This gives us the possibility to query this from other
|
73
|
-
# classes.
|
74
|
-
# ======================================================================= #
|
75
|
-
@internal_hash[:uploaded_these_files] = []
|
76
|
-
end
|
77
|
-
|
78
|
-
end; end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/connection/run.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
class Connection
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === run (run tag)
|
13
|
-
# ========================================================================= #
|
14
|
-
def run
|
15
|
-
do_connect
|
16
|
-
end
|
17
|
-
|
18
|
-
end; end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/connection/set_array_available_hosts.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
class Connection
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === set_array_available_hosts
|
13
|
-
#
|
14
|
-
# Use this method if you wish to define the available hosts. This is
|
15
|
-
# useful whenever you already have some pre-defined hosts that you wish
|
16
|
-
# to use.
|
17
|
-
# ========================================================================= #
|
18
|
-
def set_array_available_hosts(i = nil)
|
19
|
-
if Object.const_defined? :RoebeFtpConstants
|
20
|
-
i = ARRAY_AVAILABLE_HOSTS
|
21
|
-
else
|
22
|
-
i = []
|
23
|
-
end
|
24
|
-
@internal_hash[:array_available_hosts] = i
|
25
|
-
end
|
26
|
-
|
27
|
-
end; end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/connection/set_input.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
class Connection
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === set_input
|
13
|
-
# ========================================================================= #
|
14
|
-
def set_input(i)
|
15
|
-
@input = i
|
16
|
-
end
|
17
|
-
|
18
|
-
end; end
|
@@ -1,153 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/connection/show.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
class Connection
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === show_remote_directory_listing
|
13
|
-
#
|
14
|
-
# This will simply show the content of a remote directory.
|
15
|
-
#
|
16
|
-
# Invocation examples:
|
17
|
-
#
|
18
|
-
# show_remote_directory_listing
|
19
|
-
# show_remote_directory_listing :default, :show_only_directories
|
20
|
-
#
|
21
|
-
# ========================================================================= #
|
22
|
-
def show_remote_directory_listing(
|
23
|
-
i = list,
|
24
|
-
array_options = []
|
25
|
-
)
|
26
|
-
unless array_options.is_a? Array
|
27
|
-
array_options = [array_options]
|
28
|
-
end
|
29
|
-
case i
|
30
|
-
when :default
|
31
|
-
i = list
|
32
|
-
end
|
33
|
-
if i.is_a? Array
|
34
|
-
# ===================================================================== #
|
35
|
-
# Get rid of '.' and '..'.
|
36
|
-
# ===================================================================== #
|
37
|
-
i.reject! {|entry| entry.end_with?('..') or entry.end_with?('.') }
|
38
|
-
# ===================================================================== #
|
39
|
-
# First, turn them into entries.
|
40
|
-
# ===================================================================== #
|
41
|
-
i.map! {|entry| FtpParadise::Entry.new(entry) }
|
42
|
-
# ===================================================================== #
|
43
|
-
# Next, we can use different behaviours.
|
44
|
-
# ===================================================================== #
|
45
|
-
if array_options.include? :show_only_directories
|
46
|
-
i.select! {|entry| entry.is_a_directory? }
|
47
|
-
end
|
48
|
-
i.each {|entry| entry.show_the_line }
|
49
|
-
end
|
50
|
-
end; alias show_remote_files show_remote_directory_listing # === show_remote_files
|
51
|
-
|
52
|
-
# ========================================================================= #
|
53
|
-
# === show_full_names?
|
54
|
-
# ========================================================================= #
|
55
|
-
def show_full_names?
|
56
|
-
@internal_hash[:show_full_names]
|
57
|
-
end
|
58
|
-
|
59
|
-
# ========================================================================= #
|
60
|
-
# === show_remote_listing
|
61
|
-
#
|
62
|
-
# Use this method whenever you want to show the remote entries.
|
63
|
-
#
|
64
|
-
# As of June 2016, you can pass in your own dataset into this method
|
65
|
-
# as well. It must conform to the Array with the four entries, which
|
66
|
-
# is also returned via the method sanitized_remote_directory_content?.
|
67
|
-
# ========================================================================= #
|
68
|
-
def show_remote_listing(
|
69
|
-
dataset = sanitized_remote_directory_content?,
|
70
|
-
be_verbose = be_verbose?
|
71
|
-
)
|
72
|
-
n_rjust = 10
|
73
|
-
_ = dataset
|
74
|
-
if show_full_names?
|
75
|
-
_.map! {|entry|
|
76
|
-
filename = entry[0]
|
77
|
-
entry[0] = remote_pwd?+filename # This is the file size.
|
78
|
-
entry
|
79
|
-
}
|
80
|
-
end
|
81
|
-
_.each_with_index { |array, index|
|
82
|
-
if be_verbose # Display only when in verbose mode, which is the default.
|
83
|
-
file_or_directory = array[1]
|
84
|
-
name_of_the_file = array.first
|
85
|
-
# =================================================================== #
|
86
|
-
# Get a pointer to the filesize as well.
|
87
|
-
# =================================================================== #
|
88
|
-
filesize = array[2].to_s.rjust(n_rjust)
|
89
|
-
if file_or_directory == 'directory'
|
90
|
-
name_of_the_file << '/' unless name_of_the_file.end_with? '/'
|
91
|
-
end
|
92
|
-
# =================================================================== #
|
93
|
-
# === Put a proper padding to the index
|
94
|
-
# =================================================================== #
|
95
|
-
new_index = (index+1).to_s.rjust(_.size.to_s.size)
|
96
|
-
n_pad = 125
|
97
|
-
case file_or_directory
|
98
|
-
when 'directory' # Display for directories.
|
99
|
-
name_of_the_file = sdir(name_of_the_file)
|
100
|
-
e (padding?+sdir(new_index+') ')+name_of_the_file).ljust(n_pad)+' '+
|
101
|
-
filesize
|
102
|
-
else
|
103
|
-
e (padding?+sfancy(new_index+') ')+sfancy(name_of_the_file)).ljust(n_pad)+' '+
|
104
|
-
filesize
|
105
|
-
end
|
106
|
-
end
|
107
|
-
}
|
108
|
-
end; alias show_file_listing show_remote_listing # === show_file_listing
|
109
|
-
alias show_remote_file_listing show_remote_listing # === show_remote_file_listing
|
110
|
-
|
111
|
-
# ========================================================================= #
|
112
|
-
# === show_remote_directories
|
113
|
-
# ========================================================================= #
|
114
|
-
def show_remote_directories
|
115
|
-
show_remote_directory_listing :default, :show_only_directories
|
116
|
-
end
|
117
|
-
|
118
|
-
# ========================================================================= #
|
119
|
-
# === show_full_names=
|
120
|
-
# ========================================================================= #
|
121
|
-
def show_full_names=(i = true)
|
122
|
-
@internal_hash[:show_full_names] = i
|
123
|
-
end; alias show_full_names show_full_names= # === show_full_names
|
124
|
-
|
125
|
-
# ========================================================================= #
|
126
|
-
# === show_user_and_password
|
127
|
-
# ========================================================================= #
|
128
|
-
def show_user_and_password
|
129
|
-
ljust = 12
|
130
|
-
e
|
131
|
-
e ('User-Name: ').ljust(ljust)+sfancy(user_name?.to_s)
|
132
|
-
e ('Password: ' ).ljust(ljust)+sfancy(password?)
|
133
|
-
e
|
134
|
-
end; alias show_user_name_and_password show_user_and_password # === show_user_name_and_password
|
135
|
-
|
136
|
-
# ========================================================================= #
|
137
|
-
# === show_host_user_name_port_and_password
|
138
|
-
#
|
139
|
-
# Inform us about the basic settings.
|
140
|
-
# ========================================================================= #
|
141
|
-
def show_host_user_name_port_and_password(
|
142
|
-
do_use_spacer_around_the_output = true
|
143
|
-
)
|
144
|
-
ljust = 15
|
145
|
-
e if do_use_spacer_around_the_output
|
146
|
-
e ('Host: ' ).ljust(ljust)+sfancy(host?)
|
147
|
-
e ('User-Name: ').ljust(ljust)+sfancy(user_name?.to_s)
|
148
|
-
e ('Port: ' ).ljust(ljust)+sfancy(port?)
|
149
|
-
e ('Password: ' ).ljust(ljust)+sfancy(password?)
|
150
|
-
e if do_use_spacer_around_the_output
|
151
|
-
end
|
152
|
-
|
153
|
-
end; end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/connection/sync_ftp_object_onto_the_main_namespace.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
class Connection
|
10
|
-
|
11
|
-
require 'ftp_paradise/connection/ftp_object.rb'
|
12
|
-
require 'ftp_paradise/toplevel_methods/ftp_object.rb'
|
13
|
-
|
14
|
-
# ========================================================================= #
|
15
|
-
# === sync_ftp_object_onto_the_main_namespace
|
16
|
-
#
|
17
|
-
# Invoke this method only after having made sure that ftp_object?
|
18
|
-
# returns a non-nil object.
|
19
|
-
# ========================================================================= #
|
20
|
-
def sync_ftp_object_onto_the_main_namespace
|
21
|
-
::FtpParadise.ftp_object = self
|
22
|
-
end
|
23
|
-
|
24
|
-
end; end
|