directory_paradise 1.4.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -22
- data/lib/directory_paradise/base/base.rb +33 -0
- data/lib/directory_paradise/base/colours.rb +12 -12
- data/lib/directory_paradise/project/project.rb +0 -0
- data/lib/directory_paradise/report/report.rb +1460 -113
- data/lib/directory_paradise/version/version.rb +2 -2
- metadata +4 -9
- data/lib/directory_paradise/report/constants.rb +0 -39
- data/lib/directory_paradise/report/initialize.rb +0 -75
- data/lib/directory_paradise/report/misc.rb +0 -675
- data/lib/directory_paradise/report/obtain.rb +0 -357
- data/lib/directory_paradise/report/reset.rb +0 -174
@@ -1,357 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'directory_paradise/report/obtain.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
require 'directory_paradise/base/base.rb'
|
8
|
-
|
9
|
-
module DirectoryParadise
|
10
|
-
|
11
|
-
class Report < Base # === DirectoryParadise::Report
|
12
|
-
|
13
|
-
# ========================================================================= #
|
14
|
-
# === n_directories?
|
15
|
-
#
|
16
|
-
# This will exclude directories with a trailing '.'
|
17
|
-
# ========================================================================= #
|
18
|
-
def n_directories?
|
19
|
-
directories = directories?.reject {|entry| entry.end_with? '/.' }
|
20
|
-
return directories.size
|
21
|
-
end
|
22
|
-
|
23
|
-
# ========================================================================= #
|
24
|
-
# === hash_colours_for_bytes_value?
|
25
|
-
# ========================================================================= #
|
26
|
-
def hash_colours_for_bytes_value?
|
27
|
-
@internal_hash[:hash_colours_for_bytes_value]
|
28
|
-
end
|
29
|
-
|
30
|
-
# ========================================================================= #
|
31
|
-
# === report_filesize?
|
32
|
-
# ========================================================================= #
|
33
|
-
def report_filesize?
|
34
|
-
@internal_hash[:report_filesize]
|
35
|
-
end; alias report_the_total_filesize? report_filesize? # === report_the_total_filesize?
|
36
|
-
|
37
|
-
# ========================================================================= #
|
38
|
-
# === total_filesize?
|
39
|
-
# ========================================================================= #
|
40
|
-
def total_filesize?
|
41
|
-
@internal_hash[:total_filesize]
|
42
|
-
end; alias total_file_size? total_filesize? # === total_file_size?
|
43
|
-
|
44
|
-
# ========================================================================= #
|
45
|
-
# === work_on_which_directory?
|
46
|
-
# ========================================================================= #
|
47
|
-
def work_on_which_directory?
|
48
|
-
@internal_hash[:work_on_this_directory]
|
49
|
-
end; alias from_which_directory? work_on_which_directory? # === from_which_directory?
|
50
|
-
alias base_directory? work_on_which_directory? # === base_directory?
|
51
|
-
alias input? work_on_which_directory? # === input?
|
52
|
-
alias which_directory? work_on_which_directory? # === which_directory?
|
53
|
-
alias which_dir? work_on_which_directory? # === which_dir?
|
54
|
-
alias base_dir? work_on_which_directory? # === base_dir?
|
55
|
-
alias dir? work_on_which_directory? # === dir?
|
56
|
-
|
57
|
-
# ========================================================================= #
|
58
|
-
# === symlinks?
|
59
|
-
# ========================================================================= #
|
60
|
-
def symlinks?
|
61
|
-
@internal_hash[:directory_content].symlinks?
|
62
|
-
end
|
63
|
-
|
64
|
-
# ========================================================================= #
|
65
|
-
# === n_symlinks?
|
66
|
-
# ========================================================================= #
|
67
|
-
def n_symlinks?
|
68
|
-
symlinks?.size
|
69
|
-
end
|
70
|
-
|
71
|
-
# ========================================================================= #
|
72
|
-
# === directories?
|
73
|
-
# ========================================================================= #
|
74
|
-
def directories? # Feedback all available directories here.
|
75
|
-
@internal_hash[:directory_content].directories?
|
76
|
-
end
|
77
|
-
|
78
|
-
# ========================================================================= #
|
79
|
-
# === files?
|
80
|
-
#
|
81
|
-
# Query for all available files, by delegating towards class
|
82
|
-
# DirectoryContent.
|
83
|
-
# ========================================================================= #
|
84
|
-
def files?
|
85
|
-
@internal_hash[:directory_content].files?
|
86
|
-
end
|
87
|
-
|
88
|
-
# ========================================================================= #
|
89
|
-
# === n_files?
|
90
|
-
# ========================================================================= #
|
91
|
-
def n_files?
|
92
|
-
files?.size
|
93
|
-
end
|
94
|
-
|
95
|
-
# ========================================================================= #
|
96
|
-
# === show_statistics?
|
97
|
-
# ========================================================================= #
|
98
|
-
def show_statistics?
|
99
|
-
@internal_hash[:show_statistics]
|
100
|
-
end
|
101
|
-
|
102
|
-
# ========================================================================= #
|
103
|
-
# === return_directory_content
|
104
|
-
# ========================================================================= #
|
105
|
-
def return_directory_content(
|
106
|
-
i = @internal_hash[:work_on_this_directory]
|
107
|
-
)
|
108
|
-
obtain_from_directory_content(i)
|
109
|
-
consider_sorting
|
110
|
-
_ = @internal_hash[:directory_content].entries?
|
111
|
-
return _
|
112
|
-
end; alias gather_content return_directory_content # === gather_content
|
113
|
-
alias gather return_directory_content # === gather
|
114
|
-
alias run_main_loop return_directory_content # === run_main_loop
|
115
|
-
alias obtain_directory_listing return_directory_content # === obtain_directory_listing
|
116
|
-
alias obtain_entries return_directory_content # === obtain_entries
|
117
|
-
|
118
|
-
# ========================================================================= #
|
119
|
-
# === display_content?
|
120
|
-
# ========================================================================= #
|
121
|
-
def display_content?
|
122
|
-
@internal_hash[:display_content]
|
123
|
-
end
|
124
|
-
|
125
|
-
# ========================================================================= #
|
126
|
-
# === directory_content?
|
127
|
-
# ========================================================================= #
|
128
|
-
def directory_content?
|
129
|
-
@internal_hash[:directory_content]
|
130
|
-
end
|
131
|
-
|
132
|
-
# ========================================================================= #
|
133
|
-
# === obtain_from_directory_content
|
134
|
-
# ========================================================================= #
|
135
|
-
def obtain_from_directory_content(i)
|
136
|
-
@internal_hash[:directory_content].obtain_from(i)
|
137
|
-
end
|
138
|
-
|
139
|
-
# ========================================================================= #
|
140
|
-
# === show_permissionsbits?
|
141
|
-
# ========================================================================= #
|
142
|
-
def show_permission_bits?
|
143
|
-
@internal_hash[:show_permission_bits]
|
144
|
-
end; alias show_permissions? show_permission_bits? # === show_permissions?
|
145
|
-
|
146
|
-
# ========================================================================= #
|
147
|
-
# === display_only_directories?
|
148
|
-
# ========================================================================= #
|
149
|
-
def display_only_directories?
|
150
|
-
@internal_hash[:display_only_directories]
|
151
|
-
end
|
152
|
-
|
153
|
-
# ========================================================================= #
|
154
|
-
# === show_hidden_files?
|
155
|
-
# ========================================================================= #
|
156
|
-
def show_hidden_files?
|
157
|
-
@internal_hash[:show_hidden_files]
|
158
|
-
end
|
159
|
-
|
160
|
-
# ========================================================================= #
|
161
|
-
# === show_index?
|
162
|
-
# ========================================================================= #
|
163
|
-
def show_index?
|
164
|
-
@internal_hash[:show_index]
|
165
|
-
end; alias use_index? show_index? # === use_index?
|
166
|
-
|
167
|
-
# ========================================================================= #
|
168
|
-
# === entries?
|
169
|
-
# ========================================================================= #
|
170
|
-
def entries?
|
171
|
-
@internal_hash[:directory_content].entries
|
172
|
-
end; alias _ entries? # === _
|
173
|
-
|
174
|
-
# ========================================================================= #
|
175
|
-
# === sort_by?
|
176
|
-
# ========================================================================= #
|
177
|
-
def sort_by?
|
178
|
-
@internal_hash[:sort_by]
|
179
|
-
end
|
180
|
-
|
181
|
-
# ========================================================================= #
|
182
|
-
# === show_dots_only_entries?
|
183
|
-
# ========================================================================= #
|
184
|
-
def show_dots_only_entries?
|
185
|
-
@internal_hash[:show_dots_only_entries]
|
186
|
-
end
|
187
|
-
|
188
|
-
# ========================================================================= #
|
189
|
-
# === show_only_symlinks?
|
190
|
-
# ========================================================================= #
|
191
|
-
def show_only_symlinks?
|
192
|
-
@internal_hash[:show_only_symlinks]
|
193
|
-
end
|
194
|
-
|
195
|
-
# ========================================================================= #
|
196
|
-
# === ignore_backups?
|
197
|
-
# ========================================================================= #
|
198
|
-
def ignore_backups?
|
199
|
-
@internal_hash[:ignore_backups]
|
200
|
-
end
|
201
|
-
|
202
|
-
# ========================================================================= #
|
203
|
-
# === collapse?
|
204
|
-
#
|
205
|
-
# The revers of whether we will show the full path or not.
|
206
|
-
# ========================================================================= #
|
207
|
-
def collapse?
|
208
|
-
!show_full_path?
|
209
|
-
end
|
210
|
-
|
211
|
-
# ========================================================================= #
|
212
|
-
# === content?
|
213
|
-
# ========================================================================= #
|
214
|
-
def content?
|
215
|
-
@internal_hash[:directory_content].content?
|
216
|
-
end; alias content content? # === content?
|
217
|
-
|
218
|
-
# ========================================================================= #
|
219
|
-
# === show_inode?
|
220
|
-
# ========================================================================= #
|
221
|
-
def show_inode?
|
222
|
-
@internal_hash[:show_inode]
|
223
|
-
end
|
224
|
-
|
225
|
-
# ========================================================================= #
|
226
|
-
# === show_full_path?
|
227
|
-
# ========================================================================= #
|
228
|
-
def show_full_path?
|
229
|
-
@internal_hash[:show_full_path]
|
230
|
-
end; alias show_full_path show_full_path? # === show_full_path
|
231
|
-
|
232
|
-
# ========================================================================= #
|
233
|
-
# === show_group_information?
|
234
|
-
# ========================================================================= #
|
235
|
-
def show_group_information?
|
236
|
-
@internal_hash[:show_group_information]
|
237
|
-
end
|
238
|
-
|
239
|
-
# ========================================================================= #
|
240
|
-
# === show_size?
|
241
|
-
# ========================================================================= #
|
242
|
-
def show_size?
|
243
|
-
@internal_hash[:show_size]
|
244
|
-
end
|
245
|
-
|
246
|
-
# ========================================================================= #
|
247
|
-
# === colourize_path?
|
248
|
-
# ========================================================================= #
|
249
|
-
def colourize_path?
|
250
|
-
@internal_hash[:colourize_path]
|
251
|
-
end
|
252
|
-
|
253
|
-
# ========================================================================= #
|
254
|
-
# === show_permission_bits?
|
255
|
-
# ========================================================================= #
|
256
|
-
def show_permission_bits?
|
257
|
-
@internal_hash[:show_permission_bits]
|
258
|
-
end
|
259
|
-
|
260
|
-
# ========================================================================= #
|
261
|
-
# === show_header?
|
262
|
-
#
|
263
|
-
# Whether we will show the header or whether we will not. That header
|
264
|
-
# is not typical for the normal GNU "ls" command, hence why we need
|
265
|
-
# to have such an option.
|
266
|
-
# ========================================================================= #
|
267
|
-
def show_header?
|
268
|
-
@internal_hash[:show_header]
|
269
|
-
end
|
270
|
-
|
271
|
-
# ========================================================================= #
|
272
|
-
# === colourize_kb_and_mb?
|
273
|
-
# ========================================================================= #
|
274
|
-
def colourize_kb_and_mb?
|
275
|
-
@internal_hash[:colourize_kb_and_mb]
|
276
|
-
end
|
277
|
-
|
278
|
-
# ========================================================================= #
|
279
|
-
# === stop_on_missing_symlink?
|
280
|
-
# ========================================================================= #
|
281
|
-
def stop_on_missing_symlink?
|
282
|
-
@internal_hash[:stop_on_missing_symlink]
|
283
|
-
end
|
284
|
-
|
285
|
-
# ========================================================================= #
|
286
|
-
# === result?
|
287
|
-
#
|
288
|
-
# This will show the string that can be displayed.
|
289
|
-
# ========================================================================= #
|
290
|
-
def result?
|
291
|
-
@internal_hash[:result]
|
292
|
-
end
|
293
|
-
|
294
|
-
# ========================================================================= #
|
295
|
-
# === show_condensed_permissions?
|
296
|
-
# ========================================================================= #
|
297
|
-
def show_condensed_permissions?
|
298
|
-
@internal_hash[:show_condensed_permissions]
|
299
|
-
end; alias condensed? show_condensed_permissions? # === condensed?
|
300
|
-
|
301
|
-
# ========================================================================= #
|
302
|
-
# === owner?
|
303
|
-
# ========================================================================= #
|
304
|
-
def owner?(i)
|
305
|
-
@internal_hash[:directory_content].owner?(i)
|
306
|
-
end
|
307
|
-
|
308
|
-
# ========================================================================= #
|
309
|
-
# === truncate_long_file_names?
|
310
|
-
# ========================================================================= #
|
311
|
-
def truncate_long_file_names?
|
312
|
-
@internal_hash[:truncate_long_file_names]
|
313
|
-
end
|
314
|
-
|
315
|
-
# ========================================================================= #
|
316
|
-
# === show_simplified?
|
317
|
-
# ========================================================================= #
|
318
|
-
def show_simplified?
|
319
|
-
@internal_hash[:show_simplified]
|
320
|
-
end
|
321
|
-
|
322
|
-
# ========================================================================= #
|
323
|
-
# === show_modification_time?
|
324
|
-
# ========================================================================= #
|
325
|
-
def show_modification_time?
|
326
|
-
@internal_hash[:show_modification_time]
|
327
|
-
end
|
328
|
-
|
329
|
-
# ========================================================================= #
|
330
|
-
# === show_leading_slash?
|
331
|
-
# ========================================================================= #
|
332
|
-
def show_leading_slash?
|
333
|
-
@internal_hash[:show_leading_slash]
|
334
|
-
end
|
335
|
-
|
336
|
-
# ========================================================================= #
|
337
|
-
# === colour_for_files?
|
338
|
-
# ========================================================================= #
|
339
|
-
def colour_for_files?
|
340
|
-
@internal_hash[:colour_for_files]
|
341
|
-
end
|
342
|
-
|
343
|
-
# ========================================================================= #
|
344
|
-
# === colour_for_symlinks?
|
345
|
-
# ========================================================================= #
|
346
|
-
def colour_for_symlinks?
|
347
|
-
@internal_hash[:colour_for_symlinks]
|
348
|
-
end
|
349
|
-
|
350
|
-
# ========================================================================= #
|
351
|
-
# === colour_for_directories?
|
352
|
-
# ========================================================================= #
|
353
|
-
def colour_for_directories?
|
354
|
-
@internal_hash[:colour_for_directories]
|
355
|
-
end
|
356
|
-
|
357
|
-
end; end
|
@@ -1,174 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'directory_paradise/report/reset.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
require 'directory_paradise/base/base.rb'
|
8
|
-
|
9
|
-
module DirectoryParadise
|
10
|
-
|
11
|
-
class Report < Base # === DirectoryParadise::Report
|
12
|
-
|
13
|
-
# ========================================================================= #
|
14
|
-
# === reset (reset tag)
|
15
|
-
# ========================================================================= #
|
16
|
-
def reset
|
17
|
-
# ======================================================================= #
|
18
|
-
# === @internal_hash
|
19
|
-
# ======================================================================= #
|
20
|
-
@internal_hash = {}
|
21
|
-
# ======================================================================= #
|
22
|
-
# === :work_on_this_directory
|
23
|
-
# ======================================================================= #
|
24
|
-
@internal_hash[:work_on_this_directory] = return_pwd
|
25
|
-
# ======================================================================= #
|
26
|
-
# === :collapse
|
27
|
-
#
|
28
|
-
# Whether to collapse or not.
|
29
|
-
# ======================================================================= #
|
30
|
-
@internal_hash[:collapse] = false
|
31
|
-
# ======================================================================= #
|
32
|
-
# === :total_filesize
|
33
|
-
# ======================================================================= #
|
34
|
-
@internal_hash[:total_filesize] = 0 # Keep the total file size.
|
35
|
-
# ======================================================================= #
|
36
|
-
# === :report_filesize
|
37
|
-
#
|
38
|
-
# Tell the user the total filesize of the listing.
|
39
|
-
# ======================================================================= #
|
40
|
-
@internal_hash[:report_filesize] = true
|
41
|
-
# ======================================================================= #
|
42
|
-
# === :default_colour
|
43
|
-
# ======================================================================= #
|
44
|
-
@internal_hash[:default_colour] = :steelblue
|
45
|
-
# ======================================================================= #
|
46
|
-
# === :colourize_kb_and_mb
|
47
|
-
# ======================================================================= #
|
48
|
-
@internal_hash[:colourize_kb_and_mb] = COLOURIZE_KB_AND_MB
|
49
|
-
# ======================================================================= #
|
50
|
-
# === :threshold_for_file_size
|
51
|
-
#
|
52
|
-
# Only honoured if @truncate_long_file_names is true.
|
53
|
-
# ======================================================================= #
|
54
|
-
@internal_hash[:threshold_for_file_size] = FILE_SIZE_THRESHOLD
|
55
|
-
# ======================================================================= #
|
56
|
-
# === :show_group_information
|
57
|
-
# ======================================================================= #
|
58
|
-
@internal_hash[:show_group_information] = true
|
59
|
-
# ======================================================================= #
|
60
|
-
# === :show_modification_time
|
61
|
-
#
|
62
|
-
# if true then we show the modification time of the inode in question.
|
63
|
-
# ======================================================================= #
|
64
|
-
@internal_hash[:show_modification_time] = true
|
65
|
-
# ======================================================================= #
|
66
|
-
# === :use_colours
|
67
|
-
# ======================================================================= #
|
68
|
-
@internal_hash[:use_colours] = true
|
69
|
-
# ======================================================================= #
|
70
|
-
# === :show_leading_slash
|
71
|
-
#
|
72
|
-
# Show the leading slash in / directory.
|
73
|
-
# ======================================================================= #
|
74
|
-
@internal_hash[:show_leading_slash] = false
|
75
|
-
# ======================================================================= #
|
76
|
-
# === :sort_by
|
77
|
-
#
|
78
|
-
# This value must be nil initially, so that we will not do any
|
79
|
-
# sorting at all whatsoever.
|
80
|
-
# ======================================================================= #
|
81
|
-
@internal_hash[:sort_by] = nil
|
82
|
-
# ======================================================================= #
|
83
|
-
# === :show_only_symlinks
|
84
|
-
# ======================================================================= #
|
85
|
-
@internal_hash[:show_only_symlinks] = false
|
86
|
-
# ======================================================================= #
|
87
|
-
# === truncate_long_file_names
|
88
|
-
#
|
89
|
-
# If true, we truncate too-long file names.
|
90
|
-
# ======================================================================= #
|
91
|
-
@internal_hash[:truncate_long_file_names] = false
|
92
|
-
# ======================================================================= #
|
93
|
-
# === :show_simplified
|
94
|
-
#
|
95
|
-
# The following variable tells this class to keep a simplified directory
|
96
|
-
# layout.
|
97
|
-
#
|
98
|
-
# If it is true, then we only display a short variant of the file
|
99
|
-
# content.
|
100
|
-
# ======================================================================= #
|
101
|
-
@internal_hash[:show_simplified] = true
|
102
|
-
# ======================================================================= #
|
103
|
-
# === :colour_for_symlinks
|
104
|
-
# ======================================================================= #
|
105
|
-
@internal_hash[:colour_for_symlinks] = Colours.colour_for_symlinks
|
106
|
-
# ======================================================================= #
|
107
|
-
# === :show_size
|
108
|
-
#
|
109
|
-
# Whether to show the size of the entry at hand.
|
110
|
-
# ======================================================================= #
|
111
|
-
@internal_hash[:show_size] = true
|
112
|
-
# ======================================================================= #
|
113
|
-
# === :colourize_kb_and_mb
|
114
|
-
# ======================================================================= #
|
115
|
-
@internal_hash[:colourize_kb_and_mb] = true
|
116
|
-
# ======================================================================= #
|
117
|
-
# === :show_header
|
118
|
-
# ======================================================================= #
|
119
|
-
@internal_hash[:show_header] = true
|
120
|
-
# ======================================================================= #
|
121
|
-
# === :show_index
|
122
|
-
#
|
123
|
-
# Whether to show a leading index or not. I like this, so it is on
|
124
|
-
# by default.
|
125
|
-
# ======================================================================= #
|
126
|
-
@internal_hash[:show_index] = true
|
127
|
-
# ======================================================================= #
|
128
|
-
# === :colourize_path
|
129
|
-
#
|
130
|
-
# If the next variable is set to true then the path, such as
|
131
|
-
# /foo/bar.md will be colourized when .report() is called.
|
132
|
-
# ======================================================================= #
|
133
|
-
@internal_hash[:colourize_path] = true
|
134
|
-
# ======================================================================= #
|
135
|
-
# === :show_permission_bits
|
136
|
-
#
|
137
|
-
# If the following variable is set to true then the entry at hand
|
138
|
-
# will show inclusive "drwxr-xr-x".
|
139
|
-
# ======================================================================= #
|
140
|
-
@internal_hash[:show_permission_bits] = true
|
141
|
-
# ======================================================================= #
|
142
|
-
# === :show_dots_only_entries
|
143
|
-
#
|
144
|
-
# This setting filters away '.' and '..' from the result.
|
145
|
-
# ======================================================================= #
|
146
|
-
@internal_hash[:show_dots_only_entries] = false
|
147
|
-
# ======================================================================= #
|
148
|
-
# === :show_statistics
|
149
|
-
# ======================================================================= #
|
150
|
-
@internal_hash[:show_statistics] = true
|
151
|
-
# ======================================================================= #
|
152
|
-
# === :directory_content
|
153
|
-
#
|
154
|
-
# This variable will keep a reference to class
|
155
|
-
# DirectoryParadise::Content.
|
156
|
-
# ======================================================================= #
|
157
|
-
@internal_hash[:directory_content] = DirectoryParadise::Content.new
|
158
|
-
# ======================================================================= #
|
159
|
-
# === :hash_colours_for_bytes_value
|
160
|
-
#
|
161
|
-
# We need to capture this here because we may try to want to sanitize
|
162
|
-
# the given values, such as when the user types an incorrect colour,
|
163
|
-
# like "mediumpurples" rather than "mediumpurple".
|
164
|
-
# ======================================================================= #
|
165
|
-
@internal_hash[:hash_colours_for_bytes_value] = HASH_COLOURS_FOR_BYTES_VALUE
|
166
|
-
do_not_show_hidden_files # Do not show hidden files by default.
|
167
|
-
do_show_header
|
168
|
-
do_show_index
|
169
|
-
do_show_modification_time
|
170
|
-
do_show_the_content
|
171
|
-
do_not_stop_on_missing_symlink
|
172
|
-
end
|
173
|
-
|
174
|
-
end; end
|