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,233 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/constants/roebe_ftp_constants.rb'
|
6
|
-
# include FtpParadise::RoebeFtpConstants
|
7
|
-
# =========================================================================== #
|
8
|
-
module FtpParadise # === FtpParadise::RoebeFtpConstants
|
9
|
-
|
10
|
-
module RoebeFtpConstants
|
11
|
-
|
12
|
-
require 'ftp_paradise/constants/roebe.rb'
|
13
|
-
require 'yaml'
|
14
|
-
|
15
|
-
# ========================================================================= #
|
16
|
-
# === FtpParadise::RoebeFtpConstants::@hash_ftp_dataset
|
17
|
-
# ========================================================================= #
|
18
|
-
@hash_ftp_dataset = {}
|
19
|
-
|
20
|
-
# ========================================================================= #
|
21
|
-
# === FTP_DATASET
|
22
|
-
#
|
23
|
-
# Here we will load my custom ftp file, but only if this file exists.
|
24
|
-
#
|
25
|
-
# If it does not exist, then we will not load it, and we will not
|
26
|
-
# make use of it. That way others can ignore this file altogether.
|
27
|
-
#
|
28
|
-
# The location for my file is at:
|
29
|
-
#
|
30
|
-
# bl $MY_FTP/YAML/roebe_ftp.yml
|
31
|
-
#
|
32
|
-
# ========================================================================= #
|
33
|
-
if File.exist? FILE_ROEBE_FTP
|
34
|
-
FTP_DATASET = FILE_ROEBE_FTP
|
35
|
-
else
|
36
|
-
begin
|
37
|
-
home_dir = File.expand_path('~')
|
38
|
-
rescue; end
|
39
|
-
home_dir = '/root' if home_dir.nil? # A safeguard here if ENV is unavailable.
|
40
|
-
FTP_DATASET = "#{home_dir}/roebe_ftp.yml"
|
41
|
-
end
|
42
|
-
|
43
|
-
# ========================================================================= #
|
44
|
-
# === FtpParadise::RoebeFtpConstants.file?
|
45
|
-
#
|
46
|
-
# Feedback where that file is.
|
47
|
-
# ========================================================================= #
|
48
|
-
def self.file?
|
49
|
-
FILE_ROEBE_FTP
|
50
|
-
end
|
51
|
-
|
52
|
-
# ========================================================================= #
|
53
|
-
# === FtpParadise::RoebeFtpConstants.hash_ftp_dataset?
|
54
|
-
# ========================================================================= #
|
55
|
-
def self.hash_ftp_dataset?
|
56
|
-
@hash_ftp_dataset
|
57
|
-
end; self.instance_eval { alias hash? hash_ftp_dataset? } # === FtpParadise::RoebeFtpConstants.hash_ftp_dataset?.hash?
|
58
|
-
|
59
|
-
# ========================================================================= #
|
60
|
-
# Next check whether the roebe_ftp.yml file exists. If it does then
|
61
|
-
# we will load it up.
|
62
|
-
# ========================================================================= #
|
63
|
-
if File.exist? file?
|
64
|
-
dataset = YAML.load_file(file?)
|
65
|
-
@hash_ftp_dataset.update(dataset) # Sync the dataset.
|
66
|
-
# ======================================================================= #
|
67
|
-
# The format of the dataset has to be uniform. We start with the
|
68
|
-
# remote URL, then the user name, the password, and then the port.
|
69
|
-
# ======================================================================= #
|
70
|
-
|
71
|
-
# ======================================================================= #
|
72
|
-
# === A1 TAG
|
73
|
-
# ======================================================================= #
|
74
|
-
_ = dataset['a1']
|
75
|
-
A1 = [
|
76
|
-
_['url'],
|
77
|
-
_['user_name'],
|
78
|
-
_['password'],
|
79
|
-
_['port']
|
80
|
-
]
|
81
|
-
|
82
|
-
# ======================================================================= #
|
83
|
-
# === ZYMIX TAG
|
84
|
-
# ======================================================================= #
|
85
|
-
_ = dataset['zymix']
|
86
|
-
ZYMIX = [
|
87
|
-
_['url'],
|
88
|
-
_['user_name'],
|
89
|
-
_['password'],
|
90
|
-
_['port']
|
91
|
-
]
|
92
|
-
|
93
|
-
# ======================================================================= #
|
94
|
-
# === Bytehost Tag
|
95
|
-
#
|
96
|
-
# bl $MY_FTP/YAML/roebe_ftp.yml
|
97
|
-
# ======================================================================= #
|
98
|
-
_ = dataset['bytehost']
|
99
|
-
BYTEHOST = [
|
100
|
-
_['url'],
|
101
|
-
_['user_name'],
|
102
|
-
_['password'],
|
103
|
-
_['port']
|
104
|
-
]
|
105
|
-
|
106
|
-
# ======================================================================= #
|
107
|
-
# === UNIVIE
|
108
|
-
#
|
109
|
-
# Uni tag, Univie tag
|
110
|
-
# ======================================================================= #
|
111
|
-
_ = dataset['univie']
|
112
|
-
UNIVIE = [
|
113
|
-
_['url'],
|
114
|
-
_['user_name'],
|
115
|
-
_['password'],
|
116
|
-
_['port']
|
117
|
-
]
|
118
|
-
|
119
|
-
# ======================================================================= #
|
120
|
-
# === Zerofees tag
|
121
|
-
# ======================================================================= #
|
122
|
-
_ = dataset['zerofees']
|
123
|
-
ZEROFEES = [
|
124
|
-
_['url'],
|
125
|
-
_['user_name'],
|
126
|
-
_['password'],
|
127
|
-
_['port']
|
128
|
-
]
|
129
|
-
|
130
|
-
# ======================================================================= #
|
131
|
-
# === UCOZ tag
|
132
|
-
# ======================================================================= #
|
133
|
-
_ = dataset['ucoz']
|
134
|
-
UCOZ = [
|
135
|
-
_['url'],
|
136
|
-
_['user_name'],
|
137
|
-
_['password'],
|
138
|
-
_['port']
|
139
|
-
]
|
140
|
-
|
141
|
-
# ======================================================================= #
|
142
|
-
# === UNIWIEN_HOMEPAGE tag
|
143
|
-
# ======================================================================= #
|
144
|
-
_ = dataset['uniwien_homepage']
|
145
|
-
UNIWIEN_HOMEPAGE = [
|
146
|
-
_['url'],
|
147
|
-
_['user_name'],
|
148
|
-
_['password'],
|
149
|
-
_['port']
|
150
|
-
]
|
151
|
-
|
152
|
-
# ======================================================================= #
|
153
|
-
# === bplaced
|
154
|
-
# ======================================================================= #
|
155
|
-
_ = dataset['bplaced']
|
156
|
-
BPLACED = [
|
157
|
-
_['url'],
|
158
|
-
_['user_name'],
|
159
|
-
_['password'],
|
160
|
-
_['port']
|
161
|
-
]
|
162
|
-
|
163
|
-
# ======================================================================= #
|
164
|
-
# === podserver
|
165
|
-
# ======================================================================= #
|
166
|
-
_ = dataset['podserver']
|
167
|
-
PODSERVER = [
|
168
|
-
_['url'],
|
169
|
-
_['user_name'],
|
170
|
-
_['password'],
|
171
|
-
_['port']
|
172
|
-
]
|
173
|
-
|
174
|
-
# ======================================================================= #
|
175
|
-
# === RoebeFtpConstants::ARRAY_AVAILABLE_HOSTS
|
176
|
-
#
|
177
|
-
# All available hosts are kept in the following Array.
|
178
|
-
#
|
179
|
-
# It is always available when the roebe_ftp.yml file was found.
|
180
|
-
#
|
181
|
-
# Append to this Array if you add new entries above.
|
182
|
-
# ======================================================================= #
|
183
|
-
ARRAY_AVAILABLE_HOSTS = [
|
184
|
-
BYTEHOST.first,
|
185
|
-
A1.first,
|
186
|
-
ZYMIX.first,
|
187
|
-
UNIVIE.first,
|
188
|
-
ZEROFEES.first,
|
189
|
-
UCOZ.first,
|
190
|
-
UNIWIEN_HOMEPAGE.first,
|
191
|
-
PODSERVER.first
|
192
|
-
]
|
193
|
-
end
|
194
|
-
|
195
|
-
# ========================================================================= #
|
196
|
-
# === RoebeFtpConstants.possible_hosts?
|
197
|
-
# ========================================================================= #
|
198
|
-
def self.possible_hosts?
|
199
|
-
ARRAY_AVAILABLE_HOSTS
|
200
|
-
end
|
201
|
-
|
202
|
-
# ========================================================================= #
|
203
|
-
# === RoebeFtpConstants.geas?
|
204
|
-
# ========================================================================= #
|
205
|
-
def self.geas?
|
206
|
-
GEAS
|
207
|
-
end
|
208
|
-
|
209
|
-
# ========================================================================= #
|
210
|
-
# === RoebeFtpConstants.return_user_name_based_on_given_host
|
211
|
-
#
|
212
|
-
# This method may return the proper user name.
|
213
|
-
# ========================================================================= #
|
214
|
-
def self.return_user_name_based_on_given_host(i)
|
215
|
-
if ARRAY_AVAILABLE_HOSTS.include? i
|
216
|
-
i = PODSERVER[1] # Hardcoded for now. [1] is the user-name.
|
217
|
-
end if FtpParadise.const_defined? :RoebeFtpConstants
|
218
|
-
i
|
219
|
-
end
|
220
|
-
|
221
|
-
end; end
|
222
|
-
|
223
|
-
if __FILE__ == $PROGRAM_NAME # Testing RoebeFtpConstants next.
|
224
|
-
require 'cliner'
|
225
|
-
require 'colours/colours_e_autoinclude.rb'
|
226
|
-
include RoebeFtpConstants
|
227
|
-
cliner
|
228
|
-
e RoebeFtpConstants.file?
|
229
|
-
cliner
|
230
|
-
pp RoebeFtpConstants.hash_ftp_dataset?
|
231
|
-
pp RoebeFtpConstants::GEAS
|
232
|
-
pp RoebeFtpConstants.geas?
|
233
|
-
end # $FTP_PARADISE/roebe_ftp_constants.rb
|
@@ -1,34 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# === FtpParadise::GUI::Gtk::FtpParadise
|
6
|
-
# =========================================================================== #
|
7
|
-
# require 'ftp_paradise/gui/gtk2/ftp_paradise.rb'
|
8
|
-
# FtpParadise::GUI::Gtk::FtpParadise.run
|
9
|
-
# =========================================================================== #
|
10
|
-
require 'gtk_paradise/require_gtk2'
|
11
|
-
|
12
|
-
module FtpParadise
|
13
|
-
|
14
|
-
module GUI
|
15
|
-
|
16
|
-
module Gtk
|
17
|
-
|
18
|
-
class FtpParadise < ::Gtk::Box
|
19
|
-
|
20
|
-
require 'ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb'
|
21
|
-
include ::FtpParadise::GUI::Gtk::FtpParadiseModule
|
22
|
-
|
23
|
-
# ========================================================================= #
|
24
|
-
# === FtpParadise::GUI::Gtk::FtpParadise.run
|
25
|
-
# ========================================================================= #
|
26
|
-
def self.run
|
27
|
-
::FtpParadise::GUI::Gtk::FtpParadiseModule.run
|
28
|
-
end
|
29
|
-
|
30
|
-
end; end; end; end
|
31
|
-
|
32
|
-
if __FILE__ == $PROGRAM_NAME
|
33
|
-
FtpParadise::GUI::Gtk::FtpParadise.run
|
34
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# === FtpParadise::GUI::Gtk::FtpParadise
|
6
|
-
# =========================================================================== #
|
7
|
-
# require 'ftp_paradise/gui/gtk3/ftp_paradise.rb'
|
8
|
-
# FtpParadise::GUI::Gtk::FtpParadise.run
|
9
|
-
# =========================================================================== #
|
10
|
-
require 'gtk_paradise/require_gtk3'
|
11
|
-
|
12
|
-
module FtpParadise
|
13
|
-
|
14
|
-
module GUI
|
15
|
-
|
16
|
-
module Gtk
|
17
|
-
|
18
|
-
class FtpParadise < ::Gtk::Box
|
19
|
-
|
20
|
-
require 'ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb'
|
21
|
-
include ::FtpParadise::GUI::Gtk::FtpParadiseModule
|
22
|
-
|
23
|
-
# ========================================================================= #
|
24
|
-
# === FtpParadise::GUI::Gtk::FtpParadise.run
|
25
|
-
# ========================================================================= #
|
26
|
-
def self.run
|
27
|
-
::FtpParadise::GUI::Gtk::FtpParadiseModule.run
|
28
|
-
end
|
29
|
-
|
30
|
-
end; end; end; end
|
31
|
-
|
32
|
-
if __FILE__ == $PROGRAM_NAME
|
33
|
-
FtpParadise::GUI::Gtk::FtpParadise.run
|
34
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# All constants for class Interactive shall be stored in this file here.
|
6
|
-
# =========================================================================== #
|
7
|
-
# require 'ftp_paradise/interactive_ftp/constants.rb'
|
8
|
-
# =========================================================================== #
|
9
|
-
module FtpParadise
|
10
|
-
|
11
|
-
class InteractiveFtp # === FtpParadise::InteractiveFtp
|
12
|
-
|
13
|
-
require 'ftp_paradise/toplevel_methods/rds.rb'
|
14
|
-
|
15
|
-
# ========================================================================= #
|
16
|
-
# === NAMESPACE
|
17
|
-
# ========================================================================= #
|
18
|
-
NAMESPACE = inspect
|
19
|
-
|
20
|
-
# ========================================================================= #
|
21
|
-
# === TITLE
|
22
|
-
# ========================================================================= #
|
23
|
-
TITLE = 'Interactive FTP'
|
24
|
-
|
25
|
-
# ========================================================================= #
|
26
|
-
# === SHOW_REMOTE_FILES_UPON_SUCCESSFUL_LOGIN
|
27
|
-
#
|
28
|
-
# If this constant is true then we will show the remote file
|
29
|
-
# listing upon a successful (first) login action.
|
30
|
-
# ========================================================================= #
|
31
|
-
SHOW_REMOTE_FILES_UPON_SUCCESSFUL_LOGIN = false
|
32
|
-
|
33
|
-
# ========================================================================= #
|
34
|
-
# === SHALL_WE_DEBUG
|
35
|
-
# ========================================================================= #
|
36
|
-
SHALL_WE_DEBUG = true
|
37
|
-
|
38
|
-
# ========================================================================= #
|
39
|
-
# === PROMPT_TO_USE
|
40
|
-
#
|
41
|
-
# Which Prompt to use by default for the Interactive FTP component.
|
42
|
-
# ========================================================================= #
|
43
|
-
PROMPT_TO_USE = '> '
|
44
|
-
|
45
|
-
# ========================================================================= #
|
46
|
-
# === ARRAY_FORBIDDEN_HISTORY_COMMANDS
|
47
|
-
# ========================================================================= #
|
48
|
-
ARRAY_FORBIDDEN_HISTORY_COMMANDS = %w(
|
49
|
-
last
|
50
|
-
) # Dont append last to the history.
|
51
|
-
|
52
|
-
# ========================================================================= #
|
53
|
-
# === OPEN_IN_DEFAULT_EDITOR
|
54
|
-
# ========================================================================= #
|
55
|
-
OPEN_IN_DEFAULT_EDITOR = true
|
56
|
-
|
57
|
-
# ========================================================================= #
|
58
|
-
# === USE_THIS_EDITOR
|
59
|
-
# ========================================================================= #
|
60
|
-
USE_THIS_EDITOR = ENV['EDITOR'].to_s
|
61
|
-
|
62
|
-
# ========================================================================= #
|
63
|
-
# === DEFAULT_LOCAL_DIRECTORY
|
64
|
-
# ========================================================================= #
|
65
|
-
DEFAULT_LOCAL_DIRECTORY = ::FtpParadise.rds("#{Dir.pwd}/") # More flexible that way, I suppose.
|
66
|
-
|
67
|
-
# ========================================================================= #
|
68
|
-
# === NAME_OF_THIS_FILE
|
69
|
-
# ========================================================================= #
|
70
|
-
NAME_OF_THIS_FILE = "#{PROJECT_BASE_DIRECTORY}interactive_ftp.rb"
|
71
|
-
|
72
|
-
# ========================================================================= #
|
73
|
-
# === ARRAY_PROJECT_FILES
|
74
|
-
#
|
75
|
-
# The following files have to be opened when you wish to open the
|
76
|
-
# project files.
|
77
|
-
# ========================================================================= #
|
78
|
-
ARRAY_PROJECT_FILES = %w(
|
79
|
-
library.rb
|
80
|
-
interactive.rb
|
81
|
-
addon/constants/roebe_ftp_constants.rb
|
82
|
-
doc/TODO
|
83
|
-
).map {|entry| PROJECT_BASE_DIRECTORY+entry}
|
84
|
-
|
85
|
-
# ========================================================================= #
|
86
|
-
# === DEFAULT_REMOTE_DIRECTORY
|
87
|
-
#
|
88
|
-
# The default remote directory.
|
89
|
-
# ========================================================================= #
|
90
|
-
DEFAULT_REMOTE_DIRECTORY = %q(
|
91
|
-
htdocs
|
92
|
-
).delete("\n").strip # kill newlines and empty spaces.
|
93
|
-
|
94
|
-
# ========================================================================= #
|
95
|
-
# === DEFAULT_REMOTE_FILE
|
96
|
-
#
|
97
|
-
# The default remote file comes next.
|
98
|
-
# ========================================================================= #
|
99
|
-
DEFAULT_REMOTE_FILE = %q(
|
100
|
-
README.md
|
101
|
-
).gsub(/\n/,'').strip
|
102
|
-
|
103
|
-
end; end
|
@@ -1,216 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/interactive_ftp/directory_handling.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
class InteractiveFtp
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === ftp_remote_directory?
|
13
|
-
# ========================================================================= #
|
14
|
-
def ftp_remote_directory?
|
15
|
-
ftp?.remote_directory?
|
16
|
-
end; alias return_remote_pwd ftp_remote_directory? # === return_remote_pwd
|
17
|
-
|
18
|
-
# ========================================================================= #
|
19
|
-
# === report_remote_directory
|
20
|
-
#
|
21
|
-
# This method will report the remote directory.
|
22
|
-
# ========================================================================= #
|
23
|
-
def report_remote_directory(
|
24
|
-
make_newline = true
|
25
|
-
)
|
26
|
-
if is_connected?
|
27
|
-
remote_dir = sdir(ftp_remote_directory?)
|
28
|
-
if make_newline
|
29
|
-
e 'The remote directory is: '
|
30
|
-
e " #{sdir(remote_dir)}"
|
31
|
-
else
|
32
|
-
e 'The remote directory is: '+sdir(remote_dir)
|
33
|
-
end
|
34
|
-
else
|
35
|
-
e 'No connection is available. You may have to re-connect again.'
|
36
|
-
end
|
37
|
-
end; alias show_remote_directory report_remote_directory # === show_remote_directory
|
38
|
-
|
39
|
-
# ========================================================================= #
|
40
|
-
# === remote_directory?
|
41
|
-
# ========================================================================= #
|
42
|
-
def remote_directory?
|
43
|
-
@remote_directory
|
44
|
-
end
|
45
|
-
|
46
|
-
# ========================================================================= #
|
47
|
-
# === set_remote_directory
|
48
|
-
# ========================================================================= #
|
49
|
-
def set_remote_directory(i)
|
50
|
-
i = File.dirname(i) if ftp?.is_file?(i) # Get the base directory here.
|
51
|
-
@remote_directory = i
|
52
|
-
@array_history_remote_directories << @remote_directory
|
53
|
-
end
|
54
|
-
|
55
|
-
# ========================================================================= #
|
56
|
-
# === upload_directory
|
57
|
-
# ========================================================================= #
|
58
|
-
def upload_directory(i)
|
59
|
-
ftp?.upload_directory(i)
|
60
|
-
end
|
61
|
-
|
62
|
-
# ========================================================================= #
|
63
|
-
# === remote_change_directory
|
64
|
-
#
|
65
|
-
# This method can be used to change directory on the remote host.
|
66
|
-
#
|
67
|
-
# An argument such as :show_remote_file_listing can be passed as second
|
68
|
-
# argument to this method, in which case we will list the content of
|
69
|
-
# the remote directory after the cd-action.
|
70
|
-
#
|
71
|
-
# If readline is used, as determined by the instance variable @use_readline,
|
72
|
-
# then we will attempt to cd-<TAB>.
|
73
|
-
#
|
74
|
-
# Invocation example:
|
75
|
-
#
|
76
|
-
# rcd htdocs
|
77
|
-
#
|
78
|
-
# ========================================================================= #
|
79
|
-
def remote_change_directory(
|
80
|
-
i = f?,
|
81
|
-
optional_instruction = nil,
|
82
|
-
be_verbose = false
|
83
|
-
)
|
84
|
-
i = i.first if i.is_a? Array
|
85
|
-
i = '..' if i.nil? # <- Tiny "safeguard".
|
86
|
-
# ======================================================================= #
|
87
|
-
# We must first check whether we input only numbers,
|
88
|
-
# and whether such a directory does NOT exist.
|
89
|
-
# ======================================================================= #
|
90
|
-
if (i =~ /^\d+$/) and !is_dir?(i)
|
91
|
-
ftp?.update_file_listing
|
92
|
-
i = ftp?.array_file_listing[i.to_i - 1]
|
93
|
-
end
|
94
|
-
if be_verbose
|
95
|
-
e "Trying to cd into the remote directory `#{sfancy(i)}`."
|
96
|
-
end
|
97
|
-
case i # case tag
|
98
|
-
when '?' # intercept ?
|
99
|
-
e 'You went into these remote directories so far:'
|
100
|
-
@array_history_remote_directories.each { |entry|
|
101
|
-
e "- #{entry}"
|
102
|
-
}
|
103
|
-
else # This is the default.
|
104
|
-
if i
|
105
|
-
i.squeeze!('/') if i.include? '//' # Get rid of multiple //.
|
106
|
-
e "Changing remote directory to `#{sdir(i)}` now."
|
107
|
-
end
|
108
|
-
begin
|
109
|
-
ftp?.chdir(i)
|
110
|
-
set_remote_directory(i)
|
111
|
-
if optional_instruction
|
112
|
-
case optional_instruction
|
113
|
-
when :show_remote_file_listing
|
114
|
-
show_remote_files
|
115
|
-
end
|
116
|
-
end
|
117
|
-
rescue Exception => error
|
118
|
-
pp error
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end; alias remote_cd remote_change_directory # === remote_cd
|
122
|
-
|
123
|
-
# ========================================================================= #
|
124
|
-
# === change_local_and_remote_directories
|
125
|
-
#
|
126
|
-
# We combine local cd and remote cd here.
|
127
|
-
# ========================================================================= #
|
128
|
-
def change_local_and_remote_directories(
|
129
|
-
target = DEFAULT_LOCAL_DIRECTORY
|
130
|
-
)
|
131
|
-
change_directory(target, :be_silent) # Mandatory since as of 01.05.2011
|
132
|
-
if are_we_connected?
|
133
|
-
remote_change_directory(target) # Since as of August 2011.
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
# ========================================================================= #
|
138
|
-
# === set_start_directory=
|
139
|
-
# ========================================================================= #
|
140
|
-
def set_start_directory=(i) # set_start_directory=(i)
|
141
|
-
change_directory(i)
|
142
|
-
end
|
143
|
-
|
144
|
-
# ========================================================================= #
|
145
|
-
# === change_directory (cd tag)
|
146
|
-
#
|
147
|
-
# This only changes for local directories, not remote directories.
|
148
|
-
# ========================================================================= #
|
149
|
-
def change_directory(
|
150
|
-
i = DEFAULT_LOCAL_DIRECTORY,
|
151
|
-
be_verbose = true
|
152
|
-
)
|
153
|
-
i = '..' if i.nil?
|
154
|
-
be_verbose = false if be_verbose == :be_silent
|
155
|
-
i = i.to_s
|
156
|
-
i.gsub!(/; pwd/,'') if i.include? '; pwd'
|
157
|
-
begin
|
158
|
-
i = get_env_of(i) if i.include? '$'
|
159
|
-
if File.exist?(i)
|
160
|
-
# =================================================================== #
|
161
|
-
# Next, do the actual "change directory" action.
|
162
|
-
# =================================================================== #
|
163
|
-
Dir.chdir(i) # This will cd for local directories.
|
164
|
-
i = return_pwd if i == '..'
|
165
|
-
i = rds(return_pwd) unless i.include? '/'
|
166
|
-
set_local_directory(i) # Set the new pwd here.
|
167
|
-
report_local_directory if be_verbose
|
168
|
-
else # else, the directory does not exist.
|
169
|
-
e swarn('But the directory '+sdir(i)+' does not exist '\
|
170
|
-
'locally in '+sdir(return_pwd)+'.')
|
171
|
-
end
|
172
|
-
rescue Exception => error
|
173
|
-
e 'An exception occurred in '+swarn('change_directory()')
|
174
|
-
e "The directory `#{sdir(i)}` does not exist."
|
175
|
-
pp error # Should remove this and error perhaps.
|
176
|
-
end
|
177
|
-
end; alias cd change_directory # === cd
|
178
|
-
|
179
|
-
# ========================================================================= #
|
180
|
-
# === report_local_directory
|
181
|
-
#
|
182
|
-
# Use only this method when reporting the local directory.
|
183
|
-
# ========================================================================= #
|
184
|
-
def report_local_directory
|
185
|
-
e 'The local directory is: '+N+
|
186
|
-
@pad+sdir(return_pwd)
|
187
|
-
end; alias report_local_dir report_local_directory # === report_local_dir
|
188
|
-
|
189
|
-
# ========================================================================= #
|
190
|
-
# === remote_create_directory
|
191
|
-
# ========================================================================= #
|
192
|
-
def remote_create_directory(
|
193
|
-
i = a?,
|
194
|
-
be_verbose = true
|
195
|
-
)
|
196
|
-
if i.is_a? Array
|
197
|
-
i.each {|entry| remote_create_directory(entry, be_verbose) }
|
198
|
-
else
|
199
|
-
# ===================================================================== #
|
200
|
-
# Delegate towards the respective module-method next.
|
201
|
-
# ===================================================================== #
|
202
|
-
if be_verbose
|
203
|
-
e "Creating the directory #{sdir(i)} next:"
|
204
|
-
end
|
205
|
-
FtpParadise.remote_create_directory(i, @ftp)
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
# ========================================================================= #
|
210
|
-
# === return_pwd
|
211
|
-
# ========================================================================= #
|
212
|
-
def return_pwd
|
213
|
-
("#{Dir.pwd}/").squeeze '/'
|
214
|
-
end
|
215
|
-
|
216
|
-
end; end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'ftp_paradise/interactive_ftp/help.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module FtpParadise
|
8
|
-
|
9
|
-
class InteractiveFtp
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === show_help (help tag)
|
13
|
-
# ========================================================================= #
|
14
|
-
def show_help
|
15
|
-
cliner
|
16
|
-
e "Try one of these #{sfancy('help options')} for interactive-ftp:#{N}#{N}"
|
17
|
-
e parens(:assign)+' '+pound_token+'Assign to the @file variable'
|
18
|
-
e parens(:help)+' '+pound_token+'To see the help section'
|
19
|
-
e parens(:history)+' '+pound_token+'To show the history'
|
20
|
-
e parens(:cd)+' '+pound_token+'Change local directory'
|
21
|
-
e parens(:config)+' '+pound_token+'Show the configuration'
|
22
|
-
e parens(:dated)+' '+pound_token+'Display the remote directory '\
|
23
|
-
'content in a time-sorted manner'
|
24
|
-
e parens(:edit)+' '+pound_token+'Edit this file here in your main editor'
|
25
|
-
e parens(:everything)+' '+pound_token+'Show everything (username, password, host and so on)'
|
26
|
-
e parens(:login)+' '+pound_token+'Connect to the remote host (alias '\
|
27
|
-
'to connect_to exists)'
|
28
|
-
e parens(:list)+' '+pound_token+'List remote files'
|
29
|
-
e parens(:last)+' '+pound_token+'Repeat the last action (or show the last action)'
|
30
|
-
e parens(:rcd)+' '+pound_token+'Change remote directory'
|
31
|
-
e parens(:remote?)+' '+pound_token+'List where we are connected'
|
32
|
-
e parens(:stat)+' '+pound_token+'Show information about a file'
|
33
|
-
e parens(:status?)+' '+pound_token+'See the current status of the connection'
|
34
|
-
e parens(:file?)+' '+pound_token+'Shows whether we have a '+
|
35
|
-
'default file set (which can be used to upload)'
|
36
|
-
e parens(:info)+' '+pound_token+'Shows some information (debug)'
|
37
|
-
e parens(:set_port)+' '+pound_token+'Set the port number'
|
38
|
-
e parens(:q)+' '+pound_token+'To quit/exit'
|
39
|
-
e parens(:quit)+' '+pound_token+'Quit the session'
|
40
|
-
if on_roebe? # Display it only for me.
|
41
|
-
e parens(:shevy)+' '+pound_token+'Connect to shevy'
|
42
|
-
end
|
43
|
-
e parens(:lpwd)+' '+pound_token+'Report the current remote directory'
|
44
|
-
e parens(:pwd)+' '+pound_token+'Report the local directory'+N
|
45
|
-
e parens(:welcome)+' '+pound_token+'Show the welcome-message of the remote FTP server'+N
|
46
|
-
e
|
47
|
-
cliner
|
48
|
-
end; alias show_help_options show_help # === show_help_options
|
49
|
-
|
50
|
-
end; end
|