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.

Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +152 -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} +0 -0
  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 +554 -448
  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
@@ -34,6 +34,9 @@ module FtpParadise
34
34
  &block
35
35
  )
36
36
  case remote_host
37
+ # ======================================================================= #
38
+ # === :dont_run_yet
39
+ # ======================================================================= #
37
40
  when :dont_run_yet
38
41
  remote_host = :default
39
42
  run_already = false
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'ftp_paradise/toplevel_methods/dataset.rb'
6
+ # =========================================================================== #
7
+ module FtpParadise
8
+
9
+ require 'ftp_paradise/toplevel_methods/login_name.rb'
10
+ require 'ftp_paradise/toplevel_methods/password.rb'
11
+ require 'ftp_paradise/toplevel_methods/port.rb'
12
+ require 'ftp_paradise/toplevel_methods/remote_url.rb'
13
+
14
+ # ========================================================================= #
15
+ # === FtpParadise.clear_user_dataset
16
+ #
17
+ # This method will reset the user-dataset to nil again, that is,
18
+ # user name, password and remote url.
19
+ #
20
+ # This method had to be added so that we can easily clean-up on
21
+ # a disconnect-action.
22
+ # ========================================================================= #
23
+ def self.clear_user_dataset
24
+ FtpParadise.set_remote_url(nil)
25
+ FtpParadise.set_user_name(nil)
26
+ FtpParadise.set_password(nil)
27
+ end
28
+
29
+ # ========================================================================= #
30
+ # === FtpParadise.data?
31
+ #
32
+ # This method will return the name of the user; the password; and the
33
+ # remote URL. It is mostly just a convenience method.
34
+ # ========================================================================= #
35
+ def self.data?
36
+ {
37
+ user_name: FtpParadise.username?,
38
+ password: FtpParadise.password?,
39
+ remote_url: FtpParadise.remote_url?,
40
+ port: FtpParadise.port?
41
+ }
42
+ end; self.instance_eval { alias dataset? data? } # === FtpParadise.dataset?
43
+ self.instance_eval { alias main_hash? data? } # === FtpParadise.main_hash?
44
+ self.instance_eval { alias info? data? } # === FtpParadise.info?
45
+
46
+ # ========================================================================= #
47
+ # === FtpParadise.determine_user_dataset_from_this_hash
48
+ #
49
+ # This method can set relevant entries from an input Hash.
50
+ #
51
+ # The IDs should be 'url', 'user_name', 'password' and 'port'.
52
+ #
53
+ # Usage example:
54
+ #
55
+ # FtpParadise.determine_user_dataset_from_this_hash(YAML.load_file(FtpParadise.my_yaml_file), :default)
56
+ #
57
+ # ========================================================================= #
58
+ def self.determine_user_dataset_from_this_hash(
59
+ i, optional_use_this_entry = nil
60
+ )
61
+ case optional_use_this_entry
62
+ # ======================================================================= #
63
+ # === :default
64
+ # ======================================================================= #
65
+ when :default
66
+ optional_use_this_entry = 'bplaced'
67
+ end
68
+ if i.is_a? Hash
69
+ if optional_use_this_entry and i.has_key?(optional_use_this_entry)
70
+ i = i[optional_use_this_entry]
71
+ end
72
+ # ===================================================================== #
73
+ # === url
74
+ # ===================================================================== #
75
+ if i.has_key? 'url'
76
+ _ = i.fetch('url')
77
+ FtpParadise.set_remote_url(_)
78
+ end
79
+ # ===================================================================== #
80
+ # === user_name
81
+ # ===================================================================== #
82
+ if i.has_key? 'user_name'
83
+ _ = i.fetch('user_name')
84
+ FtpParadise.set_user_name(_)
85
+ end
86
+ # ===================================================================== #
87
+ # === password
88
+ # ===================================================================== #
89
+ if i.has_key? 'password'
90
+ _ = i.fetch('password')
91
+ FtpParadise.set_password(_)
92
+ end
93
+ # ===================================================================== #
94
+ # === port
95
+ # ===================================================================== #
96
+ if i.has_key? 'port'
97
+ _ = i.fetch('port')
98
+ FtpParadise.set_port(_)
99
+ end
100
+ return main_hash? # We can return it here as well.
101
+ end
102
+ end
103
+
104
+ end
105
+
106
+ if __FILE__ == $PROGRAM_NAME
107
+ require 'yaml'
108
+ dataset = YAML.load_file('/home/x/data/personal/yaml/ftp/roebe_ftp.yml')
109
+ FtpParadise.determine_user_dataset_from_this_hash(dataset, :default)
110
+ pp FtpParadise.dataset?
111
+ end
@@ -13,14 +13,15 @@ module FtpParadise
13
13
  #
14
14
  # Use this method whenever you want to get all (local) files.
15
15
  #
16
- # By default, this method will return all files from the current directory.
16
+ # By default, this method will return all files from the current
17
+ # directory.
17
18
  # ========================================================================= #
18
19
  def self.get_files(
19
20
  from = '*'
20
21
  )
21
22
  entries = Dir[from]
22
23
  entries.select! {|entry| File.file?(entry) }
23
- entries
24
+ return entries
24
25
  end
25
26
 
26
27
  # ========================================================================= #
@@ -37,7 +38,7 @@ module FtpParadise
37
38
  #
38
39
  # Consistently use this method if you wish to delete a (local) file.
39
40
  # ========================================================================= #
40
- def self.delete(i) # ← Added this method as of April 2014.
41
+ def self.delete(i) # ← This method was added in April 2014.
41
42
  i = i.to_s # We don't want nil-errors here.
42
43
  if File.exist? i
43
44
  File.delete(i)
@@ -6,7 +6,9 @@
6
6
  # =========================================================================== #
7
7
  module FtpParadise
8
8
 
9
- require 'net/ftp'
9
+ require 'yaml'
10
+ require 'ftp_paradise/constants/constants.rb'
11
+ require 'ftp_paradise/requires/require_net_ftp.rb'
10
12
  require 'ftp_paradise/toplevel_methods/e.rb'
11
13
  require 'ftp_paradise/toplevel_methods/login_name.rb'
12
14
  require 'ftp_paradise/toplevel_methods/password.rb'
@@ -22,8 +24,6 @@ module FtpParadise
22
24
  # ========================================================================= #
23
25
  @ftp_object = nil
24
26
 
25
- require 'yaml'
26
- require 'ftp_paradise/constants/roebe.rb'
27
27
  # ========================================================================= #
28
28
  # === FtpParadise.initialize_ftp_object
29
29
  #
@@ -36,10 +36,11 @@ module FtpParadise
36
36
  # === :default
37
37
  # ======================================================================= #
38
38
  when :default
39
- use_this_url = YAML.load_file(FILE_ROEBE_FTP)['podserver']['url']
39
+ use_this_url = YAML.load_file(FILE_ROEBE_FTP)['bplaced']['url']
40
40
  end
41
41
  @ftp_object = Net::FTP.new(use_this_url)
42
- end
42
+ return @ftp_object
43
+ end; self.instance_eval { alias initialize_the_ftp_dataset initialize_ftp_object } # === FtpParadise.initialize_the_ftp_dataset
43
44
 
44
45
  # ========================================================================= #
45
46
  # === FtpParadise.do_login (login tag)
@@ -7,7 +7,7 @@
7
7
  module FtpParadise
8
8
 
9
9
  require 'yaml'
10
- require 'ftp_paradise/constants/roebe.rb'
10
+ require 'ftp_paradise/constants/constants.rb'
11
11
 
12
12
  # ========================================================================= #
13
13
  # === @login_name
@@ -25,7 +25,8 @@ module FtpParadise
25
25
  # === FtpParadise.set_login_name
26
26
  # ========================================================================= #
27
27
  def self.set_login_name(
28
- i = :try_to_infer_automatically
28
+ i = :try_to_infer_automatically,
29
+ use_this_entry_point = 'bplaced'
29
30
  )
30
31
  case i
31
32
  # ======================================================================= #
@@ -34,7 +35,7 @@ module FtpParadise
34
35
  when :try_to_infer_automatically,
35
36
  :infer
36
37
  if File.exist? FILE_ROEBE_FTP
37
- i = YAML.load_file(FILE_ROEBE_FTP)['podserver']['user_name']
38
+ i = YAML.load_file(FILE_ROEBE_FTP)[use_this_entry_point]['user_name']
38
39
  end
39
40
  end
40
41
  @login_name = i
@@ -44,6 +45,7 @@ module FtpParadise
44
45
  end
45
46
 
46
47
  if __FILE__ == $PROGRAM_NAME
48
+ alias e puts
47
49
  FtpParadise.set_login_name
48
- puts FtpParadise.login_name?
50
+ e FtpParadise.login_name?
49
51
  end
@@ -13,4 +13,23 @@ module FtpParadise
13
13
  return ("#{Dir.pwd}/").squeeze('/')
14
14
  end
15
15
 
16
+ # ========================================================================= #
17
+ # === FtpParadise.can_connect_to_remote_site?
18
+ #
19
+ # This method can be used to query whether we can connect to a remote
20
+ # website via the FtpParadise project.
21
+ #
22
+ # The method will return a boolean: either true or false.
23
+ # ========================================================================= #
24
+ def self.can_connect_to_remote_site?
25
+ require 'ftp_paradise/connection/connection.rb'
26
+ ftp = FtpParadise::Connection.new(:dont_run_yet) { :use_default_dataset }
27
+ ftp.be_quiet
28
+ return ftp.is_connected?
29
+ end
30
+
31
+ end
32
+
33
+ if __FILE__ == $PROGRAM_NAME
34
+ p FtpParadise.can_connect_to_remote_site?
16
35
  end
@@ -10,7 +10,7 @@ module FtpParadise
10
10
  require 'opn'
11
11
  rescue LoadError; end
12
12
 
13
- require 'ftp_paradise/constants/namespace.rb'
13
+ require 'ftp_paradise/constants/constants.rb'
14
14
 
15
15
  # ========================================================================= #
16
16
  # === FtpParadise.opn
@@ -7,7 +7,7 @@
7
7
  module FtpParadise
8
8
 
9
9
  require 'yaml'
10
- require 'ftp_paradise/constants/roebe.rb'
10
+ require 'ftp_paradise/constants/constants.rb'
11
11
 
12
12
  # ========================================================================= #
13
13
  # === @password
@@ -32,11 +32,13 @@ module FtpParadise
32
32
  i = :try_to_infer_automatically
33
33
  )
34
34
  case i
35
+ # ======================================================================= #
35
36
  # === :try_to_infer_automatically
37
+ # ======================================================================= #
36
38
  when :try_to_infer_automatically,
37
39
  :infer
38
40
  if File.exist? FILE_ROEBE_FTP
39
- i = YAML.load_file(FILE_ROEBE_FTP)['bytehost']['password']
41
+ i = YAML.load_file(FILE_ROEBE_FTP)['bplaced']['password']
40
42
  end
41
43
  end
42
44
  @password = i
@@ -18,9 +18,12 @@ module FtpParadise
18
18
  i = :try_to_infer_automatically
19
19
  )
20
20
  case i
21
+ # ======================================================================= #
22
+ # === :try_to_infer_automatically
23
+ # ======================================================================= #
21
24
  when :try_to_infer_automatically
22
25
  if File.exist? FILE_ROEBE_FTP
23
- i = YAML.load_file(FILE_ROEBE_FTP)['podcast']['port']
26
+ i = YAML.load_file(FILE_ROEBE_FTP)['bplaced']['port']
24
27
  end
25
28
  end
26
29
  @port = i
@@ -6,6 +6,10 @@
6
6
  # =========================================================================== #
7
7
  module FtpParadise
8
8
 
9
+ require 'yaml'
10
+ require 'ftp_paradise/toplevel_methods/is_on_roebe.rb'
11
+ require 'ftp_paradise/constants/constants.rb'
12
+
9
13
  # ========================================================================= #
10
14
  # === @remote_url
11
15
  #
@@ -22,9 +26,6 @@ module FtpParadise
22
26
  @remote_url
23
27
  end
24
28
 
25
- require 'yaml'
26
- require 'ftp_paradise/toplevel_methods/is_on_roebe.rb'
27
- require 'ftp_paradise/constants/roebe.rb'
28
29
  # ========================================================================= #
29
30
  # === FtpParadise.set_remote_url
30
31
  #
@@ -34,10 +35,15 @@ module FtpParadise
34
35
  i = :try_to_infer
35
36
  )
36
37
  case i
37
- when nil, :infer, :try_to_infer
38
+ # ======================================================================= #
39
+ # === :try_to_infer
40
+ # ======================================================================= #
41
+ when :try_to_infer,
42
+ :infer,
43
+ nil
38
44
  if is_on_roebe?
39
45
  if File.exist? FILE_ROEBE_FTP
40
- i = YAML.load_file(FILE_ROEBE_FTP)['bytehost']['url']
46
+ i = YAML.load_file(FILE_ROEBE_FTP)['bplaced']['url']
41
47
  end
42
48
  end
43
49
  end
@@ -53,6 +53,7 @@ module FtpParadise
53
53
  end
54
54
  if yielded
55
55
  if yielded.is_a? Hash
56
+ # === :cd_into_this_directory
56
57
  if yielded.has_key? :cd_into_this_directory
57
58
  use_this_as_ftp_object.remote_cd(yielded[:cd_into_this_directory])
58
59
  end
@@ -9,7 +9,12 @@ module FtpParadise
9
9
  # ========================================================================= #
10
10
  # === VERSION
11
11
  # ========================================================================= #
12
- VERSION = '1.4.5'
12
+ VERSION = '1.5.3'
13
+
14
+ # ========================================================================= #
15
+ # === LAST_UPDATE
16
+ # ========================================================================= #
17
+ LAST_UPDATE = '23.07.2022'
13
18
 
14
19
  end
15
20
 
@@ -4,7 +4,7 @@
4
4
  # =========================================================================== #
5
5
  # http://localhost/DATA/PROGRAMMING_LANGUAGES/RUBY/src/ftp_paradise/lib/ftp_paradise/www/web_interface.cgi
6
6
  # =========================================================================== #
7
- require 'web_object/autoinclude'
7
+ require 'cyberweb/autoinclude'
8
8
  require 'ftp_paradise'
9
9
 
10
10
  english {
File without changes
File without changes
File without changes
File without changes
@@ -11,18 +11,28 @@ require 'net/ftp'
11
11
 
12
12
  e Colours.rev+'Now testing a minimal FTP example.'
13
13
 
14
- _ = '/home/x/DATA/PC/OS/LINUX/FTP/YAML/roebe_ftp.yml'
15
- dataset = YAML.load_file(_)['bytehost']
14
+ _ = '/home/x/data/personal/yaml/ftp/roebe_ftp.yml'
15
+ dataset = YAML.load_file(_)['bplaced'] # ['bytehost']
16
16
  url = dataset.fetch 'url'
17
17
  _port = dataset.fetch 'port'
18
18
  user_name = dataset.fetch 'user_name'
19
19
  password = dataset.fetch 'password'
20
-
20
+ e
21
21
  e 'We will use this url: '+sfancy(url)
22
22
  e 'We will use this user name: '+sfancy(user_name)
23
23
  e 'We will use this password: '+sfancy(password)
24
+ e
24
25
  ftp = Net::FTP.new(url)
25
26
  ftp.login(user_name, password) # First the user's name, then the password
26
27
  pp ftp
28
+ e
29
+ pp ftp.list
30
+ e
31
+ ftp.chdir('www')
27
32
  pp ftp.list
33
+ # =========================================================================== #
34
+ # Next we can test downloading something via FTP:
35
+ # =========================================================================== #
36
+ # ftp.getbinaryfile('basic_chemistry.pdf')
37
+ # ftp.getbinaryfile("PRÜFFUNGSFRAGEN.md")
28
38
  ftp.close