ftp_paradise 1.3.8

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 (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,27 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'ftp_paradise/constants/roebe.rb'
6
+ # FILE_ROEBE_FTP
7
+ # HOME_DIRECTOY_OF_USER_X
8
+ # =========================================================================== #
9
+ module FtpParadise
10
+
11
+ # =========================================================================== #
12
+ # === HOME_DIRECTOY_OF_USER_X
13
+ # =========================================================================== #
14
+ HOME_DIRECTOY_OF_USER_X = '/home/x/'
15
+
16
+ # =========================================================================== #
17
+ # === FtpParadise::FILE_ROEBE_FTP
18
+ #
19
+ # This will, on my home directory, expand to:
20
+ #
21
+ # /home/x/DATA/PC/OS/LINUX/FTP/YAML/roebe_ftp.yml
22
+ #
23
+ # =========================================================================== #
24
+ FILE_ROEBE_FTP =
25
+ "#{HOME_DIRECTOY_OF_USER_X}DATA/PC/OS/LINUX/FTP/YAML/roebe_ftp.yml"
26
+
27
+ end
@@ -0,0 +1,219 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'ftp_paradise/constants/roebe_ftp_constants.rb'
6
+ # include FtpParadise::RoebeFtpConstants
7
+ # =========================================================================== #
8
+ module FtpParadise # === FtpParadise::RoebeFtpConstants
9
+
10
+ module RoebeFtpConstants
11
+
12
+ require 'ftp_paradise/constants/roebe.rb'
13
+ require 'yaml'
14
+
15
+ # ========================================================================= #
16
+ # === FtpParadise::RoebeFtpConstants::@hash_ftp_dataset
17
+ # ========================================================================= #
18
+ @hash_ftp_dataset = {}
19
+
20
+ # ========================================================================= #
21
+ # === FTP_DATASET
22
+ #
23
+ # Here we will load my custom ftp file, but only if this file exists.
24
+ #
25
+ # If it does not exist, then we will not load it, and we will not
26
+ # make use of it. That way others can ignore this file altogether.
27
+ #
28
+ # The location for my file is at:
29
+ # bl $MY_FTP/YAML/roebe_ftp.yml
30
+ # ========================================================================= #
31
+ if File.exist? FILE_ROEBE_FTP
32
+ FTP_DATASET = FILE_ROEBE_FTP
33
+ else
34
+ begin
35
+ home_dir = File.expand_path('~')
36
+ rescue; end
37
+ home_dir = '/root' if home_dir.nil? # A safeguard here if ENV is unavailable.
38
+ FTP_DATASET = "#{home_dir}/roebe_ftp.yml"
39
+ end
40
+
41
+ # ========================================================================= #
42
+ # === FtpParadise::RoebeFtpConstants.file?
43
+ #
44
+ # Feedback where that file is.
45
+ # ========================================================================= #
46
+ def self.file?
47
+ FILE_ROEBE_FTP
48
+ end
49
+
50
+ # ========================================================================= #
51
+ # === FtpParadise::RoebeFtpConstants.hash_ftp_dataset?
52
+ # ========================================================================= #
53
+ def self.hash_ftp_dataset?
54
+ @hash_ftp_dataset
55
+ end; self.instance_eval { alias hash? hash_ftp_dataset? } # === FtpParadise::RoebeFtpConstants.hash_ftp_dataset?.hash?
56
+
57
+ # ========================================================================= #
58
+ # Next check whether the roebe_ftp.yml file exists. If it does then
59
+ # we will load it up.
60
+ # ========================================================================= #
61
+ if File.exist? file?
62
+ dataset = YAML.load_file(file?)
63
+ @hash_ftp_dataset.update(dataset) # Sync the dataset.
64
+ # ======================================================================= #
65
+ # The format of the dataset has to be uniform. We start with the
66
+ # remote URL, then the user name, the password, and then the port.
67
+ # ======================================================================= #
68
+
69
+ # ======================================================================= #
70
+ # === A1 TAG
71
+ # ======================================================================= #
72
+ _ = dataset['a1']
73
+ A1 = [
74
+ _['url'],
75
+ _['user_name'],
76
+ _['password'],
77
+ _['port']
78
+ ]
79
+
80
+ # ======================================================================= #
81
+ # === ZYMIX TAG
82
+ # ======================================================================= #
83
+ _ = dataset['zymix']
84
+ ZYMIX = [
85
+ _['url'],
86
+ _['user_name'],
87
+ _['password'],
88
+ _['port']
89
+ ]
90
+
91
+ # ======================================================================= #
92
+ # === Bytehost Tag
93
+ #
94
+ # bl $MY_FTP/YAML/roebe_ftp.yml
95
+ # ======================================================================= #
96
+ _ = dataset['bytehost']
97
+ BYTEHOST = [
98
+ _['url'],
99
+ _['user_name'],
100
+ _['password'],
101
+ _['port']
102
+ ]
103
+
104
+ # ======================================================================= #
105
+ # === UNIVIE
106
+ #
107
+ # Uni tag, Univie tag
108
+ # ======================================================================= #
109
+ _ = dataset['univie']
110
+ UNIVIE = [
111
+ _['url'],
112
+ _['user_name'],
113
+ _['password'],
114
+ _['port']
115
+ ]
116
+
117
+ # ======================================================================= #
118
+ # === Zerofees tag
119
+ # ======================================================================= #
120
+ _ = dataset['zerofees']
121
+ ZEROFEES = [
122
+ _['url'],
123
+ _['user_name'],
124
+ _['password'],
125
+ _['port']
126
+ ]
127
+
128
+ # ======================================================================= #
129
+ # === UCOZ tag
130
+ # ======================================================================= #
131
+ _ = dataset['ucoz']
132
+ UCOZ = [
133
+ _['url'],
134
+ _['user_name'],
135
+ _['password'],
136
+ _['port']
137
+ ]
138
+
139
+ # ======================================================================= #
140
+ # === UNIWIEN_HOMEPAGE tag
141
+ # ======================================================================= #
142
+ _ = dataset['uniwien_homepage']
143
+ UNIWIEN_HOMEPAGE = [
144
+ _['url'],
145
+ _['user_name'],
146
+ _['password'],
147
+ _['port']
148
+ ]
149
+
150
+ # ======================================================================= #
151
+ # === bplaced
152
+ # ======================================================================= #
153
+ _ = dataset['bplaced']
154
+ BPLACED = [
155
+ _['url'],
156
+ _['user_name'],
157
+ _['password'],
158
+ _['port']
159
+ ]
160
+
161
+ # ======================================================================= #
162
+ # === RoebeFtpConstants::ARRAY_AVAILABLE_HOSTS
163
+ #
164
+ # All available hosts are kept in the following Array.
165
+ #
166
+ # It is always available when the roebe_ftp.yml file was found.
167
+ #
168
+ # Append to this Array if you add new entries above.
169
+ # ======================================================================= #
170
+ ARRAY_AVAILABLE_HOSTS = [
171
+ BYTEHOST.first,
172
+ A1.first,
173
+ ZYMIX.first,
174
+ UNIVIE.first,
175
+ ZEROFEES.first,
176
+ UCOZ.first,
177
+ UNIWIEN_HOMEPAGE.first
178
+ ]
179
+ end
180
+
181
+ # ========================================================================= #
182
+ # === RoebeFtpConstants.possible_hosts?
183
+ # ========================================================================= #
184
+ def self.possible_hosts?
185
+ ARRAY_AVAILABLE_HOSTS
186
+ end
187
+
188
+ # ========================================================================= #
189
+ # === RoebeFtpConstants.geas?
190
+ # ========================================================================= #
191
+ def self.geas?
192
+ GEAS
193
+ end
194
+
195
+ # ========================================================================= #
196
+ # === RoebeFtpConstants.return_user_name_based_on_given_host
197
+ #
198
+ # This method may return the proper user name.
199
+ # ========================================================================= #
200
+ def self.return_user_name_based_on_given_host(i)
201
+ if ARRAY_AVAILABLE_HOSTS.include? i
202
+ i = SQUARE7[1] # Hardcoded for now. [1] is the user-name.
203
+ end if FtpParadise.const_defined? :RoebeFtpConstants
204
+ i
205
+ end
206
+
207
+ end; end
208
+
209
+ if __FILE__ == $PROGRAM_NAME # Testing RoebeFtpConstants next.
210
+ require 'cliner'
211
+ require 'colours/colours_e_autoinclude.rb'
212
+ include RoebeFtpConstants
213
+ cliner
214
+ e RoebeFtpConstants.file?
215
+ cliner
216
+ pp RoebeFtpConstants.hash_ftp_dataset?
217
+ pp RoebeFtpConstants::GEAS
218
+ pp RoebeFtpConstants.geas?
219
+ end # $FTP_PARADISE/roebe_ftp_constants.rb
@@ -0,0 +1,293 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === FtpParadise::Entry
6
+ #
7
+ # This class is sort of similar to class Net::FTP::List::Entry.
8
+ #
9
+ # We want to parse a FTP entry into corresponding slots on the object.
10
+ #
11
+ # The input should be an individual line from a remote Net::FTP object.
12
+ #
13
+ # The output would be an object such as:
14
+ #
15
+ # <FtpParadise::Entry:0x000055561f61b370 @basename="usher-0.0.12.gem", @filesize=2048, @mtime=2014-10-25 00:00:00 +0200, @raw="-rw-r--r-- 1 330 330 6144 Dec 27 2015 usher-0.0.12.gem", @server_type="Unix", @symlink=false, @dir=true, @file=false, @device=false, @splitted=["-rw-r--r--", "1", "330", "330", "6144", "Dec", "27", "2015", "usher-0.0.12.gem"]
16
+ #
17
+ # =========================================================================== #
18
+ # require 'ftp_paradise/entry/entry.rb'
19
+ # =========================================================================== #
20
+ module FtpParadise
21
+
22
+ class Entry # === FtpParadise::Entry
23
+
24
+ require 'time'
25
+
26
+ alias e puts
27
+
28
+ attr_reader :basename
29
+ attr_reader :device
30
+ attr_reader :file
31
+ attr_reader :raw
32
+ attr_reader :server_type
33
+
34
+ # ========================================================================= #
35
+ # === FtpParadise::Entry::DEFAULT_INPUT_FOR_THE_ENTRY_CALLED_RAW
36
+ # ========================================================================= #
37
+ DEFAULT_INPUT_FOR_THE_ENTRY_CALLED_RAW = 'drwxr-xr-x 2 330 330 2048 Oct 25 2019 .'
38
+
39
+ # ========================================================================= #
40
+ # === initialize
41
+ # ========================================================================= #
42
+ def initialize(
43
+ input_string = ARGV,
44
+ run_already = true
45
+ )
46
+ reset
47
+ set_raw(input_string)
48
+ run if run_already
49
+ end
50
+
51
+ # ========================================================================= #
52
+ # === set_raw
53
+ # ========================================================================= #
54
+ def set_raw(i)
55
+ i = i.first if i.is_a? Array
56
+ @raw = i.to_s.rstrip
57
+ if @raw.include? ' '
58
+ set_splitted(
59
+ @raw.split(' ')
60
+ ) # Determine @splitted as well here.
61
+ else
62
+ # ===================================================================== #
63
+ # This is for entries that may be short, such as the changed
64
+ # directory-display for FTP data.
65
+ # ===================================================================== #
66
+ @raw = @raw.rjust(67)
67
+ set_splitted(nil)
68
+ end
69
+ end
70
+
71
+ # ========================================================================= #
72
+ # === raw_input?
73
+ # ========================================================================= #
74
+ def raw_input?
75
+ @raw
76
+ end; alias raw? raw_input? # === raw?
77
+
78
+ # ========================================================================= #
79
+ # === set_splitted
80
+ # ========================================================================= #
81
+ def set_splitted(i)
82
+ @splitted = i
83
+ end
84
+
85
+ # ========================================================================= #
86
+ # === last
87
+ #
88
+ # This should return the name of the file.
89
+ # ========================================================================= #
90
+ def last
91
+ @splitted.last
92
+ end
93
+
94
+ # ========================================================================= #
95
+ # === symlink?
96
+ # ========================================================================= #
97
+ def symlink?
98
+ @symlink
99
+ end; alias symlink symlink? # === symlink
100
+
101
+ # ========================================================================= #
102
+ # === reset
103
+ # ========================================================================= #
104
+ def reset
105
+ @basename = '.'
106
+ @filesize = 0 # Is 0 initially.
107
+ @mtime = Time.parse('2014-10-25 00:00:00 +0200') # <- This requires time.
108
+ @raw = DEFAULT_INPUT_FOR_THE_ENTRY_CALLED_RAW
109
+ @server_type = 'Unix'
110
+ @symlink = false
111
+ @directory = true
112
+ @file = false
113
+ @device = false
114
+ end
115
+
116
+ # ========================================================================= #
117
+ # === filesize?
118
+ # ========================================================================= #
119
+ def filesize?
120
+ @filesize
121
+ end; alias filesize filesize? # === filesize
122
+
123
+ # ========================================================================= #
124
+ # === set_filesize
125
+ # ========================================================================= #
126
+ def set_filesize(i)
127
+ @filesize = i.to_i
128
+ end
129
+
130
+ # ========================================================================= #
131
+ # === show_the_line
132
+ # ========================================================================= #
133
+ def show_the_line
134
+ e @raw
135
+ end
136
+
137
+ # ========================================================================= #
138
+ # === is_directory
139
+ #
140
+ # Setter method to determine that we have found a directory.
141
+ # ========================================================================= #
142
+ def is_directory
143
+ @symlink = false
144
+ @file = false
145
+ @device = false
146
+ @directory = true
147
+ end
148
+
149
+ # ========================================================================= #
150
+ # === line?
151
+ # ========================================================================= #
152
+ def line?
153
+ @raw
154
+ end
155
+
156
+ # ========================================================================= #
157
+ # === name
158
+ # ========================================================================= #
159
+ def name
160
+ @basename
161
+ end; alias return_name name # === return_name
162
+ alias name? name # === name?
163
+ alias filename? name # === filename?
164
+
165
+ # ========================================================================= #
166
+ # === determine_timestamp
167
+ # ========================================================================= #
168
+ def determine_timestamp
169
+ if @splitted
170
+ new_string = "#{@splitted[5]}-#{@splitted[6]}-#{@splitted[7]}"
171
+ @mtime = new_string
172
+ else
173
+ @mtime = nil
174
+ end
175
+ end
176
+
177
+ # ========================================================================= #
178
+ # === parsed_timestamp?
179
+ # ========================================================================= #
180
+ def parsed_timestamp?
181
+ Time.parse(@mtime)
182
+ end
183
+
184
+ # ========================================================================= #
185
+ # === determine_filesize
186
+ #
187
+ # This method will determine the filesize of our remote entry at
188
+ # hand. The input may look like this:
189
+ # "-rw-rw-rw- 1 web netscape 10548 May 30 2011 Chained.rb"
190
+ # So when we split on ' ', the filesize will be entry number 4.
191
+ # ========================================================================= #
192
+ def determine_filesize
193
+ if @splitted
194
+ set_filesize(@splitted[4])
195
+ else
196
+ set_filesize(0)
197
+ end
198
+ end
199
+
200
+ # ========================================================================= #
201
+ # === determine_basename
202
+ # ========================================================================= #
203
+ def determine_basename
204
+ if @splitted
205
+ @basename = @splitted.last
206
+ else
207
+ @basename = raw
208
+ end
209
+ end
210
+
211
+ # ========================================================================= #
212
+ # === is_a_directory?
213
+ # ========================================================================= #
214
+ def is_a_directory?
215
+ @basename.end_with?('/') or @raw.start_with?('d')
216
+ end; alias is_directory? is_a_directory? # === is_directory?
217
+
218
+ # ========================================================================= #
219
+ # === file_or_directory?
220
+ #
221
+ # This will return the string 'file' or the string 'directory',
222
+ # depending on whether we have a file or a directory.
223
+ # ========================================================================= #
224
+ def file_or_directory?
225
+ if is_directory?
226
+ 'directory'
227
+ else
228
+ 'file'
229
+ end
230
+ end; alias file_or_directory file_or_directory? # === file_or_directory
231
+ alias type? file_or_directory? # === type?
232
+
233
+ # ========================================================================= #
234
+ # === directory?
235
+ # ========================================================================= #
236
+ def directory?
237
+ @directory
238
+ end; alias dir directory? # === dir
239
+ alias dir? directory? # === dir?
240
+
241
+ # ========================================================================= #
242
+ # === is_a_file?
243
+ # ========================================================================= #
244
+ def is_a_file?
245
+ !is_a_directory?
246
+ end
247
+
248
+ # ========================================================================= #
249
+ # === mtime?
250
+ # ========================================================================= #
251
+ def mtime?
252
+ @mtime
253
+ end; alias mtime mtime? # === mtime
254
+
255
+ # ========================================================================= #
256
+ # === run
257
+ # ========================================================================= #
258
+ def run
259
+ case @raw[0,1]
260
+ when 'd' # If it starts with a 'd', then it is a directory.
261
+ is_directory
262
+ end
263
+ determine_basename
264
+ determine_timestamp
265
+ determine_filesize
266
+ end
267
+
268
+ # ========================================================================= #
269
+ # === Entry.parse
270
+ # ========================================================================= #
271
+ def self.parse(i)
272
+ self.new(i)
273
+ end
274
+
275
+ end; end
276
+
277
+ if __FILE__ == $PROGRAM_NAME
278
+ alias e puts
279
+ array = ["-rw-r--r-- 1 0 2 0 Oct 29 19:23 DO NOT UPLOAD FILES HERE",
280
+ "htdocs/",
281
+ "-rw-r--r-- 1 22918231 22918231 9 Oct 29 19:32 test.md",
282
+ "drwxr-xr-x 2 22918231 22918231 4096 Oct 30 10:59 test2"]
283
+ array.map! {|line|
284
+ FtpParadise::Entry.new(line)
285
+ }
286
+ pp array
287
+ entry = array[1]
288
+ e
289
+ pp entry
290
+ e
291
+ puts entry.file_or_directory?
292
+ puts entry.type?
293
+ end