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.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +155 -28
  3. data/bin/{iftp → ftp_paradise_shell} +1 -1
  4. data/doc/README.gen +97 -15
  5. data/doc/todo/{TODO_FOR_FTP_PARADISE_PROJECT.md → todo_for_the_ftp_paradise_project.md} +11 -1
  6. data/ftp_paradise.gemspec +30 -39
  7. data/lib/ftp_paradise/base/base.rb +375 -0
  8. data/lib/ftp_paradise/colours/colours.rb +27 -27
  9. data/lib/ftp_paradise/colours/use_colours.rb +6 -1
  10. data/lib/ftp_paradise/configuration/configuration.rb +7 -4
  11. data/lib/ftp_paradise/connection/README.md +0 -0
  12. data/lib/ftp_paradise/connection/connection.rb +2782 -15
  13. data/lib/ftp_paradise/constants/constants.rb +91 -5
  14. data/lib/ftp_paradise/entry/entry.rb +42 -5
  15. data/lib/ftp_paradise/{connection → gui/gtk3/ftp_client}/constants.rb +33 -21
  16. data/lib/ftp_paradise/gui/{shared_code/ftp_paradise/ftp_paradise_module.rb → gtk3/ftp_client/ftp_client.rb} +658 -170
  17. data/lib/ftp_paradise/gui/gtk3/ftp_client/misc.rb +27 -0
  18. data/lib/ftp_paradise/project/project.rb +11 -15
  19. data/lib/ftp_paradise/requires/require_class_connection.rb +7 -0
  20. data/lib/ftp_paradise/requires/require_net_ftp.rb +7 -0
  21. data/lib/ftp_paradise/requires/require_the_ftp_paradise_project.rb +4 -3
  22. data/lib/ftp_paradise/requires/require_the_ftp_paradise_project_with_the_GUI_bindings.rb +1 -1
  23. data/lib/ftp_paradise/requires/require_the_toplevel_methods.rb +1 -0
  24. data/lib/ftp_paradise/{interactive_ftp → shell}/menu.rb +564 -449
  25. data/lib/ftp_paradise/shell/shell.rb +2321 -0
  26. data/lib/ftp_paradise/toplevel_methods/connect.rb +3 -0
  27. data/lib/ftp_paradise/toplevel_methods/dataset.rb +111 -0
  28. data/lib/ftp_paradise/toplevel_methods/file_related_actions.rb +4 -3
  29. data/lib/ftp_paradise/toplevel_methods/ftp_object.rb +6 -5
  30. data/lib/ftp_paradise/toplevel_methods/login_name.rb +6 -4
  31. data/lib/ftp_paradise/toplevel_methods/misc.rb +19 -0
  32. data/lib/ftp_paradise/toplevel_methods/opn.rb +1 -1
  33. data/lib/ftp_paradise/toplevel_methods/password.rb +4 -2
  34. data/lib/ftp_paradise/toplevel_methods/port.rb +4 -1
  35. data/lib/ftp_paradise/toplevel_methods/remote_url.rb +11 -5
  36. data/lib/ftp_paradise/toplevel_methods/upload_and_download.rb +1 -0
  37. data/lib/ftp_paradise/version/version.rb +6 -1
  38. data/lib/ftp_paradise/www/web_interface.cgi +1 -1
  39. data/lib/ftp_paradise/yaml/automatically_connect_on_startup_of_the_interactive_ftp_shell.yml +0 -0
  40. data/lib/ftp_paradise/yaml/debug.yml +0 -0
  41. data/lib/ftp_paradise/yaml/open_in_default_editor.yml +0 -0
  42. data/lib/ftp_paradise/yaml/show_full_names.yml +0 -0
  43. data/lib/ftp_paradise/yaml/use_colours.yml +0 -0
  44. data/test/testing_minimal_pure_net_ftp_example_to_connect.rb +13 -3
  45. metadata +52 -126
  46. data/lib/ftp_paradise/base/cliner.rb +0 -23
  47. data/lib/ftp_paradise/base/colours.rb +0 -83
  48. data/lib/ftp_paradise/base/prototype.rb +0 -171
  49. data/lib/ftp_paradise/base/reset.rb +0 -29
  50. data/lib/ftp_paradise/connection/data.rb +0 -164
  51. data/lib/ftp_paradise/connection/debug.rb +0 -78
  52. data/lib/ftp_paradise/connection/directory_handling.rb +0 -271
  53. data/lib/ftp_paradise/connection/do_login.rb +0 -108
  54. data/lib/ftp_paradise/connection/download.rb +0 -86
  55. data/lib/ftp_paradise/connection/file_handling.rb +0 -174
  56. data/lib/ftp_paradise/connection/ftp_object.rb +0 -21
  57. data/lib/ftp_paradise/connection/initialize.rb +0 -88
  58. data/lib/ftp_paradise/connection/initialize_a_new_net_ftp_object_with_this_url.rb +0 -20
  59. data/lib/ftp_paradise/connection/is_connected.rb +0 -46
  60. data/lib/ftp_paradise/connection/misc.rb +0 -474
  61. data/lib/ftp_paradise/connection/notify.rb +0 -71
  62. data/lib/ftp_paradise/connection/password.rb +0 -47
  63. data/lib/ftp_paradise/connection/port.rb +0 -33
  64. data/lib/ftp_paradise/connection/remote_pwd.rb +0 -72
  65. data/lib/ftp_paradise/connection/remote_url.rb +0 -164
  66. data/lib/ftp_paradise/connection/remove.rb +0 -143
  67. data/lib/ftp_paradise/connection/reset.rb +0 -78
  68. data/lib/ftp_paradise/connection/run.rb +0 -18
  69. data/lib/ftp_paradise/connection/set_array_available_hosts.rb +0 -27
  70. data/lib/ftp_paradise/connection/set_input.rb +0 -18
  71. data/lib/ftp_paradise/connection/show.rb +0 -153
  72. data/lib/ftp_paradise/connection/sync_ftp_object_onto_the_main_namespace.rb +0 -24
  73. data/lib/ftp_paradise/connection/transfer_mode.rb +0 -163
  74. data/lib/ftp_paradise/connection/upload.rb +0 -253
  75. data/lib/ftp_paradise/connection/use_default_dataset.rb +0 -40
  76. data/lib/ftp_paradise/connection/username.rb +0 -42
  77. data/lib/ftp_paradise/constants/misc.rb +0 -57
  78. data/lib/ftp_paradise/constants/namespace.rb +0 -14
  79. data/lib/ftp_paradise/constants/newline.rb +0 -14
  80. data/lib/ftp_paradise/constants/roebe.rb +0 -31
  81. data/lib/ftp_paradise/constants/roebe_ftp_constants.rb +0 -233
  82. data/lib/ftp_paradise/gui/gtk2/ftp_paradise.rb +0 -34
  83. data/lib/ftp_paradise/gui/gtk3/ftp_paradise.rb +0 -34
  84. data/lib/ftp_paradise/interactive_ftp/constants.rb +0 -103
  85. data/lib/ftp_paradise/interactive_ftp/directory_handling.rb +0 -216
  86. data/lib/ftp_paradise/interactive_ftp/help.rb +0 -50
  87. data/lib/ftp_paradise/interactive_ftp/initialize.rb +0 -27
  88. data/lib/ftp_paradise/interactive_ftp/interactive_ftp.rb +0 -998
  89. data/lib/ftp_paradise/interactive_ftp/main_loop.rb +0 -51
  90. data/lib/ftp_paradise/interactive_ftp/misc.rb +0 -208
  91. data/lib/ftp_paradise/interactive_ftp/mode.rb +0 -124
  92. data/lib/ftp_paradise/interactive_ftp/readline.rb +0 -113
  93. data/lib/ftp_paradise/interactive_ftp/remove.rb +0 -97
  94. data/lib/ftp_paradise/interactive_ftp/reset.rb +0 -90
  95. data/lib/ftp_paradise/interactive_ftp/run.rb +0 -22
  96. data/lib/ftp_paradise/interactive_ftp/show.rb +0 -184
  97. data/lib/ftp_paradise/interactive_ftp/upload.rb +0 -90
  98. data/lib/ftp_paradise/interactive_ftp/user_input.rb +0 -53
  99. data/lib/ftp_paradise/toplevel_methods/can_connect_to_remote_site.rb +0 -28
  100. data/lib/ftp_paradise/toplevel_methods/clear_user_dataset.rb +0 -28
  101. data/lib/ftp_paradise/toplevel_methods/data.rb +0 -31
  102. data/lib/ftp_paradise/toplevel_methods/determine_user_dataset_from_this_hash.rb +0 -37
@@ -1,51 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'ftp_paradise/interactive_ftp/main_loop.rb'
6
- # =========================================================================== #
7
- module FtpParadise
8
-
9
- class InteractiveFtp # === FtpParadise::InteractiveFtp
10
-
11
- # ========================================================================= #
12
- # === enter_main_loop
13
- # ========================================================================= #
14
- def enter_main_loop
15
- # ======================================================================= #
16
- # Enter the remote directory htdocs if we are on ftpupload.net
17
- # or on a similar host..
18
- # ======================================================================= #
19
- if remote_url?.include?('ftpupload.net')
20
- remote_cd 'htdocs', :be_verbose
21
- elsif remote_url?.include?('shevy.bplaced.net')
22
- remote_cd 'www', :be_verbose
23
- end
24
- check_commandline_arguments # <- This will also query the menu() method.
25
- show_welcome_message
26
- display_prompt
27
- loop {
28
- begin
29
- # =================================================================== #
30
- # Obtain the user input:
31
- # =================================================================== #
32
- obtain_user_input
33
- # =================================================================== #
34
- # Pass the user input into the menu interface:
35
- # =================================================================== #
36
- result = menu
37
- result = result.first if result.is_a? Array
38
- case result
39
- when *ARRAY_VALID_OPTIONS_FOR_EXITING_THE_SHELL, :break
40
- break
41
- when :exit
42
- exit
43
- end
44
- rescue Interrupt
45
- e 'In order to quit, please use "'+
46
- steelblue('q')+'" instead.'
47
- end
48
- }
49
- end; alias enter_loop enter_main_loop # === enter_loop
50
-
51
- end; end
@@ -1,208 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'ftp_paradise/interactive_ftp/misc.rb'
6
- # =========================================================================== #
7
- module FtpParadise
8
-
9
- class InteractiveFtp
10
-
11
- require 'ftp_paradise/interactive_ftp/directory_handling.rb'
12
-
13
- require 'ftp_paradise/toplevel_methods/determine_user_dataset_from_this_hash.rb'
14
-
15
- # ========================================================================= #
16
- # === set_editor
17
- # ========================================================================= #
18
- def set_editor(
19
- i, be_verbose = true
20
- )
21
- i = i.first if i.is_a? Array
22
- if be_verbose
23
- opnn; e "Now using the editor called `#{sfancy(i)}`."
24
- end
25
- @use_this_editor = i
26
- end
27
-
28
- # ========================================================================= #
29
- # === report_which_editor_is_in_use
30
- # ========================================================================= #
31
- def report_which_editor_is_in_use
32
- opnn; e "The editor in use is `#{sfancy(@use_this_editor)}`."
33
- end
34
-
35
- # ========================================================================= #
36
- # === open_this_file_in_editor (edit tag, editor tag, open tag)
37
- #
38
- # If you pass as first argument to this method the string 'ALL', we
39
- # will try to open the (local) project files in your editor.
40
- #
41
- # To test this, do:
42
- #
43
- # open ALL
44
- # open YAML
45
- #
46
- # ========================================================================= #
47
- def open_this_file_in_editor(
48
- this_file = @file
49
- )
50
- this_file = ARRAY_PROJECT_FILES if this_file.nil?
51
- if this_file.is_a? Array
52
- this_file.each {|entry| open_this_file_in_editor(entry) }
53
- else
54
- this_file = this_file.to_s
55
- if this_file == 'TODO'
56
- this_file = ARRAY_PROJECT_FILES.select {|entry| entry.include? 'TODO' }[0]
57
- end
58
- if this_file.to_s =~ /^\d+$/ # If only numbers were given.
59
- this_file = Dir['*'].sort[this_file.to_i - 1]
60
- end
61
- this_file = NAME_OF_THIS_FILE if this_file.empty?
62
- if this_file == 'ALL' and ! File.exist?('ALL')
63
- open_this_file_in_editor(ARRAY_PROJECT_FILES)
64
- elsif this_file == 'YAML' and ! File.exist?('YAML')
65
- open_this_file_in_editor(YAML_FILE)
66
- else
67
- _ = @use_this_editor+" #{this_file}"
68
- if File.exist?(this_file) && File.file?(this_file)
69
- unless has_unwanted_file_suffix?(this_file)
70
- e 'Loading '+sfile(this_file)+' in editor '+
71
- 'now as '+simp('USE_THIS_EDITOR')+' was set '+
72
- 'to true:'
73
- e ' '+_+' &'
74
- `#{_}`
75
- end
76
- set_file(this_file) # Since 24.12.2011 we also assign it.
77
- else
78
- e swarn('But the file `')+sfile(this_file)+
79
- swarn('` does not exist.')
80
- end
81
- end
82
- end
83
- end; alias open_in_editor open_this_file_in_editor # === open_in_editor
84
-
85
- # ========================================================================= #
86
- # === determine_user_dataset_from_this_hash
87
- #
88
- # This method can set relevant entries from an input Hash.
89
- # ========================================================================= #
90
- def determine_user_dataset_from_this_hash(
91
- i,
92
- optional_use_this_entry = :default
93
- )
94
- if optional_use_this_entry
95
- case optional_use_this_entry
96
- # ===================================================================== #
97
- # === :default
98
- # ===================================================================== #
99
- when :default
100
- optional_use_this_entry = :bplaced
101
- end
102
- end
103
- FtpParadise.determine_user_dataset_from_this_hash(i)
104
- end
105
-
106
- # ========================================================================= #
107
- # === set_password
108
- # ========================================================================= #
109
- def set_password(
110
- i, be_verbose = be_verbose?
111
- )
112
- i = i.to_s
113
- if be_verbose
114
- e "Setting password to #{sfancy(i)} now."
115
- end
116
- FtpParadise.set_password(i)
117
- end
118
-
119
- # ========================================================================= #
120
- # === pass_commandline_arguments_into_the_menu
121
- # ========================================================================= #
122
- def pass_commandline_arguments_into_the_menu
123
- menu(@commandline_arguments)
124
- end
125
-
126
- # ========================================================================= #
127
- # === set_port
128
- #
129
- # Use this method to set the port.
130
- # ========================================================================= #
131
- def set_port(
132
- i = 21, be_verbose = false
133
- )
134
- if be_verbose
135
- e "Setting port to #{sfancy(i)} now."
136
- end
137
- ftp?.set_port(i)
138
- end
139
-
140
- # ========================================================================= #
141
- # === remote_url?
142
- # ========================================================================= #
143
- def remote_url?
144
- FtpParadise.remote_url?
145
- end; alias remote_host? remote_url? # === remote_host?
146
-
147
- # ========================================================================= #
148
- # === remote_remove_file
149
- # ========================================================================= #
150
- def remote_remove_file(
151
- i = @first_argument
152
- )
153
- if i.is_a? Array
154
- i.each {|entry| remote_remove_file(entry) }
155
- else
156
- e "Trying to remove `#{sfile(i)}` next:"
157
- @ftp.delete(i)
158
- end
159
- end; alias remote_remove_files remote_remove_file # === remote_remove_files
160
-
161
- # ========================================================================= #
162
- # === display_file
163
- #
164
- # Use this method to display a file in question.
165
- # ========================================================================= #
166
- def display_file(i)
167
- if File.exist? i
168
- _ = File.readlines(i).join
169
- e _
170
- else
171
- ewarn "File #{sfile(i)} does not exist."
172
- end
173
- end
174
-
175
- # ========================================================================= #
176
- # === report_version
177
- # ========================================================================= #
178
- def report_version
179
- e sfancy(FtpParadise::VERSION)
180
- end
181
-
182
- # ========================================================================= #
183
- # === all_arguments?
184
- #
185
- # The alias a? may be an easier wrapper over @all_arguments.
186
- # ========================================================================= #
187
- def all_arguments?
188
- @all_arguments
189
- end; alias a? all_arguments? # === a?
190
-
191
- # ========================================================================= #
192
- # === try_to_chmod_this_remote_file
193
- # ========================================================================= #
194
- def try_to_chmod_this_remote_file(
195
- filename, chmod_value_to_use = '0777'
196
- )
197
- e "Trying to chmod the remote file #{filename} next."
198
- ftp?.sendcmd("SITE CHMOD #{chmod_value_to_use} #{filename}")
199
- end
200
-
201
- # ========================================================================= #
202
- # === password?
203
- # ========================================================================= #
204
- def password?
205
- FtpParadise.password?
206
- end
207
-
208
- end; end
@@ -1,124 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'ftp_paradise/interactive_ftp/mode.rb'
6
- # =========================================================================== #
7
- module FtpParadise
8
-
9
- class InteractiveFtp # === FtpParadise::InteractiveFtp
10
-
11
- # ========================================================================= #
12
- # === use_binary_mode
13
- #
14
- # This enables use the binary mode.
15
- # ========================================================================= #
16
- def use_binary_mode(
17
- be_verbose = false
18
- )
19
- case be_verbose
20
- when :be_quiet
21
- be_verbose = false
22
- when :be_verbose
23
- be_verbose = true
24
- end
25
- e 'Using binary mode now.' if be_verbose
26
- set_mode :binary
27
- end; alias set_binary use_binary_mode # === set_binary
28
-
29
- # ========================================================================= #
30
- # === set_mode
31
- #
32
- # Set the mode here. We default to :ascii mode.
33
- #
34
- # There are only two valid modes:
35
- #
36
- # :ascii
37
- # :binary
38
- #
39
- # ========================================================================= #
40
- def set_mode(
41
- i = :ascii
42
- )
43
- @mode = i
44
- ftp?.set_transfer_mode(
45
- @mode, :be_quiet # Cascade the variable down into ftp_lib.rb.
46
- )
47
- end
48
-
49
- # ========================================================================= #
50
- # === do_use_binary_mode
51
- # ========================================================================= #
52
- def do_use_binary_mode
53
- use_binary_mode(:be_quiet)
54
- end
55
-
56
- # ========================================================================= #
57
- # === change
58
- #
59
- # This method can be used to change the main transfer mode.
60
- # ========================================================================= #
61
- def change(i)
62
- case i
63
- # ======================================================================= #
64
- # === mode
65
- # ======================================================================= #
66
- when 'mode' # Change the mode that we use.
67
- use_binary_mode
68
- end
69
- end
70
-
71
- # ========================================================================= #
72
- # === set_run_mode
73
- #
74
- # This will set the run-mode. The run-mode can be either :standalone or
75
- # :connected.
76
- # ========================================================================= #
77
- def set_run_mode(
78
- i = :standalone
79
- )
80
- @run_mode = i
81
- end
82
-
83
- # ========================================================================= #
84
- # === toggle_modes
85
- # ========================================================================= #
86
- def toggle_modes
87
- if @mode == :ascii
88
- set_mode :binary
89
- else
90
- set_mode :ascii
91
- end
92
- e mode?.to_s
93
- end
94
-
95
- # ========================================================================= #
96
- # === use_ascii_mode
97
- # ========================================================================= #
98
- def use_ascii_mode(be_verbose = false)
99
- e 'Using ascii mode now.' if be_verbose
100
- set_mode :ascii
101
- end
102
-
103
- # ========================================================================= #
104
- # === mode?
105
- #
106
- # @mode is a Symbol, hence we will not apply .to_s on it.
107
- # ========================================================================= #
108
- def mode?
109
- return @mode
110
- end
111
-
112
- # ========================================================================= #
113
- # === set_passive
114
- # ========================================================================= #
115
- def set_passive(
116
- be_verbose = false
117
- )
118
- if be_verbose
119
- e 'Enabling passive mode for FTP.'
120
- end
121
- ftp?.passive = true
122
- end
123
-
124
- end; end
@@ -1,113 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # The Readline component will belong to class FtpParadise::InteractiveFtp.
6
- #
7
- # It would not make any sense to use it elsewhere within the FtpParadise
8
- # project, as we don't have other interactive elements elsewhere.
9
- # =========================================================================== #
10
- # require 'ftp_paradise/interactive_ftp/readline.rb'
11
- # =========================================================================== #
12
- module FtpParadise
13
-
14
- class InteractiveFtp # === FtpParadise::Interactive
15
-
16
- begin
17
- require 'readline'
18
- rescue LoadError; end # Silent rescue.
19
-
20
- # ========================================================================= #
21
- # === use_readline?
22
- # ========================================================================= #
23
- def use_readline?
24
- @use_readline
25
- end; alias do_we_use_readline? use_readline? # === do_we_use_readline?
26
-
27
- # ========================================================================= #
28
- # === do_not_use_readline
29
- # ========================================================================= #
30
- def do_not_use_readline
31
- @use_readline = false
32
- end
33
-
34
- # ========================================================================= #
35
- # === enable_readline
36
- # ========================================================================= #
37
- def enable_readline
38
- @use_readline = true
39
- try_to_use_readline
40
- end
41
-
42
- # ========================================================================= #
43
- # === try_to_use_readline
44
- #
45
- # This method ought to be called before we invoke the method menu().
46
- # ========================================================================= #
47
- def try_to_use_readline
48
- if @use_readline
49
- begin
50
- require 'readline' # Using readline since August 2011.
51
- setup_readline_completion
52
- rescue LoadError
53
- # =================================================================== #
54
- # In this case the user can not use the readline-module.
55
- # =================================================================== #
56
- do_not_use_readline
57
- end
58
- end
59
- end; alias consider_using_the_readline_module try_to_use_readline # === consider_using_the_readline_module
60
-
61
- # ========================================================================= #
62
- # === setup_readline_completion
63
- #
64
- # Call this method to invoke completion support.
65
- # ========================================================================= #
66
- def setup_readline_completion
67
- Readline.completion_case_fold = true # Ignore case on tab-completion.
68
- Readline.completer_word_break_characters = "\n"
69
- Readline.completion_append_character = ' '
70
- # ======================================================================= #
71
- # Act on Readline's completion functionality here. (readline tag)
72
- #
73
- # We will respond to these events specifically:
74
- #
75
- # - rcd
76
- # - cd
77
- # - upload
78
- # - download
79
- #
80
- # ======================================================================= #
81
- Readline.completion_proc = proc {|input|
82
- _ = []
83
- case input # case tag
84
- # ===================================================================== #
85
- # To test it, do:
86
- # rcd AUS<TAB>
87
- # ===================================================================== #
88
- when /^rcd/,
89
- /^rcd /,
90
- /^rc/,
91
- 'rchange_dir',
92
- 'lcd',
93
- 'remote_change_directory'
94
- result = @_.return_directories # This will return the remote directories only.
95
- _ << result.map {|entry| input+' '+entry}
96
- # ===================================================================== #
97
- # === cd
98
- # ===================================================================== #
99
- when /^cd/,/^cd / # Fetch only directories.
100
- _ << @_.return_local_directories
101
- when /^upload/ # Act on upload.
102
- return_local_files.each { |array| _ << array }
103
- when /^download/ # Act on download.
104
- @_.array_file_listing.each { |array| _ << array.first }
105
- else # Default.
106
- # _ << return_local_files # Disabled in June 2014 because it gives completions to things I did not ask for.
107
- end
108
- _ = _.flatten
109
- _ # Return it here finally.
110
- }
111
- end
112
-
113
- end; end
@@ -1,97 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'ftp_paradise/interactive_ftp/remove.rb'
6
- # =========================================================================== #
7
- module FtpParadise
8
-
9
- class InteractiveFtp
10
-
11
- # ========================================================================= #
12
- # === remove_local
13
- # ========================================================================= #
14
- def remove_local(i)
15
- delete(i)
16
- end
17
-
18
- # ========================================================================= #
19
- # === remove_remote_directory
20
- #
21
- # Use this method to remove a remote directory.
22
- # ========================================================================= #
23
- def remove_remote_directory(i)
24
- e "Removing remote directory `#{sdir(i)}` next."
25
- # ======================================================================= #
26
- # Delegate to ftp?. :force_remove so we remove even non-empty directories.
27
- # ======================================================================= #
28
- ftp?.remove_directory(i, :force_remove)
29
- end
30
-
31
- # ========================================================================= #
32
- # === remote_remove
33
- #
34
- # Use this if you wish to remove a remote file or a remote directory.
35
- # ========================================================================= #
36
- def remote_remove(i)
37
- if i.is_a? Array
38
- i.each {|entry| remote_remove(entry) }
39
- else
40
- i = i.to_s.strip # Added as of July 2014.
41
- i = File.basename(i) if i.include? '/'
42
- # ===================================================================== #
43
- # The user may input numbers. If the input is a number, we will try to
44
- # find the corresponding entry - but only if no remote directory or
45
- # remote file exists with that name. Some directories may be named,
46
- # e. g. "123456".
47
- # ===================================================================== #
48
- unless this_remote_entry_exists? i
49
- i = convert_number_to_file(i) if i =~ /^\d+$/
50
- end
51
- # ===================================================================== #
52
- # Next check for user input. If the user did input a '*', then we
53
- # will expand that.
54
- # ===================================================================== #
55
- if i.include?('*') or i.include?('*.')
56
- i = ftp?.array_file_listing.select {|entry|
57
- entry[0].include? i.delete('*')
58
- }
59
- i.reject! {|line|
60
- line == '.' or line == '..' # Reject '.' and '..' entries.
61
- }
62
- i.map! {|entry|
63
- File.basename(entry)
64
- } # ^^^ This is a bit hackish.
65
- remote_remove(i)
66
- else
67
- # =================================================================== #
68
- # We try to find out whether we have a directory or a file next.
69
- # =================================================================== #
70
- if is_dir?(i)
71
- remove_remote_directory(i)
72
- else # Assume it is a file.
73
- remove_remote_file(i)
74
- end
75
- end
76
- end
77
- end
78
-
79
- # ========================================================================= #
80
- # === remove_remote_file
81
- #
82
- # Use this method to attempt remove a remote file.
83
- # ========================================================================= #
84
- def remove_remote_file(i)
85
- i[0,1] = ''.dup if i.start_with? '/' # We don't like starting "/" characters here.
86
- e "Removing remote file `#{sfile(i)}` next." # We remove the remote file here.
87
- begin
88
- result = ftp?.remove_file(i)
89
- e "Successfully removed remote file `#{sfile(result)}`."
90
- rescue Net::FTPPermError => error
91
- e 'Can not remove file `'+sfile(i)+'` as you are not '\
92
- 'the owner. ('+simp('Net::FTPPermError')+')'
93
- pp error
94
- end
95
- end
96
-
97
- end; end
@@ -1,90 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'ftp_paradise/interactive_ftp/reset.rb'
6
- # =========================================================================== #
7
- module FtpParadise
8
-
9
- class InteractiveFtp # === FtpParadise::InteractiveFtp
10
-
11
- require 'ftp_paradise/interactive_ftp/misc.rb'
12
- require 'ftp_paradise/interactive_ftp/readline.rb'
13
-
14
- # ========================================================================= #
15
- # === reset (reset tag)
16
- #
17
- # Initialize and/or reset the variables used in this class.
18
- # ========================================================================= #
19
- def reset
20
- super()
21
- # ======================================================================= #
22
- # The following check is for my home system.
23
- # ======================================================================= #
24
- if File.exist? FILE_ROEBE_FTP
25
- dataset = YAML.load_file(FILE_ROEBE_FTP)
26
- determine_user_dataset_from_this_hash(dataset, :default)
27
- end
28
- # ======================================================================= #
29
- # === @user_input
30
- #
31
- # Must "initialize" @user_input.
32
- # ======================================================================= #
33
- @user_input = nil
34
- # ======================================================================= #
35
- # Which files we did download so far.
36
- # ======================================================================= #
37
- @array_downloaded_files = []
38
- # ======================================================================= #
39
- # === @array_all_input
40
- # ======================================================================= #
41
- @array_all_input = [] # Stores which was the input.
42
- # ======================================================================= #
43
- # === @history
44
- # ======================================================================= #
45
- @history = []
46
- # ======================================================================= #
47
- # === @array_history_remote_directories
48
- #
49
- # This array keeps a listing of all remote directories we rcd-ed into.
50
- # ======================================================================= #
51
- @array_history_remote_directories = []
52
- # ======================================================================= #
53
- # === @debug
54
- #
55
- # Whether we will debug or not, by default.
56
- # ======================================================================= #
57
- @debug = SHALL_WE_DEBUG
58
- # ======================================================================= #
59
- # === @are_we_connected
60
- # ======================================================================= #
61
- @are_we_connected = false
62
- # ======================================================================= #
63
- # === @pad
64
- # ======================================================================= #
65
- @pad = ' ' # The default padding to use.
66
- # ======================================================================= #
67
- # === @use_readline
68
- #
69
- # Initially we will try to make use of the Readline module.
70
- # ======================================================================= #
71
- @use_readline = true
72
- # ======================================================================= #
73
- # === @use_this_editor
74
- #
75
- # Specify which editor we may use - this can be overruled in the
76
- # interactive menu by the user of the FtpParadise project.
77
- # ======================================================================= #
78
- @use_this_editor = USE_THIS_EDITOR
79
- # ======================================================================= #
80
- # Try to make use of the Readline module as well.
81
- # ======================================================================= #
82
- consider_using_the_readline_module
83
- reset_instance_variables_that_hold_all_arguments
84
- set_file
85
- set_local_directory
86
- load_config
87
- initialize_ftp_object # Initialize the @ftp variable.
88
- end
89
-
90
- end; end