environment_information 1.4.29

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 environment_information might be problematic. Click here for more details.

Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1061 -0
  3. data/bin/envi +7 -0
  4. data/bin/fast_envi +7 -0
  5. data/doc/README.gen +893 -0
  6. data/doc/TODO_FOR_THE_ENVIRONMENT_INFORMATION_PROJECT.md +54 -0
  7. data/environment_information.gemspec +130 -0
  8. data/lib/environment_information/base/base.rb +113 -0
  9. data/lib/environment_information/class/add.rb +186 -0
  10. data/lib/environment_information/class/colours.rb +283 -0
  11. data/lib/environment_information/class/constants.rb +35 -0
  12. data/lib/environment_information/class/environment_information.rb +51 -0
  13. data/lib/environment_information/class/help.rb +86 -0
  14. data/lib/environment_information/class/html.rb +78 -0
  15. data/lib/environment_information/class/initialize.rb +178 -0
  16. data/lib/environment_information/class/menu.rb +436 -0
  17. data/lib/environment_information/class/misc.rb +821 -0
  18. data/lib/environment_information/class/opn.rb +33 -0
  19. data/lib/environment_information/class/register_sigint.rb +20 -0
  20. data/lib/environment_information/class/reset.rb +213 -0
  21. data/lib/environment_information/class/ruby.rb +79 -0
  22. data/lib/environment_information/class/run.rb +61 -0
  23. data/lib/environment_information/class/show_display_and_report.rb +310 -0
  24. data/lib/environment_information/colours/colours.rb +150 -0
  25. data/lib/environment_information/colours/sfancy.rb +19 -0
  26. data/lib/environment_information/colours/simp.rb +19 -0
  27. data/lib/environment_information/constants/array_tracked_components.rb +207 -0
  28. data/lib/environment_information/constants/constants.rb +17 -0
  29. data/lib/environment_information/constants/encoding.rb +21 -0
  30. data/lib/environment_information/constants/error_line.rb +17 -0
  31. data/lib/environment_information/constants/file_constants.rb +102 -0
  32. data/lib/environment_information/constants/misc.rb +86 -0
  33. data/lib/environment_information/constants/namespace.rb +14 -0
  34. data/lib/environment_information/constants/newline.rb +16 -0
  35. data/lib/environment_information/constants/regex.rb +30 -0
  36. data/lib/environment_information/constants/temp_directory.rb +52 -0
  37. data/lib/environment_information/gui/gtk/bindings.rb +300 -0
  38. data/lib/environment_information/misc_components/README.md +3 -0
  39. data/lib/environment_information/misc_components/cflags.rb +36 -0
  40. data/lib/environment_information/misc_components/cpuinfo.rb +64 -0
  41. data/lib/environment_information/misc_components/operating_system.rb +54 -0
  42. data/lib/environment_information/misc_components/operating_system_bit_type.rb +42 -0
  43. data/lib/environment_information/misc_components/ram.rb +30 -0
  44. data/lib/environment_information/misc_components/rubygems_installation_directory.rb +54 -0
  45. data/lib/environment_information/misc_components/screen_resolution.rb +50 -0
  46. data/lib/environment_information/project/project.rb +27 -0
  47. data/lib/environment_information/queries/README.md +2 -0
  48. data/lib/environment_information/queries/complex_version.rb +263 -0
  49. data/lib/environment_information/queries/pkg_config.rb +125 -0
  50. data/lib/environment_information/queries/simple_version.rb +211 -0
  51. data/lib/environment_information/requires/require_asciitable.rb +15 -0
  52. data/lib/environment_information/requires/require_the_constants.rb +7 -0
  53. data/lib/environment_information/requires/require_the_environment_information_project.rb +23 -0
  54. data/lib/environment_information/requires/require_the_individual_misc_components.rb +30 -0
  55. data/lib/environment_information/requires/require_the_toplevel_methods.rb +22 -0
  56. data/lib/environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb +152 -0
  57. data/lib/environment_information/toplevel_methods/cd.rb +16 -0
  58. data/lib/environment_information/toplevel_methods/e.rb +30 -0
  59. data/lib/environment_information/toplevel_methods/hash.rb +60 -0
  60. data/lib/environment_information/toplevel_methods/internet_is_available.rb +30 -0
  61. data/lib/environment_information/toplevel_methods/is_on_roebe.rb +16 -0
  62. data/lib/environment_information/toplevel_methods/menu.rb +90 -0
  63. data/lib/environment_information/toplevel_methods/misc.rb +264 -0
  64. data/lib/environment_information/toplevel_methods/n_subcommands.rb +31 -0
  65. data/lib/environment_information/toplevel_methods/prefix_to_use.rb +39 -0
  66. data/lib/environment_information/toplevel_methods/register_this_component_is_missing.rb +61 -0
  67. data/lib/environment_information/toplevel_methods/remote_url_of_this_program.rb +45 -0
  68. data/lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb +84 -0
  69. data/lib/environment_information/toplevel_methods/return_pkgconfig_based_programs.rb +28 -0
  70. data/lib/environment_information/toplevel_methods/return_remote_gtk2_version.rb +54 -0
  71. data/lib/environment_information/toplevel_methods/return_simple_version_based_programs.rb +28 -0
  72. data/lib/environment_information/toplevel_methods/return_version_of_this_program.rb +186 -0
  73. data/lib/environment_information/toplevel_methods/show_all_available_components.rb +192 -0
  74. data/lib/environment_information/toplevel_methods/write_what_into.rb +24 -0
  75. data/lib/environment_information/version/version.rb +25 -0
  76. data/lib/environment_information/www/sinatra_interface.rb +213 -0
  77. data/lib/environment_information/www/webobject_interface.cgi +29 -0
  78. data/lib/environment_information/yaml/array_default_programs_on_linux.yml +14 -0
  79. data/lib/environment_information/yaml/array_lfs_core_programs.yml +35 -0
  80. data/lib/environment_information/yaml/array_science_cluster.yml +12 -0
  81. data/lib/environment_information/yaml/array_tracked_non_programs.yml +13 -0
  82. data/lib/environment_information/yaml/array_tracked_programs.yml +165 -0
  83. data/lib/environment_information/yaml/array_tracked_xorg_components.yml +34 -0
  84. data/lib/environment_information/yaml/query_to_use_for_the_individual_components.yml +215 -0
  85. data/lib/environment_information.rb +5 -0
  86. data/test/testing_environment_information.rb +26 -0
  87. data/test/testing_missing_components.rb +9 -0
  88. data/test/testing_prefix_for_the_environment_information_project.rb +20 -0
  89. metadata +195 -0
@@ -0,0 +1,186 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/return_version_of_this_program.rb'
6
+ # EnvironmentInformation.return_version_of_this_program
7
+ # =========================================================================== #
8
+ module EnvironmentInformation
9
+
10
+ require 'yaml'
11
+ require 'environment_information/colours/colours.rb'
12
+ require 'environment_information/constants/array_tracked_components.rb'
13
+ require 'environment_information/constants/error_line.rb'
14
+ require 'environment_information/constants/misc.rb'
15
+ require 'environment_information/constants/newline.rb'
16
+ require 'environment_information/toplevel_methods/e.rb'
17
+ require 'environment_information/toplevel_methods/prefix_to_use.rb'
18
+ require 'environment_information/requires/require_the_individual_misc_components.rb'
19
+ require 'environment_information/queries/pkg_config.rb'
20
+ require 'environment_information/queries/simple_version.rb'
21
+ require 'environment_information/queries/complex_version.rb'
22
+
23
+ begin
24
+ require 'rbt/utility_scripts/report_mate_desktop_version.rb'
25
+ rescue LoadError; end
26
+
27
+ # ========================================================================= #
28
+ # === @debug
29
+ #
30
+ # This variable can be used to control whether we debug the project
31
+ # or not. It should be false by default (and upon re-destribution of
32
+ # the project to other users).
33
+ # ========================================================================= #
34
+ @debug = false
35
+
36
+ # ========================================================================= #
37
+ # === @query_to_use_for_the_individual_components
38
+ #
39
+ # Initialize our dataset here.
40
+ # ========================================================================= #
41
+ @query_to_use_for_the_individual_components = YAML.load_file(
42
+ FILE_QUERY_TO_USE_FOR_THE_INDIVIDUAL_COMPONENTS
43
+ )
44
+
45
+ # ========================================================================= #
46
+ # === EnvironmentInformation.return_version_of_this_program
47
+ #
48
+ # This is the general method that will return the version of a particular
49
+ # program at hand.
50
+ #
51
+ # The method must be able to deal with using pkg-config, but also
52
+ # querying some program's version via --version, via the commandline,
53
+ # Furthermore, some programs may require an ad-hoc fix.
54
+ # ========================================================================= #
55
+ def self.return_version_of_this_program(
56
+ this_program,
57
+ prefix_to_use = @prefix_to_use
58
+ )
59
+ prefix_to_use = prefix_to_use.dup if prefix_to_use
60
+ version = nil # ← This is the default.
61
+ if this_program.is_a? Array
62
+ this_program = this_program.flatten.first
63
+ end
64
+ # ======================================================================= #
65
+ # Next define a few aliases.
66
+ # ======================================================================= #
67
+ case this_program.to_s
68
+ when 'diff'
69
+ this_program = 'diffutils'
70
+ when 'yacc'
71
+ this_program = 'bison'
72
+ end
73
+ if ARRAY_TRACKED_NON_PROGRAMS.include? this_program
74
+ return ::EnvironmentInformation.send(this_program)
75
+ elsif @query_to_use_for_the_individual_components.has_key? this_program.to_sym
76
+ use_this_command = @query_to_use_for_the_individual_components[this_program.to_sym]
77
+ case use_this_command
78
+ # ===================================================================== #
79
+ # === :mate_desktop
80
+ #
81
+ # This entry is special.
82
+ # ===================================================================== #
83
+ when :mate_desktop
84
+ return RBT.return_mate_desktop_version_array
85
+ # ===================================================================== #
86
+ # === :pkgconfig
87
+ #
88
+ # An invocation example for this would be:
89
+ #
90
+ # x = EnvironmentInformation.return_version_of_this_program(:check) # => "0.15.2"
91
+ #
92
+ # ===================================================================== #
93
+ when :pkgconfig
94
+ version = ::EnvironmentInformation::Queries::PkgConfig.new(this_program).version?
95
+ # ===================================================================== #
96
+ # === :custom_gtk2
97
+ # ===================================================================== #
98
+ when :custom_gtk2
99
+ version = ::EnvironmentInformation::Queries::PkgConfig.new('gtk+-2.0').version?
100
+ # ===================================================================== #
101
+ # === :custom_mpc
102
+ #
103
+ # We rely on the header called mpc.h.
104
+ # ===================================================================== #
105
+ when :custom_mpc
106
+ version = ::EnvironmentInformation.return_version_of_mpc
107
+ # ===================================================================== #
108
+ # === :custom_boost
109
+ # ===================================================================== #
110
+ when :custom_boost
111
+ version = ::EnvironmentInformation.return_version_of_boost
112
+ if version.nil?
113
+ register_this_component_is_missing(:boost)
114
+ end
115
+ # ===================================================================== #
116
+ # === :version (version tag)
117
+ #
118
+ # This entry point is typically for "program_name --version"
119
+ # entries. Some of them require custom modifications.
120
+ # ===================================================================== #
121
+ when :version
122
+ # =================================================================== #
123
+ # Next enable support for AppDir layout, where programs will
124
+ # ultimately reside in the same directory.
125
+ # =================================================================== #
126
+ unless prefix_to_use.empty?
127
+ prefix_to_use << "#{this_program.to_s.capitalize}/Current/bin/"
128
+ end
129
+ cmd = "#{prefix_to_use}#{this_program} --version #{ERROR_LINE}"
130
+ if @debug
131
+ e Colours.crimson('DEBUG for the prefix-value in use: ')+
132
+ Colours.steelblue(cmd)
133
+ end
134
+ version = ::EnvironmentInformation::Queries::SimpleVersion.new(this_program) {{
135
+ prefix_to_use: prefix_to_use
136
+ }}.version?
137
+ # ===================================================================== #
138
+ # Next we will handle special programs, such as "swig -v" and similar.
139
+ # This is done by class ComplexVersion since as of 29.08.2020.
140
+ # ===================================================================== #
141
+ else # else tag
142
+ if use_this_command.start_with?('pkg-config')
143
+ version = ::EnvironmentInformation::Queries::PkgConfig.new(this_program).version?
144
+ else
145
+ cmd = "#{@prefix_to_use}#{use_this_command} #{ERROR_LINE}"
146
+ version = ::EnvironmentInformation::Queries::ComplexVersion.new(this_program) {{
147
+ prefix_to_use: prefix_to_use
148
+ }}.version?
149
+ end
150
+ end
151
+ else
152
+ e 'Not registered any key for the program: '+this_program.to_s
153
+ e 'This is currently not allowed - please add this missing information.'
154
+ exit
155
+ end
156
+ result = version
157
+ if result
158
+ unless result.include? COMMAND_NOT_FOUND
159
+ result = result.dup if result.frozen?
160
+ result.strip!
161
+ end
162
+ end
163
+ if result and (result == 'found' or result == 'foud')
164
+ register_this_component_is_missing(this_program)
165
+ elsif result and result.include?(COMMAND_NOT_FOUND)
166
+ register_this_component_is_missing(this_program)
167
+ # ======================================================================= #
168
+ # Check whether pkg-config is available or not.
169
+ # ======================================================================= #
170
+ elsif result and (
171
+ result.include?(PKGCONFIG_COMMAND_NOT_FOUND) or
172
+ result.include?(NO_SUCH_FILE_OR_DIRECTORY)
173
+ )
174
+ register_this_component_is_missing(this_program)
175
+ elsif result.nil?
176
+ register_this_component_is_missing(this_program)
177
+ end
178
+ return result
179
+ end; self.instance_eval { alias version_for? return_version_of_this_program } # === EnvironmentInformation,version_for?
180
+
181
+ end
182
+
183
+ if __FILE__ == $PROGRAM_NAME
184
+ puts EnvironmentInformation.return_version_of_this_program(ARGV)
185
+ end # envireturnversionofthisprogram ruby
186
+ # envireturnversionofthisprogram ethtools
@@ -0,0 +1,192 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/show_all_available_components.rb'
6
+ # EnvironmentInformation.show_all_available_components
7
+ # =========================================================================== #
8
+ module EnvironmentInformation
9
+
10
+ # ========================================================================= #
11
+ # The next require also pulls in the misc/ components.
12
+ # ========================================================================= #
13
+ require 'environment_information/toplevel_methods/return_version_of_this_program.rb'
14
+ require 'environment_information/constants/array_tracked_components.rb'
15
+ require 'environment_information/constants/regex.rb'
16
+ require 'environment_information/toplevel_methods/hash.rb'
17
+ require 'environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb'
18
+ require 'environment_information/toplevel_methods/misc.rb'
19
+ require 'environment_information/toplevel_methods/replay_from_the_stored_file.rb'
20
+
21
+ begin
22
+ require 'rbt/requires/swift_version.rb'
23
+ rescue LoadError; end
24
+
25
+ # ========================================================================= #
26
+ # Add colours-support next:
27
+ # ========================================================================= #
28
+ require 'environment_information/colours/colours.rb'
29
+ require 'environment_information/queries/pkg_config.rb'
30
+ require 'environment_information/toplevel_methods/e.rb'
31
+ require 'environment_information/toplevel_methods/is_on_roebe.rb'
32
+ require 'environment_information/toplevel_methods/register_this_component_is_missing.rb'
33
+
34
+ # ========================================================================= #
35
+ # === EnvironmentInformation.show_all_available_components
36
+ #
37
+ # This method will quickly and easily show all available (registered)
38
+ # components. If you need more fine-tuning when you wish to display
39
+ # the main dataset at hand, then you should use other methods that
40
+ # are also a bit more complex. This method here is really just a
41
+ # fast version-display overview.
42
+ #
43
+ # The second argument to this method contains the programs that we
44
+ # wish to display through this method.
45
+ # ========================================================================= #
46
+ def self.show_all_available_components(
47
+ n_ljust = 18,
48
+ show_these_components = ARRAY_DEFAULT_PROGRAMS_ON_LINUX+
49
+ ARRAY_TRACKED_PROGRAMS,
50
+ use_colours = use_colours?
51
+ )
52
+ clear_main_hash
53
+ if show_these_components.is_a? Array
54
+ show_these_components.flatten!
55
+ end
56
+ # ======================================================================= #
57
+ # The next variable determines whether we will also compare the
58
+ # program versions.
59
+ # ======================================================================= #
60
+ compare_program_versions = false
61
+ default_nljust_value = 30 # ← Detemine default padding.
62
+ if n_ljust.is_a?(Array) and n_ljust.empty?
63
+ n_ljust = default_nljust_value # Use the default value in this case.
64
+ end
65
+ # ======================================================================= #
66
+ # First we will treat n_ljust as a commandline-flag if it is a String
67
+ # and additionally begins with "--".
68
+ # ======================================================================= #
69
+ if n_ljust.is_a?(Array) and n_ljust.first.start_with?('--')
70
+ _ = n_ljust.first
71
+ case _
72
+ # ===================================================================== #
73
+ # === --compare-to-program-versions
74
+ #
75
+ # To invoke this, try:
76
+ #
77
+ # show_components --compare
78
+ # envi --compare-version
79
+ #
80
+ # ===================================================================== #
81
+ when *ARRAY_COMPARE_PROGRAM_VERSIONS
82
+ compare_program_versions = true
83
+ n_ljust = default_nljust_value
84
+ # ===================================================================== #
85
+ # === --xorg
86
+ # ===================================================================== #
87
+ when /^-?-?xorg$/i
88
+ show_these_components = ::EnvironmentInformation.xorg_components?
89
+ n_ljust = default_nljust_value
90
+ # ===================================================================== #
91
+ # === --help
92
+ #
93
+ # Invocation example:
94
+ #
95
+ # showcomponents --help
96
+ #
97
+ # ===================================================================== #
98
+ when /^-?-?help$/i
99
+ e 'The following options are available for bin/fast_envi (fenvi):'
100
+ e
101
+ e ' --xorg # show only the xorg-components'
102
+ e ' --compare-to-program-versions # also compare the program versions'
103
+ e
104
+ exit
105
+ end
106
+ end
107
+ e
108
+ uniq = show_these_components.uniq
109
+ uniq.sort.each {|this_program|
110
+ use_this_name_for_send = "return_version_of_#{this_program}"
111
+ # ===================================================================== #
112
+ # Next, add the name of the program at hand, onto the left hand side:
113
+ # ===================================================================== #
114
+ result = this_program.to_s.ljust(n_ljust)
115
+ if use_colours
116
+ result = ::EnvironmentInformation.colourize_and_pad_the_left_side(result)
117
+ end
118
+ # ===================================================================== #
119
+ # Some components may not be installed on the user's computer system,
120
+ # which we have to keep in mind in the following code. This is
121
+ # why we will first apply the .send(), before checking whether
122
+ # the program at hand is actually missing or not.
123
+ # ===================================================================== #
124
+ result_of_send = send(use_this_name_for_send)
125
+ if result_of_send
126
+ result_of_send = result_of_send.dup if result_of_send.frozen?
127
+ result_of_send.strip!
128
+ end
129
+ @hash_available_programs[this_program.to_sym] = result_of_send.to_s
130
+ right_component = ''.dup
131
+ if @array_this_component_is_missing.include?(this_program.to_sym)
132
+ right_component << "not installed (or otherwise not found)".ljust(12)
133
+ else
134
+ right_component << result_of_send.ljust(12) if result_of_send
135
+ end
136
+ if use_colours
137
+ # =================================================================== #
138
+ # We will distinguish between components that have been found and
139
+ # components that have not been found.
140
+ # =================================================================== #
141
+ if right_component.include?('not installed')
142
+ right_component = ::Colours.send(:mediumslateblue, right_component)
143
+ else
144
+ right_component = ::Colours.send(colour_for_the_right_side, right_component)
145
+ end
146
+ end
147
+ result = result.dup if result.frozen?
148
+ result << right_component
149
+ if compare_program_versions
150
+ if is_this_program_included?(this_program)
151
+ registered_local_version = RBT.swift_return_version_of_this_program(this_program.to_sym).to_s.dup
152
+ if registered_local_version.include? 'v'
153
+ # =============================================================== #
154
+ # Modify entries such as 'v12.15.0' into '12.15.0'.
155
+ # =============================================================== #
156
+ registered_local_version.delete!('v')
157
+ end
158
+ case this_program.to_s
159
+ when 'gtk2'
160
+ registered_local_version = query_pkgconfig_version_for(:gtk2)
161
+ else
162
+ if result_of_send.nil?
163
+ # ^^^ This is missing, then, so it will be ignored.
164
+ elsif registered_local_version <= result_of_send
165
+ # This is ok.
166
+ else
167
+ result <<
168
+ royalblue(
169
+ "\n "\
170
+ "^^^ This could be updated; the version in "\
171
+ "RBT is: #{mediumpurple(registered_local_version)}"
172
+ )
173
+ end
174
+ end
175
+ end
176
+ end
177
+ # ===================================================================== #
178
+ # Finally display our findings to the end user.
179
+ # ===================================================================== #
180
+ e result
181
+ }
182
+ e
183
+ if is_on_roebe? # And store it on my home system too.
184
+ ::EnvironmentInformation.store_relevant_files
185
+ end
186
+ end
187
+
188
+ end
189
+
190
+ if __FILE__ == $PROGRAM_NAME
191
+ EnvironmentInformation.show_all_available_components(ARGV)
192
+ end # showcomponents --compare
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/write_what_into.rb'
6
+ # EnvironmentInformation.write_what_into
7
+ # =========================================================================== #
8
+ module EnvironmentInformation
9
+
10
+ require 'environment_information/toplevel_methods/e.rb'
11
+
12
+ # ========================================================================= #
13
+ # === EnvironmentInformation.write_what_into
14
+ # ========================================================================= #
15
+ def self.write_what_into(what, into)
16
+ what = what.join("\n") if what.is_a? Array
17
+ File.open(into, 'w+') {|entry| entry.write(what) }
18
+ end
19
+
20
+ end
21
+
22
+ if __FILE__ == $PROGRAM_NAME
23
+ EnvironmentInformation.write_what_into(ARGV, 'test_this.md')
24
+ end
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/version/version.rb'
6
+ # =========================================================================== #
7
+ module EnvironmentInformation
8
+
9
+ # ========================================================================= #
10
+ # === EnvironmentInformation::VERSION
11
+ # ========================================================================= #
12
+ VERSION = '1.4.29'
13
+
14
+ # ========================================================================= #
15
+ # === LAST_UPDATE
16
+ # ========================================================================= #
17
+ LAST_UPDATE = '26.11.2020'
18
+
19
+ # ========================================================================= #
20
+ # === EnvironmentInformation::URL_TO_THE_DOCUMENTATION
21
+ # ========================================================================= #
22
+ URL_TO_THE_DOCUMENTATION =
23
+ "https://www.rubydoc.info/gems/#{self.to_s.split(/(?=[A-Z])/).join('_').downcase}/#{VERSION}"
24
+
25
+ end
@@ -0,0 +1,213 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === EnvironmentInformation::Sinatra
6
+ # =========================================================================== #
7
+ # require 'environment_information/www/sinatra_interface.rb'
8
+ # =========================================================================== #
9
+ require 'sinatra/base.rb'
10
+ require 'beautiful_url'
11
+ require 'environment_information/requires/require_the_environment_information_project.rb'
12
+
13
+ module EnvironmentInformation
14
+
15
+ class Sinatra < Sinatra::Base
16
+
17
+ include Colours
18
+ include Colours::E
19
+ begin
20
+ require 'html_tags'
21
+ include HtmlTags::BaseModule
22
+ rescue LoadError; end
23
+
24
+ # ========================================================================= #
25
+ # === USE_THIS_PORT
26
+ # ========================================================================= #
27
+ USE_THIS_PORT = '4567'
28
+
29
+ set :port, USE_THIS_PORT
30
+
31
+ # ========================================================================= #
32
+ # === initialize
33
+ # ========================================================================= #
34
+ def initialize
35
+ super()
36
+ reset
37
+ if ::EnvironmentInformation.is_on_roebe?
38
+ require 'open_in_browser'
39
+ # ===================================================================== #
40
+ # Tell us which port will be used:
41
+ # ===================================================================== #
42
+ target = "http://localhost:#{USE_THIS_PORT}/"
43
+ e sfancy(target)
44
+ Thread.new {
45
+ sleep 1.0
46
+ OpenInBrowser[target]
47
+ }
48
+ end
49
+ end
50
+
51
+ # ========================================================================= #
52
+ # === reset
53
+ # ========================================================================= #
54
+ def reset
55
+ end
56
+
57
+ # ========================================================================= #
58
+ # === html_end
59
+ # ========================================================================= #
60
+ def html_end
61
+ '<idv></body></html>'
62
+ end
63
+
64
+ # ========================================================================= #
65
+ # === return_html_start
66
+ #
67
+ # This method will include all parts up to the first main <div>
68
+ # element of the webpage.
69
+ # ========================================================================= #
70
+ def return_html_start
71
+ "<html><head><title>\n"\
72
+ "Sinatra-Interface of the EnvironmentInformation project\n"\
73
+ "</title></head><body>"\
74
+ "<div style=\"padding:2px; margin-left:0.5em\">"
75
+ end
76
+
77
+ # ========================================================================= #
78
+ # === / Entry point
79
+ #
80
+ # This is the root of our web-application.
81
+ # ========================================================================= #
82
+ get('/') {
83
+ # ======================================================================= #
84
+ # We will initialize the main Hash next, that is kept in
85
+ # EnvironmentInformation.
86
+ # ======================================================================= #
87
+ ::EnvironmentInformation.build_up_and_return_the_main_hash
88
+ inner_content =
89
+ h2('Displaying information about the local computersystem')+
90
+ uniform_p_tag('Operating system in use:',
91
+ ::EnvironmentInformation.operating_system?)+
92
+ uniform_p_tag('OS Bit type (architecture):',
93
+ ::EnvironmentInformation.bit_type?)+
94
+ uniform_p_tag('CPU Model:',
95
+ ::EnvironmentInformation.cpu_model?)+
96
+ uniform_p_tag('CFLAGS in use:',
97
+ ::EnvironmentInformation.cflags_in_use?)+
98
+ uniform_p_tag('RAM (in MB):',
99
+ ::EnvironmentInformation.ram?)+
100
+ uniform_p_tag('Screen resolution:',
101
+ ::EnvironmentInformation.screen_resolution?.to_s)
102
+ inner_content = inner_content.dup
103
+ # ======================================================================= #
104
+ # Next, add the individual components:
105
+ # ======================================================================= #
106
+ %i(
107
+ gcc
108
+ glibc
109
+ linux_kernel
110
+ binutils
111
+ awk
112
+ ruby
113
+ rubygems
114
+ coreutils
115
+ diffutils
116
+ bison
117
+ boost
118
+ cmake
119
+ file
120
+ flex
121
+ intltool
122
+ gettext
123
+ grep
124
+ gnupg
125
+ ).each {|this_component|
126
+ inner_content << sinatra_paragraph_showing_this_component(this_component).to_s
127
+ }
128
+ return_html_start+
129
+ div(css_style: 'font-size: normal; margin-top:1px; margin-bottom: 1px;') {
130
+ inner_content
131
+ }+
132
+ html_end
133
+ }
134
+
135
+ # ========================================================================= #
136
+ # === uniform_p_tag
137
+ # ========================================================================= #
138
+ def uniform_p_tag(i, content)
139
+ i = i.to_s
140
+ unless i.end_with? ':'
141
+ i = i.dup if i.frozen?
142
+ i << ':'
143
+ end
144
+ p(
145
+ "#{i}<br><b style=\"color: darkblue; margin-left:1.5em\">#{content}"\
146
+ "</b>",
147
+ css_style: 'margin-left: 2.5em;
148
+ margin: 4px;
149
+ padding: 5px;
150
+ padding-top: 0.2em'
151
+ )
152
+ end
153
+
154
+ # ========================================================================= #
155
+ # === sinatra_paragraph_showing_this_component
156
+ #
157
+ # This method was added primarily so that we can use a unified (and
158
+ # consistent) style for display.
159
+ # ========================================================================= #
160
+ def sinatra_paragraph_showing_this_component(
161
+ i = :gcc
162
+ )
163
+ content = "return_version_of_#{i}".to_s
164
+ content = ::EnvironmentInformation.send(content)
165
+ # ======================================================================= #
166
+ # Next, we grab it from the main Hash.
167
+ # ======================================================================= #
168
+ case i
169
+ when :awk,
170
+ :bison,
171
+ :boost,
172
+ :coreutils,
173
+ :binutils,
174
+ :cmake,
175
+ :diffutils,
176
+ :findutils,
177
+ :file,
178
+ :flex,
179
+ :gcc,
180
+ :gettext,
181
+ :glibc,
182
+ :grep,
183
+ :gnupg,
184
+ :intltool,
185
+ :ruby,
186
+ :rubygems
187
+ i = i.to_s.capitalize+' Version'
188
+ when :linux_kernel
189
+ i = 'Linux Kernel'
190
+ end
191
+ # ======================================================================= #
192
+ # Finally return the proper <p> tag:
193
+ # ======================================================================= #
194
+ uniform_p_tag(i, content)
195
+ end
196
+
197
+ end
198
+
199
+ # =========================================================================== #
200
+ # === EnvironmentInformation.start_sinatra_interface
201
+ #
202
+ # This method can be used to start the sinatra interface.
203
+ # =========================================================================== #
204
+ def self.start_sinatra_interface
205
+ puts 'Trying to start the sinatra-interface of EnvironmentInformation next.'
206
+ ::EnvironmentInformation::Sinatra.run!
207
+ end
208
+
209
+ end
210
+
211
+ if __FILE__ == $PROGRAM_NAME
212
+ EnvironmentInformation.start_sinatra_interface
213
+ end # envi --sinatra
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This small .cgi file just demonstrates how to use the information
6
+ # from the EnvironmentInformation project in a .cgi page.
7
+ # =========================================================================== #
8
+ # http://localhost/DATA/PROGRAMMING_LANGUAGES/RUBY/src/environment_information/lib/environment_information/www/webobject_interface.cgi
9
+ # =========================================================================== #
10
+ require 'web_object/autoinclude'
11
+
12
+ use_this_title = 'WebObject interface to EnvironmentInformation'
13
+
14
+ english {
15
+ title use_this_title
16
+ fav 'PC/RUBY/RUBY_FAVICON.png'
17
+ body_css_class 's4px padt2px marpad2px VERDANAs'
18
+ body_css_style 'background-color: #d3d2d1;'
19
+ font_size 'def'
20
+
21
+ doc('mar0px') {
22
+ h1 sg(:buero_klammer, '','drag_buero_klammer')+
23
+ use_this_title
24
+ # ========================================================================= #
25
+ # Tap into showing the information from the EnvironmentInformation project.
26
+ # This is actually built into WebObject since as of February 2020.
27
+ # ========================================================================= #
28
+ WebObject.display_information_about_the_environment
29
+ }}}
@@ -0,0 +1,14 @@
1
+ # =========================================================================== #
2
+ # x = YAML.load_file('array_default_programs_on_linux.yml')
3
+ # =========================================================================== #
4
+
5
+ - !ruby/symbol operating_system
6
+ - !ruby/symbol operating_system_bit_type
7
+ - !ruby/symbol cpuinfo
8
+ - !ruby/symbol ram
9
+ - !ruby/symbol screen_resolution
10
+ - !ruby/symbol cflags
11
+ - !ruby/symbol gcc
12
+ - !ruby/symbol glibc
13
+ - !ruby/symbol linux
14
+ - !ruby/symbol binutils