program_information 1.2.6 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/program_information_version +10 -0
- data/lib/program_information/program_information.rb +236 -83
- data/lib/program_information/toplevel_methods.rb +15 -1
- data/lib/program_information/version/version.rb +2 -2
- metadata +5 -9
- data/lib/program_information/initialize.rb +0 -43
- data/lib/program_information/menu.rb +0 -29
- data/lib/program_information/report.rb +0 -48
- data/lib/program_information/reset.rb +0 -46
- data/lib/program_information/run.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 423c820d72bf99567ed7ab239d47d8cf3e20d231cfa84ac5ccd1527f9b885eaa
|
4
|
+
data.tar.gz: 87738e4b3c93b518d90b59eba295103b9a34207714fafdb672c68611d8273062
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daa4357e1b473e0ad288774a986f6b507fc36199fa873974763b94665007209fbb4ce6d531eb02929b7e6d71e002953a70f091f57c80a6442ab84a0a7d4deb6c
|
7
|
+
data.tar.gz: 30681fae85df29685ad5824fa59087d47ee8d8106d3ec0624c0985b74bbab84842fa5ef1f9e7552954391bb98eb9220d247fbe660b577c45998ab332d28585b4
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
require 'program_information'
|
6
|
+
|
7
|
+
if ARGV.first
|
8
|
+
_ = ProgramInformation::ProgramInformation.new(ARGV)
|
9
|
+
puts _.program_version?
|
10
|
+
end
|
@@ -43,37 +43,161 @@ class ProgramInformation # === ProgramInformation::ProgramInformation
|
|
43
43
|
require 'program_information/toplevel_methods/remove_archive_type.rb'
|
44
44
|
require 'program_information/constants/constants.rb'
|
45
45
|
require 'program_information/version/version.rb'
|
46
|
-
require 'program_information/initialize.rb'
|
47
|
-
require 'program_information/menu.rb'
|
48
|
-
require 'program_information/reset.rb'
|
49
|
-
require 'program_information/report.rb'
|
50
|
-
require 'program_information/run.rb'
|
51
46
|
|
52
|
-
#
|
47
|
+
# ========================================================================== #
|
48
|
+
# === initialize
|
49
|
+
#
|
50
|
+
# Specific usage example:
|
51
|
+
#
|
52
|
+
# ProgramInformation::ProgramInformation.new('util-linux-ng-2.15')
|
53
|
+
#
|
54
|
+
# ========================================================================== #
|
55
|
+
def initialize(
|
56
|
+
i = ARGV,
|
57
|
+
run_already = true,
|
58
|
+
optional_be_verbose = false
|
59
|
+
)
|
60
|
+
reset
|
61
|
+
if optional_be_verbose
|
62
|
+
set_be_verbose(optional_be_verbose)
|
63
|
+
end
|
64
|
+
set_input(i)
|
65
|
+
case run_already
|
66
|
+
# ======================================================================= #
|
67
|
+
# === :do_run_already
|
68
|
+
# ======================================================================= #
|
69
|
+
when :do_run_already
|
70
|
+
run_already = true
|
71
|
+
# ======================================================================= #
|
72
|
+
# === :dont_run_already
|
73
|
+
# ======================================================================= #
|
74
|
+
when :dont_run_already,
|
75
|
+
:do_not_run_already
|
76
|
+
run_already = false
|
77
|
+
end
|
78
|
+
run if run_already
|
79
|
+
end
|
80
|
+
|
81
|
+
# ========================================================================== #
|
82
|
+
# === reset (reset tag)
|
83
|
+
# ========================================================================== #
|
84
|
+
def reset
|
85
|
+
set_be_verbose
|
86
|
+
# ======================================================================= #
|
87
|
+
# === @short_name
|
88
|
+
# ======================================================================= #
|
89
|
+
@short_name = nil
|
90
|
+
# ======================================================================= #
|
91
|
+
# === @real_short_name
|
92
|
+
# ======================================================================= #
|
93
|
+
@real_short_name = nil
|
94
|
+
# ======================================================================= #
|
95
|
+
# === @program_version
|
96
|
+
# ======================================================================= #
|
97
|
+
@program_version = nil
|
98
|
+
set_shall_we_downcase # Should become before set_input().
|
99
|
+
# ======================================================================= #
|
100
|
+
# === @remove_plus_and_minus
|
101
|
+
# ======================================================================= #
|
102
|
+
@remove_plus_and_minus = REMOVE_PLUS_AND_MINUS
|
103
|
+
# ======================================================================= #
|
104
|
+
# === @replace_plus_with_long_name
|
105
|
+
# ======================================================================= #
|
106
|
+
@replace_plus_with_long_name = REPLACE_PLUS_WITH_LONG_NAME
|
107
|
+
# ======================================================================= #
|
108
|
+
# === @remove_plus_token
|
109
|
+
# ======================================================================= #
|
110
|
+
@remove_plus_token = REMOVE_PLUS_TOKEN
|
111
|
+
if @remove_plus_and_minus # Overrule always in this case.
|
112
|
+
@replace_plus_with_long_name = false
|
113
|
+
end
|
114
|
+
if @remove_plus_and_minus
|
115
|
+
@remove_plus_token = false
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# ========================================================================== #
|
120
|
+
# === menu (menu tag)
|
121
|
+
# ========================================================================== #
|
122
|
+
def menu(i)
|
123
|
+
if i.is_a? Array
|
124
|
+
i.each {|entry| menu(entry) }
|
125
|
+
else
|
126
|
+
case i
|
127
|
+
# ===================================================================== #
|
128
|
+
# === help
|
129
|
+
# ===================================================================== #
|
130
|
+
when /-?-?help$/i
|
131
|
+
show_help
|
132
|
+
exit
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# ========================================================================== #
|
138
|
+
# === report (debug tag, report tag)
|
139
|
+
# ========================================================================== #
|
140
|
+
def report(
|
141
|
+
be_verbose = be_verbose?
|
142
|
+
)
|
143
|
+
case be_verbose
|
144
|
+
when :do_report, :be_verbose
|
145
|
+
be_verbose = true
|
146
|
+
end
|
147
|
+
lpad = 90
|
148
|
+
rpad = 49
|
149
|
+
if be_verbose
|
150
|
+
inner_ljust = 28
|
151
|
+
# ===================================================================== #
|
152
|
+
# === real short name
|
153
|
+
# ===================================================================== #
|
154
|
+
e (NAME_OF_CLASS+(' Program real short name ').ljust(inner_ljust)+'('+
|
155
|
+
yellow?+'@real_short_name'+rev+') is: ').ljust(lpad)+
|
156
|
+
(apostroph?+real_short_name?+apostroph?).
|
157
|
+
ljust(rpad)
|
158
|
+
# ===================================================================== #
|
159
|
+
# === short name
|
160
|
+
# ===================================================================== #
|
161
|
+
e (
|
162
|
+
NAME_OF_CLASS+(' Program name').ljust(inner_ljust)+'('+
|
163
|
+
yellow?+'@short_name'+rev+' ) is: '
|
164
|
+
).ljust(lpad)+(apostroph?+short_name?+apostroph?).
|
165
|
+
ljust(rpad)
|
166
|
+
# ===================================================================== #
|
167
|
+
# === program version
|
168
|
+
# ===================================================================== #
|
169
|
+
e (NAME_OF_CLASS+(' Program version ').ljust(inner_ljust)+'('+
|
170
|
+
yellow?+'@program_version'+rev+') is: ').ljust(lpad)+
|
171
|
+
(apostroph?+version?+apostroph?).
|
172
|
+
ljust(rpad)
|
173
|
+
end
|
174
|
+
end; alias report_result report # === report_result
|
175
|
+
|
176
|
+
# ========================================================================== #
|
53
177
|
# === return_proper_pipe_token_to_this_input
|
54
|
-
#
|
178
|
+
# ========================================================================== #
|
55
179
|
def return_proper_pipe_token_to_this_input(i)
|
56
180
|
::ProgramInformation.return_proper_pipe_token_to_this_input(i)
|
57
181
|
end
|
58
182
|
|
59
|
-
#
|
183
|
+
# ========================================================================== #
|
60
184
|
# === remove_file_suffix
|
61
185
|
#
|
62
186
|
# Delegate towards class RemoveFileSuffix. This is easier to handle
|
63
187
|
# Archive.
|
64
|
-
#
|
188
|
+
# ========================================================================== #
|
65
189
|
def remove_file_suffix(i)
|
66
190
|
RemoveFileSuffix[i.to_s]
|
67
191
|
end
|
68
192
|
|
69
|
-
#
|
193
|
+
# ========================================================================== #
|
70
194
|
# === do_not_replace_plus
|
71
|
-
#
|
195
|
+
# ========================================================================== #
|
72
196
|
def do_not_replace_plus
|
73
197
|
@replace_plus_with_long_name = false
|
74
198
|
end; alias do_not_replace_anything do_not_replace_plus # === do_not_replace_anything
|
75
199
|
|
76
|
-
#
|
200
|
+
# ========================================================================== #
|
77
201
|
# === set_program_version
|
78
202
|
#
|
79
203
|
# Use this method whenever you wish to assign to the @program_version
|
@@ -87,7 +211,7 @@ class ProgramInformation # === ProgramInformation::ProgramInformation
|
|
87
211
|
# Until March 2015 we also replaced all '_' with '.' characters,
|
88
212
|
# but input such as "ncbi_cxx--12_0_0.tar.gz" would break as a
|
89
213
|
# consequence, so this was disabled again.
|
90
|
-
#
|
214
|
+
# ========================================================================== #
|
91
215
|
def set_program_version(i)
|
92
216
|
i = remove_file_suffix(i) unless i.nil? # Disallow archive-types here.
|
93
217
|
# ======================================================================= #
|
@@ -110,88 +234,88 @@ class ProgramInformation # === ProgramInformation::ProgramInformation
|
|
110
234
|
@program_version = i
|
111
235
|
end; alias set_version set_program_version # === set_version
|
112
236
|
|
113
|
-
#
|
237
|
+
# ========================================================================== #
|
114
238
|
# === be_verbose?
|
115
|
-
#
|
239
|
+
# ========================================================================== #
|
116
240
|
def be_verbose?
|
117
241
|
@be_verbose
|
118
242
|
end
|
119
243
|
|
120
|
-
#
|
244
|
+
# ========================================================================== #
|
121
245
|
# === remove_plus_token?
|
122
|
-
#
|
246
|
+
# ========================================================================== #
|
123
247
|
def remove_plus_token?
|
124
248
|
@remove_plus_token
|
125
249
|
end
|
126
250
|
|
127
|
-
#
|
251
|
+
# ========================================================================== #
|
128
252
|
# === input?
|
129
|
-
#
|
253
|
+
# ========================================================================== #
|
130
254
|
def input?
|
131
255
|
@input
|
132
256
|
end
|
133
257
|
|
134
|
-
#
|
258
|
+
# ========================================================================== #
|
135
259
|
# === return_array
|
136
260
|
#
|
137
261
|
# This method will return a composite, 3-member Array that will hold the
|
138
262
|
# short_name, the real_short_name, and the program_version.
|
139
|
-
#
|
263
|
+
# ========================================================================== #
|
140
264
|
def return_array
|
141
265
|
[ short_name?, real_short_name?, program_version? ]
|
142
266
|
end; alias array? return_array # === array?
|
143
267
|
|
144
|
-
#
|
268
|
+
# ========================================================================== #
|
145
269
|
# === remove_plus_and_minus?
|
146
|
-
#
|
270
|
+
# ========================================================================== #
|
147
271
|
def remove_plus_and_minus?
|
148
272
|
@remove_plus_and_minus
|
149
273
|
end; alias remove_plus_and_minus remove_plus_and_minus? # === remove_plus_and_minus
|
150
274
|
|
151
|
-
#
|
275
|
+
# ========================================================================== #
|
152
276
|
# === apostroph?
|
153
|
-
#
|
277
|
+
# ========================================================================== #
|
154
278
|
def apostroph?
|
155
279
|
APOSTROPH
|
156
280
|
end
|
157
281
|
|
158
|
-
#
|
282
|
+
# ========================================================================== #
|
159
283
|
# === replace_plus_with_long_name?
|
160
|
-
#
|
284
|
+
# ========================================================================== #
|
161
285
|
def replace_plus_with_long_name?
|
162
286
|
@replace_plus_with_long_name
|
163
287
|
end
|
164
288
|
|
165
|
-
#
|
289
|
+
# ========================================================================== #
|
166
290
|
# === short_name_and_version?
|
167
291
|
#
|
168
292
|
# This method returns an aggregated @short_name+'-'+@program_version
|
169
293
|
# string.
|
170
|
-
#
|
294
|
+
# ========================================================================== #
|
171
295
|
def short_name_and_version?
|
172
296
|
"#{short_name?}-#{program_version?}"
|
173
297
|
end; alias short_name_and_version short_name_and_version? # === short_name_and_version
|
174
298
|
|
175
|
-
#
|
299
|
+
# ========================================================================== #
|
176
300
|
# === set_short_name_then_version
|
177
301
|
#
|
178
302
|
# This method will combine two other methods.
|
179
|
-
#
|
303
|
+
# ========================================================================== #
|
180
304
|
def set_short_name_then_version(a, b)
|
181
305
|
set_short_name(a)
|
182
306
|
set_program_version(b)
|
183
307
|
end; alias set_name_then_version set_short_name_then_version # === set_name_then_version
|
184
308
|
|
185
|
-
#
|
309
|
+
# ========================================================================== #
|
186
310
|
# === return_real_short_name_and_version
|
187
311
|
#
|
188
312
|
# We delegate to the module-method here.
|
189
|
-
#
|
313
|
+
# ========================================================================== #
|
190
314
|
def return_real_short_name_and_version(i)
|
191
315
|
::ProgramInformation.return_real_short_name_and_version(i)
|
192
316
|
end
|
193
317
|
|
194
|
-
#
|
318
|
+
# ========================================================================== #
|
195
319
|
# === return_name_and_version
|
196
320
|
#
|
197
321
|
# This method will return an array with two elements:
|
@@ -240,7 +364,7 @@ class ProgramInformation # === ProgramInformation::ProgramInformation
|
|
240
364
|
# "CrownCutlass-Alpha1.4"
|
241
365
|
# unless we assume that alpha is a part of the version,
|
242
366
|
# which is possibly correct.
|
243
|
-
#
|
367
|
+
# ========================================================================== #
|
244
368
|
def return_name_and_version(i = nil)
|
245
369
|
if i
|
246
370
|
determine_the_three_main_variables(i)
|
@@ -254,40 +378,49 @@ class ProgramInformation # === ProgramInformation::ProgramInformation
|
|
254
378
|
# ======================================================================= #
|
255
379
|
# i.delete!('_') if i.include? '_'
|
256
380
|
return [
|
257
|
-
@short_name,
|
381
|
+
@short_name,
|
382
|
+
@program_version
|
258
383
|
]
|
259
384
|
end; alias rnav return_name_and_version # === rnav
|
260
385
|
|
261
|
-
#
|
386
|
+
# ========================================================================== #
|
262
387
|
# === set_shall_we_downcase
|
263
|
-
#
|
388
|
+
# ========================================================================== #
|
264
389
|
def set_shall_we_downcase(
|
265
390
|
i = SHALL_WE_DOWNCASE
|
266
391
|
)
|
267
392
|
@shall_we_downcase = i
|
268
393
|
end
|
269
394
|
|
270
|
-
#
|
395
|
+
# ========================================================================== #
|
271
396
|
# === do_not_downcase
|
272
|
-
#
|
397
|
+
# ========================================================================== #
|
273
398
|
def do_not_downcase
|
274
399
|
@shall_we_downcase = false
|
275
400
|
end
|
276
|
-
|
277
|
-
#
|
401
|
+
|
402
|
+
# ========================================================================== #
|
278
403
|
# === set_be_verbose
|
279
404
|
#
|
280
405
|
# Set to report in a verbose way here.
|
281
|
-
#
|
406
|
+
# ========================================================================== #
|
282
407
|
def set_be_verbose(i = BE_VERBOSE)
|
283
408
|
case i
|
409
|
+
# ======================================================================== #
|
410
|
+
# === :be_quiet
|
411
|
+
# ======================================================================== #
|
412
|
+
when :be_quiet
|
413
|
+
i = false
|
414
|
+
# ======================================================================== #
|
415
|
+
# === :be_verbose
|
416
|
+
# ======================================================================== #
|
284
417
|
when :be_verbose
|
285
418
|
i = true
|
286
419
|
end
|
287
420
|
@be_verbose = i
|
288
421
|
end
|
289
422
|
|
290
|
-
#
|
423
|
+
# ========================================================================== #
|
291
424
|
# === determine_the_three_main_variables
|
292
425
|
#
|
293
426
|
# This method will determine the three main instance variables:
|
@@ -304,8 +437,10 @@ class ProgramInformation # === ProgramInformation::ProgramInformation
|
|
304
437
|
# Note that presently, set_input() will modify the given input and
|
305
438
|
# ensure that there will be a '-' token, even in input that does
|
306
439
|
# not have any '-' or '_' such as in 'sendmail.8.15.2'.
|
307
|
-
#
|
308
|
-
def determine_the_three_main_variables(
|
440
|
+
# ========================================================================== #
|
441
|
+
def determine_the_three_main_variables(
|
442
|
+
i = input?
|
443
|
+
)
|
309
444
|
if i
|
310
445
|
if i.include? '|'
|
311
446
|
splitted = i.split('|')
|
@@ -314,36 +449,22 @@ class ProgramInformation # === ProgramInformation::ProgramInformation
|
|
314
449
|
set_short_name(short_name)
|
315
450
|
set_program_version(program_version)
|
316
451
|
else
|
317
|
-
|
452
|
+
set_program_version(i) if (i =~ /\d+/)
|
453
|
+
if be_verbose?
|
454
|
+
opn; e "The input `#{i}` does not include a | character."
|
455
|
+
end
|
318
456
|
end
|
319
457
|
end
|
320
458
|
end; alias determine_name_and_program_version determine_the_three_main_variables # === determine_name_and_program_version
|
321
459
|
|
322
|
-
#
|
323
|
-
# === set_real_short_name
|
324
|
-
#
|
325
|
-
# The instance variable @real_short_name is not allowed to include any
|
326
|
-
# '-' characters. It may also not include any '_' characters.
|
327
|
-
#
|
328
|
-
# The latter could be found as part of program names such as "SDL_image".
|
329
|
-
# The @short_name variant may include these '_' tokens.
|
330
|
-
#
|
331
|
-
# Note that as of September 2017, we also disallow '.' tokens, such as
|
332
|
-
# may occur accidentally in input like "sendmail.5.8.2".
|
333
|
-
# ========================================================================= #
|
334
|
-
def set_real_short_name(i = @short_name)
|
335
|
-
i = i.to_s.dup.delete('-_.').rstrip
|
336
|
-
@real_short_name = i
|
337
|
-
end
|
338
|
-
|
339
|
-
# ========================================================================= #
|
460
|
+
# ========================================================================== #
|
340
461
|
# === set_short_name
|
341
462
|
#
|
342
463
|
# Use this method whenever you wish to assign to the @short_name variable.
|
343
464
|
#
|
344
465
|
# This variable is allowed to keep '-' and '_' entries, but some
|
345
466
|
# settings may also modify this.
|
346
|
-
#
|
467
|
+
# ========================================================================== #
|
347
468
|
def set_short_name(i)
|
348
469
|
i = i.dup
|
349
470
|
# ======================================================================= #
|
@@ -372,9 +493,9 @@ class ProgramInformation # === ProgramInformation::ProgramInformation
|
|
372
493
|
end; alias set_name set_short_name # === set_name
|
373
494
|
alias set_program_name set_short_name # === set_program_name
|
374
495
|
|
375
|
-
#
|
496
|
+
# ========================================================================== #
|
376
497
|
# === remove_source_like_strings
|
377
|
-
#
|
498
|
+
# ========================================================================== #
|
378
499
|
def remove_source_like_strings(i)
|
379
500
|
# ======================================================================= #
|
380
501
|
# i.gsub!(/--/,'-') if i.include? '--' # Replace '--' with '-'.
|
@@ -386,26 +507,26 @@ class ProgramInformation # === ProgramInformation::ProgramInformation
|
|
386
507
|
return i
|
387
508
|
end
|
388
509
|
|
389
|
-
#
|
510
|
+
# ========================================================================== #
|
390
511
|
# === remove_archive_type
|
391
|
-
#
|
512
|
+
# ========================================================================== #
|
392
513
|
def remove_archive_type(i)
|
393
514
|
::ProgramInformation.remove_archive_type(i)
|
394
515
|
return i
|
395
516
|
end
|
396
517
|
|
397
|
-
#
|
518
|
+
# ========================================================================== #
|
398
519
|
# === e
|
399
|
-
#
|
520
|
+
# ========================================================================== #
|
400
521
|
def e(i = '')
|
401
522
|
::ProgramInformation.e(i)
|
402
523
|
end
|
403
524
|
|
404
|
-
#
|
525
|
+
# ========================================================================== #
|
405
526
|
# === real_short_name?
|
406
527
|
#
|
407
528
|
# Keep in mind that @real_short_name does not have any '-' tokens.
|
408
|
-
#
|
529
|
+
# ========================================================================== #
|
409
530
|
def real_short_name?
|
410
531
|
@real_short_name
|
411
532
|
end; alias real_name? real_short_name? # === real_name?
|
@@ -413,13 +534,13 @@ class ProgramInformation # === ProgramInformation::ProgramInformation
|
|
413
534
|
alias real_short_name real_short_name? # === real_short_name
|
414
535
|
alias name_of_the_program? real_short_name? # === name_of_the_program?
|
415
536
|
|
416
|
-
#
|
537
|
+
# ========================================================================== #
|
417
538
|
# === short_name?
|
418
539
|
#
|
419
540
|
# Reader method for the @short_name instance variable.
|
420
541
|
#
|
421
542
|
# short_name is an alias to @short_name.
|
422
|
-
#
|
543
|
+
# ========================================================================== #
|
423
544
|
def short_name?
|
424
545
|
@short_name
|
425
546
|
end; alias program_name short_name? # === program_name
|
@@ -432,11 +553,11 @@ class ProgramInformation # === ProgramInformation::ProgramInformation
|
|
432
553
|
alias first short_name? # === first
|
433
554
|
alias return_program_real_name short_name? # === return_program_real_name
|
434
555
|
|
435
|
-
#
|
556
|
+
# ========================================================================== #
|
436
557
|
# === program_version?
|
437
558
|
#
|
438
559
|
# Getter method for the @program_version variable.
|
439
|
-
#
|
560
|
+
# ========================================================================== #
|
440
561
|
def program_version?
|
441
562
|
@program_version
|
442
563
|
end; alias program_version program_version? # === program_version
|
@@ -446,14 +567,14 @@ class ProgramInformation # === ProgramInformation::ProgramInformation
|
|
446
567
|
alias last program_version? # === last?
|
447
568
|
alias version_of_the_program? program_version? # === version_of_the_program?
|
448
569
|
|
449
|
-
#
|
450
|
-
# === show_help
|
570
|
+
# ========================================================================== #
|
571
|
+
# === show_help (help tag)
|
451
572
|
#
|
452
573
|
# To invoke this method, try:
|
453
574
|
#
|
454
575
|
# pinfo --show-help
|
455
576
|
#
|
456
|
-
#
|
577
|
+
# ========================================================================== #
|
457
578
|
def show_help
|
458
579
|
e
|
459
580
|
e 'This class is able to split a given input (a string) into'
|
@@ -475,18 +596,19 @@ class ProgramInformation # === ProgramInformation::ProgramInformation
|
|
475
596
|
e
|
476
597
|
end
|
477
598
|
|
478
|
-
#
|
599
|
+
# ========================================================================== #
|
479
600
|
# === set_input
|
480
601
|
#
|
481
602
|
# This method will, after performing some sanitize-operations, assign
|
482
603
|
# to the @input variable.
|
483
|
-
#
|
604
|
+
# ========================================================================== #
|
484
605
|
def set_input(i)
|
485
606
|
if i.is_a? Array
|
486
607
|
menu(i)
|
487
608
|
i = i.join(' ').strip
|
488
609
|
end
|
489
610
|
i = i.to_s.dup if i.frozen?
|
611
|
+
original_input = i.dup
|
490
612
|
i = File.basename(i)
|
491
613
|
# ======================================================================= #
|
492
614
|
# We .squeeze away '--' tokens.
|
@@ -548,9 +670,40 @@ class ProgramInformation # === ProgramInformation::ProgramInformation
|
|
548
670
|
i.delete!('+') if i.include? '+'
|
549
671
|
end
|
550
672
|
i = return_proper_pipe_token_to_this_input(i)
|
673
|
+
case i
|
674
|
+
when '|' # Sanitize it in this case.
|
675
|
+
i = original_input
|
676
|
+
set_be_verbose(:be_quiet)
|
677
|
+
end
|
551
678
|
@input = i
|
552
679
|
end
|
553
680
|
|
681
|
+
# ========================================================================== #
|
682
|
+
# === set_real_short_name
|
683
|
+
#
|
684
|
+
# The instance variable @real_short_name is not allowed to include any
|
685
|
+
# '-' characters. It may also not include any '_' characters.
|
686
|
+
#
|
687
|
+
# The latter could be found as part of program names such as "SDL_image".
|
688
|
+
# The @short_name variant may include these '_' tokens.
|
689
|
+
#
|
690
|
+
# Note that as of September 2017, we also disallow '.' tokens, such as
|
691
|
+
# may occur accidentally in input like "sendmail.5.8.2".
|
692
|
+
# ========================================================================== #
|
693
|
+
def set_real_short_name(
|
694
|
+
i = @short_name
|
695
|
+
)
|
696
|
+
i = i.to_s.dup.delete('-_.').rstrip
|
697
|
+
@real_short_name = i
|
698
|
+
end
|
699
|
+
|
700
|
+
# ========================================================================== #
|
701
|
+
# === run (run tag)
|
702
|
+
# ========================================================================== #
|
703
|
+
def run
|
704
|
+
determine_the_three_main_variables
|
705
|
+
end
|
706
|
+
|
554
707
|
end
|
555
708
|
|
556
709
|
# =========================================================================== #
|
@@ -55,7 +55,9 @@ module ProgramInformation
|
|
55
55
|
#
|
56
56
|
# The above would return "isocodes".
|
57
57
|
# ========================================================================= #
|
58
|
-
def self.return_real_short_name(
|
58
|
+
def self.return_real_short_name(
|
59
|
+
of_this_program = ''
|
60
|
+
)
|
59
61
|
if of_this_program.nil? or of_this_program.empty?
|
60
62
|
opnn; e 'Please provide some input to the method '\
|
61
63
|
'ProgramInformation.return_real_short_name.'
|
@@ -96,6 +98,18 @@ module ProgramInformation
|
|
96
98
|
return array
|
97
99
|
end; self.instance_eval { alias return_short_name_and_version return_short_name_and_program_version } # === ProgramInformation.return_short_name_and__version
|
98
100
|
|
101
|
+
# ========================================================================= #
|
102
|
+
# === ProgramInformation.long_program_name?
|
103
|
+
#
|
104
|
+
# Usage example:
|
105
|
+
#
|
106
|
+
# ProgramInformation.long_program_name?('man-pages-6.7')
|
107
|
+
#
|
108
|
+
# ========================================================================= #
|
109
|
+
def self.long_program_name?(i)
|
110
|
+
return_short_name_and_version(i).first
|
111
|
+
end
|
112
|
+
|
99
113
|
# ========================================================================= #
|
100
114
|
# === ProgramInformation.return_array_name_and_version
|
101
115
|
#
|
@@ -11,12 +11,12 @@ class ProgramInformation
|
|
11
11
|
# ========================================================================= #
|
12
12
|
# === VERSION
|
13
13
|
# ========================================================================= #
|
14
|
-
VERSION = '1.2.
|
14
|
+
VERSION = '1.2.8'
|
15
15
|
DEFAULT_VERSION = VERSION # Use an "alias" to the above constant.
|
16
16
|
|
17
17
|
# ========================================================================= #
|
18
18
|
# === LAST_UPDATE
|
19
19
|
# ========================================================================= #
|
20
|
-
LAST_UPDATE = '
|
20
|
+
LAST_UPDATE = '04.04.2024'
|
21
21
|
|
22
22
|
end; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: program_information
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert A. Heiler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colours
|
@@ -51,6 +51,7 @@ extra_rdoc_files: []
|
|
51
51
|
files:
|
52
52
|
- README.md
|
53
53
|
- bin/program_information
|
54
|
+
- bin/program_information_version
|
54
55
|
- doc/CONVENTIONS.md
|
55
56
|
- doc/README.gen
|
56
57
|
- lib/program_information.rb
|
@@ -58,14 +59,9 @@ files:
|
|
58
59
|
- lib/program_information/constants/colours.rb
|
59
60
|
- lib/program_information/constants/constants.rb
|
60
61
|
- lib/program_information/constants/regex.rb
|
61
|
-
- lib/program_information/initialize.rb
|
62
|
-
- lib/program_information/menu.rb
|
63
62
|
- lib/program_information/program_information.rb
|
64
63
|
- lib/program_information/project/project.rb
|
65
|
-
- lib/program_information/report.rb
|
66
64
|
- lib/program_information/requires/require_the_program_information_project.rb
|
67
|
-
- lib/program_information/reset.rb
|
68
|
-
- lib/program_information/run.rb
|
69
65
|
- lib/program_information/toplevel_methods.rb
|
70
66
|
- lib/program_information/toplevel_methods/e.rb
|
71
67
|
- lib/program_information/toplevel_methods/opnn.rb
|
@@ -93,9 +89,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
89
|
requirements:
|
94
90
|
- - ">="
|
95
91
|
- !ruby/object:Gem::Version
|
96
|
-
version: 3.5.
|
92
|
+
version: 3.5.7
|
97
93
|
requirements: []
|
98
|
-
rubygems_version: 3.5.
|
94
|
+
rubygems_version: 3.5.7
|
99
95
|
signing_key:
|
100
96
|
specification_version: 4
|
101
97
|
summary: This library is called program_information. It allows you to return the
|
@@ -1,43 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
module ProgramInformation
|
6
|
-
|
7
|
-
class ProgramInformation # === ProgramInformation::ProgramInformation
|
8
|
-
|
9
|
-
# ========================================================================= #
|
10
|
-
# === initialize
|
11
|
-
#
|
12
|
-
# Specific usage example:
|
13
|
-
#
|
14
|
-
# ProgramInformation::ProgramInformation.new('util-linux-ng-2.15')
|
15
|
-
#
|
16
|
-
# ========================================================================= #
|
17
|
-
def initialize(
|
18
|
-
i = ARGV,
|
19
|
-
run_already = true,
|
20
|
-
optional_be_verbose = false
|
21
|
-
)
|
22
|
-
reset
|
23
|
-
set_input(i)
|
24
|
-
if optional_be_verbose
|
25
|
-
set_be_verbose(optional_be_verbose)
|
26
|
-
end
|
27
|
-
case run_already
|
28
|
-
# ======================================================================= #
|
29
|
-
# === :do_run_already
|
30
|
-
# ======================================================================= #
|
31
|
-
when :do_run_already
|
32
|
-
run_already = true
|
33
|
-
# ======================================================================= #
|
34
|
-
# === :dont_run_already
|
35
|
-
# ======================================================================= #
|
36
|
-
when :dont_run_already,
|
37
|
-
:do_not_run_already
|
38
|
-
run_already = false
|
39
|
-
end
|
40
|
-
run if run_already
|
41
|
-
end
|
42
|
-
|
43
|
-
end; end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'program_information/menu.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module ProgramInformation
|
8
|
-
|
9
|
-
class ProgramInformation # === ProgramInformation::ProgramInformation
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === menu (menu tag)
|
13
|
-
# ========================================================================= #
|
14
|
-
def menu(i)
|
15
|
-
if i.is_a? Array
|
16
|
-
i.each {|entry| menu(entry) }
|
17
|
-
else
|
18
|
-
case i
|
19
|
-
# ===================================================================== #
|
20
|
-
# === help
|
21
|
-
# ===================================================================== #
|
22
|
-
when /-?-?help$/i
|
23
|
-
show_help
|
24
|
-
exit
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end; end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
module ProgramInformation
|
6
|
-
|
7
|
-
class ProgramInformation
|
8
|
-
|
9
|
-
# ========================================================================= #
|
10
|
-
# === report (debug tag, report tag)
|
11
|
-
# ========================================================================= #
|
12
|
-
def report(
|
13
|
-
be_verbose = be_verbose?
|
14
|
-
)
|
15
|
-
case be_verbose
|
16
|
-
when :do_report, :be_verbose
|
17
|
-
be_verbose = true
|
18
|
-
end
|
19
|
-
lpad = 90
|
20
|
-
rpad = 49
|
21
|
-
if be_verbose
|
22
|
-
inner_ljust = 28
|
23
|
-
# ===================================================================== #
|
24
|
-
# === real short name
|
25
|
-
# ===================================================================== #
|
26
|
-
e (NAME_OF_CLASS+(' Program real short name ').ljust(inner_ljust)+'('+
|
27
|
-
yellow?+'@real_short_name'+rev+') is: ').ljust(lpad)+
|
28
|
-
(apostroph?+real_short_name?+apostroph?).
|
29
|
-
ljust(rpad)
|
30
|
-
# ===================================================================== #
|
31
|
-
# === short name
|
32
|
-
# ===================================================================== #
|
33
|
-
e (
|
34
|
-
NAME_OF_CLASS+(' Program name').ljust(inner_ljust)+'('+
|
35
|
-
yellow?+'@short_name'+rev+' ) is: '
|
36
|
-
).ljust(lpad)+(apostroph?+short_name?+apostroph?).
|
37
|
-
ljust(rpad)
|
38
|
-
# ===================================================================== #
|
39
|
-
# === program version
|
40
|
-
# ===================================================================== #
|
41
|
-
e (NAME_OF_CLASS+(' Program version ').ljust(inner_ljust)+'('+
|
42
|
-
yellow?+'@program_version'+rev+') is: ').ljust(lpad)+
|
43
|
-
(apostroph?+version?+apostroph?).
|
44
|
-
ljust(rpad)
|
45
|
-
end
|
46
|
-
end; alias report_result report # === report_result
|
47
|
-
|
48
|
-
end; end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'program_information/reset.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module ProgramInformation
|
8
|
-
|
9
|
-
class ProgramInformation # === ProgramInformation::ProgramInformation
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === reset
|
13
|
-
# ========================================================================= #
|
14
|
-
def reset
|
15
|
-
# ======================================================================= #
|
16
|
-
# === @short_name
|
17
|
-
# ======================================================================= #
|
18
|
-
@short_name = nil
|
19
|
-
# ======================================================================= #
|
20
|
-
# === @real_short_name
|
21
|
-
# ======================================================================= #
|
22
|
-
@real_short_name = nil
|
23
|
-
# ======================================================================= #
|
24
|
-
# === @program_version
|
25
|
-
# ======================================================================= #
|
26
|
-
@program_version = nil
|
27
|
-
set_shall_we_downcase # Should become before set_input().
|
28
|
-
set_be_verbose
|
29
|
-
# ======================================================================= #
|
30
|
-
# === @remove_plus_and_minus
|
31
|
-
# ======================================================================= #
|
32
|
-
@remove_plus_and_minus = REMOVE_PLUS_AND_MINUS
|
33
|
-
# ======================================================================= #
|
34
|
-
# === @replace_plus_with_long_name
|
35
|
-
# ======================================================================= #
|
36
|
-
@replace_plus_with_long_name = REPLACE_PLUS_WITH_LONG_NAME
|
37
|
-
@remove_plus_token = REMOVE_PLUS_TOKEN
|
38
|
-
if @remove_plus_and_minus # Overrule always in this case.
|
39
|
-
@replace_plus_with_long_name = false
|
40
|
-
end
|
41
|
-
if @remove_plus_and_minus
|
42
|
-
@remove_plus_token = false
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
end; end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'program_information/run.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module ProgramInformation
|
8
|
-
|
9
|
-
class ProgramInformation
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === run
|
13
|
-
# ========================================================================= #
|
14
|
-
def run
|
15
|
-
determine_the_three_main_variables
|
16
|
-
end
|
17
|
-
|
18
|
-
end; end
|