directory_paradise 1.4.5
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.
- checksums.yaml +7 -0
- data/README.md +228 -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 +228 -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/menu.rb +329 -0
- data/lib/directory_paradise/report/report.rb +1874 -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 +105 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'directory_paradise/project/project.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module DirectoryParadise
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === PROJECT_BASE_DIRECTORY
|
11
|
+
# ========================================================================= #
|
12
|
+
PROJECT_BASE_DIRECTORY =
|
13
|
+
File.absolute_path("#{__dir__}/..")+'/'
|
14
|
+
|
15
|
+
# ========================================================================= #
|
16
|
+
# === DirectoryParadise.project_base_directory?
|
17
|
+
# ========================================================================= #
|
18
|
+
def self.project_base_directory?
|
19
|
+
PROJECT_BASE_DIRECTORY
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,329 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'directory_paradise/report/menu.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'directory_paradise/base/base.rb'
|
8
|
+
|
9
|
+
module DirectoryParadise
|
10
|
+
|
11
|
+
class Report < Base # === DirectoryParadise::Report
|
12
|
+
|
13
|
+
# ========================================================================= #
|
14
|
+
# === menu (menu tag, men tag, m tag)
|
15
|
+
#
|
16
|
+
# This method will check the given input, which is assumed to come
|
17
|
+
# from the user, against a specific action (usually a method call).
|
18
|
+
# ========================================================================= #
|
19
|
+
def menu(
|
20
|
+
i = commandline_arguments?
|
21
|
+
)
|
22
|
+
if i.is_a? Array
|
23
|
+
i.each {|entry| menu(entry) }
|
24
|
+
else
|
25
|
+
case i # case tag
|
26
|
+
# ===================================================================== #
|
27
|
+
# === sdc --noheader
|
28
|
+
# ===================================================================== #
|
29
|
+
when '2',
|
30
|
+
/^-?-?no(_|-| )?header/,
|
31
|
+
'no_header',
|
32
|
+
'nobullshit',
|
33
|
+
'pure'
|
34
|
+
dont_show_header
|
35
|
+
# ===================================================================== #
|
36
|
+
# === sdc --truncate
|
37
|
+
# ===================================================================== #
|
38
|
+
when '7',
|
39
|
+
/^-?-?truncate$/,
|
40
|
+
'truncate_long_file_names',
|
41
|
+
'tlong'
|
42
|
+
do_truncate_long_file_names
|
43
|
+
# ===================================================================== #
|
44
|
+
# === sdc --collapse
|
45
|
+
# ===================================================================== #
|
46
|
+
when '11',
|
47
|
+
/^-?-?collapse$/i,
|
48
|
+
/^-?-?do(_|-| )?shorten$/i,
|
49
|
+
/^-?-?shorten$/i,
|
50
|
+
'colla',
|
51
|
+
'coll',
|
52
|
+
'col',
|
53
|
+
'co',
|
54
|
+
'c',
|
55
|
+
'shorten',
|
56
|
+
'l',
|
57
|
+
'do_shorten_display'
|
58
|
+
do_shorten_display # Added this option in August 2012.
|
59
|
+
# ===================================================================== #
|
60
|
+
# === sdc *ru*
|
61
|
+
#
|
62
|
+
# When it has at least one *, enter here. Input such as: '*ru*'
|
63
|
+
#
|
64
|
+
# Note that this does not work in bash directly, as bash will replace
|
65
|
+
# all '*' with the corresponding entries.
|
66
|
+
#
|
67
|
+
# Example:
|
68
|
+
#
|
69
|
+
# tocd; sdc *ru*
|
70
|
+
#
|
71
|
+
# Or in plain ruby:
|
72
|
+
#
|
73
|
+
# require 'directory_paradise'; Dir.chdir('/home/x/src/'); DirectoryParadise::Report.new('*ru*')
|
74
|
+
# require 'directory_paradise'; Dir.chdir('/Depot/j/'); DirectoryParadise::Report.new('g*')
|
75
|
+
#
|
76
|
+
# ===================================================================== #
|
77
|
+
when /\*+/
|
78
|
+
target = work_on_which_directory?+i
|
79
|
+
entries = Dir[target]
|
80
|
+
hash = directory_content?.build_up_a_hash_from_these_files(entries)
|
81
|
+
report(hash)
|
82
|
+
do_not_display_content # To prevent "regular" report() from triggering again.
|
83
|
+
# ===================================================================== #
|
84
|
+
# === sdc --noreport
|
85
|
+
# ===================================================================== #
|
86
|
+
when 'noreport'
|
87
|
+
do_not_report_filesize
|
88
|
+
# ===================================================================== #
|
89
|
+
# === sdc --no-group
|
90
|
+
# ===================================================================== #
|
91
|
+
when '-G','--no-group','nogroup' # Inhibit display of group information
|
92
|
+
do_not_show_group_information
|
93
|
+
# ===================================================================== #
|
94
|
+
# === sdc --nogroups
|
95
|
+
# ===================================================================== #
|
96
|
+
when 'nogroups'
|
97
|
+
do_not_show_group_information
|
98
|
+
# ===================================================================== #
|
99
|
+
# === sdc --nomod
|
100
|
+
# ===================================================================== #
|
101
|
+
when 'disable_show_modification_time',
|
102
|
+
'nomod',
|
103
|
+
'dont_show_modtime',
|
104
|
+
'modtime',
|
105
|
+
'nomodtime'
|
106
|
+
disable_show_modification_time
|
107
|
+
# ===================================================================== #
|
108
|
+
# === sdc --uncondensed
|
109
|
+
# ===================================================================== #
|
110
|
+
when 'uncondensed',
|
111
|
+
'uncondense',
|
112
|
+
'uncon'
|
113
|
+
do_show_uncondensed_permissions
|
114
|
+
# ===================================================================== #
|
115
|
+
# === sdc --lead
|
116
|
+
# ===================================================================== #
|
117
|
+
when 'lead'
|
118
|
+
do_show_leading_slash
|
119
|
+
# ===================================================================== #
|
120
|
+
# === sdc --inode
|
121
|
+
# ===================================================================== #
|
122
|
+
when 'inode',
|
123
|
+
'--inode','ino'
|
124
|
+
do_show_inode
|
125
|
+
# ===================================================================== #
|
126
|
+
# === sdc --condensed
|
127
|
+
# ===================================================================== #
|
128
|
+
when /^-?-?condensed$/i,
|
129
|
+
'condense',
|
130
|
+
'con'
|
131
|
+
do_show_condensed_permissions
|
132
|
+
# ===================================================================== #
|
133
|
+
# === sdc --hide
|
134
|
+
# ===================================================================== #
|
135
|
+
when /^-?-?hide$/i
|
136
|
+
do_hide_files
|
137
|
+
# ===================================================================== #
|
138
|
+
# === sdc --all
|
139
|
+
# ===================================================================== #
|
140
|
+
when '6',
|
141
|
+
'show_hidden_files',
|
142
|
+
'show',
|
143
|
+
'hidden',
|
144
|
+
'unhide',
|
145
|
+
's',
|
146
|
+
'include_hidden',
|
147
|
+
'all',
|
148
|
+
'-a',
|
149
|
+
'-A',
|
150
|
+
'showhidden',
|
151
|
+
'--almost-all',
|
152
|
+
/^-?-?all$/i,
|
153
|
+
/^-?-?show$/i,
|
154
|
+
/^-?-?unhide$/i
|
155
|
+
do_show_hidden_files
|
156
|
+
# ===================================================================== #
|
157
|
+
# === sdc --only-symlinks
|
158
|
+
# ===================================================================== #
|
159
|
+
when /^-?-?only(_|-| )?symlinks$/i,
|
160
|
+
/^-?-?show(_|-| )?only(_|-| )?symlinks$/i
|
161
|
+
do_show_only_symlinks
|
162
|
+
# ===================================================================== #
|
163
|
+
# === sdc ls
|
164
|
+
#
|
165
|
+
# This is synonymous to bash/zsh "ls".
|
166
|
+
# ===================================================================== #
|
167
|
+
when 'ls'
|
168
|
+
do_not_show_the_index
|
169
|
+
dont_show_header
|
170
|
+
# ===================================================================== #
|
171
|
+
# === sdc --noowner
|
172
|
+
# ===================================================================== #
|
173
|
+
when 'nowner',
|
174
|
+
'nown',
|
175
|
+
/^-?-?noowner$/i
|
176
|
+
do_not_show_the_owner
|
177
|
+
# ===================================================================== #
|
178
|
+
# === sdc almost_nothing
|
179
|
+
# ===================================================================== #
|
180
|
+
when 'almost_nothin',
|
181
|
+
'nothing'
|
182
|
+
do_show_almost_nothing
|
183
|
+
# ===================================================================== #
|
184
|
+
# === sdc --toggle
|
185
|
+
# ===================================================================== #
|
186
|
+
when '3',
|
187
|
+
/^-?-?toggle$/i,
|
188
|
+
'to',
|
189
|
+
'tog',
|
190
|
+
't',
|
191
|
+
'--permission',
|
192
|
+
'permission'
|
193
|
+
toggle_permission
|
194
|
+
# ===================================================================== #
|
195
|
+
# === sdc --only-directories
|
196
|
+
# ===================================================================== #
|
197
|
+
when '5',
|
198
|
+
'only_dirs',
|
199
|
+
'od',
|
200
|
+
'onlydirs',
|
201
|
+
'onlydir',
|
202
|
+
'dironly',
|
203
|
+
'dirs?',
|
204
|
+
'only_dir',
|
205
|
+
'dir','--directory',
|
206
|
+
'directory',
|
207
|
+
/^-?-?only(_|-| )?directories$/i
|
208
|
+
only_directories
|
209
|
+
# ===================================================================== #
|
210
|
+
# === sdc --no-index
|
211
|
+
# ===================================================================== #
|
212
|
+
when '1',
|
213
|
+
/^-?-?no(_|-| )?index$/i,
|
214
|
+
'index',
|
215
|
+
'do_not_show_the_index'
|
216
|
+
dont_show_index
|
217
|
+
# ===================================================================== #
|
218
|
+
# === sdc --disable-colours
|
219
|
+
#
|
220
|
+
# Alternative:
|
221
|
+
#
|
222
|
+
# sdc --nocol
|
223
|
+
#
|
224
|
+
# ===================================================================== #
|
225
|
+
when '4',
|
226
|
+
'disable_colours',
|
227
|
+
'nocolours',
|
228
|
+
/^-?-?nocol/,
|
229
|
+
'nocols',
|
230
|
+
'noco',
|
231
|
+
'no_col',
|
232
|
+
'dcol'
|
233
|
+
disable_colours
|
234
|
+
# ===================================================================== #
|
235
|
+
# === sdc --reversed
|
236
|
+
# ===================================================================== #
|
237
|
+
when '-r',
|
238
|
+
'--reverse', # sdc --reverse
|
239
|
+
/^-?-?reversed/
|
240
|
+
do_sort_reversed
|
241
|
+
# ===================================================================== #
|
242
|
+
# === sdc --sort-by-date
|
243
|
+
# ===================================================================== #
|
244
|
+
when /^-?-?sort(_|-| )?by(_|-| )?date$/,
|
245
|
+
/^-?-?DATE/i,
|
246
|
+
'latest',
|
247
|
+
'-t',
|
248
|
+
'sort_by_modification_time',
|
249
|
+
/^-?-?DATED/i
|
250
|
+
sort_how :by_date
|
251
|
+
# ===================================================================== #
|
252
|
+
# === sdc --simplified
|
253
|
+
# ===================================================================== #
|
254
|
+
when '8',
|
255
|
+
/^-?-?simplified$/i
|
256
|
+
do_not_show_permissions
|
257
|
+
do_not_show_size
|
258
|
+
do_not_show_modtime
|
259
|
+
do_not_show_the_index
|
260
|
+
# ===================================================================== #
|
261
|
+
# === sdc --ignore-backups
|
262
|
+
# ===================================================================== #
|
263
|
+
when /^-?-?ignore(-|_)?backups/i,
|
264
|
+
'-B',
|
265
|
+
'--ignore-backup', # Do not list implied entries ending with ~
|
266
|
+
'ignorebackups',
|
267
|
+
'ignorebackup'
|
268
|
+
ignore_backups
|
269
|
+
# ===================================================================== #
|
270
|
+
# === sdc
|
271
|
+
# ===================================================================== #
|
272
|
+
when '' # run normally, make no change to the default settings.
|
273
|
+
# ===================================================================== #
|
274
|
+
# === sdc --test
|
275
|
+
# ===================================================================== #
|
276
|
+
when /^-?-?test$/i # This is just for testing purposes.
|
277
|
+
dont_show_full_path
|
278
|
+
dont_show_modification_time
|
279
|
+
# ===================================================================== #
|
280
|
+
# === sdc --do_show_full_path
|
281
|
+
# ===================================================================== #
|
282
|
+
when 'do_show_full_path',
|
283
|
+
'show_full_path',
|
284
|
+
'full_path',
|
285
|
+
'fullpath',
|
286
|
+
'fpath',
|
287
|
+
/^-?-?detail$/i,
|
288
|
+
/^-?-?full$/i
|
289
|
+
do_show_full_path
|
290
|
+
# ===================================================================== #
|
291
|
+
# === sdc --compact
|
292
|
+
# ===================================================================== #
|
293
|
+
when /^-?-?compact$/i,
|
294
|
+
/^-?-?s1$/,
|
295
|
+
/^-?-?l1$/
|
296
|
+
do_show_almost_nothing # As below, but we also do not show the group.
|
297
|
+
do_show_only_filename
|
298
|
+
do_not_show_the_header
|
299
|
+
do_not_show_group_information
|
300
|
+
do_not_show_the_owner
|
301
|
+
# ===================================================================== #
|
302
|
+
# === sdc --help
|
303
|
+
# ===================================================================== #
|
304
|
+
when /^-?-?help$/i,
|
305
|
+
'?'
|
306
|
+
show_help_options
|
307
|
+
# ===================================================================== #
|
308
|
+
# === sdc --dont_show_full_path
|
309
|
+
# ===================================================================== #
|
310
|
+
when /^-?-?not(_|-| )?full(_|-| )?path$/i,
|
311
|
+
/^-?-?dont(_|-| )?show(_|-| )?full(_|-| )?path/,
|
312
|
+
/^-?-?file(_|-| )?name(_|-| )?only$/,
|
313
|
+
'small',
|
314
|
+
'short',
|
315
|
+
'not_full',
|
316
|
+
'nofull',
|
317
|
+
'nof'
|
318
|
+
do_not_show_full_path
|
319
|
+
# ===================================================================== #
|
320
|
+
# === sdc --SIZE
|
321
|
+
# ===================================================================== #
|
322
|
+
when /^-?-?sized$/i,
|
323
|
+
/^-?-?size$/i
|
324
|
+
do_sort_by_size
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
end; end
|