program_information 1.1.9

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.

Files changed (29) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +9 -0
  3. data/bin/program_information +14 -0
  4. data/doc/CONVENTIONS.md +22 -0
  5. data/doc/README.gen +9 -0
  6. data/lib/program_information/constants/array_test_with_this_as_input.rb +120 -0
  7. data/lib/program_information/constants/colours.rb +42 -0
  8. data/lib/program_information/constants/constants.rb +55 -0
  9. data/lib/program_information/constants/regex.rb +85 -0
  10. data/lib/program_information/initialize.rb +34 -0
  11. data/lib/program_information/menu.rb +29 -0
  12. data/lib/program_information/program_information.rb +568 -0
  13. data/lib/program_information/project/project_base_directory.rb +22 -0
  14. data/lib/program_information/report.rb +48 -0
  15. data/lib/program_information/requires/require_the_program_information_project.rb +9 -0
  16. data/lib/program_information/reset.rb +46 -0
  17. data/lib/program_information/run.rb +18 -0
  18. data/lib/program_information/toplevel_methods/e.rb +14 -0
  19. data/lib/program_information/toplevel_methods/opnn.rb +27 -0
  20. data/lib/program_information/toplevel_methods/remove_archive_type.rb +32 -0
  21. data/lib/program_information/toplevel_methods/return_proper_pipe_token_to_this_input.rb +167 -0
  22. data/lib/program_information/toplevel_methods/return_short_name.rb +38 -0
  23. data/lib/program_information/toplevel_methods.rb +159 -0
  24. data/lib/program_information/version/version.rb +22 -0
  25. data/lib/program_information/www/embeddable_interface.rb +61 -0
  26. data/lib/program_information.rb +5 -0
  27. data/program_information.gemspec +50 -0
  28. data/test/testing_program_information.rb +49 -0
  29. metadata +115 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0dcdef18e7c5482c3ef65cfb8dd7ac448893c65b6ac3843ae49c9611ef35909d
4
+ data.tar.gz: 8da268262be8f64327f7e260d9c6e1128cc29d922c9a593611994f50b122681f
5
+ SHA512:
6
+ metadata.gz: ce5d86fc4e0cc78febbe52c1513cde843ee871e216b230f16fc28917d106e620be93eaac529fdd55b012591e61811aa79a8250f4889295486d8c3118f01191f6
7
+ data.tar.gz: 4344fb0eac4913225b24ec052db5b624c427cfb8d1418623ea9656358d99ab287ee883811c77974f557fbdc91d0eba1f61288fb47cd4950d1f3889d40fb42739
data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ ## .first and .last
2
+
3
+ You can obtain the name of the program at hand, and the associated
4
+ version, like so:
5
+
6
+ require 'program_information'
7
+ x = ProgramInformation.new('ruby-2.5.0')
8
+ puts x.first
9
+ puts x.last
@@ -0,0 +1,14 @@
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).report(:be_verbose)
9
+ else # "Normal" tests here.
10
+ _ = ProgramInformation.parse 'http://downloads.sourceforge.net/boost/boost_1_54_0.tar.bz2'
11
+ p ProgramInformation.parse('http://downloads.sourceforge.net/boost/boost_1_54_0.tar.bz2', false)
12
+ end
13
+ # p _.original_program_name
14
+ # pii
@@ -0,0 +1,22 @@
1
+ Any given input can have three components:
2
+
3
+ (1) real_short_name
4
+ (2) short_name
5
+ (3) program_version
6
+
7
+ real_short_name depends on short_name. It simply is short_name with all
8
+ instances of the '_' character removed. It is thus a dependent variable.
9
+
10
+ The three numbers above also correspond to respective @instance_variables,
11
+ so in other words we have @real_short_name, @short_name and
12
+ @program_version.
13
+
14
+ The input passed to the main class may be "unclean". The class will try
15
+ # to get the "best" result out of any given input that was supplied, no
16
+ matter how unclean this input was.
17
+
18
+ It is recommended to use this class when wanting to determine the
19
+ short_name and the program version of any given program.
20
+
21
+ Note that short_name is allowed to include '-' characters whereas
22
+ real_short_name will strip '-' characters.
data/doc/README.gen ADDED
@@ -0,0 +1,9 @@
1
+ ## .first and .last
2
+
3
+ You can obtain the name of the program at hand, and the associated
4
+ version, like so:
5
+
6
+ require 'program_information'
7
+ x = ProgramInformation.new('ruby-2.5.0')
8
+ puts x.first
9
+ puts x.last
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This is the input that can be used by the testing file.
6
+ # =========================================================================== #
7
+ # require 'program_information/constants/array_test_with_this_as_input.rb'
8
+ # =========================================================================== #
9
+ require 'program_information/constants/regex.rb'
10
+ require 'program_information/toplevel_methods/return_proper_pipe_token_to_this_input.rb'
11
+
12
+ module ProgramInformation
13
+
14
+ # ========================================================================= #
15
+ # === ProgramInformation::ARRAY_TEST_THIS_AS_INPUT
16
+ #
17
+ # The character '|' is not allowed to be part of any program name,
18
+ # so we wil use this as special token.
19
+ #
20
+ # We will insert it at the boundary level.
21
+ # ========================================================================= #
22
+ ARRAY_TEST_THIS_AS_INPUT = %w(
23
+ unieject-6
24
+ acl_2.2.47-1
25
+ ncbi_cxx-12_0_0
26
+ lynx-2.8.8-rel2
27
+ subtle-0.11.3224-xi
28
+ font-bitstream-75dpi-1.0.3
29
+ xf86-input-elographics-1.4.1
30
+ zope.interface-4.2.0
31
+ CrownCutlass-Alpha1.4
32
+ gobject-introspection-1.53.4
33
+ dvd+rw-tools-7.1
34
+ font-xfree86-type1-1.0.4
35
+ lshw-B.02.08.01
36
+ e_dbus-1.7.10
37
+ xf86-video-omap-0.4.2
38
+ at-spi2-core-2.19.2
39
+ xfce4-dev-tools-4.8.0
40
+ WebKit-r174650
41
+ akonadi-calendar-tools-17.08.1
42
+ Archive-Zip-1.46
43
+ did_you_mean-1.1.2
44
+ artemis_v16.0.11
45
+ chunky_png-1.3.8
46
+ libedit-20170329-3.1
47
+ font-adobe-utopia-type1-1.0.4
48
+ wpa_supplicant-2.6
49
+ dpkg_1.18.22
50
+ ncbi-blast-2.6.0+
51
+ ntfs-3g_ntfsprogs-2017.3.23
52
+ b43-fwcutter-015
53
+ wcd-6.0.1-beta3
54
+ xf86-video-i810-1.7.4
55
+ gnome-internet-radio-locator-0.9.0
56
+ SDL2_gfx-1.0.1
57
+ boost-1_54_0
58
+ boost_1_65_1.tar.bz2
59
+ boost_1_65_1
60
+ oxygen-icons5-5.37.0
61
+ artemis_v16.0.11.jar
62
+ mod_python_3.3.1
63
+ xfce4-statusnotifier-plugin-0.2.0
64
+ p7zip_16.02_src_all.tar.bz2
65
+ mime-types-data-3.2016.0521.gem
66
+ domain_name-0.5.20170404.gem
67
+ ftp://ftp.alsa-project.org/pub/plugins/alsa-plugins-1.0.29.tar.bz2
68
+ alsa-plugins-1.0.29.tar.bz2
69
+ alsa-plugins-1.0.29
70
+ libquvi-scripts-0.9.20131130
71
+ btrfs-progs-v4.13.2.tar.xz
72
+ btrfs-progs-v4.13.2
73
+ ImageMagick-7.0.7-7
74
+ Archive-Zip-1.46
75
+ loop-AES-v3.7d
76
+ boost-build-2014-10
77
+ openobex-1.7.1-Source
78
+ /Users/x/SRC/zope.interface/zope.interface-4.4.2.tar.gz
79
+ libatomic_ops-7.4.2.tar.gz
80
+ mod_python-11.10.2017
81
+ expect5.45.3
82
+ http://search.cpan.org/CPAN/authors/id/M/MA/MARKOV/XML-LibXML-Simple-0.98.tar.gz
83
+ https://rubygems.org/downloads/mini_portile2-2.3.0.gem
84
+ kismet-2016-07-R1.tar.xz
85
+ nana%201.5.4.zip
86
+ http://download.icu-project.org/files/icu4c/61.1/icu4c-61_1-src.tgz
87
+ XML-NamespaceSupport-1.09.tar.xz
88
+ XML-NamespaceSupport-1.09
89
+ icu4c-62_1
90
+ polkit-kde-agent-1-5.15.2
91
+ polkit-kde-agent-1-5.10.95
92
+ polkit-qt-1-0.112.0
93
+ xf86-video-amd-2.7.7.7
94
+ NVIDIA-Linux-x86-352.63.run
95
+ xf86-video-s3virge-1.11.0
96
+ youtube-dl-2019.06.27
97
+ dvd+rw-tools-7.1
98
+ )
99
+
100
+ end
101
+
102
+ if __FILE__ == $PROGRAM_NAME
103
+ require 'colours/autoinclude'
104
+ # ========================================================================= #
105
+ # This is colourized in more detail because it makes it easier to
106
+ # visualize what is going on, on the commandline.
107
+ # ========================================================================= #
108
+ ProgramInformation::ARRAY_TEST_THIS_AS_INPUT.each {|entry|
109
+ original_entry = entry.dup
110
+ entry = File.basename(entry)
111
+ entry = ProgramInformation.return_proper_pipe_token_to_this_input(entry)
112
+ use_sfancy_colour = Colours.colour_methods_to_specific_colour?[:sfancy]
113
+ e "#{simp(original_entry.ljust(36))}"\
114
+ " -> "\
115
+ "#{sfancy(
116
+ entry.sub(/\|/, Colours.orange('|')+
117
+ Colours.send(use_sfancy_colour))
118
+ )}"
119
+ }
120
+ end
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module ProgramInformation
6
+
7
+ class ProgramInformation
8
+
9
+ begin
10
+ require 'colours'
11
+ rescue LoadErrors; end
12
+
13
+ # ========================================================================= #
14
+ # === rev
15
+ # ========================================================================= #
16
+ def rev
17
+ Colours.rev
18
+ end
19
+
20
+ # ========================================================================= #
21
+ # === COLOUR_FOR_REVERT
22
+ # ========================================================================= #
23
+ COLOUR_FOR_REVERT = Colours::WHITE # WHITE is defined in the colours project.
24
+
25
+ # ========================================================================= #
26
+ # === APOSTROPH
27
+ # ========================================================================= #
28
+ APOSTROPH = Colours::TEAL+'`'+COLOUR_FOR_REVERT # +Colours.rev
29
+
30
+ # ========================================================================= #
31
+ # === NAME_OF_CLASS
32
+ # ========================================================================= #
33
+ NAME_OF_CLASS = Colours::CGREY+'ProgramInformation:'+COLOUR_FOR_REVERT
34
+
35
+ # ========================================================================= #
36
+ # === yellow?
37
+ # ========================================================================= #
38
+ def yellow?
39
+ Colours::BOLD_YELLOW
40
+ end
41
+
42
+ end; end
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'program_information/constants/constants.rb'
6
+ # =========================================================================== #
7
+ require 'program_information/constants/regex.rb'
8
+ require 'program_information/constants/colours.rb'
9
+
10
+ module ProgramInformation
11
+
12
+ class ProgramInformation
13
+
14
+ # ========================================================================= #
15
+ # === SHALL_WE_DOWNCASE
16
+ #
17
+ # So that input such as "Libgnome" can become "libgnome".
18
+ # ========================================================================= #
19
+ SHALL_WE_DOWNCASE = false
20
+
21
+ # ========================================================================= #
22
+ # === REMOVE_PLUS_AND_MINUS
23
+ #
24
+ # If true then we will remove plus '+' and minus '-' from the program name.
25
+ # ========================================================================= #
26
+ REMOVE_PLUS_AND_MINUS = false
27
+
28
+ # ========================================================================= #
29
+ # === REPLACE_PLUS_WITH_LONG_NAME
30
+ #
31
+ # If this constant is true then we will replace all '+' with the
32
+ # string 'plus' as part of the issued name. Note that remove-actions
33
+ # are stronger, so if the constant REMOVE_PLUS_AND_MINUS was also
34
+ # set to true, then the constant here will not be honoured at all.
35
+ # ========================================================================= #
36
+ REPLACE_PLUS_WITH_LONG_NAME = false
37
+
38
+ # ========================================================================= #
39
+ # === REMOVE_PLUS_TOKEN
40
+ #
41
+ # If this constant is true then we will eliminate '+' in the input.
42
+ #
43
+ # This overrules the replace-constant called REPLACE_PLUS_WITH_LONG_NAME.
44
+ #
45
+ # Also note that if the constant REMOVE_PLUS_AND_MINUS is set to true
46
+ # then this setting here will always be set to false.
47
+ # ========================================================================= #
48
+ REMOVE_PLUS_TOKEN = false
49
+
50
+ # ========================================================================= #
51
+ # === BE_VERBOSE
52
+ # ========================================================================= #
53
+ BE_VERBOSE = false
54
+
55
+ end; end
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'program_information/constants/regex.rb'
6
+ # =========================================================================== #
7
+ module ProgramInformation
8
+
9
+ # ========================================================================= #
10
+ # === REGEX_FOR_TWO_HYPHENS
11
+ #
12
+ # This is valid for input such as 'lynx-2.8.8-rel2' or
13
+ # 'gobject-introspection-1.53.4' or 'subtle-0.11.3224-xi' or
14
+ # 'dvd+rw-tools-7.1' or 'Archive-Zip-1.46' or 'btrfs-progs-v4.12.1'
15
+ # or 'color-tools-1.3.0' or 'libedit-20170329-3.1' or
16
+ # 'ncbi-blast-2.6.0+' or 'b43-fwcutter-015' or 'wcd-6.0.1-beta3'
17
+ # or 'oxygen-icons5-5.37.0' or 'btrfs-progs-v4.13.2' or
18
+ # 'Archive-Zip-1.46' or 'wcd-6.0.1-beta3' or 'openobex-1.7.1-Source'
19
+ # or 'youtube-dl-2019.06.27'.
20
+ #
21
+ # See:
22
+ #
23
+ # https://rubular.com/r/u9Yy3qcxrlp5uG
24
+ #
25
+ # ========================================================================= #
26
+ REGEX_FOR_TWO_HYPHENS =
27
+ /([A-Za-z+]{0,12}-?[a-z0-9]{0,9}-?[A-Za-z]{0,14}\d{0,4}-?[A-Za-z0-9]{0,12})-(\d{0,2}\.?[a-z]{0,1}\d{0,2}\.?[a-z]{0,1}\d{0,4}[.|-]?\d{0,8}[A-Za-z]{0,9}\d?\+?)$/
28
+
29
+ # ========================================================================= #
30
+ # === REGEX_FOR_THREE_OR_MORE_HYPHENS
31
+ #
32
+ # This is for input such as 'akonadi-calendar-tools-17.08.1' or
33
+ # 'boost-build-2014-10' or 'xf86-video-i810-1.7.4' or
34
+ # or 'xfce4-statusnotifier-plugin-0.2.0' or 'mime-types-data-3.2016.0521'
35
+ # or 'XML-LibXML-Simple-0.98' or 'kismet-2016-07-R1.tar.xz' or
36
+ # 'polkit-kde-agent-1-5.15.2' or 'xf86-video-amd-2.7.7.7'
37
+ # or 'xf86-video-s3virge-1.11.0'.
38
+ #
39
+ # See: https://rubular.com/r/lCrdU01HE7MRV4
40
+ # ========================================================================= #
41
+ REGEX_FOR_THREE_OR_MORE_HYPHENS =
42
+ /^([A-Za-z]{0,9}\d{0,2}-?[A-Za-z]{0,12}\d{0,2}-?[a-z]{0,9}\d{0,1}-?[A-Za-z]{0,8}-?1?\d{0,3}[a-z]{0,3})-(\d{0,4}\.?\d{0,4}\.?-?[A-Z]{0,1}\d{0,4}\.?\d{0,4})$/
43
+
44
+ # ========================================================================= #
45
+ # === REGEX_FOR_INPUT_HAVING_ONLY_DOTS
46
+ #
47
+ # This is valid for strange input such as 'expect5.45.3' or
48
+ # 'sendmail.8.15.2'. These have no '-' and no '_'.
49
+ # ========================================================================= #
50
+ REGEX_FOR_INPUT_HAVING_ONLY_DOTS = # See: http://rubular.com/r/KVePR7ShX3
51
+ /([a-z]{1,10})\.?(\d+\.?\d{1,2}\.?\d{0,2})/
52
+
53
+ # ========================================================================= #
54
+ # === REGEX_FOR_BOOST_LIKE_INPUT
55
+ #
56
+ # Valid input should be 'ncbi_cxx-12_0_0' or 'icu4c-61_1'.
57
+ #
58
+ # See: http://rubular.com/r/CyNqJbCMR2
59
+ # ========================================================================= #
60
+ REGEX_FOR_BOOST_LIKE_INPUT =
61
+ /([a-z]{0,3}\d{0,1}[a-z]{0,5}_?[a-z]{0,3})([-|_]{1})(\d{1,2}_\d{1,2}_?\d*)/
62
+
63
+ # ========================================================================= #
64
+ # === REGEX_FOR_ACL_LIKE_INPUT
65
+ #
66
+ # Valid input should be 'acl_2.2.47-1' or 'e_dbus-1.7.10' or
67
+ # 'wpa_supplicant-2.6' or 'SDL2_gfx-1.0.1' or 'libatomic_ops-7.4.2'
68
+ # or 'mod_python-11.10.2017' or 'mini_portile2-2.3.0.gem'.
69
+ #
70
+ # See: http://rubular.com/r/XDdBNWxipp
71
+ # ========================================================================= #
72
+ REGEX_FOR_ACL_LIKE_INPUT =
73
+ /([A-Za-z]{0,10}[0-9]{0,1}_?[0-9]{0,1}[a-z]{1,10}[0-9]{0,1})(_|-)([0-9]{0,2}\.?[0-9]{0,2}\.?[0-9]{0,2}-?[0-9]{0,2}_?[0-9]{0,4})/
74
+
75
+ # ========================================================================= #
76
+ # === REGEX_FOR_INPUT_CONTAINING_TWO_HYPHENS_AND_ONE_UNDERSCORE
77
+ #
78
+ # This is input for programs such as 'ntfs-3g_ntfsprogs-2017.3.23'.
79
+ #
80
+ # See: http://rubular.com/r/15pAuHKxt5
81
+ # ========================================================================= #
82
+ REGEX_FOR_INPUT_CONTAINING_TWO_HYPHENS_AND_ONE_UNDERSCORE =
83
+ /([a-z]{1}.+)(-)(\d{1,4}\.\d\.\d{1,2})/
84
+
85
+ end
@@ -0,0 +1,34 @@
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
+ # ProgramInformation::ProgramInformation.new('util-linux-ng-2.15')
14
+ # ========================================================================= #
15
+ def initialize(
16
+ i = ARGV,
17
+ run_already = true,
18
+ optional_be_verbose = false
19
+ )
20
+ reset
21
+ set_input(i)
22
+ if optional_be_verbose
23
+ set_be_verbose(optional_be_verbose)
24
+ end
25
+ case run_already
26
+ when :do_run_already
27
+ run_already = true
28
+ when :dont_run_already, :do_not_run_already
29
+ run_already = false
30
+ end
31
+ run if run_already
32
+ end
33
+
34
+ end; end
@@ -0,0 +1,29 @@
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
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