ftp_paradise 1.4.5 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ftp_paradise might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +152 -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} +0 -0
- 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 +554 -448
- 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,998 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# === FtpParadise::InteractiveFtp
|
6
|
-
#
|
7
|
-
# Use this class here for interactive usage of the FTP paradise project.
|
8
|
-
#
|
9
|
-
# This class provides a commandline variant of the FtpParadise project,
|
10
|
-
# which allows you to interactively issue commands and instructions
|
11
|
-
# to a remote FTP server.
|
12
|
-
#
|
13
|
-
# No GUI code is otherwise stored herein.
|
14
|
-
# =========================================================================== #
|
15
|
-
# The official source for Ruby-FTP can be found at:
|
16
|
-
#
|
17
|
-
# http://www.ruby-doc.org/stdlib/libdoc/net/ftp/rdoc/Net/FTP.html
|
18
|
-
#
|
19
|
-
# Usage example for this class here:
|
20
|
-
#
|
21
|
-
# FtpParadise::InteractiveFtp.new
|
22
|
-
# FtpParadise.interactive
|
23
|
-
#
|
24
|
-
# =========================================================================== #
|
25
|
-
# require 'ftp_paradise/interactive_ftp/interactive_ftp.rb'
|
26
|
-
# =========================================================================== #
|
27
|
-
require 'ftp_paradise/requires/common_basic_requires.rb'
|
28
|
-
require 'ftp_paradise/base/prototype.rb'
|
29
|
-
require 'ftp_paradise/toplevel_methods/data.rb'
|
30
|
-
require 'ftp_paradise/toplevel_methods/ftp_object.rb'
|
31
|
-
require 'ftp_paradise/toplevel_methods/login_name.rb'
|
32
|
-
require 'ftp_paradise/toplevel_methods/password.rb'
|
33
|
-
require 'ftp_paradise/toplevel_methods/remote_url.rb'
|
34
|
-
# =========================================================================== #
|
35
|
-
# Next ftp_connection/ files:
|
36
|
-
# =========================================================================== #
|
37
|
-
require 'ftp_paradise/connection/connection.rb'
|
38
|
-
require 'ftp_paradise/base/prototype.rb'
|
39
|
-
|
40
|
-
module FtpParadise
|
41
|
-
|
42
|
-
class InteractiveFtp # === FtpParadise::InteractiveFtp
|
43
|
-
|
44
|
-
include ::FtpParadise::Base
|
45
|
-
|
46
|
-
# ========================================================================= #
|
47
|
-
# Next, load up interactive_ftp-specific .rb files:
|
48
|
-
# ========================================================================= #
|
49
|
-
require 'ftp_paradise/interactive_ftp/constants.rb'
|
50
|
-
require 'ftp_paradise/interactive_ftp/help.rb'
|
51
|
-
require 'ftp_paradise/interactive_ftp/initialize.rb'
|
52
|
-
require 'ftp_paradise/interactive_ftp/main_loop.rb'
|
53
|
-
require 'ftp_paradise/interactive_ftp/menu.rb'
|
54
|
-
require 'ftp_paradise/interactive_ftp/misc.rb'
|
55
|
-
require 'ftp_paradise/interactive_ftp/mode.rb'
|
56
|
-
require 'ftp_paradise/interactive_ftp/remove.rb'
|
57
|
-
require 'ftp_paradise/interactive_ftp/reset.rb'
|
58
|
-
require 'ftp_paradise/interactive_ftp/run.rb'
|
59
|
-
require 'ftp_paradise/interactive_ftp/show.rb'
|
60
|
-
require 'ftp_paradise/interactive_ftp/upload.rb'
|
61
|
-
require 'ftp_paradise/interactive_ftp/user_input.rb'
|
62
|
-
|
63
|
-
begin
|
64
|
-
require 'rcfiles'
|
65
|
-
rescue LoadError; end
|
66
|
-
|
67
|
-
# ========================================================================= #
|
68
|
-
# === verbose_truth
|
69
|
-
# ========================================================================= #
|
70
|
-
def verbose_truth(i = '')
|
71
|
-
VerboseTruth[i]
|
72
|
-
end
|
73
|
-
|
74
|
-
# ========================================================================= #
|
75
|
-
# === set_url
|
76
|
-
# ========================================================================= #
|
77
|
-
def set_url(i)
|
78
|
-
::FtpParadise.set_remote_host(i)
|
79
|
-
end
|
80
|
-
|
81
|
-
# ========================================================================= #
|
82
|
-
# === ftp?
|
83
|
-
# ========================================================================= #
|
84
|
-
def ftp?
|
85
|
-
FtpParadise.ftp_object?
|
86
|
-
end; alias ftp_object? ftp? # === ftp_object?
|
87
|
-
|
88
|
-
# ========================================================================= #
|
89
|
-
# === connected_to?
|
90
|
-
#
|
91
|
-
# Feedback where we are connected to.
|
92
|
-
# ========================================================================= #
|
93
|
-
def connected_to?
|
94
|
-
if ftp?.open?
|
95
|
-
report_where_we_are_connected_to
|
96
|
-
report_remote_directory # Added Dec 2011.
|
97
|
-
# report_local_dir
|
98
|
-
# unless ftp?.empty?
|
99
|
-
# e 'The remote file listing is:'
|
100
|
-
# show_remote_listing
|
101
|
-
# end # Disabled the above chunk as of Apr 2017.
|
102
|
-
else
|
103
|
-
e 'We are not connected to any remote FTP server currently.'
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
# ========================================================================= #
|
108
|
-
# === initialize_ftp_object (reset tag)
|
109
|
-
#
|
110
|
-
# The FTP Subsection is gathered here. This method is called from
|
111
|
-
# the method reset().
|
112
|
-
# ========================================================================= #
|
113
|
-
def initialize_ftp_object
|
114
|
-
FtpParadise.use_this_as_ftp_object(
|
115
|
-
FtpParadise::Connection.new(:default, false)
|
116
|
-
)
|
117
|
-
ftp?.enable_debug if debug? # Set the @debug variable inside of @ftp to true.
|
118
|
-
set_passive
|
119
|
-
use_ascii_mode
|
120
|
-
end
|
121
|
-
|
122
|
-
# ========================================================================= #
|
123
|
-
# === f?
|
124
|
-
# ========================================================================= #
|
125
|
-
def f?
|
126
|
-
@first_argument # First argument. Keep in mind that the second argument is stored in @s.
|
127
|
-
end; alias f f? # === f
|
128
|
-
|
129
|
-
# ========================================================================= #
|
130
|
-
# === connect_to_this_remote_url
|
131
|
-
# ========================================================================= #
|
132
|
-
def connect_to_this_remote_url(
|
133
|
-
i = remote_url?,
|
134
|
-
be_verbose = :be_verbose
|
135
|
-
)
|
136
|
-
case be_verbose
|
137
|
-
when :be_verbose
|
138
|
-
be_verbose = true
|
139
|
-
end
|
140
|
-
if be_verbose
|
141
|
-
e "Connecting to this remote URL: #{sfancy(i)}"
|
142
|
-
end
|
143
|
-
FtpParadise.use_this_as_ftp_object(
|
144
|
-
FtpParadise::Connection.new(i)
|
145
|
-
)
|
146
|
-
ftp?.login(
|
147
|
-
FtpParadise.login_name?,
|
148
|
-
password?
|
149
|
-
)
|
150
|
-
end
|
151
|
-
|
152
|
-
# ========================================================================= #
|
153
|
-
# === rename
|
154
|
-
#
|
155
|
-
# This will attempt a remote rename-action.
|
156
|
-
# ========================================================================= #
|
157
|
-
def rename(a, b)
|
158
|
-
begin
|
159
|
-
a = convert_number_to_file(a)
|
160
|
-
ftp?.rename(a, b)
|
161
|
-
rescue Net::FTPPermError
|
162
|
-
e "The file at #{sfile(i)} does not seem to exist - thus, "\
|
163
|
-
"we can not rename it."
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
# ========================================================================= #
|
168
|
-
# === upload_this_file
|
169
|
-
# ========================================================================= #
|
170
|
-
def upload_this_file(
|
171
|
-
i = f?
|
172
|
-
)
|
173
|
-
if i.is_a? Array
|
174
|
-
i.each {|entry| upload_this_file(entry) }
|
175
|
-
else
|
176
|
-
e 'Trying to upload this file `'+sfile(i)+'` next:'
|
177
|
-
ftp?.puttextfile(i)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
# ========================================================================= #
|
182
|
-
# === reset_instance_variables_that_hold_all_arguments
|
183
|
-
#
|
184
|
-
# Use this method to initialite the instance variables that will hold
|
185
|
-
# the arguments to methods, from the user input.
|
186
|
-
#
|
187
|
-
# @s refers to the second argument.
|
188
|
-
# ========================================================================= #
|
189
|
-
def reset_instance_variables_that_hold_all_arguments
|
190
|
-
@splitted = @s = @first_argument = @all_arguments = nil
|
191
|
-
end
|
192
|
-
|
193
|
-
# ========================================================================= #
|
194
|
-
# === set_file
|
195
|
-
# ========================================================================= #
|
196
|
-
def set_file(i = nil) # Use only this to set @file variable.
|
197
|
-
if i # Safeguard against nil.
|
198
|
-
i = i.first if i.is_a? Array
|
199
|
-
i = i.to_s
|
200
|
-
i = Dir.pwd+'/'+i if ! i.include?('/') # Since Dec 2011 we try to use only the absolute path.
|
201
|
-
unless File.exist?(i)
|
202
|
-
i << '.c' unless i.include? '.' # Append .c to files, unless the file exists.
|
203
|
-
end
|
204
|
-
i = FtpParadise.rds(i)
|
205
|
-
end
|
206
|
-
@file = i # This is the only allowed way to modify @file.
|
207
|
-
end
|
208
|
-
|
209
|
-
# ========================================================================= #
|
210
|
-
# === be_verbose=
|
211
|
-
# ========================================================================= #
|
212
|
-
def be_verbose=(i)
|
213
|
-
@be_verbose = i
|
214
|
-
end
|
215
|
-
|
216
|
-
# ========================================================================= #
|
217
|
-
# === exit_program (exit tag)
|
218
|
-
# ========================================================================= #
|
219
|
-
def exit_program # Use only this method to exit i-ftp.
|
220
|
-
e 'Bye from '+return_title+'! (@run_mode was '+simp(@run_mode.to_s)+')'
|
221
|
-
if @run_mode == :standalone # Not embedded.
|
222
|
-
@run_mode = :exit
|
223
|
-
disconnect
|
224
|
-
exit
|
225
|
-
else
|
226
|
-
@run_mode = :break
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
# ========================================================================= #
|
231
|
-
# === download_remote_file (download tag)
|
232
|
-
#
|
233
|
-
# This method will download a remote file. When we download a remote
|
234
|
-
# file, we will also set the remote base directory since Dec 2011.
|
235
|
-
# ========================================================================= #
|
236
|
-
def download_remote_file(
|
237
|
-
file = DEFAULT_REMOTE_FILE
|
238
|
-
)
|
239
|
-
file = DEFAULT_REMOTE_FILE if file.nil?
|
240
|
-
if file.include? '*'
|
241
|
-
file = ftp?.find_matches_for(file)
|
242
|
-
end
|
243
|
-
if file.is_a? Array
|
244
|
-
file.each {|the_file| download_remote_file(the_file) }
|
245
|
-
else
|
246
|
-
if file =~ /^\d+$/ # if is a number. DEBUG HERE THOUGH.
|
247
|
-
ftp?.update
|
248
|
-
file = ftp?.array_file_listing[file.to_i - 1][0]
|
249
|
-
end
|
250
|
-
set_remote_directory(file)
|
251
|
-
unless file == '*'
|
252
|
-
opne 'Trying to download `'+sfile(file)+'` now.'
|
253
|
-
# return_value = ftp?.download(file)
|
254
|
-
result = ftp?.download(file) # Delegate to the parent class.
|
255
|
-
if result
|
256
|
-
@array_downloaded_files << file
|
257
|
-
set_file(File.basename(file)) # setting new again.
|
258
|
-
if @open_in_default_editor # Works on @file now, as we did set it before.
|
259
|
-
open_this_file_in_editor(@file)
|
260
|
-
end
|
261
|
-
else
|
262
|
-
opne 'An exception occurred - you probably lack permissions to'
|
263
|
-
opne 'download that remote file.'
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
# ========================================================================= #
|
270
|
-
# === has_unwanted_file_suffix?
|
271
|
-
#
|
272
|
-
# The following method will return true or false.
|
273
|
-
#
|
274
|
-
# I needed it so that the editor does not open every file that was
|
275
|
-
# thrown at it.
|
276
|
-
# ========================================================================= #
|
277
|
-
def has_unwanted_file_suffix?(i)
|
278
|
-
return_value = false
|
279
|
-
case File.extname(i).delete('.')
|
280
|
-
when 'xz'
|
281
|
-
return_value = true
|
282
|
-
end
|
283
|
-
return return_value
|
284
|
-
end
|
285
|
-
|
286
|
-
# ========================================================================= #
|
287
|
-
# === debug_it
|
288
|
-
# ========================================================================= #
|
289
|
-
def debug_it # debug tag
|
290
|
-
ftp?.debug(true)
|
291
|
-
# pp ftp?.array_file_listing
|
292
|
-
end
|
293
|
-
|
294
|
-
# ========================================================================= #
|
295
|
-
# === set_local_directory
|
296
|
-
# ========================================================================= #
|
297
|
-
def set_local_directory(
|
298
|
-
i = Dir.pwd
|
299
|
-
)
|
300
|
-
i = i.to_s.dup
|
301
|
-
i << '/' unless i.end_with? '/'
|
302
|
-
i = FtpParadise.rds(i)
|
303
|
-
@local_directory = i
|
304
|
-
end
|
305
|
-
|
306
|
-
# ========================================================================= #
|
307
|
-
# === show_colours
|
308
|
-
# ========================================================================= #
|
309
|
-
def show_colours # Use this to show the colours.
|
310
|
-
pp Colours.colours?
|
311
|
-
end
|
312
|
-
|
313
|
-
# ========================================================================= #
|
314
|
-
# === debug?
|
315
|
-
# ========================================================================= #
|
316
|
-
def debug?
|
317
|
-
@debug
|
318
|
-
end
|
319
|
-
|
320
|
-
# ========================================================================= #
|
321
|
-
# === save_config
|
322
|
-
# ========================================================================= #
|
323
|
-
def save_config
|
324
|
-
@config.save
|
325
|
-
end
|
326
|
-
|
327
|
-
# ========================================================================= #
|
328
|
-
# === stat_remote_file (stat tag)
|
329
|
-
#
|
330
|
-
# This method can be called via '?33' for instance, or via 'stat 33'.
|
331
|
-
# ========================================================================= #
|
332
|
-
def stat_remote_file(i)
|
333
|
-
file = ftp?[i] # Obtain that file.
|
334
|
-
matches = ftp?.array_file_listing.select {|key,value| key == file }
|
335
|
-
matches.each { |entry|
|
336
|
-
e ' '+entry[0]+': '+sfancy(entry[2]+' KB')
|
337
|
-
}
|
338
|
-
end
|
339
|
-
|
340
|
-
# ========================================================================= #
|
341
|
-
# === show_local_entries
|
342
|
-
# ========================================================================= #
|
343
|
-
def show_local_entries
|
344
|
-
show_local_files(false)
|
345
|
-
end
|
346
|
-
|
347
|
-
# ========================================================================= #
|
348
|
-
# === return_local_files
|
349
|
-
#
|
350
|
-
# Return local files. Directories will not be included here.
|
351
|
-
# ========================================================================= #
|
352
|
-
def return_local_files
|
353
|
-
entries = Dir['*']
|
354
|
-
entries = Dir[Dir.pwd+'/*'] if show_full_names? # Overrule in this case.
|
355
|
-
entries.reject! {|entry| File.directory? entry }
|
356
|
-
return entries
|
357
|
-
end; alias file_listing return_local_files # === file_listing
|
358
|
-
|
359
|
-
# ========================================================================= #
|
360
|
-
# === return_local_entries
|
361
|
-
#
|
362
|
-
# Returns all local entries.
|
363
|
-
# ========================================================================= #
|
364
|
-
def return_local_entries
|
365
|
-
entries = Dir['*']
|
366
|
-
entries = Dir[Dir.pwd+'/*'] if show_full_names? # Overrule in this case.
|
367
|
-
return entries
|
368
|
-
end
|
369
|
-
|
370
|
-
# ========================================================================= #
|
371
|
-
# === coloured_remote_host?
|
372
|
-
# ========================================================================= #
|
373
|
-
def coloured_remote_host?
|
374
|
-
sfancy(remote_host?)
|
375
|
-
end
|
376
|
-
|
377
|
-
# ========================================================================= #
|
378
|
-
# === remote_host?
|
379
|
-
# ========================================================================= #
|
380
|
-
def remote_host?
|
381
|
-
ftp?.host?.to_s
|
382
|
-
end
|
383
|
-
|
384
|
-
# ========================================================================= #
|
385
|
-
# === enable_anonymous_login
|
386
|
-
#
|
387
|
-
# We use this method to enable anonymous logins.
|
388
|
-
# ========================================================================= #
|
389
|
-
def enable_anonymous_login
|
390
|
-
opne 'We will enable anonymous login now.'
|
391
|
-
set_password :anonymous
|
392
|
-
set_user_name 'anonymous'
|
393
|
-
end
|
394
|
-
|
395
|
-
# ========================================================================= #
|
396
|
-
# === create_directory
|
397
|
-
# ========================================================================= #
|
398
|
-
def create_directory(i, be_verbose = false)
|
399
|
-
be_verbose = true if be_verbose == :be_verbose
|
400
|
-
e 'Now creating local directory '+sdir(i)+'.' if be_verbose
|
401
|
-
FileUtils.mkdir_p(i)
|
402
|
-
end
|
403
|
-
|
404
|
-
# ========================================================================= #
|
405
|
-
# === report_file
|
406
|
-
#
|
407
|
-
# Here we simply report which file we would upload.
|
408
|
-
# ========================================================================= #
|
409
|
-
def report_file
|
410
|
-
if file?
|
411
|
-
e 'The file that we would upload is: '
|
412
|
-
e ' '+sfile(file?)
|
413
|
-
else
|
414
|
-
e 'No file was specified yet.'
|
415
|
-
end
|
416
|
-
end
|
417
|
-
|
418
|
-
# ========================================================================= #
|
419
|
-
# === move_local_file
|
420
|
-
# ========================================================================= #
|
421
|
-
def move_local_file(from, to)
|
422
|
-
e 'Next moving (local) file from '+sfile(from)+' to '+sfile(to)+'.'
|
423
|
-
if File.exist? from
|
424
|
-
FileUtils.mv(from, to)
|
425
|
-
else
|
426
|
-
e 'No (local) file called '+sfile(from)+' could be found.'
|
427
|
-
end
|
428
|
-
end
|
429
|
-
|
430
|
-
# ========================================================================= #
|
431
|
-
# === disconnect
|
432
|
-
#
|
433
|
-
# Disconnect the remote connection by invoking the quit() method on
|
434
|
-
# the FTP object.
|
435
|
-
# ========================================================================= #
|
436
|
-
def disconnect(be_verbose = true)
|
437
|
-
if ftp?.did_we_connect?
|
438
|
-
e 'Disconnected from `'+coloured_remote_host?+'`.' if be_verbose
|
439
|
-
end
|
440
|
-
ftp?.quit
|
441
|
-
exit
|
442
|
-
end
|
443
|
-
|
444
|
-
# ========================================================================= #
|
445
|
-
# === move_remote_file
|
446
|
-
#
|
447
|
-
# We expect an Array as input.
|
448
|
-
#
|
449
|
-
# To test this method, do:
|
450
|
-
# rmv DONE_Pr�fungsfragen_Hartig_Einheiten_2_3_5_9_10_11_12_15_16_21.pdf PDFs/
|
451
|
-
# mmv vimrc vim
|
452
|
-
# ========================================================================= #
|
453
|
-
def move_remote_file(i)
|
454
|
-
from = i[0]
|
455
|
-
to = i[1]
|
456
|
-
if is_directory?(to)
|
457
|
-
to << '/' unless to.end_with? '/'
|
458
|
-
to << File.basename(from)
|
459
|
-
end
|
460
|
-
e 'Next moving from '+sfancy(from)+' to '+sfancy(to)+'.'
|
461
|
-
ftp?.move_file(from, to)
|
462
|
-
end
|
463
|
-
|
464
|
-
# ========================================================================= #
|
465
|
-
# === register_sigint
|
466
|
-
# ========================================================================= #
|
467
|
-
def register_sigint
|
468
|
-
Signal.trap('SIGINT') {
|
469
|
-
e 'Please use "q" to quit.'
|
470
|
-
}
|
471
|
-
end
|
472
|
-
|
473
|
-
# ========================================================================= #
|
474
|
-
# === disable
|
475
|
-
# ========================================================================= #
|
476
|
-
def disable(i = nil)
|
477
|
-
i = i.to_s.to_sym
|
478
|
-
case i
|
479
|
-
when :base_directory, :full_names
|
480
|
-
do_not_show_full_names
|
481
|
-
when :debug
|
482
|
-
@config.debug = false
|
483
|
-
ftp?.disable_debug
|
484
|
-
save_config
|
485
|
-
end
|
486
|
-
e 'Disabling '+sfancy(i.to_s)+' now.' unless i.to_s.empty?
|
487
|
-
end
|
488
|
-
|
489
|
-
# ========================================================================= #
|
490
|
-
# === toggle_show_full_names
|
491
|
-
# ========================================================================= #
|
492
|
-
def toggle_show_full_names
|
493
|
-
@config.show_full_names = ! @config.show_full_names
|
494
|
-
end
|
495
|
-
|
496
|
-
# ========================================================================= #
|
497
|
-
# === do_not_show_full_names
|
498
|
-
# ========================================================================= #
|
499
|
-
def do_not_show_full_names
|
500
|
-
ftp?.show_full_names = false
|
501
|
-
@config.show_full_names = false # Sync.
|
502
|
-
end
|
503
|
-
|
504
|
-
# ========================================================================= #
|
505
|
-
# === do_show_full_names
|
506
|
-
# ========================================================================= #
|
507
|
-
def do_show_full_names
|
508
|
-
ftp?.show_full_names = true
|
509
|
-
@config.show_full_names = true # Sync.
|
510
|
-
end
|
511
|
-
|
512
|
-
# ========================================================================= #
|
513
|
-
# === will_we_show_full_names
|
514
|
-
# ========================================================================= #
|
515
|
-
def will_we_show_full_names
|
516
|
-
e 'Will we now show full names? '+
|
517
|
-
verbose_truth(show_full_names?)
|
518
|
-
end
|
519
|
-
|
520
|
-
# ========================================================================= #
|
521
|
-
# === report_last_response
|
522
|
-
# ========================================================================= #
|
523
|
-
def report_last_response
|
524
|
-
e 'The last response was: '+simp(ftp?.ftp.last_response.to_s)
|
525
|
-
end
|
526
|
-
|
527
|
-
# ========================================================================= #
|
528
|
-
# === report_last_response_code
|
529
|
-
# ========================================================================= #
|
530
|
-
def report_last_response_code
|
531
|
-
e 'The last response code was: '+simp(ftp?.ftp.last_response_code.to_s)
|
532
|
-
end
|
533
|
-
|
534
|
-
# ========================================================================= #
|
535
|
-
# === set_commandline_arguments
|
536
|
-
# ========================================================================= #
|
537
|
-
def set_commandline_arguments(i)
|
538
|
-
@commandline_arguments = i
|
539
|
-
end
|
540
|
-
|
541
|
-
# ========================================================================= #
|
542
|
-
# === check_commandline_arguments (commandline tag)
|
543
|
-
#
|
544
|
-
# This is called from within method enter_loop().
|
545
|
-
# ========================================================================= #
|
546
|
-
def check_commandline_arguments(
|
547
|
-
i = @commandline_arguments
|
548
|
-
)
|
549
|
-
if i.is_a?(String) and i.include?(',') # Here we assume a chained-instruction.
|
550
|
-
i = i.split(',')
|
551
|
-
end
|
552
|
-
i = [i].flatten.compact
|
553
|
-
i.each {|entry|
|
554
|
-
case entry
|
555
|
-
when '',nil # Do nothing in this case.
|
556
|
-
when '--disable-colours','--disable-colors','nocolours','nocol',
|
557
|
-
/^-?-?nocol$/
|
558
|
-
e 'Now disabling colours.'
|
559
|
-
FtpParadise.disable_colours
|
560
|
-
when *ARRAY_HELP_OPTIONS
|
561
|
-
show_commandline_help
|
562
|
-
exit
|
563
|
-
when 'BINARY'
|
564
|
-
set_binary :be_verbose
|
565
|
-
else
|
566
|
-
entry = entry.to_s
|
567
|
-
if File.exist?(entry)
|
568
|
-
set_file(entry)
|
569
|
-
@commandline_arguments.reject! {|line|
|
570
|
-
line.include? entry
|
571
|
-
}
|
572
|
-
end
|
573
|
-
end
|
574
|
-
}
|
575
|
-
end
|
576
|
-
|
577
|
-
# ========================================================================= #
|
578
|
-
# === show_commandline_help
|
579
|
-
#
|
580
|
-
# This method is different from "normal" help. The "normal" help will
|
581
|
-
# be displayed when we are already running in interactive mode. The
|
582
|
-
# commandline help however had will be run when we are invoking it
|
583
|
-
# from the commandline.
|
584
|
-
# ========================================================================= #
|
585
|
-
def show_commandline_help
|
586
|
-
opne 'These options are currently supported:'
|
587
|
-
opn(use_colours?); Colours.ecomment ' --disable-colours # Run without colours.'
|
588
|
-
end
|
589
|
-
|
590
|
-
# ========================================================================= #
|
591
|
-
# === show_welcome_message
|
592
|
-
#
|
593
|
-
# The initial startup message to welcome the user.
|
594
|
-
# ========================================================================= #
|
595
|
-
def show_welcome_message
|
596
|
-
e 'Welcome to the '+return_title+' shell.'
|
597
|
-
e 'Input '+sfancy('"help"')+' to show the help-section.'
|
598
|
-
e 'Please input commands next:'
|
599
|
-
end
|
600
|
-
|
601
|
-
# ========================================================================= #
|
602
|
-
# === show_ftp_server_welcome
|
603
|
-
#
|
604
|
-
# Simply show the FTP server's welcome message.
|
605
|
-
# ========================================================================= #
|
606
|
-
def show_ftp_server_welcome
|
607
|
-
e ftp?.welcome
|
608
|
-
end
|
609
|
-
|
610
|
-
# ========================================================================= #
|
611
|
-
# === return_title
|
612
|
-
# ========================================================================= #
|
613
|
-
def return_title
|
614
|
-
sfancy(TITLE)
|
615
|
-
end
|
616
|
-
|
617
|
-
# ========================================================================= #
|
618
|
-
# === try_to_append_this_to_the_history
|
619
|
-
#
|
620
|
-
# Right now only 'last' is a forbidden entry.
|
621
|
-
# ========================================================================= #
|
622
|
-
def try_to_append_this_to_the_history(i)
|
623
|
-
unless i.empty?
|
624
|
-
@history << i unless ARRAY_FORBIDDEN_HISTORY_COMMANDS.include? i
|
625
|
-
end
|
626
|
-
end
|
627
|
-
|
628
|
-
# ========================================================================= #
|
629
|
-
# === load_config
|
630
|
-
#
|
631
|
-
# This method will load the configuration for this class.
|
632
|
-
# ========================================================================= #
|
633
|
-
def load_config
|
634
|
-
@config = ::Roebe::Configuration::Configuration.new(FtpParadise.yaml_directory?)
|
635
|
-
@open_in_default_editor = OPEN_IN_DEFAULT_EDITOR
|
636
|
-
if @config.has_entry? 'open_in_default_editor'
|
637
|
-
@open_in_default_editor = @config.open_in_default_editor
|
638
|
-
end
|
639
|
-
if @config.respond_to? :debug
|
640
|
-
@debug = @config.debug # Obtain (or rather, overrule) the @debug variable.
|
641
|
-
end
|
642
|
-
end
|
643
|
-
|
644
|
-
# ========================================================================= #
|
645
|
-
# === report_port
|
646
|
-
# ========================================================================= #
|
647
|
-
def report_port
|
648
|
-
e 'The port in use is: '+sfancy(ftp?.port)
|
649
|
-
end
|
650
|
-
|
651
|
-
# ========================================================================= #
|
652
|
-
# === get_env_of
|
653
|
-
# ========================================================================= #
|
654
|
-
def get_env_of(i)
|
655
|
-
ConvertGlobalEnv.convert(i, ConvertGlobalEnv.report_errors?)
|
656
|
-
end
|
657
|
-
|
658
|
-
# ========================================================================= #
|
659
|
-
# === file?
|
660
|
-
#
|
661
|
-
# This may always be a String.
|
662
|
-
# ========================================================================= #
|
663
|
-
def file?
|
664
|
-
@file.to_s
|
665
|
-
end
|
666
|
-
|
667
|
-
# ========================================================================= #
|
668
|
-
# === consider_reporting_file
|
669
|
-
# ========================================================================= #
|
670
|
-
def consider_reporting_file
|
671
|
-
if file?.empty?
|
672
|
-
e 'No file has been assigned yet.'
|
673
|
-
e 'You can set a specific file via '+simportant('"set_file"')+'.'
|
674
|
-
else
|
675
|
-
report_file
|
676
|
-
end
|
677
|
-
end
|
678
|
-
|
679
|
-
# ========================================================================= #
|
680
|
-
# === toggle (toggle tag)
|
681
|
-
#
|
682
|
-
# Simply toggle the value for whether we @config.show_full_names or not.
|
683
|
-
# ========================================================================= #
|
684
|
-
def toggle(
|
685
|
-
i = :names
|
686
|
-
)
|
687
|
-
i = i.to_s
|
688
|
-
i = 'mode' if i.empty? # Safeguard.
|
689
|
-
case i
|
690
|
-
# ======================================================================= #
|
691
|
-
# === mode
|
692
|
-
# ======================================================================= #
|
693
|
-
when 'mode'
|
694
|
-
if @mode == :binary
|
695
|
-
use_ascii_mode
|
696
|
-
else
|
697
|
-
use_binary_mode
|
698
|
-
end
|
699
|
-
when 'names','name'
|
700
|
-
toggle_show_full_names
|
701
|
-
will_we_show_full_names
|
702
|
-
end
|
703
|
-
e 'We will now toggle '+sfancy(i)+' to '+simp(@mode.to_s)+'.'
|
704
|
-
end; alias show_full_names toggle # === show_full_names
|
705
|
-
|
706
|
-
# ========================================================================= #
|
707
|
-
# === show_user_and_password
|
708
|
-
# ========================================================================= #
|
709
|
-
def show_user_and_password
|
710
|
-
ftp?.show_user_and_password
|
711
|
-
end
|
712
|
-
|
713
|
-
# ========================================================================= #
|
714
|
-
# === show_host_user_name_port_and_password
|
715
|
-
# ========================================================================= #
|
716
|
-
def show_host_user_name_port_and_password
|
717
|
-
ftp?.show_host_user_name_port_and_password
|
718
|
-
end
|
719
|
-
|
720
|
-
# ========================================================================= #
|
721
|
-
# === show_local_files
|
722
|
-
#
|
723
|
-
# This method shows the local file listing. That is, all the entries in
|
724
|
-
# the given directory.
|
725
|
-
# ========================================================================= #
|
726
|
-
def show_local_files(show_only_directories = true)
|
727
|
-
_ = Dir.pwd
|
728
|
-
if Dir.entries(_).size == 2 # Dir.empty?, we assume that we have '.' and '..' only
|
729
|
-
e 'The directory `'+sdir(_)+'` is empty.'
|
730
|
-
else
|
731
|
-
e 'Showing local files now from `'+sdir(_)+'`:'
|
732
|
-
e ('=' * 55)+' '+FtpParadise.yellow('LOCAL FILES')+' '+('=' * 12)
|
733
|
-
entries = return_local_entries
|
734
|
-
entries.reject! {|x| ! File.directory?(x) } if show_only_directories
|
735
|
-
entries.sort.each_with_index { |item, index|
|
736
|
-
case File.ftype(item)
|
737
|
-
when 'directory'
|
738
|
-
item = sdir(item+'/')
|
739
|
-
when 'file'
|
740
|
-
item = sfile(item)
|
741
|
-
end
|
742
|
-
e '('+('%2s' % (index+1).to_s)+') '+FtpParadise.rds(item)
|
743
|
-
}
|
744
|
-
cliner
|
745
|
-
end
|
746
|
-
end
|
747
|
-
|
748
|
-
# ========================================================================= #
|
749
|
-
# === convert_number_to_file
|
750
|
-
#
|
751
|
-
# Use this to convert a number.
|
752
|
-
# convert_number_to_file(i) if i =~ /^\d+$/
|
753
|
-
# ========================================================================= #
|
754
|
-
def convert_number_to_file(number)
|
755
|
-
number = number.to_s.chomp
|
756
|
-
if number =~ /^\d+$/ # if is a number
|
757
|
-
ftp?.update_file_listing
|
758
|
-
number = ftp?.array_file_listing[number.to_i - 1][0]
|
759
|
-
end
|
760
|
-
return number
|
761
|
-
end
|
762
|
-
|
763
|
-
# ========================================================================= #
|
764
|
-
# === is_dir?
|
765
|
-
#
|
766
|
-
# Return true or false, depending on whether the input is a directory
|
767
|
-
# or whether it is not.
|
768
|
-
# ========================================================================= #
|
769
|
-
def is_dir?(i)
|
770
|
-
ftp?.is_directory?(i)
|
771
|
-
end; alias is_directory? is_dir? # === is_directory?
|
772
|
-
|
773
|
-
# ========================================================================= #
|
774
|
-
# === is_file?
|
775
|
-
# ========================================================================= #
|
776
|
-
def is_file?(i)
|
777
|
-
ftp?.is_file?(i)
|
778
|
-
end
|
779
|
-
|
780
|
-
# ========================================================================= #
|
781
|
-
# === this_remote_entry_exists?
|
782
|
-
# ========================================================================= #
|
783
|
-
def this_remote_entry_exists?(i)
|
784
|
-
does_it_exist = false
|
785
|
-
does_it_exist = true if is_dir? i # This will also check whether it exists.
|
786
|
-
does_it_exist = true if is_file? i
|
787
|
-
return does_it_exist
|
788
|
-
end
|
789
|
-
|
790
|
-
# ========================================================================= #
|
791
|
-
# === show_date_sorted_entries
|
792
|
-
#
|
793
|
-
# This method will show the sorted entries of the given remote directory
|
794
|
-
# at hand.
|
795
|
-
# ========================================================================= #
|
796
|
-
def show_date_sorted_entries
|
797
|
-
dataset = ftp?.array_file_listing?
|
798
|
-
reverse_sort_dateset = dataset.sort_by {|_a,_b_,_c, timestamp|
|
799
|
-
timestamp
|
800
|
-
}.reverse
|
801
|
-
ftp?.show_remote_listing(reverse_sort_dateset)
|
802
|
-
end
|
803
|
-
|
804
|
-
# ========================================================================= #
|
805
|
-
# === set_name
|
806
|
-
# ========================================================================= #
|
807
|
-
def set_name(i)
|
808
|
-
i = i.to_s
|
809
|
-
e 'Setting user-name to `'+sfancy(i)+'` now.'
|
810
|
-
ftp?.set_user_name(i)
|
811
|
-
end; alias set_user_name set_name # === set_user_name
|
812
|
-
|
813
|
-
# ========================================================================= #
|
814
|
-
# === show_full_names?
|
815
|
-
# ========================================================================= #
|
816
|
-
def show_full_names?
|
817
|
-
@config.show_full_names
|
818
|
-
end
|
819
|
-
|
820
|
-
# ========================================================================= #
|
821
|
-
# === create_remote_directory
|
822
|
-
# ========================================================================= #
|
823
|
-
def create_remote_directory(i)
|
824
|
-
ftp?.mkdir(i)
|
825
|
-
end
|
826
|
-
|
827
|
-
# ========================================================================= #
|
828
|
-
# === opne
|
829
|
-
# ========================================================================= #
|
830
|
-
def opne(message)
|
831
|
-
opnn; e message
|
832
|
-
end
|
833
|
-
|
834
|
-
# ========================================================================= #
|
835
|
-
# === opnn
|
836
|
-
# ========================================================================= #
|
837
|
-
def opnn(i = {namespace: NAMESPACE, use_colours: use_colours?})
|
838
|
-
Opn.opn(i)
|
839
|
-
end
|
840
|
-
|
841
|
-
# ========================================================================= #
|
842
|
-
# === set_login
|
843
|
-
# ========================================================================= #
|
844
|
-
def set_login(i)
|
845
|
-
ftp?.set_login_name(i)
|
846
|
-
end
|
847
|
-
|
848
|
-
# ========================================================================= #
|
849
|
-
# === user_input?
|
850
|
-
# ========================================================================= #
|
851
|
-
def user_input?
|
852
|
-
@user_input
|
853
|
-
end
|
854
|
-
|
855
|
-
# ========================================================================= #
|
856
|
-
# === report_where_we_are_connected_to
|
857
|
-
# ========================================================================= #
|
858
|
-
def report_where_we_are_connected_to
|
859
|
-
if are_we_connected?
|
860
|
-
e 'We are connected to: '+simportant(ftp?.remote?)
|
861
|
-
else
|
862
|
-
e 'We are not connected. Invoke "do_connect" to connect to a FTP host.'
|
863
|
-
end
|
864
|
-
end
|
865
|
-
|
866
|
-
# ========================================================================= #
|
867
|
-
# === return_remote_files
|
868
|
-
#
|
869
|
-
# We call into FtpParadise::Connection here.
|
870
|
-
# ========================================================================= #
|
871
|
-
def return_remote_files(mode = nil)
|
872
|
-
ftp?.show_full_names if show_full_names? # Display the full path here.
|
873
|
-
ftp?.return_remote_files
|
874
|
-
end
|
875
|
-
|
876
|
-
# ========================================================================= #
|
877
|
-
# === are_we_connected?
|
878
|
-
# ========================================================================= #
|
879
|
-
def are_we_connected?
|
880
|
-
@are_we_connected
|
881
|
-
end; alias is_connected? are_we_connected? # === is_connected?
|
882
|
-
|
883
|
-
# ========================================================================= #
|
884
|
-
# === automatically_connect_on_startup_of_the_interactive_ftp_shell?
|
885
|
-
# ========================================================================= #
|
886
|
-
def automatically_connect_on_startup_of_the_interactive_ftp_shell?
|
887
|
-
_ = FILE_AUTOMATICALLY_CONNECT_ON_STARTUP_OF_THE_INTERACTIVE_FTP_SHELL
|
888
|
-
if File.exist? _
|
889
|
-
YAML.load_file(_)
|
890
|
-
else
|
891
|
-
false # In this case we default to false.
|
892
|
-
end
|
893
|
-
end
|
894
|
-
|
895
|
-
# ========================================================================= #
|
896
|
-
# === startup_actions
|
897
|
-
#
|
898
|
-
# This method can be used to designate startup actions - which are actions
|
899
|
-
# that are run when the interactive ftp-shell is first started.
|
900
|
-
#
|
901
|
-
# Presently (Sep 2018) we will only consider two startup actions:
|
902
|
-
#
|
903
|
-
# (1) Consider making use of the Readline Module
|
904
|
-
# (2) auto-connecting on startup if a certain yaml-configuration file
|
905
|
-
# has an entry set to true, and if we are on roebe.
|
906
|
-
#
|
907
|
-
# ========================================================================= #
|
908
|
-
def startup_actions
|
909
|
-
# ======================================================================= #
|
910
|
-
# We will next try to make use of the Readline-module, if it is available:
|
911
|
-
# ======================================================================= #
|
912
|
-
try_to_use_readline
|
913
|
-
if are_we_on_roebe? and automatically_connect_on_startup_of_the_interactive_ftp_shell?
|
914
|
-
# ===================================================================== #
|
915
|
-
# The next is for my home system mostly; not sure if it is worth
|
916
|
-
# to make it more general for other people too.
|
917
|
-
# ===================================================================== #
|
918
|
-
do_login_to_shevy_and_consider_showing_the_remote_files
|
919
|
-
end
|
920
|
-
end
|
921
|
-
|
922
|
-
# ========================================================================= #
|
923
|
-
# === set_active
|
924
|
-
# ========================================================================= #
|
925
|
-
def set_active
|
926
|
-
ftp?.set_active
|
927
|
-
end
|
928
|
-
|
929
|
-
# ========================================================================= #
|
930
|
-
# === datafile?
|
931
|
-
# ========================================================================= #
|
932
|
-
def datafile?
|
933
|
-
'$MY_FTP/YAML/roebe_ftp.yml'
|
934
|
-
end
|
935
|
-
|
936
|
-
# ========================================================================= #
|
937
|
-
# === display_prompt
|
938
|
-
# ========================================================================= #
|
939
|
-
def display_prompt
|
940
|
-
print PROMPT_TO_USE
|
941
|
-
end
|
942
|
-
|
943
|
-
# ========================================================================= #
|
944
|
-
# === download?
|
945
|
-
# ========================================================================= #
|
946
|
-
def download?
|
947
|
-
e 'The remote file we would download is: '
|
948
|
-
e
|
949
|
-
e " #{sfile(DEFAULT_REMOTE_FILE)}"
|
950
|
-
e
|
951
|
-
end
|
952
|
-
|
953
|
-
# ========================================================================= #
|
954
|
-
# === do_login_to_shevy_and_consider_showing_the_remote_files
|
955
|
-
# ========================================================================= #
|
956
|
-
def do_login_to_shevy_and_consider_showing_the_remote_files
|
957
|
-
do_login(:shevy)
|
958
|
-
if SHOW_REMOTE_FILES_UPON_SUCCESSFUL_LOGIN
|
959
|
-
show_remote_files :also_show_filesize # Also display this since as of March 2015.
|
960
|
-
end
|
961
|
-
end
|
962
|
-
|
963
|
-
# ========================================================================= #
|
964
|
-
# === do_login
|
965
|
-
#
|
966
|
-
# If the first argument is :dont_login_yet, which is the default,
|
967
|
-
# we will not yet connect.
|
968
|
-
# ========================================================================= #
|
969
|
-
def do_login(
|
970
|
-
i = :dont_login_yet
|
971
|
-
)
|
972
|
-
i = nil if i == :dont_login_yet
|
973
|
-
if i
|
974
|
-
# ===================================================================== #
|
975
|
-
# Next, feed this information to the ftp? object.
|
976
|
-
# ===================================================================== #
|
977
|
-
ftp?.set_data(i)
|
978
|
-
ftp?.do_login # bl $RUBY_FTP/ftp_library.rb
|
979
|
-
@are_we_connected = true
|
980
|
-
end
|
981
|
-
end
|
982
|
-
|
983
|
-
end
|
984
|
-
|
985
|
-
# =========================================================================== #
|
986
|
-
# === FtpParadise.interactive
|
987
|
-
#
|
988
|
-
# Convenience method to instantiate a new class Interactive instance.
|
989
|
-
# =========================================================================== #
|
990
|
-
def self.interactive(i = ARGV)
|
991
|
-
FtpParadise::InteractiveFtp.new(i)
|
992
|
-
end
|
993
|
-
|
994
|
-
end
|
995
|
-
|
996
|
-
if __FILE__ == $PROGRAM_NAME
|
997
|
-
FtpParadise.interactive(ARGV)
|
998
|
-
end # iftp
|