directory_paradise 1.4.4
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 directory_paradise might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.md +213 -0
- data/bin/show_directory_content +7 -0
- data/directory_paradise.gemspec +45 -0
- data/doc/README.gen +185 -0
- data/doc/todo/todo.md +4 -0
- data/lib/directory_paradise/base/base.rb +195 -0
- data/lib/directory_paradise/base/colours.rb +196 -0
- data/lib/directory_paradise/constants/newline.rb +14 -0
- data/lib/directory_paradise/content/constants.rb +23 -0
- data/lib/directory_paradise/content/content.rb +682 -0
- data/lib/directory_paradise/project/project.rb +22 -0
- data/lib/directory_paradise/report/constants.rb +39 -0
- data/lib/directory_paradise/report/initialize.rb +75 -0
- data/lib/directory_paradise/report/menu.rb +329 -0
- data/lib/directory_paradise/report/misc.rb +675 -0
- data/lib/directory_paradise/report/obtain.rb +357 -0
- data/lib/directory_paradise/report/report.rb +527 -0
- data/lib/directory_paradise/report/reset.rb +174 -0
- data/lib/directory_paradise/requires/require_class_content.rb +7 -0
- data/lib/directory_paradise/requires/require_class_report.rb +7 -0
- data/lib/directory_paradise/requires/require_the_directory_paradise_project.rb +10 -0
- data/lib/directory_paradise/sdc.rb +24 -0
- data/lib/directory_paradise/to_human_readable/to_human_readable.rb +98 -0
- data/lib/directory_paradise/version/version.rb +19 -0
- data/lib/directory_paradise/yaml/colours_for_bytes_values.yml +14 -0
- data/lib/directory_paradise.rb +1 -0
- data/test/testing_class_content.rb +16 -0
- data/test/testing_class_report.rb +40 -0
- data/test/testing_toplevel_methods.rb +14 -0
- metadata +110 -0
@@ -0,0 +1,675 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'directory_paradise/report/misc.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'directory_paradise/base/base.rb'
|
8
|
+
|
9
|
+
module DirectoryParadise
|
10
|
+
|
11
|
+
class Report < Base # === DirectoryParadise::Report
|
12
|
+
|
13
|
+
# ========================================================================= #
|
14
|
+
# === set_work_on_this_directory
|
15
|
+
#
|
16
|
+
# This method will determine on which target directory (the base
|
17
|
+
# directory) this class will work on.
|
18
|
+
#
|
19
|
+
# It must be ensured that this variable will have a trailing '/'
|
20
|
+
# character, to properly indicate that we are dealing with a
|
21
|
+
# directory here.
|
22
|
+
# ========================================================================= #
|
23
|
+
def set_work_on_this_directory(
|
24
|
+
i = return_pwd
|
25
|
+
)
|
26
|
+
# ======================================================================= #
|
27
|
+
# === Handle Hashes first
|
28
|
+
# ======================================================================= #
|
29
|
+
if i.is_a? Hash
|
30
|
+
if i.has_key? :from
|
31
|
+
i = i.delete(:from)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
if i.is_a? Array
|
35
|
+
_ = return_non_hyphen_entries_from(i)
|
36
|
+
if _.empty?
|
37
|
+
i = return_pwd
|
38
|
+
else
|
39
|
+
i = _
|
40
|
+
end
|
41
|
+
i = i.join(' ').strip if i.is_a? Array
|
42
|
+
end
|
43
|
+
case i
|
44
|
+
# ======================================================================= #
|
45
|
+
# === :dont_run_yet
|
46
|
+
# ======================================================================= #
|
47
|
+
when :dont_run_yet
|
48
|
+
i = nil
|
49
|
+
@run_already = false
|
50
|
+
# ======================================================================= #
|
51
|
+
# === :show_content
|
52
|
+
# ======================================================================= #
|
53
|
+
when :show_content
|
54
|
+
do_show_the_content
|
55
|
+
i = return_pwd
|
56
|
+
end
|
57
|
+
begin
|
58
|
+
# ===================================================================== #
|
59
|
+
# Default values come next here in this clause.
|
60
|
+
# ===================================================================== #
|
61
|
+
i = return_pwd if i.nil?
|
62
|
+
i = i.dup if i.frozen?
|
63
|
+
# ===================================================================== #
|
64
|
+
# We need to default to the current directory if there exists a
|
65
|
+
# directory with that name.
|
66
|
+
# ===================================================================== #
|
67
|
+
i = return_pwd unless Dir.exist?(i)
|
68
|
+
if i.is_a? String and i.empty?
|
69
|
+
i = return_pwd
|
70
|
+
end
|
71
|
+
rescue Errno::ENOENT # Rescue non-existing directories.
|
72
|
+
e 'An error occurred. The directory may have been removed or the local'
|
73
|
+
e "filesystem is unavailable. Thus, we will display \"/\" instead.#{N}"
|
74
|
+
i = '/'
|
75
|
+
end
|
76
|
+
i = i.dup if i.frozen?
|
77
|
+
i << '/' unless i.end_with? '/'
|
78
|
+
i.squeeze!('/')
|
79
|
+
@internal_hash[:work_on_this_directory] = i
|
80
|
+
end; alias set_from_which_directory set_work_on_this_directory # === set_from_which_directory
|
81
|
+
alias set_dir set_work_on_this_directory # === set_dir
|
82
|
+
alias set_main_directory set_work_on_this_directory # === set_main_directory
|
83
|
+
alias set_base_directory set_work_on_this_directory # === set_base_directory
|
84
|
+
|
85
|
+
|
86
|
+
# ========================================================================= #
|
87
|
+
# === apply_filter
|
88
|
+
#
|
89
|
+
# Use this method here to apply a filter on the main entries.
|
90
|
+
# ========================================================================= #
|
91
|
+
def apply_filter(i)
|
92
|
+
i = i.dup if i.frozen?
|
93
|
+
i.delete!('*') if i.include? '*'
|
94
|
+
i.delete!('/') if i.include? '/' # This may be incorrect.
|
95
|
+
obtain_entries unless entries?
|
96
|
+
entries?.select! {|entry|
|
97
|
+
entry.include?(i)
|
98
|
+
}
|
99
|
+
entries?
|
100
|
+
end
|
101
|
+
|
102
|
+
# ========================================================================= #
|
103
|
+
# === consider_colourizing_filename
|
104
|
+
# ========================================================================= #
|
105
|
+
def consider_colourizing_filename(filename)
|
106
|
+
result = ''.dup
|
107
|
+
if File.exist? filename
|
108
|
+
filetype = File.ftype(filename)
|
109
|
+
unless show_leading_slash?
|
110
|
+
filename[0,1] = '' if filename.start_with? '/'
|
111
|
+
end
|
112
|
+
# ===================================================================== #
|
113
|
+
# Next, honour the variable @show_full_path if it was set to true.
|
114
|
+
# ===================================================================== #
|
115
|
+
unless show_full_path?
|
116
|
+
filename = File.basename(filename)
|
117
|
+
end
|
118
|
+
case filetype
|
119
|
+
when 'link' # Handle Symlinks here.
|
120
|
+
result = colourize_symlink(filename)
|
121
|
+
when 'directory'
|
122
|
+
result = colourize_directory(filename) # This is actually sdir().
|
123
|
+
when 'file'
|
124
|
+
result = sfile(filename)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
result
|
128
|
+
end
|
129
|
+
|
130
|
+
# ========================================================================= #
|
131
|
+
# === do_ignore_backups
|
132
|
+
# ========================================================================= #
|
133
|
+
def do_ignore_backups
|
134
|
+
# ======================================================================= #
|
135
|
+
# Do not list implied entries ending with '~' in the following option.
|
136
|
+
# ======================================================================= #
|
137
|
+
if ignore_backups?
|
138
|
+
directory_content?.ignore_backups
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# ========================================================================= #
|
143
|
+
# === consider_sorting_by
|
144
|
+
#
|
145
|
+
# This is the specific sorting-action. The method will delegate onto
|
146
|
+
# class DirectoryContent::ShowDirectoryContent.
|
147
|
+
# ========================================================================= #
|
148
|
+
def consider_sorting_by(
|
149
|
+
i = sort_by?
|
150
|
+
)
|
151
|
+
directory_content?.consider_sorting_by(i)
|
152
|
+
end
|
153
|
+
|
154
|
+
# ========================================================================= #
|
155
|
+
# === shorten_file_elegantly
|
156
|
+
#
|
157
|
+
# We need to take into account that our file could be a directory too.
|
158
|
+
# ========================================================================= #
|
159
|
+
def shorten_file_elegantly(
|
160
|
+
i, threshold = FILE_SIZE_THRESHOLD
|
161
|
+
)
|
162
|
+
i = i.to_s.dup
|
163
|
+
middle_pos = (i.size / 2) - 10
|
164
|
+
oversize = i.size - threshold # The oversize value
|
165
|
+
if oversize > 0
|
166
|
+
start_pos = middle_pos - (oversize / 2)
|
167
|
+
end_pos = start_pos + oversize
|
168
|
+
i[start_pos .. end_pos] = '[… Truncated …]' # This is the padding to use.
|
169
|
+
end
|
170
|
+
return i
|
171
|
+
end
|
172
|
+
|
173
|
+
# ========================================================================= #
|
174
|
+
# === do_not_display_content
|
175
|
+
# ========================================================================= #
|
176
|
+
def do_not_display_content
|
177
|
+
@internal_hash[:display_content] = false # if true, we display() the result.
|
178
|
+
end
|
179
|
+
|
180
|
+
# ========================================================================= #
|
181
|
+
# === do_show_the_content
|
182
|
+
# ========================================================================= #
|
183
|
+
def do_show_the_content
|
184
|
+
@internal_hash[:display_content] = true
|
185
|
+
end; alias do_display_content do_show_the_content # === do_display_content
|
186
|
+
|
187
|
+
# ========================================================================= #
|
188
|
+
# === colourize_symlink
|
189
|
+
#
|
190
|
+
# Use this method to colourize a symlink.
|
191
|
+
# ========================================================================= #
|
192
|
+
def colourize_symlink(i)
|
193
|
+
result = return_name_of_this_symlink(i)
|
194
|
+
# ======================================================================= #
|
195
|
+
# Check whether we will use colours or whether we will not.
|
196
|
+
# ======================================================================= #
|
197
|
+
if File.symlink?(i)
|
198
|
+
if use_colours?
|
199
|
+
if stop_on_missing_symlink? and !File.readlink?(i)
|
200
|
+
opn; e "The symlink for #{i} does not exist."
|
201
|
+
opn; e 'Exiting now, as set per a configuration option.'
|
202
|
+
exit
|
203
|
+
end
|
204
|
+
result = ' → '+
|
205
|
+
skyblue(
|
206
|
+
File.readlink(i)
|
207
|
+
) # Need to readlink on the original variant.
|
208
|
+
else
|
209
|
+
result = ' → '+File.readlink(i)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
result
|
213
|
+
end
|
214
|
+
|
215
|
+
# ========================================================================= #
|
216
|
+
# === return_name_of_this_symlink
|
217
|
+
#
|
218
|
+
# File.basename() kills off leading '/', hence we need this method.
|
219
|
+
# ========================================================================= #
|
220
|
+
def return_name_of_this_symlink(i)
|
221
|
+
i = File.basename(i)
|
222
|
+
if return_pwd == '/' and show_leading_slash?
|
223
|
+
i.prepend '/'
|
224
|
+
end
|
225
|
+
return i
|
226
|
+
end
|
227
|
+
|
228
|
+
# ========================================================================= #
|
229
|
+
# === do_show_only_symlinks
|
230
|
+
# ========================================================================= #
|
231
|
+
def do_show_only_symlinks
|
232
|
+
@internal_hash[:show_only_symlinks] = true
|
233
|
+
end
|
234
|
+
|
235
|
+
# ========================================================================= #
|
236
|
+
# === toggle_permission
|
237
|
+
# ========================================================================= #
|
238
|
+
def toggle_permission
|
239
|
+
_ = @internal_hash[:show_condensed_permissions]
|
240
|
+
@internal_hash[:show_condensed_permissions] = !_ # Toggle it here.
|
241
|
+
end
|
242
|
+
|
243
|
+
# ========================================================================= #
|
244
|
+
# === do_not_display_only_directories
|
245
|
+
# ========================================================================= #
|
246
|
+
def do_not_display_only_directories
|
247
|
+
@internal_hash[:display_only_directories] = false # Whether to display only directories or not.
|
248
|
+
end
|
249
|
+
|
250
|
+
# ========================================================================= #
|
251
|
+
# === dont_show_header
|
252
|
+
# ========================================================================= #
|
253
|
+
def dont_show_header
|
254
|
+
@internal_hash[:show_header] = false
|
255
|
+
end; alias do_not_show_the_header dont_show_header # === do_not_show_the_header
|
256
|
+
|
257
|
+
# ========================================================================= #
|
258
|
+
# === do_show_hidden_files
|
259
|
+
# ========================================================================= #
|
260
|
+
def do_show_hidden_files
|
261
|
+
@internal_hash[:show_hidden_files] = true
|
262
|
+
end
|
263
|
+
|
264
|
+
# ========================================================================= #
|
265
|
+
# == dont_show_index
|
266
|
+
# ========================================================================= #
|
267
|
+
def dont_show_index
|
268
|
+
@internal_hash[:show_index] = false
|
269
|
+
end; alias do_not_show_the_index dont_show_index # === do_not_show_the_index
|
270
|
+
alias do_not_show_index dont_show_index # === do_not_show_index
|
271
|
+
|
272
|
+
# ========================================================================= #
|
273
|
+
# === toggle_colourize
|
274
|
+
# ========================================================================= #
|
275
|
+
def toggle_colourize
|
276
|
+
if @internal_hash[:colourize_kb_and_mb] == false
|
277
|
+
@internal_hash[:colourize_kb_and_mb] = true
|
278
|
+
else
|
279
|
+
@internal_hash[:colourize_kb_and_mb] = false
|
280
|
+
end
|
281
|
+
end; alias toggle toggle_colourize # === toggle
|
282
|
+
|
283
|
+
# ========================================================================= #
|
284
|
+
# === rev
|
285
|
+
# ========================================================================= #
|
286
|
+
def rev
|
287
|
+
@internal_hash[:default_colour]
|
288
|
+
end
|
289
|
+
|
290
|
+
# ========================================================================= #
|
291
|
+
# === do_not_stop_on_missing_symlink
|
292
|
+
# ========================================================================= #
|
293
|
+
def do_not_stop_on_missing_symlink
|
294
|
+
@internal_hash[:stop_on_missing_symlink] = false # if true we will stop on missing symlink.
|
295
|
+
end
|
296
|
+
|
297
|
+
# ========================================================================= #
|
298
|
+
# === do_show_condensed_permissions
|
299
|
+
# ========================================================================= #
|
300
|
+
def do_show_condensed_permissions
|
301
|
+
@internal_hash[:show_condensed_permissions] = true
|
302
|
+
end
|
303
|
+
|
304
|
+
# ========================================================================= #
|
305
|
+
# === do_not_ignore_backups
|
306
|
+
# ========================================================================= #
|
307
|
+
def do_not_ignore_backups
|
308
|
+
@internal_hash[:ignore_backups] = false
|
309
|
+
end
|
310
|
+
|
311
|
+
# ========================================================================= #
|
312
|
+
# === ignore_backups
|
313
|
+
# ========================================================================= #
|
314
|
+
def ignore_backups
|
315
|
+
@internal_hash[:ignore_backups] = true
|
316
|
+
end
|
317
|
+
|
318
|
+
# ========================================================================= #
|
319
|
+
# === do_not_report_filesize
|
320
|
+
# ========================================================================= #
|
321
|
+
def do_not_report_filesize
|
322
|
+
@internal_hash[:report_filesize] = false
|
323
|
+
end; alias dont_report_total_filesize do_not_report_filesize # === dont_report_total_filesize
|
324
|
+
|
325
|
+
# ========================================================================= #
|
326
|
+
# === do_show_index
|
327
|
+
# ========================================================================= #
|
328
|
+
def do_show_index
|
329
|
+
@internal_hash[:show_index] = true # if true then we will show the index.
|
330
|
+
end
|
331
|
+
|
332
|
+
# ========================================================================= #
|
333
|
+
# === do_report_filesize
|
334
|
+
# ========================================================================= #
|
335
|
+
def do_report_filesize
|
336
|
+
@internal_hash[:report_filesize] = true
|
337
|
+
end
|
338
|
+
|
339
|
+
# ========================================================================= #
|
340
|
+
# === do_not_show_size
|
341
|
+
# ========================================================================= #
|
342
|
+
def do_not_show_size
|
343
|
+
@internal_hash[:show_size] = false
|
344
|
+
end
|
345
|
+
|
346
|
+
# ========================================================================= #
|
347
|
+
# === do_show_almost_nothing
|
348
|
+
# ========================================================================= #
|
349
|
+
def do_show_almost_nothing
|
350
|
+
do_not_show_size
|
351
|
+
do_not_show_index
|
352
|
+
do_not_show_permissions
|
353
|
+
do_not_show_modtime
|
354
|
+
end
|
355
|
+
|
356
|
+
# ========================================================================= #
|
357
|
+
# === do_truncate_long_file_names
|
358
|
+
# ========================================================================= #
|
359
|
+
def do_truncate_long_file_names
|
360
|
+
@internal_hash[:truncate_long_file_names] = true
|
361
|
+
end; alias truncate do_truncate_long_file_names # === truncate
|
362
|
+
|
363
|
+
# ========================================================================= #
|
364
|
+
# === disable_show_modification_time
|
365
|
+
# ========================================================================= #
|
366
|
+
def disable_show_modification_time
|
367
|
+
@internal_hash[:show_modification_time] = false
|
368
|
+
end; alias dont_show_modification_time disable_show_modification_time
|
369
|
+
alias do_not_show_modification_time disable_show_modification_time
|
370
|
+
alias do_not_show_modtime disable_show_modification_time
|
371
|
+
|
372
|
+
# ========================================================================= #
|
373
|
+
# === do_shorten_display
|
374
|
+
# ========================================================================= #
|
375
|
+
def do_shorten_display
|
376
|
+
enable_collapse
|
377
|
+
disable_show_modification_time # Added Aug 2012.
|
378
|
+
end
|
379
|
+
|
380
|
+
# ========================================================================= #
|
381
|
+
# === do_not_debug
|
382
|
+
# ========================================================================= #
|
383
|
+
def do_not_debug
|
384
|
+
@internal_hash[:debug] = false # Whether we debug this class or not.
|
385
|
+
end
|
386
|
+
|
387
|
+
# ========================================================================= #
|
388
|
+
# === do_not_truncate_long_file_names
|
389
|
+
# ========================================================================= #
|
390
|
+
def do_not_truncate_long_file_names
|
391
|
+
@internal_hash[:truncate_long_file_names] = false
|
392
|
+
end
|
393
|
+
|
394
|
+
# ========================================================================= #
|
395
|
+
# === show_simplified
|
396
|
+
# ========================================================================= #
|
397
|
+
def do_show_simplified
|
398
|
+
@internal_hash[:show_simplified] = true
|
399
|
+
end; alias show_simplified do_show_simplified # === show_simplified
|
400
|
+
|
401
|
+
# ========================================================================= #
|
402
|
+
# === do_show_leading_slash
|
403
|
+
# ========================================================================= #
|
404
|
+
def do_show_leading_slash
|
405
|
+
@internal_hash[:show_leading_slash] = true
|
406
|
+
end
|
407
|
+
|
408
|
+
# ========================================================================= #
|
409
|
+
# === do_show_modification_time
|
410
|
+
# ========================================================================= #
|
411
|
+
def do_show_modification_time
|
412
|
+
@internal_hash[:show_modification_time] = true
|
413
|
+
end
|
414
|
+
|
415
|
+
# ========================================================================= #
|
416
|
+
# === do_not_show_inode
|
417
|
+
# ========================================================================= #
|
418
|
+
def do_not_show_inode
|
419
|
+
@internal_hash[:show_inode] = false
|
420
|
+
end
|
421
|
+
|
422
|
+
# ========================================================================= #
|
423
|
+
# === do_show_inode
|
424
|
+
# ========================================================================= #
|
425
|
+
def do_show_inode # Show the inode number if true.
|
426
|
+
@internal_hash[:show_inode] = true
|
427
|
+
end
|
428
|
+
|
429
|
+
# ========================================================================= #
|
430
|
+
# === do_hide_files
|
431
|
+
# ========================================================================= #
|
432
|
+
def do_hide_files
|
433
|
+
@internal_hash[:show_hidden_files] = false
|
434
|
+
end; alias do_not_show_hidden_files do_hide_files # === do_not_show_hidden_files
|
435
|
+
|
436
|
+
# ========================================================================= #
|
437
|
+
# === do_show_uncondensed_permissions
|
438
|
+
# ========================================================================= #
|
439
|
+
def do_show_uncondensed_permissions
|
440
|
+
@internal_hash[:show_condensed_permissions] = false
|
441
|
+
end; alias dont_show_condensed_permissions do_show_uncondensed_permissions
|
442
|
+
|
443
|
+
# ========================================================================= #
|
444
|
+
# === show_this_help_line
|
445
|
+
# ========================================================================= #
|
446
|
+
def show_this_help_line(
|
447
|
+
i = :toggle, optional_additional_argument = nil
|
448
|
+
)
|
449
|
+
if optional_additional_argument
|
450
|
+
e " - #{sfancy(i)} / #{sfancy(optional_additional_argument)}"
|
451
|
+
else
|
452
|
+
e " - #{sfancy(i)}"
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
# ========================================================================= #
|
457
|
+
# === set_show_full_path
|
458
|
+
# ========================================================================= #
|
459
|
+
def set_show_full_path(i = true)
|
460
|
+
@internal_hash[:show_full_path] = i
|
461
|
+
end
|
462
|
+
|
463
|
+
# ========================================================================= #
|
464
|
+
# === do_colourize_kb_and_mb
|
465
|
+
# ========================================================================= #
|
466
|
+
def do_colourize_kb_and_mb
|
467
|
+
@internal_hash[:colourize_kb_and_mb] = true
|
468
|
+
end
|
469
|
+
|
470
|
+
# ========================================================================= #
|
471
|
+
# === collapse=
|
472
|
+
# ========================================================================= #
|
473
|
+
def collapse=(i)
|
474
|
+
@internal_hash[:collapse] = i
|
475
|
+
end
|
476
|
+
|
477
|
+
# ========================================================================= #
|
478
|
+
# === do_not_show_simplified
|
479
|
+
# ========================================================================= #
|
480
|
+
def do_not_show_simplified
|
481
|
+
@internal_hash[:show_simplified] = false
|
482
|
+
end
|
483
|
+
|
484
|
+
# ========================================================================= #
|
485
|
+
# === stop_on_missing_symlink=
|
486
|
+
# ========================================================================= #
|
487
|
+
def stop_on_missing_symlink=(i)
|
488
|
+
@internal_hash[:stop_on_missing_symlink] = i
|
489
|
+
end
|
490
|
+
|
491
|
+
# ========================================================================= #
|
492
|
+
# === do_show_full_path
|
493
|
+
# ========================================================================= #
|
494
|
+
def do_show_full_path
|
495
|
+
@internal_hash[:show_full_path] = true
|
496
|
+
end
|
497
|
+
|
498
|
+
# ========================================================================= #
|
499
|
+
# === dont_show_full_path
|
500
|
+
#
|
501
|
+
# I assume that this option is interconnected with another option,
|
502
|
+
# namely the ability to show, or rather not show, a leading slash.
|
503
|
+
#
|
504
|
+
# Thus, as of May 2015, we will also disable showing the leading
|
505
|
+
# slash whenever we invoke this method here.
|
506
|
+
# ========================================================================= #
|
507
|
+
def dont_show_full_path
|
508
|
+
set_show_full_path(false)
|
509
|
+
do_not_show_leading_slash
|
510
|
+
end; alias do_not_show_full_path dont_show_full_path # === do_not_show_full_path
|
511
|
+
alias enable_collapse dont_show_full_path # === enable_collapse
|
512
|
+
alias do_not_show_the_full_path dont_show_full_path # === do_not_show_the_full_path
|
513
|
+
alias do_show_only_filename dont_show_full_path # === do_show_only_filename
|
514
|
+
|
515
|
+
# ========================================================================= #
|
516
|
+
# === do_not_show_permissions
|
517
|
+
# ========================================================================= #
|
518
|
+
def do_not_show_permissions
|
519
|
+
@internal_hash[:show_permission_bits] = false
|
520
|
+
end
|
521
|
+
|
522
|
+
# ========================================================================= #
|
523
|
+
# === do_show_header
|
524
|
+
# ========================================================================= #
|
525
|
+
def do_show_header
|
526
|
+
@internal_hash[:show_header] = true
|
527
|
+
end
|
528
|
+
|
529
|
+
# ========================================================================= #
|
530
|
+
# === do_sort_reversed
|
531
|
+
# ========================================================================= #
|
532
|
+
def do_sort_reversed
|
533
|
+
sort_how :reverse
|
534
|
+
end
|
535
|
+
|
536
|
+
# ========================================================================= #
|
537
|
+
# === do_not_show_group_information
|
538
|
+
# ========================================================================= #
|
539
|
+
def do_not_show_group_information
|
540
|
+
@internal_hash[:show_group_information] = false
|
541
|
+
end; alias no_groups do_not_show_group_information # === no_groups
|
542
|
+
|
543
|
+
# ========================================================================= #
|
544
|
+
# === do_not_show_the_owner
|
545
|
+
# ========================================================================= #
|
546
|
+
def do_not_show_the_owner
|
547
|
+
@internal_hash[:show_owner] = false
|
548
|
+
end
|
549
|
+
|
550
|
+
# ========================================================================= #
|
551
|
+
# === do_show_group_information
|
552
|
+
# ========================================================================= #
|
553
|
+
def do_show_group_information
|
554
|
+
@internal_hash[:show_group_information] = true
|
555
|
+
end
|
556
|
+
|
557
|
+
# ========================================================================= #
|
558
|
+
# === do_show_owner
|
559
|
+
# ========================================================================= #
|
560
|
+
def do_show_owner
|
561
|
+
@internal_hash[:show_owner] = true
|
562
|
+
end
|
563
|
+
|
564
|
+
# ========================================================================= #
|
565
|
+
# === do_not_show_leading_slash
|
566
|
+
# ========================================================================= #
|
567
|
+
def do_not_show_leading_slash
|
568
|
+
@internal_hash[:show_leading_slash] = false
|
569
|
+
end
|
570
|
+
|
571
|
+
# ========================================================================= #
|
572
|
+
# === do_show_permissions
|
573
|
+
# ========================================================================= #
|
574
|
+
def do_show_permissions
|
575
|
+
@internal_hash[:show_permission_bits] = true
|
576
|
+
end
|
577
|
+
|
578
|
+
# ========================================================================= #
|
579
|
+
# === only_directories
|
580
|
+
#
|
581
|
+
# Only get directories, with this method.
|
582
|
+
# ========================================================================= #
|
583
|
+
def only_directories
|
584
|
+
@internal_hash[:display_only_directories] = true
|
585
|
+
end
|
586
|
+
|
587
|
+
# ========================================================================= #
|
588
|
+
# === run_then_display
|
589
|
+
# ========================================================================= #
|
590
|
+
def run_then_display
|
591
|
+
run
|
592
|
+
display
|
593
|
+
end; alias gather_then_display_content run_then_display # === gather_then_display_content
|
594
|
+
|
595
|
+
# ========================================================================= #
|
596
|
+
# === define_colours
|
597
|
+
#
|
598
|
+
# define_colours() is called from reset()
|
599
|
+
# ========================================================================= #
|
600
|
+
def define_colours(
|
601
|
+
optional_hash_use_these_colours = nil
|
602
|
+
) # Colours tag, colors tag.
|
603
|
+
_ = optional_hash_use_these_colours
|
604
|
+
if use_colours?
|
605
|
+
if _ # If the Hash is defined, enter here.
|
606
|
+
@internal_hash[:default_colour] = Colours.beautiful _['colour_for_normal']
|
607
|
+
@internal_hash[:colour_for_files] = Colours.beautiful _['colour_for_files']
|
608
|
+
@internal_hash[:colour_for_symlinks] = Colours.beautiful _['colour_for_symlinks']
|
609
|
+
@internal_hash[:colour_for_directories] = Colours.beautiful _['colour_for_directories']
|
610
|
+
else # Try to use Konsole after this point.
|
611
|
+
if Object.const_defined? :Colours
|
612
|
+
@internal_hash[:default_colour] = Colours.restore? # Restore the default again.
|
613
|
+
@internal_hash[:colour_for_files] = Colours.springgreen
|
614
|
+
@internal_hash[:colour_for_symlinks] = Colours.slateblue
|
615
|
+
@internal_hash[:colour_for_directories] = Colours.paleturquoise
|
616
|
+
else # Else, use the default colours. They are defined in the module Colours.
|
617
|
+
@internal_hash[:default_colour] = Colours::WHITE
|
618
|
+
@internal_hash[:colour_for_files] = Colours::GREEN
|
619
|
+
@internal_hash[:colour_for_symlinks] = Colours::BLUE
|
620
|
+
@internal_hash[:colour_for_directories] = Colours::CYAN # Which colour to use for directories.
|
621
|
+
end
|
622
|
+
end
|
623
|
+
end
|
624
|
+
end
|
625
|
+
|
626
|
+
# ========================================================================= #
|
627
|
+
# === check_whether_we_use_colours
|
628
|
+
#
|
629
|
+
# We will enable the colours if necessary.
|
630
|
+
# ========================================================================= #
|
631
|
+
def check_whether_we_use_colours
|
632
|
+
if use_colours?
|
633
|
+
enable_colours
|
634
|
+
check_whether_the_colours_defined_in_the_yaml_file_are_valid
|
635
|
+
define_colours
|
636
|
+
end
|
637
|
+
end
|
638
|
+
|
639
|
+
# ========================================================================= #
|
640
|
+
# === yaml_file?
|
641
|
+
# ========================================================================= #
|
642
|
+
def yaml_file?
|
643
|
+
FILE_COLOURS_FOR_BYTES_VALUES
|
644
|
+
end
|
645
|
+
|
646
|
+
# ========================================================================= #
|
647
|
+
# === check_whether_the_colours_defined_in_the_yaml_file_are_valid
|
648
|
+
# ========================================================================= #
|
649
|
+
def check_whether_the_colours_defined_in_the_yaml_file_are_valid
|
650
|
+
_ = @internal_hash[:hash_colours_for_bytes_value]
|
651
|
+
_.each_pair {|key, value| # The entries will be 'KB' and :lightgreen, for instance.
|
652
|
+
if Object.const_defined?(:Colours) and
|
653
|
+
::Colours.respond_to?(value)
|
654
|
+
else
|
655
|
+
e 'Attention please: the Colours namespace does not have a'
|
656
|
+
e 'colour named `'+value.to_s+'` defined.'
|
657
|
+
e
|
658
|
+
e 'One key (the one named '+key.to_s+') currently has this'
|
659
|
+
e 'value defined, though.'
|
660
|
+
e
|
661
|
+
e 'Please change this by modifying the following file:'
|
662
|
+
e
|
663
|
+
e sfile(" #{yaml_file?}")
|
664
|
+
e
|
665
|
+
e 'To get a listing of all defined colour-names, do this:'
|
666
|
+
e
|
667
|
+
e " require 'colours'"
|
668
|
+
e ' pp Colours.html_colours?'
|
669
|
+
e
|
670
|
+
exit
|
671
|
+
end
|
672
|
+
}
|
673
|
+
end
|
674
|
+
|
675
|
+
end; end
|