ftp_paradise 1.3.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ftp_paradise might be problematic. Click here for more details.

Files changed (118) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +309 -0
  3. data/bin/create_remote_directory +9 -0
  4. data/bin/ftp_get +17 -0
  5. data/bin/ftp_upload +42 -0
  6. data/bin/ftp_upload_binary +18 -0
  7. data/bin/iftp +7 -0
  8. data/bin/remote_remove +28 -0
  9. data/doc/README.gen +292 -0
  10. data/doc/TODO_FOR_FTP_PARADISE_PROJECT.md +79 -0
  11. data/ftp_paradise.gemspec +114 -0
  12. data/lib/ftp_paradise.rb +5 -0
  13. data/lib/ftp_paradise/base/cliner.rb +21 -0
  14. data/lib/ftp_paradise/base/colours.rb +83 -0
  15. data/lib/ftp_paradise/base/prototype.rb +169 -0
  16. data/lib/ftp_paradise/base/reset.rb +29 -0
  17. data/lib/ftp_paradise/colours/colours.rb +141 -0
  18. data/lib/ftp_paradise/colours/use_colours.rb +74 -0
  19. data/lib/ftp_paradise/configuration/configuration.rb +49 -0
  20. data/lib/ftp_paradise/connection/README.md +1 -0
  21. data/lib/ftp_paradise/connection/connection.rb +35 -0
  22. data/lib/ftp_paradise/connection/constants.rb +46 -0
  23. data/lib/ftp_paradise/connection/data.rb +148 -0
  24. data/lib/ftp_paradise/connection/debug.rb +80 -0
  25. data/lib/ftp_paradise/connection/directory_handling.rb +271 -0
  26. data/lib/ftp_paradise/connection/do_login.rb +108 -0
  27. data/lib/ftp_paradise/connection/download.rb +86 -0
  28. data/lib/ftp_paradise/connection/file_handling.rb +172 -0
  29. data/lib/ftp_paradise/connection/ftp_object.rb +21 -0
  30. data/lib/ftp_paradise/connection/initialize.rb +86 -0
  31. data/lib/ftp_paradise/connection/initialize_a_new_net_ftp_object_with_this_url.rb +20 -0
  32. data/lib/ftp_paradise/connection/is_connected.rb +46 -0
  33. data/lib/ftp_paradise/connection/misc.rb +472 -0
  34. data/lib/ftp_paradise/connection/notify.rb +71 -0
  35. data/lib/ftp_paradise/connection/password.rb +47 -0
  36. data/lib/ftp_paradise/connection/port.rb +33 -0
  37. data/lib/ftp_paradise/connection/remote_pwd.rb +72 -0
  38. data/lib/ftp_paradise/connection/remote_url.rb +163 -0
  39. data/lib/ftp_paradise/connection/remove.rb +143 -0
  40. data/lib/ftp_paradise/connection/reset.rb +75 -0
  41. data/lib/ftp_paradise/connection/run.rb +18 -0
  42. data/lib/ftp_paradise/connection/set_array_available_hosts.rb +27 -0
  43. data/lib/ftp_paradise/connection/set_input.rb +18 -0
  44. data/lib/ftp_paradise/connection/show.rb +153 -0
  45. data/lib/ftp_paradise/connection/sync_ftp_object_onto_the_main_namespace.rb +24 -0
  46. data/lib/ftp_paradise/connection/transfer_mode.rb +162 -0
  47. data/lib/ftp_paradise/connection/upload.rb +253 -0
  48. data/lib/ftp_paradise/connection/use_default_dataset.rb +41 -0
  49. data/lib/ftp_paradise/connection/username.rb +42 -0
  50. data/lib/ftp_paradise/constants/constants.rb +19 -0
  51. data/lib/ftp_paradise/constants/misc.rb +57 -0
  52. data/lib/ftp_paradise/constants/namespace.rb +14 -0
  53. data/lib/ftp_paradise/constants/newline.rb +14 -0
  54. data/lib/ftp_paradise/constants/roebe.rb +27 -0
  55. data/lib/ftp_paradise/constants/roebe_ftp_constants.rb +219 -0
  56. data/lib/ftp_paradise/entry/entry.rb +293 -0
  57. data/lib/ftp_paradise/gui/gtk/constants.rb +58 -0
  58. data/lib/ftp_paradise/gui/gtk/ftp_bindings.rb +1149 -0
  59. data/lib/ftp_paradise/interactive_ftp/constants.rb +103 -0
  60. data/lib/ftp_paradise/interactive_ftp/directory_handling.rb +215 -0
  61. data/lib/ftp_paradise/interactive_ftp/help.rb +50 -0
  62. data/lib/ftp_paradise/interactive_ftp/initialize.rb +27 -0
  63. data/lib/ftp_paradise/interactive_ftp/interactive_ftp.rb +995 -0
  64. data/lib/ftp_paradise/interactive_ftp/main_loop.rb +50 -0
  65. data/lib/ftp_paradise/interactive_ftp/menu.rb +788 -0
  66. data/lib/ftp_paradise/interactive_ftp/misc.rb +208 -0
  67. data/lib/ftp_paradise/interactive_ftp/mode.rb +124 -0
  68. data/lib/ftp_paradise/interactive_ftp/readline.rb +115 -0
  69. data/lib/ftp_paradise/interactive_ftp/remove.rb +97 -0
  70. data/lib/ftp_paradise/interactive_ftp/reset.rb +90 -0
  71. data/lib/ftp_paradise/interactive_ftp/run.rb +22 -0
  72. data/lib/ftp_paradise/interactive_ftp/show.rb +184 -0
  73. data/lib/ftp_paradise/interactive_ftp/upload.rb +90 -0
  74. data/lib/ftp_paradise/interactive_ftp/user_input.rb +53 -0
  75. data/lib/ftp_paradise/project/project.rb +62 -0
  76. data/lib/ftp_paradise/requires/common_basic_requires.rb +13 -0
  77. data/lib/ftp_paradise/requires/common_external_requires.rb +9 -0
  78. data/lib/ftp_paradise/requires/require_the_constants.rb +7 -0
  79. data/lib/ftp_paradise/requires/require_the_ftp_paradise_project.rb +18 -0
  80. data/lib/ftp_paradise/requires/require_the_ftp_paradise_project_with_the_GUI_bindings.rb +10 -0
  81. data/lib/ftp_paradise/requires/require_the_toplevel_methods.rb +24 -0
  82. data/lib/ftp_paradise/toplevel_methods/can_connect_to_remote_site.rb +29 -0
  83. data/lib/ftp_paradise/toplevel_methods/clear_user_dataset.rb +28 -0
  84. data/lib/ftp_paradise/toplevel_methods/connect.rb +49 -0
  85. data/lib/ftp_paradise/toplevel_methods/create_file.rb +18 -0
  86. data/lib/ftp_paradise/toplevel_methods/data.rb +31 -0
  87. data/lib/ftp_paradise/toplevel_methods/delete.rb +23 -0
  88. data/lib/ftp_paradise/toplevel_methods/determine_user_dataset_from_this_hash.rb +37 -0
  89. data/lib/ftp_paradise/toplevel_methods/e.rb +16 -0
  90. data/lib/ftp_paradise/toplevel_methods/ftp_object.rb +270 -0
  91. data/lib/ftp_paradise/toplevel_methods/get_files.rb +24 -0
  92. data/lib/ftp_paradise/toplevel_methods/is_directory.rb +33 -0
  93. data/lib/ftp_paradise/toplevel_methods/is_on_roebe.rb +20 -0
  94. data/lib/ftp_paradise/toplevel_methods/login_name.rb +49 -0
  95. data/lib/ftp_paradise/toplevel_methods/opn.rb +24 -0
  96. data/lib/ftp_paradise/toplevel_methods/password.rb +48 -0
  97. data/lib/ftp_paradise/toplevel_methods/port.rb +41 -0
  98. data/lib/ftp_paradise/toplevel_methods/rds.rb +18 -0
  99. data/lib/ftp_paradise/toplevel_methods/remote_url.rb +57 -0
  100. data/lib/ftp_paradise/toplevel_methods/time.rb +45 -0
  101. data/lib/ftp_paradise/toplevel_methods/upload.rb +29 -0
  102. data/lib/ftp_paradise/toplevel_methods/upload_this_binary_file.rb +58 -0
  103. data/lib/ftp_paradise/version/version.rb +19 -0
  104. data/lib/ftp_paradise/www/public/css/style.css +3 -0
  105. data/lib/ftp_paradise/www/sinatra_web_interface.rb +242 -0
  106. data/lib/ftp_paradise/www/views/index.slim +3 -0
  107. data/lib/ftp_paradise/www/views/layout.slim +11 -0
  108. data/lib/ftp_paradise/www/web_interface.cgi +35 -0
  109. data/lib/ftp_paradise/yaml/automatically_connect_on_startup_of_the_interactive_ftp_shell.yml +1 -0
  110. data/lib/ftp_paradise/yaml/debug.yml +1 -0
  111. data/lib/ftp_paradise/yaml/open_in_default_editor.yml +1 -0
  112. data/lib/ftp_paradise/yaml/show_full_names.yml +1 -0
  113. data/lib/ftp_paradise/yaml/use_colours.yml +1 -0
  114. data/test/testing_ftp_paradise.rb +94 -0
  115. data/test/testing_minimal_pure_net_ftp_example_to_connect.rb +28 -0
  116. data/test/testing_the_ftp_connection_component.rb +70 -0
  117. data/test/testing_upload_a_local_directory.rb +10 -0
  118. metadata +315 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 500f307720442be0d408bc34e4035ecd316a8e650c1662b82d7ac1ffaec3ad88
4
+ data.tar.gz: faf604c3f0d8d80a580203078cca63c39d9bc87c8eead888e425889643e25215
5
+ SHA512:
6
+ metadata.gz: 54588cac933f4322db0f1df4a6c0a336359266fec96edb35365c0d91cd6716f219bfb90addc6a96218a988ed80d1b48b48893308372866bfe86a75a9827c621c
7
+ data.tar.gz: 8050acc810f17e39d34eb26481be6c2991506b00b0b6b7c150e1ed1d8bbbd0349d54e85c1f3c6245449f82ab7aba923da7971cb2902aebc5607ddaa02c421f80
@@ -0,0 +1,309 @@
1
+ [![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](https://www.gobolinux.org/)
2
+ [![forthebadge](http://forthebadge.com/images/badges/made-with-ruby.svg)](https://www.ruby-lang.org/en/)
3
+ [![Gem Version](https://badge.fury.io/rb/ftp_paradise.svg)](https://badge.fury.io/rb/ftp_paradise)
4
+
5
+ ## FtpParadise - Introduction
6
+
7
+ This README file contains FTP-related information about the ruby
8
+ scripts that are part of the **FtpParadise project**.
9
+
10
+ Currently the most important part of the FTP Paradise project is
11
+ the Library around the Ruby-FTP base library, and an interactive
12
+ component that can check on the given user-input.
13
+
14
+ A simple **GUI** also exists to support the extended FTP
15
+ functionality, but this GUI is extremely limited - I recommend
16
+ to use the commandline variant instead. (The commandline variant
17
+ is also significantly faster, in my experience.)
18
+
19
+ Since as of **March 2014** a web-interface of some sorts is
20
+ available too, currently being offered as a sinatra-app and
21
+ a .cgi file. This is also limited, so again: prefer to use
22
+ the commandline variant whenever possible.
23
+
24
+ The interactive component can be used to connect to remote websites
25
+ by making use of the script called **iftp** at **bin/iftp**. This
26
+ file is distributed with the project.
27
+
28
+ The name **iftp** indicates towards "interactive_ftp", which
29
+ describes its functionality best - it allows you to interactively
30
+ enter commands, which will then be evaluated in the context of
31
+ FTP. (Evidently you have to first connect to the remote
32
+ website via your FTP login credentials, so make sure to do
33
+ that first before inputting commands.)
34
+
35
+ ## Requiring the FtpParadise library:
36
+
37
+ Simply do the following in order to require this project:
38
+
39
+ require 'ftp_paradise'
40
+
41
+ Please do note that rather than the various .set_ methods, you
42
+ could also use traditional = methods instead.
43
+
44
+ So, for instance:
45
+
46
+ set_port()
47
+
48
+ is the very same as using a direct setter method such as:
49
+
50
+ port=
51
+
52
+ This is mostly for convenience. Use in your code whatever you
53
+ prefer. Most may prefer foo=, I like to read a leading set_
54
+ though, visually.
55
+
56
+ ## The interactive component of the FTP Paradise:
57
+
58
+ The **interactive** component will properly tell the user whether
59
+ he/she is connected to a remote host or whether the user is not
60
+ connected, since as of the version **1.0.35**.
61
+
62
+ If you need to determine manually whether you are connected, do
63
+ input this command in the interactive shell:
64
+
65
+ connected?
66
+
67
+ ## Autoconnecting (Added as of December 2017)
68
+
69
+ This presently works only on my home system, by checking whether
70
+ the environment variable IS_ROEBE was set. If it was set, and
71
+ if **an upload event** occurs before we have connected
72
+ somewhere, then we will first connect.
73
+
74
+ This functionality could be changed to include any way to
75
+ auto-connect, but for now, this has to suffice.
76
+
77
+ In September 2018, an additional option has been added. The
78
+ file **automatically_connect_on-statup_of_the_interactive_ftp_shell.yml**
79
+ has been created. If its content is set to true, and if we
80
+ are on **roebe**, and we start the interactive ftp-shell, then
81
+ we will automatically connect to the remote shevy-FTP site.
82
+
83
+ This obviously is only useful on my home system, but it could
84
+ in theory be expanded to include other FTP sites as well.
85
+
86
+ ## Readline support
87
+
88
+ The interactive component of the FtpParadise project will try
89
+ to make use of the readline module, if it is available. Not
90
+ every ruby version installed may have support for Readline,
91
+ though, so this must be **optional**.
92
+
93
+ If you do not want to use readline or do not need it, you can
94
+ pass the flag --no-readline to disable this for the current
95
+ invocation.
96
+
97
+ iftp --no-readline
98
+
99
+ (Where **iftp** stands short for interactive ftp.)
100
+
101
+ ## Using FTP Paradise it in a project:
102
+
103
+ First, you must require this gem, as stated above:
104
+
105
+ require 'ftp_paradise'
106
+
107
+ Then you can use Ruby code such as this one here:
108
+
109
+ _ = FtpParadise::Connection.new("science_news")
110
+ _.set_user 'the_name_of_your_user_here' # <-- this is optional
111
+ _.set_port '21' # <-- this is also optional
112
+ _.connect_to 'insert_the_ftp_host_here'
113
+ _.run # Start transation (as in, try to login).
114
+
115
+ Note that most of the above is completely optional and thus can be
116
+ omitted.
117
+
118
+ It simply allows you to fine tune when you need to set these entries.
119
+
120
+ Convenience methods exist of course, for instance:
121
+
122
+ FtpParadise.connect to: 'url here'
123
+
124
+ A much simpler alternative to the above is to provide a Hash with all
125
+ that required information instead.
126
+
127
+ If you don't want to connect the very moment a new Library class is
128
+ instantiated, then you can do the following:
129
+
130
+ _ = FtpParadise::Connection.new :dont_run
131
+
132
+ You can also directly upload a file, by using a class_method such
133
+ as this one here:
134
+
135
+ FtpParadise.upload(this, to)
136
+
137
+ Class methods (or rather, module methods in this case), will
138
+ be stored in the file module.rb.
139
+
140
+ A pure commandline-program also exists, called:
141
+
142
+ ftp_upload
143
+
144
+ Check it's --help option for its available options.
145
+
146
+ ## Uploading content to a remote FTP server
147
+
148
+ Remember that you can do all of this via the **official ruby FTP
149
+ bindings** already - I only wanted to be able to do so interactively
150
+ as well.
151
+
152
+ Uploading from the interactive FTP paradise executable can be done
153
+ by giving numbers. The FTP paradise project will assume that any
154
+ numbers given, will refer to the index position of the current
155
+ working directory.
156
+
157
+ That is, index 7 would mean file position at 7 in the current
158
+ directory:
159
+
160
+ upload 7,8
161
+
162
+ The above instructions would try to **upload file number 7**
163
+ and **8** to the remote host. Of course you could use the file
164
+ name instead directly - the numbers are just there for
165
+ convenience. Less to type when in an interactive mode.
166
+
167
+ Also note that this refers only to files. Directories will be
168
+ ignored for this purpose. This behaviour may change in the
169
+ future, but then again it may not. (The default is mostly
170
+ what is the most convenient and most used behaviour; for me
171
+ it is a LOT more common to just quickly upload files to a
172
+ remote ftp server, so the number support above prefers
173
+ files too.)
174
+
175
+ To **upload files** do:
176
+
177
+ upload foo.txt
178
+
179
+ You can **upload** several files by using , as a delimiter:
180
+
181
+ upload 6,7
182
+
183
+ This would upload file 6 and file 7.
184
+
185
+ If you wish to batch-upload some .pdf files, you can try this:
186
+
187
+ upload *pdf
188
+
189
+ To simply batch-upload the content of the current working
190
+ directory, this should suffice:
191
+
192
+ upload *
193
+
194
+
195
+ ## General use cases for the interactive FTP component - using the interactive component
196
+
197
+ The interactive FTP component allows you to do several **ftp-related
198
+ commands** via an interactive interface. I needed this functionality
199
+ so that I can connect to remote FTP servers and quickly do things
200
+ such as creating a directory, removing it, renaming files, uploading
201
+ and downloading content.
202
+
203
+ Once you are all set and finished working with the Interactive
204
+ Ftp component of the ftp_paradise project, you can type **q** or
205
+ **quit** to exit from it again - or simply hit Ctrl-D, which achieves
206
+ the same, more or less.
207
+
208
+ To start the interactive ftp component, you can issue a command
209
+ such as:
210
+
211
+ _ = FtpParadise::InteractiveFtp.new
212
+
213
+ This should start the interactive component of the **FtpParadise project**.
214
+
215
+ If you want a **simplified API** call, you can also use:
216
+
217
+ _ = FtpParadise.interactive
218
+
219
+ instead. This variant has the benefit of being more succinct.
220
+
221
+ Once inside the main loop there, the one that will continually
222
+ fetch user input, you can issue "help" to get help.
223
+
224
+ The same syntax that is used via <b>upload</b>ing content, can
225
+ also be used by **downloading**, such as via:
226
+
227
+ download 8
228
+ download 8,9
229
+ download 1,2,3
230
+
231
+ In short, we can use positional numbers to handle files and
232
+ directories. The number 3 means "whatever is at the third
233
+ position", be it a file or a directory.
234
+
235
+ You can also specifically download a binary file by issuing:
236
+
237
+ download_remote_file test.bin
238
+
239
+ You can show the full path to a file, both remote or local,
240
+ if you wish to.
241
+
242
+ For this do either of:
243
+
244
+ toggle show
245
+ show_names
246
+
247
+ If you wish to remove all remote entries from a remote directory,
248
+ do issue this command:
249
+
250
+ remote_remove *
251
+
252
+ You can also upload from the commandline, by using the script
253
+ **ftp_upload**:
254
+
255
+ ftp_upload file_that_should_exist_comes_here.txt
256
+ ftp_upload *
257
+
258
+ The latter command would simply upload all the found files in
259
+ the current directory.
260
+
261
+ You can also do the above in **binary mode**:
262
+
263
+ ftp_upload file --binary
264
+
265
+ ## Editor
266
+
267
+ You can query which editor is in use, in the interactive FTP
268
+ component of the **FtpParadise project**, by issuing this
269
+ command:
270
+
271
+ editor?
272
+
273
+ You can also assign another editor in use, via:
274
+
275
+ set_editor vim # Use "vim" as the editor.
276
+
277
+ This value is used when you wish to quickly **modify a file**
278
+ from within the **interactive_ftp component**. The latter
279
+ is triggered via:
280
+
281
+ edit NAME_OF_THE_FILE_HERE
282
+ edit foobar.md # <- an example
283
+
284
+ ## Remote Hosts
285
+
286
+ If you need to determine the remote host, you can use this
287
+ toplevel method:
288
+
289
+ FtpParadise.remote_host?
290
+
291
+ This will return nil if no connection has been made as of
292
+ yet.
293
+
294
+
295
+ ## Contact information
296
+
297
+ If your creative mind has ideas and specific suggestions to make this
298
+ gem more useful in general, feel free to drop me an email at any
299
+ time, via:
300
+
301
+ shevegen@gmail.com
302
+
303
+ (Do keep in mind that responding to emails may take some time, depending
304
+ on the amount of work I may have at that moment, due to reallife. I will,
305
+ however had, read feedback. Patches and code changes are welcome too
306
+ of course, as long as they are in the spirit of the project at
307
+ hand, e. g. fitting to the general theme.)
308
+
309
+ Thank you.
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'ftp_paradise/toplevel_methods/ftp_object.rb'
6
+
7
+ ARGV.each {|entry|
8
+ FtpParadise.remote_create_directory(entry)
9
+ }
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'ftp_paradise'
6
+
7
+ _ = FtpParadise::Connection.new(:dont_run_yet) { :use_default_dataset }
8
+ _.be_verbose
9
+ _.do_login
10
+ _.do_use_colours
11
+ _.remote_cd 'www'
12
+
13
+ ARGV.each {|obtain_this_file|
14
+ _.download(
15
+ obtain_this_file
16
+ )
17
+ }
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # Usage example for a binary upload:
6
+ #
7
+ # ftp_upload file --binary
8
+ #
9
+ # =========================================================================== #
10
+ require 'ftp_paradise'
11
+
12
+ if ARGV.empty?
13
+ puts 'Please supply at least one argument.'
14
+ exit
15
+ end
16
+
17
+ _ = FtpParadise::Connection.new(:dont_run_yet)
18
+ _.be_verbose
19
+
20
+ # =========================================================================== #
21
+ # Next, check commandline arguments given:
22
+ # =========================================================================== #
23
+ ARGV.each {|entry|
24
+ case entry.to_s.delete('-')
25
+ when '--start-gui',
26
+ '--gui',
27
+ 'gui',
28
+ 'startgui' # fupload --gui
29
+ FtpParadise.do_start_gui
30
+ exit
31
+ when /-?-?help/
32
+ e ' --binary # use binary method'
33
+ exit
34
+ when 'binary','BINARY','BIN','bin','--binary'
35
+ _.set_mode :binary, :be_verbose
36
+ end
37
+ }
38
+ _.set_data('SHEVY')
39
+ _.do_login('SHEVY')
40
+ ARGV.each {|file|
41
+ _.upload(file, :be_silent) if File.exist? file
42
+ }
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This code can be used to upload a binary file.
6
+ # =========================================================================== #
7
+ require 'ftp_paradise/toplevel_methods/upload_this_binary_file.rb'
8
+
9
+ if ARGV.empty?
10
+ puts 'Please supply at least one argument to this file.'
11
+ exit
12
+ end
13
+
14
+ ARGV.each {|file|
15
+ if File.exist? file
16
+ FtpParadise.upload_this_binary_file(file, :be_silent)
17
+ end
18
+ }
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'ftp_paradise'
6
+
7
+ FtpParadise.interactive(ARGV)
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This code can be used to remove a remote file from a FTP site.
6
+ # =========================================================================== #
7
+ require 'ftp_paradise'
8
+
9
+ if ARGV.empty?
10
+ puts 'Please supply at the least one argument.'
11
+ exit
12
+ end
13
+
14
+ _ = ::FtpParadise::Connection.new(:dont_run_yet)
15
+ # =========================================================================== #
16
+ # This is presently hardcoded to my system.
17
+ # =========================================================================== #
18
+ _.set_data('SHEVY')
19
+ _.do_login('SHEVY')
20
+
21
+ ARGV.each {|file|
22
+ if file.include? '/' # Handle / given, meaning that we first cd into the base dir there.
23
+ dirname = File.dirname(file)
24
+ _.cd_into_this_remote_directory(dirname)
25
+ file = File.basename(file)
26
+ end
27
+ _.delete(file, :be_verbose) # Be verbose rather than silent.
28
+ }
@@ -0,0 +1,292 @@
1
+ DEFAULT_RUBY_HEADER
2
+
3
+ ## FtpParadise - Introduction
4
+
5
+ This README file contains FTP-related information about the ruby
6
+ scripts that are part of the **FtpParadise project**.
7
+
8
+ Currently the most important part of the FTP Paradise project is
9
+ the Library around the Ruby-FTP base library, and an interactive
10
+ component that can check on the given user-input.
11
+
12
+ A simple **GUI** also exists to support the extended FTP
13
+ functionality, but this GUI is extremely limited - I recommend
14
+ to use the commandline variant instead. (The commandline variant
15
+ is also significantly faster, in my experience.)
16
+
17
+ Since as of **March 2014** a web-interface of some sorts is
18
+ available too, currently being offered as a sinatra-app and
19
+ a .cgi file. This is also limited, so again: prefer to use
20
+ the commandline variant whenever possible.
21
+
22
+ The interactive component can be used to connect to remote websites
23
+ by making use of the script called **iftp** at **bin/iftp**. This
24
+ file is distributed with the project.
25
+
26
+ The name **iftp** indicates towards "interactive_ftp", which
27
+ describes its functionality best - it allows you to interactively
28
+ enter commands, which will then be evaluated in the context of
29
+ FTP. (Evidently you have to first connect to the remote
30
+ website via your FTP login credentials, so make sure to do
31
+ that first before inputting commands.)
32
+
33
+ ## Requiring the FtpParadise library:
34
+
35
+ Simply do the following in order to require this project:
36
+
37
+ require 'ftp_paradise'
38
+
39
+ Please do note that rather than the various .set_ methods, you
40
+ could also use traditional = methods instead.
41
+
42
+ So, for instance:
43
+
44
+ set_port()
45
+
46
+ is the very same as using a direct setter method such as:
47
+
48
+ port=
49
+
50
+ This is mostly for convenience. Use in your code whatever you
51
+ prefer. Most may prefer foo=, I like to read a leading set_
52
+ though, visually.
53
+
54
+ ## The interactive component of the FTP Paradise:
55
+
56
+ The **interactive** component will properly tell the user whether
57
+ he/she is connected to a remote host or whether the user is not
58
+ connected, since as of the version **1.0.35**.
59
+
60
+ If you need to determine manually whether you are connected, do
61
+ input this command in the interactive shell:
62
+
63
+ connected?
64
+
65
+ ## Autoconnecting (Added as of December 2017)
66
+
67
+ This presently works only on my home system, by checking whether
68
+ the environment variable IS_ROEBE was set. If it was set, and
69
+ if **an upload event** occurs before we have connected
70
+ somewhere, then we will first connect.
71
+
72
+ This functionality could be changed to include any way to
73
+ auto-connect, but for now, this has to suffice.
74
+
75
+ In September 2018, an additional option has been added. The
76
+ file **automatically_connect_on-statup_of_the_interactive_ftp_shell.yml**
77
+ has been created. If its content is set to true, and if we
78
+ are on **roebe**, and we start the interactive ftp-shell, then
79
+ we will automatically connect to the remote shevy-FTP site.
80
+
81
+ This obviously is only useful on my home system, but it could
82
+ in theory be expanded to include other FTP sites as well.
83
+
84
+ ## Readline support
85
+
86
+ The interactive component of the FtpParadise project will try
87
+ to make use of the readline module, if it is available. Not
88
+ every ruby version installed may have support for Readline,
89
+ though, so this must be **optional**.
90
+
91
+ If you do not want to use readline or do not need it, you can
92
+ pass the flag --no-readline to disable this for the current
93
+ invocation.
94
+
95
+ iftp --no-readline
96
+
97
+ (Where **iftp** stands short for interactive ftp.)
98
+
99
+ ## Using FTP Paradise it in a project:
100
+
101
+ First, you must require this gem, as stated above:
102
+
103
+ require 'ftp_paradise'
104
+
105
+ Then you can use Ruby code such as this one here:
106
+
107
+ _ = FtpParadise::Connection.new("science_news")
108
+ _.set_user 'the_name_of_your_user_here' # <-- this is optional
109
+ _.set_port '21' # <-- this is also optional
110
+ _.connect_to 'insert_the_ftp_host_here'
111
+ _.run # Start transation (as in, try to login).
112
+
113
+ Note that most of the above is completely optional and thus can be
114
+ omitted.
115
+
116
+ It simply allows you to fine tune when you need to set these entries.
117
+
118
+ Convenience methods exist of course, for instance:
119
+
120
+ FtpParadise.connect to: 'url here'
121
+
122
+ A much simpler alternative to the above is to provide a Hash with all
123
+ that required information instead.
124
+
125
+ If you don't want to connect the very moment a new Library class is
126
+ instantiated, then you can do the following:
127
+
128
+ _ = FtpParadise::Connection.new :dont_run
129
+
130
+ You can also directly upload a file, by using a class_method such
131
+ as this one here:
132
+
133
+ FtpParadise.upload(this, to)
134
+
135
+ Class methods (or rather, module methods in this case), will
136
+ be stored in the file module.rb.
137
+
138
+ A pure commandline-program also exists, called:
139
+
140
+ ftp_upload
141
+
142
+ Check it's --help option for its available options.
143
+
144
+ ## Uploading content to a remote FTP server
145
+
146
+ Remember that you can do all of this via the **official ruby FTP
147
+ bindings** already - I only wanted to be able to do so interactively
148
+ as well.
149
+
150
+ Uploading from the interactive FTP paradise executable can be done
151
+ by giving numbers. The FTP paradise project will assume that any
152
+ numbers given, will refer to the index position of the current
153
+ working directory.
154
+
155
+ That is, index 7 would mean file position at 7 in the current
156
+ directory:
157
+
158
+ upload 7,8
159
+
160
+ The above instructions would try to **upload file number 7**
161
+ and **8** to the remote host. Of course you could use the file
162
+ name instead directly - the numbers are just there for
163
+ convenience. Less to type when in an interactive mode.
164
+
165
+ Also note that this refers only to files. Directories will be
166
+ ignored for this purpose. This behaviour may change in the
167
+ future, but then again it may not. (The default is mostly
168
+ what is the most convenient and most used behaviour; for me
169
+ it is a LOT more common to just quickly upload files to a
170
+ remote ftp server, so the number support above prefers
171
+ files too.)
172
+
173
+ To **upload files** do:
174
+
175
+ upload foo.txt
176
+
177
+ You can **upload** several files by using , as a delimiter:
178
+
179
+ upload 6,7
180
+
181
+ This would upload file 6 and file 7.
182
+
183
+ If you wish to batch-upload some .pdf files, you can try this:
184
+
185
+ upload *pdf
186
+
187
+ To simply batch-upload the content of the current working
188
+ directory, this should suffice:
189
+
190
+ upload *
191
+
192
+
193
+ ## General use cases for the interactive FTP component - using the interactive component
194
+
195
+ The interactive FTP component allows you to do several **ftp-related
196
+ commands** via an interactive interface. I needed this functionality
197
+ so that I can connect to remote FTP servers and quickly do things
198
+ such as creating a directory, removing it, renaming files, uploading
199
+ and downloading content.
200
+
201
+ Once you are all set and finished working with the Interactive
202
+ Ftp component of the ftp_paradise project, you can type **q** or
203
+ **quit** to exit from it again - or simply hit Ctrl-D, which achieves
204
+ the same, more or less.
205
+
206
+ To start the interactive ftp component, you can issue a command
207
+ such as:
208
+
209
+ _ = FtpParadise::InteractiveFtp.new
210
+
211
+ This should start the interactive component of the **FtpParadise project**.
212
+
213
+ If you want a **simplified API** call, you can also use:
214
+
215
+ _ = FtpParadise.interactive
216
+
217
+ instead. This variant has the benefit of being more succinct.
218
+
219
+ Once inside the main loop there, the one that will continually
220
+ fetch user input, you can issue "help" to get help.
221
+
222
+ The same syntax that is used via <b>upload</b>ing content, can
223
+ also be used by **downloading**, such as via:
224
+
225
+ download 8
226
+ download 8,9
227
+ download 1,2,3
228
+
229
+ In short, we can use positional numbers to handle files and
230
+ directories. The number 3 means "whatever is at the third
231
+ position", be it a file or a directory.
232
+
233
+ You can also specifically download a binary file by issuing:
234
+
235
+ download_remote_file test.bin
236
+
237
+ You can show the full path to a file, both remote or local,
238
+ if you wish to.
239
+
240
+ For this do either of:
241
+
242
+ toggle show
243
+ show_names
244
+
245
+ If you wish to remove all remote entries from a remote directory,
246
+ do issue this command:
247
+
248
+ remote_remove *
249
+
250
+ You can also upload from the commandline, by using the script
251
+ **ftp_upload**:
252
+
253
+ ftp_upload file_that_should_exist_comes_here.txt
254
+ ftp_upload *
255
+
256
+ The latter command would simply upload all the found files in
257
+ the current directory.
258
+
259
+ You can also do the above in **binary mode**:
260
+
261
+ ftp_upload file --binary
262
+
263
+ ## Editor
264
+
265
+ You can query which editor is in use, in the interactive FTP
266
+ component of the **FtpParadise project**, by issuing this
267
+ command:
268
+
269
+ editor?
270
+
271
+ You can also assign another editor in use, via:
272
+
273
+ set_editor vim # Use "vim" as the editor.
274
+
275
+ This value is used when you wish to quickly **modify a file**
276
+ from within the **interactive_ftp component**. The latter
277
+ is triggered via:
278
+
279
+ edit NAME_OF_THE_FILE_HERE
280
+ edit foobar.md # <- an example
281
+
282
+ ## Remote Hosts
283
+
284
+ If you need to determine the remote host, you can use this
285
+ toplevel method:
286
+
287
+ FtpParadise.remote_host?
288
+
289
+ This will return nil if no connection has been made as of
290
+ yet.
291
+
292
+ ADD_CONTACT_DETAILS