environment_information 1.4.124 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +91 -15
  3. data/doc/README.gen +42 -14
  4. data/doc/todo/TODO_FOR_THE_ENVIRONMENT_INFORMATION_PROJECT.md +16 -12
  5. data/lib/environment_information/base/base.rb +483 -99
  6. data/lib/environment_information/colours/colours.rb +92 -66
  7. data/lib/environment_information/commandline/commandline.rb +137 -0
  8. data/lib/environment_information/constants/constants.rb +372 -11
  9. data/lib/environment_information/project/project.rb +1 -1
  10. data/lib/environment_information/query/constants.rb +46 -0
  11. data/lib/environment_information/query/help.rb +88 -0
  12. data/lib/environment_information/query/menu.rb +487 -0
  13. data/lib/environment_information/query/misc.rb +2006 -0
  14. data/lib/environment_information/query/query.rb +245 -0
  15. data/lib/environment_information/query/reset.rb +202 -0
  16. data/lib/environment_information/query/run.rb +70 -0
  17. data/lib/environment_information/requires/require_the_environment_information_project.rb +2 -7
  18. data/lib/environment_information/requires/require_the_toplevel_methods.rb +1 -3
  19. data/lib/environment_information/toplevel_methods/toplevel_methods.rb +2258 -0
  20. data/lib/environment_information/version/version.rb +2 -2
  21. data/lib/environment_information/www/sinatra_interface.rb +20 -17
  22. data/lib/environment_information/www/webobject_interface.cgi +6 -7
  23. data/lib/environment_information/yaml/colours.yml +3 -3
  24. data/lib/environment_information/yaml/query_to_use_for_all_components.yml +284 -0
  25. data/lib/environment_information/yaml/{array_tracked_programs.yml → track_these_components.yml} +77 -11
  26. metadata +18 -60
  27. data/lib/environment_information/class/class.rb +0 -2580
  28. data/lib/environment_information/class/colours.rb +0 -282
  29. data/lib/environment_information/colours/sfancy.rb +0 -19
  30. data/lib/environment_information/colours/simp.rb +0 -19
  31. data/lib/environment_information/constants/array_tracked_components.rb +0 -210
  32. data/lib/environment_information/constants/encoding.rb +0 -21
  33. data/lib/environment_information/constants/error_line.rb +0 -17
  34. data/lib/environment_information/constants/file_constants.rb +0 -102
  35. data/lib/environment_information/constants/misc.rb +0 -86
  36. data/lib/environment_information/constants/namespace.rb +0 -14
  37. data/lib/environment_information/constants/newline.rb +0 -16
  38. data/lib/environment_information/constants/regex.rb +0 -30
  39. data/lib/environment_information/constants/temp_directory.rb +0 -52
  40. data/lib/environment_information/misc_components/README.md +0 -3
  41. data/lib/environment_information/misc_components/cflags.rb +0 -36
  42. data/lib/environment_information/misc_components/cpuinfo.rb +0 -64
  43. data/lib/environment_information/misc_components/operating_system.rb +0 -54
  44. data/lib/environment_information/misc_components/operating_system_bit_type.rb +0 -42
  45. data/lib/environment_information/misc_components/ram.rb +0 -30
  46. data/lib/environment_information/misc_components/rubygems_installation_directory.rb +0 -54
  47. data/lib/environment_information/misc_components/screen_resolution.rb +0 -50
  48. data/lib/environment_information/queries/README.md +0 -2
  49. data/lib/environment_information/queries/complex_version.rb +0 -273
  50. data/lib/environment_information/queries/pkg_config.rb +0 -125
  51. data/lib/environment_information/queries/simple_version.rb +0 -272
  52. data/lib/environment_information/requires/require_the_individual_misc_components.rb +0 -30
  53. data/lib/environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb +0 -153
  54. data/lib/environment_information/toplevel_methods/cd.rb +0 -16
  55. data/lib/environment_information/toplevel_methods/e.rb +0 -43
  56. data/lib/environment_information/toplevel_methods/hash.rb +0 -65
  57. data/lib/environment_information/toplevel_methods/internet_is_available.rb +0 -30
  58. data/lib/environment_information/toplevel_methods/is_on_roebe.rb +0 -16
  59. data/lib/environment_information/toplevel_methods/menu.rb +0 -90
  60. data/lib/environment_information/toplevel_methods/misc.rb +0 -324
  61. data/lib/environment_information/toplevel_methods/n_subcommands.rb +0 -31
  62. data/lib/environment_information/toplevel_methods/prefix_to_use.rb +0 -39
  63. data/lib/environment_information/toplevel_methods/register_this_component_is_missing.rb +0 -61
  64. data/lib/environment_information/toplevel_methods/remote_url_of_this_program.rb +0 -45
  65. data/lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb +0 -84
  66. data/lib/environment_information/toplevel_methods/return_alias_to.rb +0 -30
  67. data/lib/environment_information/toplevel_methods/return_pkgconfig_based_programs.rb +0 -28
  68. data/lib/environment_information/toplevel_methods/return_remote_gtk2_version.rb +0 -54
  69. data/lib/environment_information/toplevel_methods/return_simple_version_based_programs.rb +0 -28
  70. data/lib/environment_information/toplevel_methods/return_version_of_this_program.rb +0 -182
  71. data/lib/environment_information/toplevel_methods/show_all_available_components.rb +0 -192
  72. data/lib/environment_information/toplevel_methods/write_what_into.rb +0 -24
  73. data/lib/environment_information/yaml/array_default_programs_on_linux.yml +0 -15
  74. data/lib/environment_information/yaml/array_lfs_core_programs.yml +0 -37
  75. data/lib/environment_information/yaml/array_science_cluster.yml +0 -12
  76. data/lib/environment_information/yaml/array_tracked_non_programs.yml +0 -13
  77. data/lib/environment_information/yaml/array_tracked_xorg_components.yml +0 -37
  78. data/lib/environment_information/yaml/query_to_use_for_the_individual_components.yml +0 -284
@@ -1,86 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'environment_information/constants/misc.rb'
6
- # =========================================================================== #
7
- module EnvironmentInformation
8
-
9
- require 'environment_information/constants/encoding.rb'
10
- require 'environment_information/constants/temp_directory.rb'
11
-
12
- # ========================================================================= #
13
- # === EnvironmentInformation::NOT_INSTALLED_OR_NOT_FOUND
14
- # ========================================================================= #
15
- NOT_INSTALLED_OR_NOT_FOUND = '[Not installed or not found.]'
16
-
17
- # ========================================================================= #
18
- # === EnvironmentInformation::COMMAND_NOT_FOUND
19
- # ========================================================================= #
20
- COMMAND_NOT_FOUND = 'command not found'
21
-
22
- # ========================================================================= #
23
- # === EnvironmentInformation::NOT_FOUND
24
- # ========================================================================= #
25
- NOT_FOUND = 'not found'
26
-
27
- # ========================================================================= #
28
- # === EnvironmentInformation::VERSION_STRING
29
- # ========================================================================= #
30
- VERSION_STRING = 'version'
31
-
32
- # ========================================================================= #
33
- # === EnvironmentInformation::NOT_FOUND_IN_PKG_CONFIG_SEARCH_PATH
34
- #
35
- # This constant is specifically for missing (or not found) .pc
36
- # files.
37
- # ========================================================================= #
38
- NOT_FOUND_IN_PKG_CONFIG_SEARCH_PATH =
39
- 'as not found in the pkg-config search path'
40
-
41
- # ========================================================================= #
42
- # === EnvironmentInformation::THE_PROGRAM_WAS_NOT_FOUND
43
- # ========================================================================= #
44
- THE_PROGRAM_WAS_NOT_FOUND =
45
- '[The program was not found.]'
46
-
47
- # ========================================================================= #
48
- # === EnvironmentInformation::PKGCONFIG_COMMAND_NOT_FOUND
49
- #
50
- # The constant that follows next is used to determine whether
51
- # pkg-config could find a corresponding .pc file. If not then
52
- # pkg-config will typically report a line such as this:
53
- #
54
- # Package libdr was not found in the pkg-config search path.
55
- #
56
- # We will include the last part of this string, as a generic
57
- # message that can be used to indicate "this package could
58
- # not be found on the given computer system at hand".
59
- # ========================================================================= #
60
- PKGCONFIG_COMMAND_NOT_FOUND =
61
- ' was not found in the pkg-config search path.'
62
-
63
- # ========================================================================= #
64
- # === EnvironmentInformation::NO_SUCH_FILE_OR_DIRECTORY
65
- # ========================================================================= #
66
- NO_SUCH_FILE_OR_DIRECTORY =
67
- 'No such file or directory'
68
-
69
- # ========================================================================= #
70
- # === TRY_TO_MAKE_USE_OF_THE_OPN_GEM_IF_IT_IS_AVAILABLE
71
- #
72
- # This gem is closely connected to the NAMESPACE constant, so it
73
- # will also reside in this file here.
74
- # ========================================================================= #
75
- TRY_TO_MAKE_USE_OF_THE_OPN_GEM_IF_IT_IS_AVAILABLE = true
76
-
77
- # ========================================================================= #
78
- # === EnvironmentInformation::SAVE_FILE
79
- #
80
- # Where to save stuff to. This depends on a proper setting of the
81
- # toplevel variable called @temp_directory.
82
- # ========================================================================= #
83
- SAVE_FILE =
84
- "#{@temp_directory}EnvironmentInformation.md"
85
-
86
- end
@@ -1,14 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'environment_information/constants/namespace.rb'
6
- # =========================================================================== #
7
- module EnvironmentInformation
8
-
9
- # ========================================================================= #
10
- # === NAMESPACE
11
- # ========================================================================= #
12
- NAMESPACE = inspect
13
-
14
- end
@@ -1,16 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'environment_information/constants/newline.rb'
6
- # =========================================================================== #
7
- module EnvironmentInformation
8
-
9
- # ========================================================================= #
10
- # === EnvironmentInformation::N
11
- #
12
- # A newline constant to simplify our life.
13
- # ========================================================================= #
14
- N = "\n"
15
-
16
- end
@@ -1,30 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # All regexes that relate to EnvironmentInformation project should be
6
- # stored in this file here.
7
- # =========================================================================== #
8
- # require 'environment_information/constants/regex.rb'
9
- # =========================================================================== #
10
- module EnvironmentInformation
11
-
12
- # ========================================================================= #
13
- # === EnvironmentInformation::ARRAY_VERSION
14
- # ========================================================================= #
15
- ARRAY_VERSION = [
16
- /^-?-?version\??$/i
17
- ]
18
-
19
- # ========================================================================= #
20
- # === EnvironmentInformation::ARRAY_COMPARE_PROGRAM_VERSIONS
21
- # ========================================================================= #
22
- ARRAY_COMPARE_PROGRAM_VERSIONS = [
23
- /^-?-?compare(-|_)?to(-|_)?program(-|_)?versions$/i,
24
- /^-?-?compare(-|_)?program(-|_)?versions$/i,
25
- /^-?-?compare(-|_)?programs$/i,
26
- /^-?-?compare$/i,
27
- /^-?-?compare(-|_)?version$/i
28
- ]
29
-
30
- end
@@ -1,52 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'environment_information/constants/temp_directory.rb'
6
- # =========================================================================== #
7
- module EnvironmentInformation
8
-
9
- # ========================================================================= #
10
- # === EnvironmentInformation::TEMP_DIRECTORY
11
- #
12
- # This constant denotes into which directory files should be stored,
13
- # e. g. autogenerated files from the EnvironmentInformation project.
14
- #
15
- # This constant MUST have a trailing '/' character.
16
- #
17
- # The environment variable called MY_TEMP_DIR can overrule all
18
- # other guesses made here, but it is not always available,
19
- # e. g. in a .cgi file such an environment variable may not
20
- # be available.
21
- # ========================================================================= #
22
- if ENV.has_key? 'MY_TEMP_DIR'
23
- TEMP_DIRECTORY = ENV['MY_TEMP_DIR'].to_s
24
- elsif File.directory? '/home/Temp/' # ← My main directory.
25
- TEMP_DIRECTORY = '/home/Temp/'
26
- elsif File.directory? '/Depot/Temp/'
27
- TEMP_DIRECTORY = '/Depot/Temp/'
28
- else
29
- TEMP_DIRECTORY = '/tmp/' # ← "Rescue" for most other users on linux.
30
- end
31
-
32
- # ========================================================================= #
33
- # === @temp_directory
34
- # ========================================================================= #
35
- @temp_directory = TEMP_DIRECTORY
36
-
37
- # ========================================================================= #
38
- # === EnvironmentInformation.temp_directory?
39
- #
40
- # This method will refer to the temp-directory in use for this project.
41
- #
42
- # It is advised to make use of the method, rather than the
43
- # TEMP_DIRECTORY constant, as that is more convenient in the
44
- # long run.
45
- # ========================================================================= #
46
- def self.temp_directory?(
47
- i = @temp_directory
48
- )
49
- i.squeeze('/').dup
50
- end; self.instance_eval { alias temp_dir? temp_directory? } # === EnvironmentInformation.temp_dir?
51
-
52
- end
@@ -1,3 +0,0 @@
1
- Ruby files in this directory relate to components that are not really
2
- programs, such as CFLAGS, or the number of processors, or the amount
3
- of RAM on a given computer system.
@@ -1,36 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'environment_information/misc_components/cflags.rb'
6
- # EnvironmentInformation.cflags_in_use?
7
- # =========================================================================== #
8
- module EnvironmentInformation
9
-
10
- # ========================================================================= #
11
- # === EnvironmentInformation.cflags? (cflags tag)
12
- #
13
- # The following is equivalent to the value stored in the variable
14
- # $CFLAGS, which on unix-like systems may be obtained by issuing
15
- # the following command:
16
- #
17
- # echo $CFLAGS
18
- #
19
- # The output may be like this:
20
- #
21
- # -O2 -fPIC -fno-strict-overflow -Wno-error
22
- #
23
- # ========================================================================= #
24
- def self.cflags?
25
- version = ENV['CFLAGS'].to_s.strip
26
- version = '<none>' if version.empty? # Display special status if it is empty.
27
- version
28
- end; self.instance_eval { alias cflags_in_use? cflags? } # === EnvironmentInformation.cflags_in_use?
29
- self.instance_eval { alias return_version_of_cflags cflags? } # === EnvironmentInformation.return_version_of_cflags
30
- self.instance_eval { alias cflags cflags? } # === EnvironmentInformation.cflags
31
-
32
- end
33
-
34
- if __FILE__ == $PROGRAM_NAME
35
- puts EnvironmentInformation.cflags?
36
- end
@@ -1,64 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'environment_information/misc_components/cpuinfo.rb'
6
- # EnvironmentInformation.cpuinfo?
7
- # =========================================================================== #
8
- module EnvironmentInformation
9
-
10
- require 'environment_information/constants/newline.rb'
11
- require 'environment_information/constants/error_line.rb'
12
-
13
- # ========================================================================= #
14
- # === EnvironmentInformation.cpuinfo? (cpuinfo tag)
15
- #
16
- # This method currently relies on /proc/cpuinfo, thus favouring
17
- # Linux-based systems.
18
- #
19
- # The output will be similar to this:
20
- #
21
- # AMD A8-7600 Radeon R7, 10 Compute Cores 4C+6G, 4 cores
22
- #
23
- # It will become the display part of "CPU Model".
24
- # ========================================================================= #
25
- def self.cpuinfo?
26
- result = '/proc/cpuinfo'
27
- if File.exist? result
28
- readlines = File.readlines(result)
29
- _ = readlines.grep(/model name/).first.chomp
30
- splitted = _.split(':')
31
- _ = splitted[1].strip # => "model name\t: AMD Sempron(tm) 145 Processor"
32
- # ===================================================================== #
33
- # Next, add the amount of cores. We use "nproc" for this but "lscpu"
34
- # also contains this information. The following regex could be used
35
- # for lscpu:
36
- #
37
- # Core\(s\) per socket: (.+)
38
- #
39
- # Ok, we use lscpu for now.
40
- # ===================================================================== #
41
- n_cores = `nproc --all`.strip
42
- case n_cores.to_s
43
- when '1'
44
- n_cores << ' core' # Singular.
45
- else
46
- n_cores << ' cores' # Plural then.
47
- end
48
- _ << ", #{n_cores}" unless n_cores.empty?
49
- result = _
50
- else
51
- result = nil
52
- end
53
- result
54
- end; self.instance_eval { alias append_operating_system_cpuinfo cpuinfo? } # === EnvironmentInformation.append_operating_system_cpuinfo
55
- self.instance_eval { alias cpu_model cpuinfo? } # === EnvironmentInformation.cpu_model
56
- self.instance_eval { alias cpu_model? cpuinfo? } # === EnvironmentInformation.cpu_model?
57
- self.instance_eval { alias return_version_of_cpuinfo cpuinfo? } # === EnvironmentInformation.return_version_of_cpuinfo
58
- self.instance_eval { alias cpuinfo cpuinfo? } # === EnvironmentInformation.cpuinfo
59
-
60
- end
61
-
62
- if __FILE__ == $PROGRAM_NAME
63
- puts EnvironmentInformation.cpuinfo?
64
- end
@@ -1,54 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'environment_information/misc_components/operating_system.rb'
6
- # =========================================================================== #
7
- module EnvironmentInformation
8
-
9
- require 'environment_information/constants/newline.rb'
10
- require 'environment_information/constants/error_line.rb'
11
-
12
- # ========================================================================= #
13
- # === EnvironmentInformation.operating_system (os tag)
14
- #
15
- # This method is also known as "bit type".
16
- #
17
- # The return value of this method may be a String such as this one here:
18
- #
19
- # "GNU/Linux"
20
- #
21
- # This is then further modified a bit to drop the "GNU/" part
22
- # specifically.
23
- #
24
- # ========================================================================= #
25
- def self.operating_system
26
- cmd = 'uname -mo'
27
- result = `#{cmd}`.chomp
28
- if result.start_with? 'GNU'
29
- # ===================================================================== #
30
- # The next part removes 'GNU/' specifically. It is a simpler name
31
- # than "GNU Linux" and variants, just as "BSD" is simpler than
32
- # e. g. "FreeBSD". You can reason that it may be "less accurate",
33
- # but it makes the notification-part of this gem simpler.
34
- # ===================================================================== #
35
- result.sub!(/^GNU\//,'') # Experimental as of Sep 2019.
36
- end
37
- if result.include? ' '
38
- result = result.split(' ').last
39
- end
40
- result
41
- end; self.instance_eval { alias operating_system? operating_system } # === EnvironmentInformation.operating_system?
42
- self.instance_eval { alias operating_system_information? operating_system } # === EnvironmentInformation.operating_system_information
43
- self.instance_eval { alias add_operating_system_information operating_system } # === EnvironmentInformation.add_operating_system_information
44
- self.instance_eval { alias append_operating_system_in_use operating_system } # === EnvironmentInformation.append_operating_system_in_use
45
- self.instance_eval { alias add_os_information operating_system } # === EnvironmentInformation.add_os_information
46
- self.instance_eval { alias operating_system_in_use? operating_system } # === EnvironmentInformation.operating_system_in_use?
47
- self.instance_eval { alias return_version_of_operating_system operating_system } # === EnvironmentInformation.return_version_of_operating_system
48
- self.instance_eval { alias return_version_of_operating_system_in_use operating_system } # === EnvironmentInformation.return_version_of_operating_system_in_use
49
-
50
- end
51
-
52
- if __FILE__ == $PROGRAM_NAME
53
- puts EnvironmentInformation.operating_system
54
- end # envi_operating_system
@@ -1,42 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'environment_information/misc_components/operating_system.rb'
6
- # =========================================================================== #
7
- module EnvironmentInformation
8
-
9
- require 'environment_information/constants/newline.rb'
10
- require 'environment_information/constants/error_line.rb'
11
-
12
- # ========================================================================= #
13
- # === EnvironmentInformation.operating_system_bit_type_information (bit tag, bit type tag)
14
- #
15
- # This method will return the bit type in use, as a String,
16
- # such as "x86_64" or "x86_64 (64 bit)" specifically. The
17
- # reason why this method appends ' (64 bit)' is mostly so
18
- # that the user can quickly see whether a computer is on
19
- # 32 bit or on 64 bit.
20
- # ========================================================================= #
21
- def self.operating_system_bit_type_information
22
- cmd = 'uname -m'
23
- result = `#{cmd}`.chomp
24
- result = result.split(' ')[-1] if result.include?(' ')
25
- result = result.dup if result.frozen?
26
- case result
27
- when 'x86_64'
28
- result << ' (64 bit)'
29
- end
30
- result
31
- end; self.instance_eval { alias add_bit_type_information operating_system_bit_type_information } # === EnvironmentInformation.add_bit_type_information
32
- self.instance_eval { alias add_operating_system_bit_type operating_system_bit_type_information } # === EnvironmentInformation.add_operating_system_bit_type
33
- self.instance_eval { alias bit_type? operating_system_bit_type_information } # === EnvironmentInformation.bit_type?
34
- self.instance_eval { alias return_version_of_operating_system_bit_type operating_system_bit_type_information } # === EnvironmentInformation.return_version_of_operating_system_bit_type
35
- self.instance_eval { alias operating_system_bit_type? operating_system_bit_type_information } # === EnvironmentInformation.operating_system_bit_type?
36
- self.instance_eval { alias operating_system_bit_type operating_system_bit_type_information } # === EnvironmentInformation.operating_system_bit_type
37
-
38
- end
39
-
40
- if __FILE__ == $PROGRAM_NAME
41
- puts EnvironmentInformation.operating_system_bit_type_information
42
- end
@@ -1,30 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'environment_information/misc_components/ram.rb'
6
- # ::EnvironmentInformation.ram?
7
- # =========================================================================== #
8
- module EnvironmentInformation
9
-
10
- # ========================================================================= #
11
- # === EnvironmentInformation.ram? (ram tag)
12
- #
13
- # This method will determine how much RAM the given computer host has.
14
- #
15
- # The result will be given in n MB.
16
- # ========================================================================= #
17
- def self.ram?
18
- result_in_n_mb = `free -m 2>&1`.split("\n")[1]
19
- if result_in_n_mb and result_in_n_mb.include?(' ')
20
- result_in_n_mb = result_in_n_mb.split(' ')[1]
21
- end
22
- result_in_n_mb
23
- end; self.instance_eval { alias return_version_of_ram ram? } # === EnvironmentInformation.return_version_of_ram
24
- self.instance_eval { alias ram ram? } # === EnvironmentInformation.ram
25
-
26
- end
27
-
28
- if __FILE__ == $PROGRAM_NAME
29
- puts EnvironmentInformation.ram?
30
- end
@@ -1,54 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'environment_information/misc_components/rubygems_installation_directory.rb'
6
- # EnvironmentInformation.rubygems_installation_directory?
7
- # =========================================================================== #
8
- module EnvironmentInformation
9
-
10
- require 'environment_information/constants/newline.rb'
11
- require 'environment_information/constants/error_line.rb'
12
- require 'environment_information/toplevel_methods/prefix_to_use.rb'
13
-
14
- # ========================================================================= #
15
- # === EnvironmentInformation.rubygems_installation_directory
16
- #
17
- # This method will return the path to the rubygems installation
18
- # directory, if possible (if it exists).
19
- #
20
- # As this ought to be a directory, we will ensure that a trailing '/'
21
- # character exists.
22
- #
23
- # This method may return a String such as "/root/.gem/".
24
- # ========================================================================= #
25
- def self.rubygems_installation_directory(
26
- prefix_to_use = @prefix_to_use
27
- )
28
- result = `#{prefix_to_use}gem env #{ERROR_LINE}` # We need the 2>&1 to check if gem is available.
29
- unless result.include? 'not found'
30
- # ===================================================================== #
31
- # Apply a regex next.
32
- # ===================================================================== #
33
- path_to_the_rubygem_directory = result.to_s.scan(
34
- /INSTALLATION DIRECTORY: (.+)/ # Obtain the proper match here.
35
- ).flatten.first.to_s
36
- if File.directory? path_to_the_rubygem_directory
37
- path_to_the_rubygem_directory << '/'
38
- end unless path_to_the_rubygem_directory.end_with? '/'
39
- result = path_to_the_rubygem_directory
40
- else
41
- result = nil
42
- end
43
- result
44
- end; self.instance_eval { alias add_rubygems_installation_directory_information rubygems_installation_directory } # === EnvironmentInformation.add_rubygems_installation_directory_information
45
- self.instance_eval { alias add_rubygem_directory_information rubygems_installation_directory } # === EnvironmentInformation.add_rubygem_directory_information
46
- self.instance_eval { alias append_rubygem_installation_directory rubygems_installation_directory } # === EnvironmentInformation.append_rubygem_installation_directory
47
- self.instance_eval { alias return_version_of_rubygems_installation_directory rubygems_installation_directory } # === EnvironmentInformation.return_version_of_rubygems_installation_directory
48
- self.instance_eval { alias rubygems_installation_directory? rubygems_installation_directory } # === EnvironmentInformation.rubygems_installation_directory?
49
-
50
- end
51
-
52
- if __FILE__ == $PROGRAM_NAME
53
- puts EnvironmentInformation.rubygems_installation_directory
54
- end
@@ -1,50 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'environment_information/misc_components/screen_resolution.rb'
6
- # EnvironmentInformation.screen_resolution?
7
- # =========================================================================== #
8
- module EnvironmentInformation
9
-
10
- require 'environment_information/constants/newline.rb'
11
- require 'environment_information/constants/error_line.rb'
12
-
13
- # ========================================================================= #
14
- # === EnvironmentInformation.screen_resolution (screen tag)
15
- #
16
- # This method will typically make use of xdpyinfo first, as it also
17
- # works in a .cgi environment. For non-cgi environments, on linux,
18
- # we could use xrandr, which is a bit more elegant.
19
- #
20
- # On success, the method here will return a String such as "1920x1080".
21
- # ========================================================================= #
22
- def self.screen_resolution
23
- result = '(unknown)' # This is the default return-value, then.
24
- # ======================================================================= #
25
- # === Check for linux as host OS first
26
- # ======================================================================= #
27
- if RUBY_PLATFORM.downcase.include? 'linux'
28
- # ================================================================= #
29
- # We have to be careful as xdpyinfo may not be installed on the
30
- # given computer system.
31
- # ================================================================= #
32
- resolution = `xdpyinfo #{ERROR_LINE}`.scan(/dimensions:.+$/).first # The error here may be: "xdpyinfo: unable to open display"
33
- if resolution and resolution.include? ':'
34
- result = resolution.split(':').last.strip.split('pixels').first.strip
35
- end
36
- # ======================================================================= #
37
- # === Else simply assume to be on windows here
38
- # ======================================================================= #
39
- else
40
- result = `wmic desktopmonitor get screenheight,screenwidth #{ERROR_LINE}`
41
- end
42
- result
43
- end; self.instance_eval { alias screen_resolution? screen_resolution } # === EnvironmentInformation.screen_resolution?
44
- self.instance_eval { alias return_version_of_screen_resolution screen_resolution } # === EnvironmentInformation.return_version_of_screen_resolution
45
-
46
- end
47
-
48
- if __FILE__ == $PROGRAM_NAME
49
- puts EnvironmentInformation.screen_resolution
50
- end
@@ -1,2 +0,0 @@
1
- This directory contains code to specifically handle the different
2
- query-related ways.