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,163 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/connection/transfer_mode.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
class Connection
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === set_passive_mode
|
13
|
-
#
|
14
|
-
# Use this when modifying the passive setting.
|
15
|
-
# ========================================================================= #
|
16
|
-
def set_passive_mode
|
17
|
-
set_transfer_mode :ascii
|
18
|
-
ftp_object?.passive = true if ftp_object?
|
19
|
-
end; alias set_passive set_passive_mode # === set_passive
|
20
|
-
|
21
|
-
# ========================================================================= #
|
22
|
-
# === set_default_transfer_mode
|
23
|
-
# ========================================================================= #
|
24
|
-
def set_default_transfer_mode(
|
25
|
-
be_verbose = :be_quiet
|
26
|
-
)
|
27
|
-
set_transfer_mode(DEFAULT_TRANSFER_MODE, be_verbose)
|
28
|
-
end
|
29
|
-
|
30
|
-
# ========================================================================= #
|
31
|
-
# === set_transfer_mode
|
32
|
-
#
|
33
|
-
# This method will set to either one of two different possibles modes:
|
34
|
-
#
|
35
|
-
# (1) :ascii
|
36
|
-
# (2) :binary
|
37
|
-
# (3) :passive
|
38
|
-
#
|
39
|
-
# Note that :passive "mode" is ascii, with an additional invocation to
|
40
|
-
# change the transfer mode to .passive.
|
41
|
-
#
|
42
|
-
# It will also change passive mode. The argument :default will default
|
43
|
-
# to the more commonly used ASCII mode.
|
44
|
-
#
|
45
|
-
# When would you want to use ASCII mode?
|
46
|
-
#
|
47
|
-
# Use ascii mode for:
|
48
|
-
#
|
49
|
-
# txt, rtf, html, php
|
50
|
-
#
|
51
|
-
# Use binary mode for:
|
52
|
-
#
|
53
|
-
# images, videos and similar.
|
54
|
-
#
|
55
|
-
# ========================================================================= #
|
56
|
-
def set_transfer_mode(
|
57
|
-
i = DEFAULT_TRANSFER_MODE, # Will usually default to :ascii
|
58
|
-
be_verbose = be_verbose?
|
59
|
-
)
|
60
|
-
case be_verbose
|
61
|
-
when :be_verbose
|
62
|
-
be_verbose = true
|
63
|
-
when :be_quiet
|
64
|
-
be_verbose = false
|
65
|
-
end
|
66
|
-
i = :ascii if i == :default
|
67
|
-
case i
|
68
|
-
# ======================================================================= #
|
69
|
-
# === :ascii
|
70
|
-
# ======================================================================= #
|
71
|
-
when :ascii
|
72
|
-
notify_the_user_about(i, __method__) if be_verbose
|
73
|
-
@internal_hash[:transfer_mode] = :ascii
|
74
|
-
ftp_object?.binary = false if ftp_object?
|
75
|
-
# ======================================================================= #
|
76
|
-
# === :binary
|
77
|
-
# ======================================================================= #
|
78
|
-
when :binary
|
79
|
-
notify_the_user_about(i, __method__) if be_verbose
|
80
|
-
@internal_hash[:transfer_mode] = :binary
|
81
|
-
# ======================================================================= #
|
82
|
-
# === :passive
|
83
|
-
# ======================================================================= #
|
84
|
-
when :passive,
|
85
|
-
:pass
|
86
|
-
notify_the_user_about(i, __method__) if be_verbose
|
87
|
-
@internal_hash[:transfer_mode] = :ascii
|
88
|
-
ftp_object?.passive = true if ftp_object?
|
89
|
-
else
|
90
|
-
opnn; e swarn('Not found the following mode: ')+
|
91
|
-
sfancy(i.to_s)
|
92
|
-
end
|
93
|
-
end; alias mode_to_use= set_transfer_mode # === mode_to_use=
|
94
|
-
alias set_mode set_transfer_mode # === set_mode
|
95
|
-
|
96
|
-
# ========================================================================= #
|
97
|
-
# === report_transfer_mode_in_use
|
98
|
-
# ========================================================================= #
|
99
|
-
def report_transfer_mode_in_use
|
100
|
-
e "Transfer mode: #{sfancy(transfer_mode?.to_s)}"
|
101
|
-
end
|
102
|
-
|
103
|
-
# ========================================================================= #
|
104
|
-
# === set_active
|
105
|
-
# ========================================================================= #
|
106
|
-
def set_active
|
107
|
-
ftp_object?.passive = false
|
108
|
-
end
|
109
|
-
|
110
|
-
# ========================================================================= #
|
111
|
-
# === passive_transfer?
|
112
|
-
# ========================================================================= #
|
113
|
-
def passive_transfer?
|
114
|
-
ftp_object?.passive
|
115
|
-
end; alias passive? passive_transfer? # === passive?
|
116
|
-
|
117
|
-
# ========================================================================= #
|
118
|
-
# === transfer_mode?
|
119
|
-
#
|
120
|
-
# This method will return the currently used transfer_mode. This mode
|
121
|
-
# can be either :binary, or :ascii. By default it will be :binary.
|
122
|
-
#
|
123
|
-
# The transfer mode can be :binary or :text. :ascii is an alias to
|
124
|
-
# :text.
|
125
|
-
# ========================================================================= #
|
126
|
-
def transfer_mode?
|
127
|
-
@internal_hash[:transfer_mode]
|
128
|
-
end; alias transfer_mode transfer_mode? # === transfer_mode
|
129
|
-
alias mode? transfer_mode? # === mode?
|
130
|
-
alias type transfer_mode? # === type
|
131
|
-
alias type? transfer_mode? # === type?
|
132
|
-
|
133
|
-
# ========================================================================= #
|
134
|
-
# === set_ascii
|
135
|
-
#
|
136
|
-
# Easier wrapper method.
|
137
|
-
# ========================================================================= #
|
138
|
-
def set_ascii
|
139
|
-
set_transfer_mode :ascii
|
140
|
-
end; alias set_ascii_mode set_ascii # === set_ascii_mode
|
141
|
-
|
142
|
-
# ========================================================================= #
|
143
|
-
# === binary?
|
144
|
-
#
|
145
|
-
# When this is true, then then all FTP-transfers will be performed in
|
146
|
-
# binary mode.
|
147
|
-
#
|
148
|
-
# Deaults to true.
|
149
|
-
# ========================================================================= #
|
150
|
-
def binary?
|
151
|
-
ftp_object?.binary
|
152
|
-
end; alias binary binary? # === binary
|
153
|
-
|
154
|
-
# ========================================================================= #
|
155
|
-
# === set_binary_mode
|
156
|
-
# ========================================================================= #
|
157
|
-
def set_binary_mode
|
158
|
-
set_transfer_mode :binary
|
159
|
-
ftp_object?.binary = true
|
160
|
-
end; alias set_binary set_binary_mode # === set_binary
|
161
|
-
alias set_to_binary_mode set_binary_mode # === set_to_binary_mode
|
162
|
-
|
163
|
-
end; end
|
@@ -1,253 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/connection/upload.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
class Connection
|
10
|
-
|
11
|
-
require 'ftp_paradise/connection/remote_pwd.rb'
|
12
|
-
require 'ftp_paradise/connection/is_connected.rb'
|
13
|
-
|
14
|
-
# ========================================================================= #
|
15
|
-
# === upload_binary_file
|
16
|
-
#
|
17
|
-
# Use this method to upload a binary file to a remote host.
|
18
|
-
#
|
19
|
-
# The first argument `i` is the file that we wish to upload.
|
20
|
-
#
|
21
|
-
# The method will make use of the method .putbinaryfile().
|
22
|
-
#
|
23
|
-
# Documentation for that file can be found here:
|
24
|
-
#
|
25
|
-
# https://ruby-doc.org/stdlib/libdoc/net/ftp/rdoc/Net/FTP.html#method-i-putbinaryfile
|
26
|
-
#
|
27
|
-
# ========================================================================= #
|
28
|
-
def upload_binary_file(
|
29
|
-
i,
|
30
|
-
be_verbose = be_verbose?
|
31
|
-
)
|
32
|
-
be_verbose = false if be_verbose == :be_silent
|
33
|
-
if i.is_a? Array
|
34
|
-
i.each {|entry| upload_binary_file(entry, be_verbose) }
|
35
|
-
else
|
36
|
-
i = i.strip.delete(N) # Added Feb 2014.
|
37
|
-
if be_verbose
|
38
|
-
notify_the_user_about(i, __method__)
|
39
|
-
end
|
40
|
-
begin
|
41
|
-
# =================================================================== #
|
42
|
-
# Next we will delegate towards the @ftp_object:
|
43
|
-
# =================================================================== #
|
44
|
-
ftp_object?.putbinaryfile(i) # We will use the method .putbinaryfile()
|
45
|
-
@internal_hash[:uploaded_these_files] << i
|
46
|
-
if be_verbose
|
47
|
-
remote_path = rds(remote_path?+'/'+File.basename(i))
|
48
|
-
e 'Done uploading! The remote path is: '
|
49
|
-
e " #{simp(remote_path)}"
|
50
|
-
report_finished_uploading_of_this_file(i)
|
51
|
-
end
|
52
|
-
rescue Exception => error
|
53
|
-
e 'An error happened as we tried to use the method '+simp('upload_binary()')+'.'
|
54
|
-
e 'The method we used was: '+simp('ftp?.putbinaryfile(i)')
|
55
|
-
e 'We will feedback this error now (of class '+sfancy(error.class.to_s)+'):'
|
56
|
-
pp error
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end; alias upload_binary upload_binary_file # === upload_binary
|
60
|
-
alias upload_this_binary_file upload_binary_file # === upload_this_binary_file()
|
61
|
-
|
62
|
-
# ========================================================================= #
|
63
|
-
# === upload_file
|
64
|
-
#
|
65
|
-
# This method will distinguish between a binary file or a text file,
|
66
|
-
# based on the transfer mode in use. The default is to work on a
|
67
|
-
# text file.
|
68
|
-
# ========================================================================= #
|
69
|
-
def upload_file(
|
70
|
-
i,
|
71
|
-
be_verbose = be_verbose?
|
72
|
-
)
|
73
|
-
if File.exist? i
|
74
|
-
case transfer_mode?
|
75
|
-
# ===================================================================== #
|
76
|
-
# === :ascii
|
77
|
-
# ===================================================================== #
|
78
|
-
when :ascii,
|
79
|
-
:text,
|
80
|
-
:default
|
81
|
-
upload_this_text_file(i, be_verbose)
|
82
|
-
# ===================================================================== #
|
83
|
-
# === :binary
|
84
|
-
# ===================================================================== #
|
85
|
-
when :binary
|
86
|
-
upload_this_binary_file(i, be_verbose)
|
87
|
-
end
|
88
|
-
update_raw_listing(:be_quiet)
|
89
|
-
else
|
90
|
-
opnn; e "No file called `#{sfile(i)}` appears to exist locally."
|
91
|
-
end
|
92
|
-
end; alias upload_this_file upload_file # === upload_this_file
|
93
|
-
|
94
|
-
# ========================================================================= #
|
95
|
-
# === upload (upload tag)
|
96
|
-
#
|
97
|
-
# This method can upload binary files, text files and whole directories.
|
98
|
-
# Based on that check, the method body will behave differently, and
|
99
|
-
# delegate to other methods such as upload_directory() or upload_file().
|
100
|
-
#
|
101
|
-
# A single file (as String) can be uploaded, or an Array of files. The
|
102
|
-
# upload activity will transfer the file or the files onto the remote host.
|
103
|
-
#
|
104
|
-
# The second argument specifies whether the method will be verbose and
|
105
|
-
# report back to the user, or whether the method will be quiet,
|
106
|
-
# defaulting to the return value of the method `be_verbose?`.
|
107
|
-
# ========================================================================= #
|
108
|
-
def upload(
|
109
|
-
i,
|
110
|
-
be_verbose = be_verbose?
|
111
|
-
)
|
112
|
-
be_verbose = false if be_verbose == :be_silent
|
113
|
-
if i.is_a? Array
|
114
|
-
i.each {|entry| upload(entry, be_verbose) }
|
115
|
-
else
|
116
|
-
if i == '*' # Here we want to upload all files.
|
117
|
-
i = get_all_local_files
|
118
|
-
upload(i, be_verbose)
|
119
|
-
else
|
120
|
-
# =================================================================== #
|
121
|
-
# === Handle upload of directories first
|
122
|
-
# =================================================================== #
|
123
|
-
if File.directory? i
|
124
|
-
upload_directory(i, be_verbose)
|
125
|
-
# =================================================================== #
|
126
|
-
# === Handle uploading of files next
|
127
|
-
# =================================================================== #
|
128
|
-
else
|
129
|
-
upload_file(i, be_verbose)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
# ========================================================================= #
|
136
|
-
# === uploaded_these_files?
|
137
|
-
# ========================================================================= #
|
138
|
-
def uploaded_these_files?
|
139
|
-
@internal_hash[:uploaded_these_files]
|
140
|
-
end
|
141
|
-
|
142
|
-
# ========================================================================= #
|
143
|
-
# === report_finished_uploading_of_this_file
|
144
|
-
#
|
145
|
-
# Report that we have finished uploading a file.
|
146
|
-
#
|
147
|
-
# We should also denote the leading http part.
|
148
|
-
# ========================================================================= #
|
149
|
-
def report_finished_uploading_of_this_file(i)
|
150
|
-
if is_connected?
|
151
|
-
remote_path = "http://#{rds(remote_path?+File.basename(i))}"
|
152
|
-
opnn; e "Done uploading `#{sfile(i)}` to `"\
|
153
|
-
"#{sdir(remote_path)}`!"
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
# ========================================================================= #
|
158
|
-
# === puttextfile
|
159
|
-
#
|
160
|
-
# This method will transfer a localfile to the remote server in
|
161
|
-
# ASCII (text) mode. The result will be stored in "remotefile".
|
162
|
-
#
|
163
|
-
# If a callback or an associated block is supplied, calls it, passing
|
164
|
-
# in the transmitted data one line at a time.
|
165
|
-
# ========================================================================= #
|
166
|
-
def puttextfile(
|
167
|
-
local_file, remotefile = File.basename(local_file)
|
168
|
-
)
|
169
|
-
begin
|
170
|
-
ftp_object?.puttextfile(local_file)
|
171
|
-
@internal_hash[:uploaded_these_files] << local_file
|
172
|
-
rescue Net::FTPPermError => error
|
173
|
-
opnn; e swarn('Can not upload `')+sfile(local_file)+swarn('`.')
|
174
|
-
opnn; e swarn('Reason provided to this method was:')
|
175
|
-
opnn; e " → #{sfancy(error.to_s)}"
|
176
|
-
rescue Exception => error
|
177
|
-
opnn; e "An error happened in the method #{__method__}"
|
178
|
-
pp error
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
# ========================================================================= #
|
183
|
-
# === upload_this_text_file
|
184
|
-
#
|
185
|
-
# This method can be used to upload one or several text files.
|
186
|
-
#
|
187
|
-
# The first argument should be an Array or a String, denoting the
|
188
|
-
# name/path of the local text file that you wish to upload.
|
189
|
-
# ========================================================================= #
|
190
|
-
def upload_this_text_file(
|
191
|
-
i,
|
192
|
-
be_verbose = be_verbose?
|
193
|
-
)
|
194
|
-
be_verbose = false if be_verbose == :be_silent
|
195
|
-
if i.is_a? Array
|
196
|
-
i.each {|entry| upload_this_text_file(entry, be_verbose) }
|
197
|
-
else
|
198
|
-
i = i.strip.delete(N) # Added in February 2014.
|
199
|
-
case i
|
200
|
-
when :default
|
201
|
-
ENV['MISC'].to_s+'/SITEMAP.cgi' # <- Makes only sense for text-files anyway.
|
202
|
-
end
|
203
|
-
case be_verbose
|
204
|
-
when :be_quiet
|
205
|
-
be_verbose = false
|
206
|
-
end
|
207
|
-
if be_verbose
|
208
|
-
notify_the_user_about(i, __method__)
|
209
|
-
end
|
210
|
-
puttextfile(i) # <- Delegate towards the method puttextfile().
|
211
|
-
report_finished_uploading_of_this_file(i) if be_verbose
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
# ========================================================================= #
|
216
|
-
# === upload_this_directory
|
217
|
-
#
|
218
|
-
# This method can be used to upload a local directory to a remote host.
|
219
|
-
#
|
220
|
-
# If the first input argument is an Array, then the method will call
|
221
|
-
# itself recursively. This allows us to transfer several directories
|
222
|
-
# in one go.
|
223
|
-
#
|
224
|
-
# If the input is a (local and existing) directory, then this method
|
225
|
-
# will also have to create a remote directory, then chdir into it,
|
226
|
-
# and then upload the content of that local directory to the remote
|
227
|
-
# host.
|
228
|
-
# ========================================================================= #
|
229
|
-
def upload_this_directory(
|
230
|
-
i,
|
231
|
-
be_verbose = be_verbose?
|
232
|
-
)
|
233
|
-
if i.is_a? Array
|
234
|
-
i.each {|entry| upload_this_directory(i, be_verbose) }
|
235
|
-
else
|
236
|
-
if File.directory? i
|
237
|
-
unless this_remote_directory_exists?(i)
|
238
|
-
remote_create_directory(i, be_verbose)
|
239
|
-
end
|
240
|
-
change_local_directory(i)
|
241
|
-
change_remote_directory(i)
|
242
|
-
report_remote_directory
|
243
|
-
content = return_directory_content(i) # Last but not least, copy all files to that dir.
|
244
|
-
content.each {|this_file| upload(this_file) }
|
245
|
-
else
|
246
|
-
opnn; e "The given input `#{sfancy(i)}` is not a directory."
|
247
|
-
opnn; e 'This method can only upload directories.'
|
248
|
-
end
|
249
|
-
end
|
250
|
-
end; alias upload_directory upload_this_directory # === upload_directory
|
251
|
-
alias upload_these_directories upload_this_directory # === upload_these_directories
|
252
|
-
|
253
|
-
end; end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/connection/use_default_dataset.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
class Connection # === FtpParadise::Connection
|
10
|
-
|
11
|
-
require 'ftp_paradise/toplevel_methods/determine_user_dataset_from_this_hash.rb'
|
12
|
-
|
13
|
-
require 'ftp_paradise/connection/do_login.rb'
|
14
|
-
|
15
|
-
# ========================================================================= #
|
16
|
-
# === use_default_dataset
|
17
|
-
#
|
18
|
-
# This method will just take the default dataset for my FTP connections,
|
19
|
-
# hence the "File.exist?" check.
|
20
|
-
#
|
21
|
-
# Additionally we will initialize the default net-ftp object.
|
22
|
-
# ========================================================================= #
|
23
|
-
def use_default_dataset(
|
24
|
-
i = 'shevy' # ← This is the default.
|
25
|
-
)
|
26
|
-
if File.exist? FILE_ROEBE_FTP
|
27
|
-
dataset = YAML.load_file(FILE_ROEBE_FTP)
|
28
|
-
# ===================================================================== #
|
29
|
-
# Default to what the user provided to the method.
|
30
|
-
# ===================================================================== #
|
31
|
-
use_this_dataset = dataset[i]
|
32
|
-
# ===================================================================== #
|
33
|
-
# Set remote-url, username and password through the following method:
|
34
|
-
# ===================================================================== #
|
35
|
-
FtpParadise.determine_user_dataset_from_this_hash(use_this_dataset)
|
36
|
-
do_login
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
end; end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/connection/username.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
class Connection
|
10
|
-
|
11
|
-
require 'ftp_paradise/toplevel_methods/login_name.rb'
|
12
|
-
|
13
|
-
# ========================================================================= #
|
14
|
-
# === set_username
|
15
|
-
#
|
16
|
-
# Set the username that you wish to use here. If the input is nil, a
|
17
|
-
# default name will be used instead.
|
18
|
-
# ========================================================================= #
|
19
|
-
def set_username(
|
20
|
-
i = DEFAULT_USER_NAME
|
21
|
-
)
|
22
|
-
i = i.first if i.is_a? Array
|
23
|
-
i = DEFAULT_USER_NAME if i.nil?
|
24
|
-
# ======================================================================= #
|
25
|
-
# The username will be stored on the toplevel-module.
|
26
|
-
# ======================================================================= #
|
27
|
-
FtpParadise.set_username(i)
|
28
|
-
end; alias set_user_name set_username # === set_user_name
|
29
|
-
alias login_name= set_username # === login_name?
|
30
|
-
alias set_name set_username # === set_name
|
31
|
-
alias set_user set_username # === set_user
|
32
|
-
alias set_login_name set_username # === set_login_name
|
33
|
-
alias user_name= set_username # === user_name?
|
34
|
-
|
35
|
-
# ========================================================================= #
|
36
|
-
# === username?
|
37
|
-
# ========================================================================= #
|
38
|
-
def username?
|
39
|
-
FtpParadise.username?.to_s
|
40
|
-
end; alias user_name? username? # === user_name?
|
41
|
-
|
42
|
-
end; end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen-string-literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/constants/misc.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
require 'ftp_paradise/project/project.rb'
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === SHALL_WE_DEBUG
|
13
|
-
# ========================================================================= #
|
14
|
-
SHALL_WE_DEBUG = false
|
15
|
-
|
16
|
-
# ========================================================================= #
|
17
|
-
# === ARRAY_HELP_OPTIONS
|
18
|
-
#
|
19
|
-
# This Array is only required in the interactive variant though.
|
20
|
-
# ========================================================================= #
|
21
|
-
ARRAY_HELP_OPTIONS = %w(
|
22
|
-
HELP --help help hel he h hlep
|
23
|
-
) # ,'?'
|
24
|
-
|
25
|
-
# ========================================================================= #
|
26
|
-
# === ARRAY_BINARY_FILES
|
27
|
-
#
|
28
|
-
# Just note down the extension names.
|
29
|
-
# ========================================================================= #
|
30
|
-
ARRAY_BINARY_FILES = %w(
|
31
|
-
pdf
|
32
|
-
docx
|
33
|
-
odt
|
34
|
-
doc
|
35
|
-
)
|
36
|
-
|
37
|
-
# ========================================================================= #
|
38
|
-
# === ARRAY_VALID_OPTIONS_FOR_EXITING_THE_SHELL
|
39
|
-
# ========================================================================= #
|
40
|
-
ARRAY_VALID_OPTIONS_FOR_EXITING_THE_SHELL = %w(
|
41
|
-
q
|
42
|
-
quit
|
43
|
-
exit
|
44
|
-
break
|
45
|
-
)
|
46
|
-
|
47
|
-
# ========================================================================= #
|
48
|
-
# === FtpParadise::FILE_AUTOMATICALLY_CONNECT_ON_STARTUP_OF_THE_INTERACTIVE_FTP_SHELL
|
49
|
-
# ========================================================================= #
|
50
|
-
FILE_AUTOMATICALLY_CONNECT_ON_STARTUP_OF_THE_INTERACTIVE_FTP_SHELL =
|
51
|
-
"#{PROJECT_YAML_DIRECTORY}automatically_connect_on_startup_of_the_interactive_ftp_shell.yml"
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
if __FILE__ == $PROGRAM_NAME
|
56
|
-
puts FtpParadise::FILE_AUTOMATICALLY_CONNECT_ON_STARTUP_OF_THE_INTERACTIVE_FTP_SHELL
|
57
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/constants/namespace.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
# ========================================================================= #
|
10
|
-
# === NAMESPACE
|
11
|
-
# ========================================================================= #
|
12
|
-
NAMESPACE = inspect
|
13
|
-
|
14
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen-string-literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/constants/newline.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
# ========================================================================= #
|
10
|
-
# === N
|
11
|
-
# ========================================================================= #
|
12
|
-
N = "\n"
|
13
|
-
|
14
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/constants/roebe.rb'
|
6
|
-
# FILE_ROEBE_FTP
|
7
|
-
# HOME_DIRECTOY_OF_USER_X
|
8
|
-
# =========================================================================== #
|
9
|
-
module FtpParadise
|
10
|
-
|
11
|
-
# =========================================================================== #
|
12
|
-
# === HOME_DIRECTORY_OF_USER_X
|
13
|
-
#
|
14
|
-
# This is also only useful on my home setup.
|
15
|
-
# =========================================================================== #
|
16
|
-
HOME_DIRECTORY_OF_USER_X = '/home/x/'
|
17
|
-
|
18
|
-
# =========================================================================== #
|
19
|
-
# === FILE_ROEBE_FTP
|
20
|
-
#
|
21
|
-
# In theory you could change this if you use a similar .yml file.
|
22
|
-
#
|
23
|
-
# This will, on my home directory, expand to:
|
24
|
-
#
|
25
|
-
# /home/x/DATA/PC/OS/LINUX/FTP/YAML/roebe_ftp.yml
|
26
|
-
#
|
27
|
-
# =========================================================================== #
|
28
|
-
FILE_ROEBE_FTP =
|
29
|
-
"#{HOME_DIRECTORY_OF_USER_X}DATA/PC/OS/LINUX/FTP/YAML/roebe_ftp.yml"
|
30
|
-
|
31
|
-
end
|