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,90 @@
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
+ require 'ftp_paradise/interactive_ftp/misc.rb'
8
+ require 'ftp_paradise/interactive_ftp/readline.rb'
9
+
10
+ module FtpParadise
11
+
12
+ class InteractiveFtp < FtpParadise::Base # === FtpParadise::InteractiveFtp
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
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'ftp_paradise/interactive_ftp/run.rb'
6
+ # =========================================================================== #
7
+ module FtpParadise
8
+
9
+ class InteractiveFtp < FtpParadise::Base # === FtpParadise::InteractiveFtp
10
+
11
+ # ========================================================================= #
12
+ # === run
13
+ # ========================================================================= #
14
+ def run
15
+ set_passive :be_verbose
16
+ pass_commandline_arguments_into_the_menu # <- Must come before startup_actions().
17
+ startup_actions
18
+ do_login # Next, login.
19
+ enter_main_loop
20
+ end
21
+
22
+ end; end
@@ -0,0 +1,184 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'ftp_paradise/interactive_ftp/show.rb'
6
+ # =========================================================================== #
7
+ module FtpParadise
8
+
9
+ class InteractiveFtp < Base
10
+
11
+ # ========================================================================= #
12
+ # === show_remote_directories
13
+ # ========================================================================= #
14
+ def show_remote_directories
15
+ e "The remote directories at #{sdir(return_remote_pwd)} are:"
16
+ e
17
+ ftp?.return_remote_directories.each_with_index {|dir, index|
18
+ index += 1
19
+ e index.to_s.rjust(3)+') '+sdir(dir)
20
+ }
21
+ e
22
+ end
23
+
24
+ # ========================================================================= #
25
+ # === show_remote_files
26
+ #
27
+ # Use this method to show all remote files on a FTP site.
28
+ # ========================================================================= #
29
+ def show_remote_files(
30
+ mode = nil
31
+ ) # Show the content of the remote host.
32
+ ftp?.show_remote_files
33
+ end
34
+
35
+ # ========================================================================= #
36
+ # === show_hosts
37
+ # ========================================================================= #
38
+ def show_hosts
39
+ e "The available hosts are:#{N}#{N}"
40
+ ftp?.array_available_hosts.each {|host|
41
+ e simp(" #{host}")
42
+ }; e
43
+ end
44
+
45
+ # ========================================================================= #
46
+ # === show_remote_listing
47
+ #
48
+ # This will display the remote file listing.
49
+ # ========================================================================= #
50
+ def show_remote_listing
51
+ ftp?.show_remote_listing
52
+ end
53
+
54
+ # ========================================================================= #
55
+ # === show_status
56
+ # ========================================================================= #
57
+ def show_status
58
+ cliner {
59
+ # e
60
+ # show_help # <- Disabled as of May 2017.
61
+ e
62
+ report_where_we_are_connected_to
63
+ report_remote_directory # Added Dec 2011.
64
+ report_local_dir
65
+ # debug_it
66
+ e
67
+ }
68
+ end
69
+
70
+ # ========================================================================= #
71
+ # === show_title
72
+ #
73
+ # Use this method to give us the title
74
+ # ========================================================================= #
75
+ def show_title
76
+ e return_title
77
+ end
78
+
79
+ # ========================================================================= #
80
+ # === show_history
81
+ #
82
+ # This method can be used to display the input-history of the user.
83
+ # ========================================================================= #
84
+ def show_history # History tag.
85
+ e "The history for #{sfancy(return_title)} is:"
86
+ @history.each_with_index { |key, index|
87
+ e '%3s' % (index+1).to_s+' '+key
88
+ }
89
+ end
90
+
91
+ # ========================================================================= #
92
+ # === show_which_files_we_did_download_so_far
93
+ # ========================================================================= #
94
+ def show_which_files_we_did_download_so_far
95
+ if @array_downloaded_files.empty?
96
+ e 'We did not yet download any file.'
97
+ else
98
+ e 'We downloaded these files so far:'
99
+ pp @array_downloaded_files
100
+ end
101
+ end
102
+
103
+ # ========================================================================= #
104
+ # === show_ftp_docu
105
+ #
106
+ # This method will show where to find ruby's ftp docu.
107
+ # ========================================================================= #
108
+ def show_ftp_docu
109
+ e
110
+ e ' https://www.ruby-doc.org/stdlib/libdoc/net/ftp/rdoc/Net/FTP.html'
111
+ e
112
+ end
113
+
114
+ # ========================================================================= #
115
+ # === show_ftp_yaml_file
116
+ # ========================================================================= #
117
+ def show_ftp_yaml_file
118
+ e 'The yaml file in question can be found at:'
119
+ e
120
+ e " #{sfile(FILE_ROEBE_FTP)}"
121
+ e
122
+ end
123
+
124
+ # ========================================================================= #
125
+ # === show_modtime_of
126
+ # ========================================================================= #
127
+ def show_modtime_of(i)
128
+ e "The modification time of #{sfile(i)} is:"
129
+ e
130
+ e ' '+sfancy(ftp?.modification_time_of?(i))
131
+ e
132
+ end
133
+
134
+ # ========================================================================= #
135
+ # === display_configuration_options (show config tag)
136
+ #
137
+ # This method will show the configuration settings.
138
+ #
139
+ # You can invoke this in an interactive FTP session by doing this:
140
+ #
141
+ # config?
142
+ #
143
+ # ========================================================================= #
144
+ def display_configuration_options # Config tag.
145
+ cliner {
146
+ if @file.to_s.empty?
147
+ e '@file is: unassigned as of yet'
148
+ else
149
+ e '@file is: '+sfancy(@file.to_s)
150
+ end
151
+ e '@local_directory is: '+sfancy(@local_directory.to_s)
152
+ e '@splitted is: '+sfancy(@splitted.to_s)
153
+ e 'Will we use the Readline module? '+
154
+ sfancy(verbose_truth(use_readline?))
155
+ e 'Will we show full names (with full path)? '+
156
+ sfancy(verbose_truth(show_full_names?))
157
+ e 'What is the base directory? '+
158
+ sfancy(@config.base_directory.to_s)
159
+ }
160
+ end
161
+
162
+ # ========================================================================= #
163
+ # === show_available_connections
164
+ # ========================================================================= #
165
+ def show_available_connections(
166
+ i = ARRAY_AVAILABLE_HOSTS
167
+ )
168
+ i.each_with_index {|entry, index|
169
+ e "#{index} #{entry}"
170
+ } if Object.const_defined? :RoebeFtpConstants
171
+ end
172
+
173
+ # ========================================================================= #
174
+ # === show_www_component
175
+ # ========================================================================= #
176
+ def show_www_component
177
+ e 'Make sure to visit:'
178
+ path = '$RSRC/ftp_paradise/lib/ftp_paradise/www/sinatra_web_interface.rb'
179
+ e " #{sfancy(path)}"
180
+ _ = get_env_of("ruby #{path}")
181
+ esystem _
182
+ end
183
+
184
+ end; end
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'ftp_paradise/interactive_ftp/upload.rb'
6
+ # =========================================================================== #
7
+ module FtpParadise
8
+
9
+ class InteractiveFtp < Base # === FtpParadise::Interactive
10
+
11
+ # ========================================================================= #
12
+ # === upload (upload tag)
13
+ #
14
+ # Use this method to upload something locally to the remote site.
15
+ #
16
+ # You can also upload several files in one go - to do this, try
17
+ # one of these ways:
18
+ #
19
+ # upload 7,8 # This would upload file position 7 and 8.
20
+ # upload 1..293
21
+ #
22
+ # ========================================================================= #
23
+ def upload(
24
+ i = Dir['*']
25
+ )
26
+ # ======================================================================= #
27
+ # We will always work with an Array past the following point.
28
+ # ======================================================================= #
29
+ i = [i].flatten.compact # Safeguard against nil.
30
+ if i.empty?
31
+ i << @file if @file
32
+ end
33
+ i.map! {|entry|
34
+ if entry.include?('-') and !entry.include?('.') # Assume a range was given like 1-20.
35
+ splitted = entry.split('-')
36
+ entry = (splitted[0] .. splitted[1]).to_a
37
+ elsif entry.include?('..') # Assume a range such as: upload 1..25
38
+ entry =~ /(\d+)\.\.(\d+)/
39
+ start_position = $1.to_s.dup.to_i
40
+ end_position = $2.to_s.dup.to_i
41
+ entry = return_local_files[start_position, end_position]
42
+ elsif entry.include?(',')
43
+ splitted = i.split(',')
44
+ entry = (splitted[0] .. splitted[1]).to_a
45
+ elsif (entry == 'ALL') or (entry == '*')
46
+ entry = Dir['*']
47
+ elsif entry.include?('*.') or entry.include?('*')
48
+ entry = Dir[entry]
49
+ end
50
+ entry
51
+ }
52
+ i.flatten!
53
+ i.compact!
54
+ if on_roebe? and !is_connected?
55
+ connect_to :shevy
56
+ end
57
+ i.each {|this_file|
58
+ if this_file =~ /^\d+$/ # upload only a specific number.
59
+ sorted = Dir['*'].sort
60
+ if i.is_a? Array
61
+ i = i.first
62
+ end
63
+ this_file = sorted[i.to_i - 1]
64
+ end
65
+ _ = this_file # default to upload to 'all'
66
+ if File.exist?(_)
67
+ # =================================================================== #
68
+ # Next, some files will always be in binary mode. These are
69
+ # defined in the Array ARRAY_BINARY_FILES.
70
+ # =================================================================== #
71
+ if ARRAY_BINARY_FILES.include?(File.extname(_).delete('.')) and
72
+ (@mode != :binary)
73
+ use_binary_mode
74
+ end
75
+ case @mode
76
+ when :ascii
77
+ set_file(_)
78
+ ftp?.upload(_) # And now, call the functionality in the FTP lib.
79
+ else
80
+ ftp?.upload_binary(_)
81
+ end
82
+ else
83
+ opne swarn('But the file `')+
84
+ sfile(i)+
85
+ swarn('` does not exist.')
86
+ end
87
+ }
88
+ end
89
+
90
+ end; end
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'ftp_paradise/interactive_ftp/user_input.rb'
6
+ # =========================================================================== #
7
+ module FtpParadise
8
+
9
+ class InteractiveFtp < FtpParadise::Base # === FtpParadise::InteractiveFtp
10
+
11
+ # ========================================================================= #
12
+ # === obtain_user_input
13
+ #
14
+ # This method will obtain user input, and assign it to the variable
15
+ # @user_input.
16
+ # ========================================================================= #
17
+ def obtain_user_input
18
+ if @use_readline
19
+ user_input = Readline.readline('', true)
20
+ Readline::HISTORY.pop if user_input.strip.empty?
21
+ else
22
+ user_input = $stdin.gets.chomp
23
+ end
24
+ # ======================================================================= #
25
+ # Get rid of potential '#' comments in the input.
26
+ # ======================================================================= #
27
+ if user_input.include? '#'
28
+ user_input = user_input[0 .. user_input.index('#')-1]
29
+ end
30
+ user_input.strip! # Get rid of ' ' empty characters.
31
+ _ = user_input
32
+ unless _.empty? # append to history.
33
+ try_to_append_this_to_the_history(_)
34
+ end
35
+ # ======================================================================= #
36
+ # If the user did input a ';' character then we will assume that he
37
+ # wants to send multiple commands. We will however NOT assume so
38
+ # if the string also includes a 'http://' - in that case, we assume
39
+ # a HTTP URL instead.
40
+ # ======================================================================= #
41
+ if user_input.include? ';' and !user_input.include?('http://')
42
+ user_input = user_input.split(';')
43
+ else
44
+ user_input = [user_input] # In this case simply turn it into an Array.
45
+ end
46
+ # ======================================================================= #
47
+ # The @user_input variable should always be an Array.
48
+ # ======================================================================= #
49
+ @user_input = user_input
50
+ end; alias get_user_input obtain_user_input # === get_user_input
51
+ alias fetch_user_input obtain_user_input # === fetch_user_input
52
+
53
+ end; end
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen-string-literal: true
4
+ # =========================================================================== #
5
+ # require 'ftp_paradise/project/project.rb'
6
+ # =========================================================================== #
7
+ module FtpParadise
8
+
9
+ _ = File.absolute_path("#{__dir__}/..")+'/'
10
+
11
+ # ========================================================================= #
12
+ # === FtpParadise::PROJECT_BASE_DIRECTORY
13
+ # ========================================================================= #
14
+ begin # We need to make it failsafe.
15
+ PROJECT_BASE_DIRECTORY = (File.realpath(_)+'/').squeeze '/'
16
+ rescue
17
+ puts 'An error happened. We will hardcode the constant towards -> '+_
18
+ PROJECT_BASE_DIRECTORY = # Else default to my directory.
19
+ '/home/x/DATA/PROGRAMMING_LANGUAGES/RUBY/src/'\
20
+ 'ftp_paradise/lib/ftp_paradise/'
21
+ end
22
+
23
+ # ========================================================================= #
24
+ # === FtpParadise.project_base_dir?
25
+ # ========================================================================= #
26
+ def self.project_base_dir?
27
+ PROJECT_BASE_DIRECTORY
28
+ end
29
+
30
+ # ========================================================================= #
31
+ # === FtpParadise::PROJECT_YAML_DIRECTORY
32
+ #
33
+ # This constant specifies where the project-specific yaml/ directory
34
+ # will be kept at for the ftp_paradise project. Ideally you should
35
+ # use the method rather than this constant, though.
36
+ # ========================================================================= #
37
+ PROJECT_YAML_DIRECTORY = "#{PROJECT_BASE_DIRECTORY}yaml/"
38
+ YAML_DIRECTORY = PROJECT_YAML_DIRECTORY
39
+
40
+ # ========================================================================= #
41
+ # === FtpParadise.project_yaml_dir?
42
+ #
43
+ # This method here must be defined before FtpParadise.initialize()
44
+ # is to be invoked.
45
+ # ========================================================================= #
46
+ def self.project_yaml_dir?
47
+ "#{PROJECT_BASE_DIRECTORY}yaml/"
48
+ end; self.instance_eval { alias yaml_directory? project_yaml_dir? } # === FtpParadise.yaml_directory?
49
+
50
+ # ========================================================================= #
51
+ # === yaml_directory?
52
+ # ========================================================================= #
53
+ def yaml_directory?
54
+ FtpParadise.yaml_directory?
55
+ end
56
+
57
+ end
58
+
59
+ if __FILE__ == $PROGRAM_NAME
60
+ pp FtpParadise.project_base_dir?
61
+ pp FtpParadise.project_yaml_dir?
62
+ end