program_information 1.2.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.
Potentially problematic release.
This version of program_information might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.md +80 -0
- data/bin/program_information +14 -0
- data/doc/CONVENTIONS.md +22 -0
- data/doc/README.gen +37 -0
- data/lib/program_information/constants/array_test_with_this_as_input.rb +121 -0
- data/lib/program_information/constants/colours.rb +42 -0
- data/lib/program_information/constants/constants.rb +55 -0
- data/lib/program_information/constants/regex.rb +87 -0
- data/lib/program_information/initialize.rb +43 -0
- data/lib/program_information/menu.rb +29 -0
- data/lib/program_information/program_information.rb +569 -0
- data/lib/program_information/project/project.rb +22 -0
- data/lib/program_information/report.rb +48 -0
- data/lib/program_information/requires/require_the_program_information_project.rb +9 -0
- data/lib/program_information/reset.rb +46 -0
- data/lib/program_information/run.rb +18 -0
- data/lib/program_information/toplevel_methods/e.rb +14 -0
- data/lib/program_information/toplevel_methods/opnn.rb +27 -0
- data/lib/program_information/toplevel_methods/remove_archive_type.rb +32 -0
- data/lib/program_information/toplevel_methods/return_proper_pipe_token_to_this_input.rb +169 -0
- data/lib/program_information/toplevel_methods/return_short_name.rb +38 -0
- data/lib/program_information/toplevel_methods.rb +164 -0
- data/lib/program_information/version/version.rb +22 -0
- data/lib/program_information/www/embeddable_interface.rb +61 -0
- data/lib/program_information.rb +5 -0
- data/program_information.gemspec +52 -0
- data/test/testing_program_information.rb +49 -0
- metadata +107 -0
@@ -0,0 +1,569 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === ProgramInformation::ProgramInformation
|
6
|
+
#
|
7
|
+
# The main class will reside here.
|
8
|
+
#
|
9
|
+
# This class can provide us with the proper name, and the proper version
|
10
|
+
# for any given program.
|
11
|
+
#
|
12
|
+
# We simply take the given input and use three components for it:
|
13
|
+
#
|
14
|
+
# (1) real_short_name
|
15
|
+
# (2) short_name
|
16
|
+
# (3) program_version
|
17
|
+
#
|
18
|
+
# Note that real_short_name depends on short_name. It simply is short_name
|
19
|
+
# with all instances of the '_' character removed. It is thus a dependent
|
20
|
+
# variable.
|
21
|
+
#
|
22
|
+
# The three numbers above also correspond to respective @instance_variables,
|
23
|
+
# so in other words we have @real_short_name, @short_name and
|
24
|
+
# @program_version.
|
25
|
+
#
|
26
|
+
# The input can be a bit "unclean". The class will try to get the "best"
|
27
|
+
# result out of any given input, no matter how unclean it is.
|
28
|
+
#
|
29
|
+
# It is recommended to use this class when wanting to determine the
|
30
|
+
# short_name and the program version of any given program.
|
31
|
+
# =========================================================================== #
|
32
|
+
# require 'program_information/program_information.rb'
|
33
|
+
# =========================================================================== #
|
34
|
+
module ProgramInformation
|
35
|
+
|
36
|
+
class ProgramInformation # === ProgramInformation::ProgramInformation
|
37
|
+
|
38
|
+
require 'remove_file_suffix'
|
39
|
+
|
40
|
+
require 'program_information/project/project.rb'
|
41
|
+
require 'program_information/toplevel_methods/e.rb'
|
42
|
+
require 'program_information/toplevel_methods/return_proper_pipe_token_to_this_input.rb'
|
43
|
+
require 'program_information/toplevel_methods/remove_archive_type.rb'
|
44
|
+
require 'program_information/constants/constants.rb'
|
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
|
+
|
52
|
+
# ========================================================================= #
|
53
|
+
# === return_proper_pipe_token_to_this_input
|
54
|
+
# ========================================================================= #
|
55
|
+
def return_proper_pipe_token_to_this_input(i)
|
56
|
+
::ProgramInformation.return_proper_pipe_token_to_this_input(i)
|
57
|
+
end
|
58
|
+
|
59
|
+
# ========================================================================= #
|
60
|
+
# === remove_file_suffix
|
61
|
+
#
|
62
|
+
# Delegate towards class RemoveFileSuffix. This is easier to handle
|
63
|
+
# Archive.
|
64
|
+
# ========================================================================= #
|
65
|
+
def remove_file_suffix(i)
|
66
|
+
RemoveFileSuffix[i.to_s]
|
67
|
+
end
|
68
|
+
|
69
|
+
# ========================================================================= #
|
70
|
+
# === do_not_replace_plus
|
71
|
+
# ========================================================================= #
|
72
|
+
def do_not_replace_plus
|
73
|
+
@replace_plus_with_long_name = false
|
74
|
+
end; alias do_not_replace_anything do_not_replace_plus # === do_not_replace_anything
|
75
|
+
|
76
|
+
# ========================================================================= #
|
77
|
+
# === set_program_version
|
78
|
+
#
|
79
|
+
# Use this method whenever you wish to assign to the @program_version
|
80
|
+
# variable.
|
81
|
+
#
|
82
|
+
# The input to this method may include stuff such as ".tar.xz", which
|
83
|
+
# should be chopped off, as it is not part of the program version.
|
84
|
+
#
|
85
|
+
# Keep in mind that we may also return nil.
|
86
|
+
#
|
87
|
+
# Until March 2015 we also replaced all '_' with '.' characters,
|
88
|
+
# but input such as "ncbi_cxx--12_0_0.tar.gz" would break as a
|
89
|
+
# consequence, so this was disabled again.
|
90
|
+
# ========================================================================= #
|
91
|
+
def set_program_version(i)
|
92
|
+
i = remove_file_suffix(i) unless i.nil? # Disallow archive-types here.
|
93
|
+
# ======================================================================= #
|
94
|
+
# The following check is not good at all because we may have input
|
95
|
+
# such as "1-0.112.0". Polkitqt has this, for instance.
|
96
|
+
# Thus, the following line was disabled on Feb 2016.
|
97
|
+
# ======================================================================= #
|
98
|
+
# if i.include? '-' # In this case, we use only the last part.
|
99
|
+
# i = i.split('-').last
|
100
|
+
# end
|
101
|
+
# ======================================================================= #
|
102
|
+
# And if result is actually an empty String, but the original input
|
103
|
+
# has included at the least one number, such as in "3.3.6-pl1",
|
104
|
+
# then we will simply use that instead.
|
105
|
+
# ======================================================================= #
|
106
|
+
if i.is_a?(String) and i.empty? and
|
107
|
+
@input =~ /\d+/ # <- If the input has at the least one Number.
|
108
|
+
i = @input.dup
|
109
|
+
end
|
110
|
+
@program_version = i
|
111
|
+
end; alias set_version set_program_version # === set_version
|
112
|
+
|
113
|
+
# ========================================================================= #
|
114
|
+
# === be_verbose?
|
115
|
+
# ========================================================================= #
|
116
|
+
def be_verbose?
|
117
|
+
@be_verbose
|
118
|
+
end
|
119
|
+
|
120
|
+
# ========================================================================= #
|
121
|
+
# === remove_plus_token?
|
122
|
+
# ========================================================================= #
|
123
|
+
def remove_plus_token?
|
124
|
+
@remove_plus_token
|
125
|
+
end
|
126
|
+
|
127
|
+
# ========================================================================= #
|
128
|
+
# === input?
|
129
|
+
# ========================================================================= #
|
130
|
+
def input?
|
131
|
+
@input
|
132
|
+
end
|
133
|
+
|
134
|
+
# ========================================================================= #
|
135
|
+
# === return_array
|
136
|
+
#
|
137
|
+
# This method will return a composite, 3-member Array that will hold the
|
138
|
+
# short_name, the real_short_name, and the program_version.
|
139
|
+
# ========================================================================= #
|
140
|
+
def return_array
|
141
|
+
[ short_name?, real_short_name?, program_version? ]
|
142
|
+
end; alias array? return_array # === array?
|
143
|
+
|
144
|
+
# ========================================================================= #
|
145
|
+
# === remove_plus_and_minus?
|
146
|
+
# ========================================================================= #
|
147
|
+
def remove_plus_and_minus?
|
148
|
+
@remove_plus_and_minus
|
149
|
+
end; alias remove_plus_and_minus remove_plus_and_minus? # === remove_plus_and_minus
|
150
|
+
|
151
|
+
# ========================================================================= #
|
152
|
+
# === apostroph?
|
153
|
+
# ========================================================================= #
|
154
|
+
def apostroph?
|
155
|
+
APOSTROPH
|
156
|
+
end
|
157
|
+
|
158
|
+
# ========================================================================= #
|
159
|
+
# === replace_plus_with_long_name?
|
160
|
+
# ========================================================================= #
|
161
|
+
def replace_plus_with_long_name?
|
162
|
+
@replace_plus_with_long_name
|
163
|
+
end
|
164
|
+
|
165
|
+
# ========================================================================= #
|
166
|
+
# === short_name_and_version?
|
167
|
+
#
|
168
|
+
# This method returns an aggregated @short_name+'-'+@program_version
|
169
|
+
# string.
|
170
|
+
# ========================================================================= #
|
171
|
+
def short_name_and_version?
|
172
|
+
"#{short_name?}-#{program_version?}"
|
173
|
+
end; alias short_name_and_version short_name_and_version? # === short_name_and_version
|
174
|
+
|
175
|
+
# ========================================================================= #
|
176
|
+
# === set_short_name_then_version
|
177
|
+
#
|
178
|
+
# This method will combine two other methods.
|
179
|
+
# ========================================================================= #
|
180
|
+
def set_short_name_then_version(a, b)
|
181
|
+
set_short_name(a)
|
182
|
+
set_program_version(b)
|
183
|
+
end; alias set_name_then_version set_short_name_then_version # === set_name_then_version
|
184
|
+
|
185
|
+
# ========================================================================= #
|
186
|
+
# === return_real_short_name_and_version
|
187
|
+
#
|
188
|
+
# We delegate to the module-method here.
|
189
|
+
# ========================================================================= #
|
190
|
+
def return_real_short_name_and_version(i)
|
191
|
+
::ProgramInformation.return_real_short_name_and_version(i)
|
192
|
+
end
|
193
|
+
|
194
|
+
# ========================================================================= #
|
195
|
+
# === return_name_and_version
|
196
|
+
#
|
197
|
+
# This method will return an array with two elements:
|
198
|
+
#
|
199
|
+
# (1) The first element is the name of the program in question.
|
200
|
+
# (2) The second element is the version of the program in question.
|
201
|
+
#
|
202
|
+
# The input can be rather tricky and complicated.
|
203
|
+
#
|
204
|
+
# Consider the following examples:
|
205
|
+
#
|
206
|
+
# 'libunwind-1.0-rc1'
|
207
|
+
# 'htop-1.0.0'
|
208
|
+
# 'WebKit-r93670'
|
209
|
+
# 'xfce4-dev-tools-4.8.0'
|
210
|
+
# 'e_dbus-1.7.10.tar.gz'
|
211
|
+
# 'boost_1_54_0.tar.bz2'
|
212
|
+
# 'short-mime-1.0.0-rc1'
|
213
|
+
#
|
214
|
+
# This can all be valid input.
|
215
|
+
#
|
216
|
+
# Which are the key-assumptions that we can do here?
|
217
|
+
#
|
218
|
+
# I think the best assumption we can do is to find the first NUMBER in
|
219
|
+
# the given string, and then group the rest of the data according to
|
220
|
+
# this NUMBER. This will not work in the case of something such as
|
221
|
+
# WebKit-r93, as there is a 'r' character before that number.
|
222
|
+
# So we will have to make a second assumption: if the character preceding
|
223
|
+
# the first found integer is NOT a '-' character, we will instead split
|
224
|
+
# on that character instead. This will however lead to a problem for
|
225
|
+
# something like "xfce4-dev-tools-4.8.0". So, in case there is a '-'
|
226
|
+
# character immediately after the pos variable, we assume we have such
|
227
|
+
# a special case.
|
228
|
+
#
|
229
|
+
# On Sep 2011, I came up with a far simpler idea. We simply have to
|
230
|
+
# find the most important '-' and then split accordingly. As long as
|
231
|
+
# we can identify the most important '-' correctly, so long will
|
232
|
+
# everything else "just work". This also did not work out, so I
|
233
|
+
# switched to a regex instead. Since then it has worked very fine.
|
234
|
+
#
|
235
|
+
# Take input such as:
|
236
|
+
#
|
237
|
+
# "font-bitstream-75dpi-1.0.0"
|
238
|
+
#
|
239
|
+
# Note though that this approach does not work with input like:
|
240
|
+
# "CrownCutlass-Alpha1.4"
|
241
|
+
# unless we assume that alpha is a part of the version,
|
242
|
+
# which is possibly correct.
|
243
|
+
# ========================================================================= #
|
244
|
+
def return_name_and_version(i = nil)
|
245
|
+
if i
|
246
|
+
determine_the_three_main_variables(i)
|
247
|
+
end
|
248
|
+
# ======================================================================= #
|
249
|
+
# We must consider what we wish to do about the '_' characters. We could
|
250
|
+
# remove them, but certain programs such as e_dbus may require it as
|
251
|
+
# part of their name. Also, Version entries such as '1_2_3' will become
|
252
|
+
# '123' rather than '1.2.3'. Thus, on Jan 2014 I have disabled the
|
253
|
+
# following line.
|
254
|
+
# ======================================================================= #
|
255
|
+
# i.delete!('_') if i.include? '_'
|
256
|
+
return [
|
257
|
+
@short_name, @program_version
|
258
|
+
]
|
259
|
+
end; alias rnav return_name_and_version # === rnav
|
260
|
+
|
261
|
+
# ========================================================================= #
|
262
|
+
# === set_shall_we_downcase
|
263
|
+
# ========================================================================= #
|
264
|
+
def set_shall_we_downcase(
|
265
|
+
i = SHALL_WE_DOWNCASE
|
266
|
+
)
|
267
|
+
@shall_we_downcase = i
|
268
|
+
end
|
269
|
+
|
270
|
+
# ========================================================================= #
|
271
|
+
# === do_not_downcase
|
272
|
+
# ========================================================================= #
|
273
|
+
def do_not_downcase
|
274
|
+
@shall_we_downcase = false
|
275
|
+
end
|
276
|
+
|
277
|
+
# ========================================================================= #
|
278
|
+
# === set_be_verbose
|
279
|
+
#
|
280
|
+
# Set to report in a verbose way here.
|
281
|
+
# ========================================================================= #
|
282
|
+
def set_be_verbose(i = BE_VERBOSE)
|
283
|
+
case i
|
284
|
+
when :be_verbose
|
285
|
+
i = true
|
286
|
+
end
|
287
|
+
@be_verbose = i
|
288
|
+
end
|
289
|
+
|
290
|
+
# ========================================================================= #
|
291
|
+
# === determine_the_three_main_variables
|
292
|
+
#
|
293
|
+
# This method will determine the three main instance variables:
|
294
|
+
#
|
295
|
+
# - @short_name
|
296
|
+
# - @real_short_name
|
297
|
+
# - @program_version
|
298
|
+
#
|
299
|
+
# We must be careful, as the input may not include any '-' or '_' token,
|
300
|
+
# and then the regex would fail. Hence, the behaviour of this method
|
301
|
+
# will depend on whether the input includes a '-' or whether it
|
302
|
+
# does not.
|
303
|
+
#
|
304
|
+
# Note that presently, set_input() will modify the given input and
|
305
|
+
# ensure that there will be a '-' token, even in input that does
|
306
|
+
# not have any '-' or '_' such as in 'sendmail.8.15.2'.
|
307
|
+
# ========================================================================= #
|
308
|
+
def determine_the_three_main_variables(i = @input)
|
309
|
+
if i
|
310
|
+
if i.include? '|'
|
311
|
+
splitted = i.split('|')
|
312
|
+
short_name = splitted.first.to_s.dup
|
313
|
+
program_version = splitted.last.to_s.dup
|
314
|
+
set_short_name(short_name)
|
315
|
+
set_program_version(program_version)
|
316
|
+
else
|
317
|
+
opn; e "The input `#{i}` does not include a | character."
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end; alias determine_name_and_program_version determine_the_three_main_variables # === determine_name_and_program_version
|
321
|
+
|
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
|
+
# ========================================================================= #
|
340
|
+
# === set_short_name
|
341
|
+
#
|
342
|
+
# Use this method whenever you wish to assign to the @short_name variable.
|
343
|
+
#
|
344
|
+
# This variable is allowed to keep '-' and '_' entries, but some
|
345
|
+
# settings may also modify this.
|
346
|
+
# ========================================================================= #
|
347
|
+
def set_short_name(i)
|
348
|
+
i = i.dup
|
349
|
+
# ======================================================================= #
|
350
|
+
# First, consider getting rid of '+' and '-' tokens in the
|
351
|
+
# @short_name variant of the program name.
|
352
|
+
# For this to work, @remove_plus_and_minus has to be set to true.
|
353
|
+
# ======================================================================= #
|
354
|
+
if remove_plus_and_minus?
|
355
|
+
i.delete!('+') if i.include? '+'
|
356
|
+
i.delete!('-') if i.include? '-'
|
357
|
+
end
|
358
|
+
# ======================================================================= #
|
359
|
+
# === Get rid of '+' tokens, if they are included.
|
360
|
+
# ======================================================================= #
|
361
|
+
if remove_plus_token?
|
362
|
+
i.delete!('+') if i.include? '+'
|
363
|
+
# ======================================================================= #
|
364
|
+
# === Alternatively, replace '+' with the string 'plus' should it
|
365
|
+
# exist there.
|
366
|
+
# ======================================================================= #
|
367
|
+
elsif replace_plus_with_long_name?
|
368
|
+
i.gsub!(/\+/, 'plus') if i.include? '+'
|
369
|
+
end
|
370
|
+
@short_name = i
|
371
|
+
set_real_short_name(i) # We will also sync towards @real_short_name.
|
372
|
+
end; alias set_name set_short_name # === set_name
|
373
|
+
alias set_program_name set_short_name # === set_program_name
|
374
|
+
|
375
|
+
# ========================================================================= #
|
376
|
+
# === remove_source_like_strings
|
377
|
+
# ========================================================================= #
|
378
|
+
def remove_source_like_strings(i)
|
379
|
+
# ======================================================================= #
|
380
|
+
# i.gsub!(/--/,'-') if i.include? '--' # Replace '--' with '-'.
|
381
|
+
# ^^^ May not be good, depending on the input.
|
382
|
+
# ======================================================================= #
|
383
|
+
i.sub!(/-src/,'') if i.include? '-src' # Get rid of -src entries.
|
384
|
+
i.sub!(/\.source/,'') if i.include? '.source'
|
385
|
+
i.sub!(/-source$/,'') if i.end_with? '-source'
|
386
|
+
return i
|
387
|
+
end
|
388
|
+
|
389
|
+
# ========================================================================= #
|
390
|
+
# === remove_archive_type
|
391
|
+
# ========================================================================= #
|
392
|
+
def remove_archive_type(i)
|
393
|
+
::ProgramInformation.remove_archive_type(i)
|
394
|
+
return i
|
395
|
+
end
|
396
|
+
|
397
|
+
# ========================================================================= #
|
398
|
+
# === e
|
399
|
+
# ========================================================================= #
|
400
|
+
def e(i = '')
|
401
|
+
::ProgramInformation.e(i)
|
402
|
+
end
|
403
|
+
|
404
|
+
# ========================================================================= #
|
405
|
+
# === real_short_name?
|
406
|
+
#
|
407
|
+
# Keep in mind that @real_short_name does not have any '-' tokens.
|
408
|
+
# ========================================================================= #
|
409
|
+
def real_short_name?
|
410
|
+
@real_short_name
|
411
|
+
end; alias real_name? real_short_name? # === real_name?
|
412
|
+
alias real_program_name? real_short_name? # === real_program_name?
|
413
|
+
alias real_short_name real_short_name? # === real_short_name
|
414
|
+
alias name_of_the_program? real_short_name? # === name_of_the_program?
|
415
|
+
|
416
|
+
# ========================================================================= #
|
417
|
+
# === short_name?
|
418
|
+
#
|
419
|
+
# Reader method for the @short_name instance variable.
|
420
|
+
#
|
421
|
+
# short_name is an alias to @short_name.
|
422
|
+
# ========================================================================= #
|
423
|
+
def short_name?
|
424
|
+
@short_name
|
425
|
+
end; alias program_name short_name? # === program_name
|
426
|
+
alias program_name? short_name? # === program_name?
|
427
|
+
alias name short_name? # === name
|
428
|
+
alias name? short_name? # === name?
|
429
|
+
alias return_short_name short_name? # === return_short_name
|
430
|
+
alias short_name short_name? # === short_name
|
431
|
+
alias return_name short_name? # === return_name
|
432
|
+
alias first short_name? # === first
|
433
|
+
alias return_program_real_name short_name? # === return_program_real_name
|
434
|
+
|
435
|
+
# ========================================================================= #
|
436
|
+
# === program_version?
|
437
|
+
#
|
438
|
+
# Getter method for the @program_version variable.
|
439
|
+
# ========================================================================= #
|
440
|
+
def program_version?
|
441
|
+
@program_version
|
442
|
+
end; alias program_version program_version? # === program_version
|
443
|
+
alias version program_version? # === version
|
444
|
+
alias version? program_version? # === version?
|
445
|
+
alias last? program_version? # === last?
|
446
|
+
alias last program_version? # === last?
|
447
|
+
alias version_of_the_program? program_version? # === version_of_the_program?
|
448
|
+
|
449
|
+
# ========================================================================= #
|
450
|
+
# === show_help (help tag)
|
451
|
+
#
|
452
|
+
# To invoke this method, try:
|
453
|
+
#
|
454
|
+
# pinfo --show-help
|
455
|
+
#
|
456
|
+
# ========================================================================= #
|
457
|
+
def show_help
|
458
|
+
e
|
459
|
+
e 'This class is able to split a given input (a string) into'
|
460
|
+
e 'the inferred program-name, and associated program version '\
|
461
|
+
'of said string.'
|
462
|
+
e
|
463
|
+
e 'For example, if you have this input string:'
|
464
|
+
e
|
465
|
+
e ' gobject-introspection-1.52.1'
|
466
|
+
e
|
467
|
+
e 'then this class can split this into these constituents:'
|
468
|
+
e
|
469
|
+
e ' @real_short_name: gobjectintrospection'
|
470
|
+
e ' @short_name: gobject-introspection'
|
471
|
+
e ' @program_version: 1.52.1'
|
472
|
+
e
|
473
|
+
e 'This is especially useful for other projects that require this'
|
474
|
+
e 'functionality, such as the rbt gem.'
|
475
|
+
e
|
476
|
+
end
|
477
|
+
|
478
|
+
# ========================================================================= #
|
479
|
+
# === set_input
|
480
|
+
#
|
481
|
+
# This method will, after performing some sanitize-operations, assign
|
482
|
+
# to the @input variable.
|
483
|
+
# ========================================================================= #
|
484
|
+
def set_input(i)
|
485
|
+
if i.is_a? Array
|
486
|
+
menu(i)
|
487
|
+
i = i.join(' ').strip
|
488
|
+
end
|
489
|
+
i = i.to_s.dup if i.frozen?
|
490
|
+
i = File.basename(i)
|
491
|
+
# ======================================================================= #
|
492
|
+
# We .squeeze away '--' tokens.
|
493
|
+
# ======================================================================= #
|
494
|
+
i.squeeze!('-')
|
495
|
+
i.strip!
|
496
|
+
# ======================================================================= #
|
497
|
+
# Next, some simple replacements without any method.
|
498
|
+
# ======================================================================= #
|
499
|
+
i.sub!(/-paco/,'') if i.include? '-paco'
|
500
|
+
i.sub!(/\/Programs\//,'') if i.include? '/Programs'
|
501
|
+
# ======================================================================= #
|
502
|
+
# The following must not conflict with i.e. "pkgconfig", hence why we
|
503
|
+
# also include a '/' character.
|
504
|
+
# ======================================================================= #
|
505
|
+
i.gsub!(/\/pkg/,'') if i.include? '/pkg'
|
506
|
+
# ======================================================================= #
|
507
|
+
# i.gsub!(/\//,'-') # Controversial. Disabled for now as of Jan 2014.
|
508
|
+
# ======================================================================= #
|
509
|
+
# We don't want either { or }.
|
510
|
+
# ======================================================================= #
|
511
|
+
i.delete!('{') if i.include? '{'
|
512
|
+
i.delete!('}') if i.include? '}'
|
513
|
+
# ======================================================================= #
|
514
|
+
# As of July 2016, we get rid of all tokens that follow a '#' character.
|
515
|
+
# We also will get rid of the '#' as well. Must come before we call
|
516
|
+
# remove_archive_type().
|
517
|
+
# ======================================================================= #
|
518
|
+
if i.include? '#'
|
519
|
+
i = i[0...i.index('#')]
|
520
|
+
end
|
521
|
+
i = remove_archive_type(i)
|
522
|
+
i = remove_source_like_strings(i)
|
523
|
+
# ======================================================================= #
|
524
|
+
# Next, we correct for input such as "nana%201.5.4". This one has no
|
525
|
+
# '-' token and no '_' token, but a '%' token. This '%' token will be
|
526
|
+
# replaced.
|
527
|
+
# ======================================================================= #
|
528
|
+
if i.include? '%'
|
529
|
+
unless i.include?('_') or i.include?('-')
|
530
|
+
i.tr!('%','-')
|
531
|
+
end
|
532
|
+
end
|
533
|
+
# ======================================================================= #
|
534
|
+
# Leading '-' will be removed.
|
535
|
+
# ======================================================================= #
|
536
|
+
i[0,1] = '' if i.start_with? '-'
|
537
|
+
# ======================================================================= #
|
538
|
+
# === Handle downcasing of the given input
|
539
|
+
#
|
540
|
+
# This will consider downcasing the input. The reason as to why this is
|
541
|
+
# necessary is so that input such as "Libgnome" can become "libgnome".
|
542
|
+
# ======================================================================= #
|
543
|
+
i.downcase! if @shall_we_downcase
|
544
|
+
# ======================================================================= #
|
545
|
+
# === Handle '+' tokens
|
546
|
+
# ======================================================================= #
|
547
|
+
if REMOVE_PLUS_TOKEN
|
548
|
+
i.delete!('+') if i.include? '+'
|
549
|
+
end
|
550
|
+
i = return_proper_pipe_token_to_this_input(i)
|
551
|
+
@input = i
|
552
|
+
end
|
553
|
+
|
554
|
+
end
|
555
|
+
|
556
|
+
# =========================================================================== #
|
557
|
+
# === ProgramInformation[]
|
558
|
+
# =========================================================================== #
|
559
|
+
def self.[](i)
|
560
|
+
::ProgramInformation::ProgramInformation.new(i)
|
561
|
+
end; self.instance_eval { alias new [] } # === ProgramInformation.new
|
562
|
+
self.instance_eval { alias parse [] } # === ProgramInformation.parse
|
563
|
+
self.instance_eval { alias combined [] } # === ProgramInformation.combined
|
564
|
+
|
565
|
+
end
|
566
|
+
|
567
|
+
if __FILE__ == $PROGRAM_NAME
|
568
|
+
ProgramInformation::ProgramInformation.new(ARGV)
|
569
|
+
end # pinfo /Users/x/SRC/gobjectintrospection/gobject-introspection-1.52.1.tar.xz
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'program_information/project/project.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module ProgramInformation
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === ProgramInformation::PROJECT_BASE_DIRECTORY
|
11
|
+
# ========================================================================= #
|
12
|
+
PROJECT_BASE_DIRECTORY =
|
13
|
+
"#{RbConfig::CONFIG['sitelibdir']}/program_information/"
|
14
|
+
|
15
|
+
# ========================================================================= #
|
16
|
+
# === ProgramInformation.project_base_dir?
|
17
|
+
# ========================================================================= #
|
18
|
+
def self.project_base_dir?
|
19
|
+
PROJECT_BASE_DIRECTORY
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,48 @@
|
|
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
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'program_information/requires/require_the_program_information_project.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'program_information/toplevel_methods.rb'
|
8
|
+
require 'program_information/constants/array_test_with_this_as_input.rb'
|
9
|
+
require 'program_information/www/embeddable_interface.rb'
|