module EnvironmentInformation

#

require ‘environment_information/base/base.rb’ < ::EnvironmentInformation::Base

#
#

require ‘environment_information/colours/colours.rb’ EnvironmentInformation.colour_for_the_left_side

#
#

require ‘environment_information/colours/sfancy.rb’

#
#

require ‘environment_information/colours/simp.rb’

#
#

require ‘environment_information/constants/array_tracked_components.rb’ EnvironmentInformation.is_this_program_included?

#
#

require ‘environment_information/constants/encoding.rb’

#
#

require ‘environment_information/constants/error_line.rb’

#
#

require ‘environment_information/constants/file_constants.rb’ EnvironmentInformation.file_query_to_use_for_the_individual_components EnvironmentInformation.query_to_use_for_the_individual_components?

#
#

require ‘environment_information/constants/misc.rb’

#
#

require ‘environment_information/constants/namespace.rb’

#
#

require ‘environment_information/constants/newline.rb’

#
#

All regexes that relate to EnvironmentInformation project should be stored in this file here.

#

require ‘environment_information/constants/regex.rb’

#
#

require ‘environment_information/constants/temp_directory.rb’

#
#

EnvironmentInformation::GUI::UniversalWidgets::EnvironmentInformationModule

#

require ‘environment_information/gui/shared_code/environment_information/environment_information_module.rb’ include ::EnvironmentInformation::GUI::UniversalWidgets::EnvironmentInformationModule

#
#

require ‘environment_information/misc_components/cflags.rb’ EnvironmentInformation.cflags_in_use?

#
#

require ‘environment_information/misc_components/cpuinfo.rb’ EnvironmentInformation.cpuinfo?

#
#

require ‘environment_information/misc_components/operating_system.rb’

#
#

require ‘environment_information/misc_components/operating_system.rb’

#
#

require ‘environment_information/misc_components/ram.rb’ ::EnvironmentInformation.ram?

#
#

require ‘environment_information/misc_components/rubygems_installation_directory.rb’ EnvironmentInformation.rubygems_installation_directory?

#
#

require ‘environment_information/misc_components/screen_resolution.rb’ EnvironmentInformation.screen_resolution?

#
#

require ‘environment_information/project/project.rb’

#
#

require ‘environment_information/requires/require_the_individual_misc_components.rb’

#
#

require ‘environment_information/requires/require_the_toplevel_methods.rb’

#
#

Code in this file is tasked to autogenerate the relevant methods for use in the toplevel EnvironmentInformation namespace.

#

require ‘environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb’

#
#

require ‘environment_information/toplevel_methods/cd.rb’

#
#

require ‘environment_information/toplevel_methods/e.rb’ EnvironmentInformation.e

#
#

require ‘environment_information/toplevel_methods/hash.rb’ EnvironmentInformation.hash?

#
#

require ‘environment_information/toplevel_methods/internet_is_available.rb’

#
#

require ‘environment_information/toplevel_methods/is_on_roebe.rb’

#
#

require ‘environment_information/toplevel_methods/menu.rb’

#
#

require ‘environment_information/toplevel_methods/misc.rb’ EnvironmentInformation.return_version_of_mpc

#
#

require ‘environment_information/toplevel_methods/n_subcommands.rb’

#
#

require ‘environment_information/toplevel_methods/prefix_to_use.rb’

#
#

require ‘environment_information/toplevel_methods/register_this_component_is_missing.rb’ EnvironmentInformation.register_this_component_is_missing

#
#

require ‘environment_information/toplevel_methods/remote_url_of_this_program.rb’

#
#

require ‘environment_information/toplevel_methods/replay_from_the_stored_file.rb’ EnvironmentInformation.replay_from_the_stored_file EnvironmentInformation.colourize_and_pad_the_left_side

#
#

require ‘environment_information/toplevel_methods/return_alias_to.rb’ EnvironmentInformation.return_alias_to

#
#

require ‘environment_information/toplevel_methods/return_pkgconfig_based_programs.rb’

#
#

require ‘environment_information/toplevel_methods/return_remote_gtk2_version.rb’ EnvironmentInformation.return_remote_gtk2_version

#
#

require ‘environment_information/toplevel_methods/return_simple_version_based_programs.rb’

#
#

require ‘environment_information/toplevel_methods/return_version_of_this_program.rb’ EnvironmentInformation.return_version_of_this_program

#
#

require ‘environment_information/toplevel_methods/show_all_available_components.rb’ EnvironmentInformation.show_all_available_components

#
#

require ‘environment_information/toplevel_methods/write_what_into.rb’ EnvironmentInformation.write_what_into

#
#

require ‘environment_information/version/version.rb’

#

Constants

ARRAY_COMPARE_PROGRAM_VERSIONS
#

EnvironmentInformation::ARRAY_COMPARE_PROGRAM_VERSIONS

#
ARRAY_DEFAULT_PROGRAMS_ON_LINUX
#

EnvironmentInformation::ARRAY_DEFAULT_PROGRAMS_ON_LINUX

This Array keeps track of the default programs on a linux computer.

#
ARRAY_LFS_CORE_PROGRAMS
#

EnvironmentInformation::ARRAY_LFS_CORE_PROGRAMS

All the LFS core programs are registered here in this Array.

#
ARRAY_LFS_TEMPORARY_PROGRAMS
#

EnvironmentInformation::ARRAY_LFS_TEMPORARY_PROGRAMS

All programs that are temporary, e. g. for enabling the bootstrapping of the compiler, are stored in the following Array.

#
ARRAY_SCIENCE_CLUSTER
#

EnvironmentInformation::ARRAY_SCIENCE_CLUSTER (science tag)

Science-specific applications are gathered in this array.

#
ARRAY_TRACKED_NON_PROGRAMS
#

EnvironmentInformation::ARRAY_TRACKED_NON_PROGRAMS

The entry rubygems_installation_directory depends on the executable called “gem”, which is part of ruby.

This Array has also been called “registered extra functionality” in the past. The entries here are special in one way or another. Usually these entries are NOT standalone-programs, which is why they are tracked separately.

#
ARRAY_TRACKED_PROGRAMS
ARRAY_VERSION
#

EnvironmentInformation::ARRAY_VERSION

#
ARRAY_XORG_COMPONENTS
#

EnvironmentInformation::ARRAY_XORG_COMPONENTS (xorg tag)

All xorg-components will be collected here. Sort alphabetically, please, and keep the entries downcased.

xf86dga is an xorg-component, but since as of October 2018 it has been removed and will no longer be checked - it seems to have been abandoned, more or less.

#
ASCIITABLE_IS_AVAILABLE

puts ‘asciitable is not available, consider installing it.’ puts ‘We will, however, continue, as it is not a mandatory package.’

COMMAND_NOT_FOUND
#

EnvironmentInformation::COMMAND_NOT_FOUND

#
ERROR_LINE
#

ERROR_LINE

The error line is the one that can be appended to system-related queries (e. g. via system()).

#
FILE_ARRAY_DEFAULT_PROGRAMS_ON_LINUX
#

EnvironmentInformation::FILE_ARRAY_DEFAULT_PROGRAMS_ON_LINUX

#
FILE_ARRAY_LFS_CORE_PROGRAMS
#

EnvironmentInformation::FILE_ARRAY_LFS_CORE_PROGRAMS

#
FILE_ARRAY_SCIENCE_CLUSTER
#

EnvironmentInformation::FILE_ARRAY_SCIENCE_CLUSTER

#
FILE_ARRAY_TRACKED_NON_PROGRAMS
#

EnvironmentInformation::FILE_ARRAY_TRACKED_NON_PROGRAMS

#
FILE_ARRAY_TRACKED_PROGRAMS
#

EnvironmentInformation::FILE_ARRAY_TRACKED_PROGRAMS

#
FILE_ARRAY_TRACKED_XORG_COMPONENTS
#

EnvironmentInformation::FILE_ARRAY_TRACKED_XORG_COMPONENTS

#
FILE_QUERY_TO_USE_FOR_THE_INDIVIDUAL_COMPONENTS
#

EnvironmentInformation::FILE_QUERY_TO_USE_FOR_THE_INDIVIDUAL_COMPONENTS

#
FILE_THESE_PROGRAMS_CAN_BE_UPGRADED
#

FILE_THESE_PROGRAMS_CAN_BE_UPGRADED

We may store which programs could be upgraded into a local file.

#
LAST_UPDATE
#

LAST_UPDATE

#
MAIN_ENCODING
#

EnvironmentInformation::MAIN_ENCODING

#
N
#

EnvironmentInformation::N

A newline constant to simplify our life.

#
NAMESPACE
#

NAMESPACE

#
NOT_FOUND
#

EnvironmentInformation::NOT_FOUND

#
NOT_FOUND_IN_PKG_CONFIG_SEARCH_PATH
#

EnvironmentInformation::NOT_FOUND_IN_PKG_CONFIG_SEARCH_PATH

This constant is specifically for missing (or not found) .pc files.

#
NOT_INSTALLED_OR_NOT_FOUND
#

EnvironmentInformation::NOT_INSTALLED_OR_NOT_FOUND

#
NO_SUCH_FILE_OR_DIRECTORY
#

EnvironmentInformation::NO_SUCH_FILE_OR_DIRECTORY

#
PKGCONFIG_COMMAND_NOT_FOUND
#

EnvironmentInformation::PKGCONFIG_COMMAND_NOT_FOUND

The constant that follows next is used to determine whether pkg-config could find a corresponding .pc file. If not then pkg-config will typically report a line such as this:

Package libdr was not found in the pkg-config search path.

We will include the last part of this string, as a generic message that can be used to indicate “this package could not be found on the given computer system at hand”.

#
PROJECT_BASE_DIRECTORY
#

EnvironmentInformation::PROJECT_BASE_DIRECTORY

This constant may point to a target such as:

/home/Programs/Ruby/2.7.1/lib/ruby/site_ruby/2.7.0/environment_information/
#
SAVE_FILE
#

EnvironmentInformation::SAVE_FILE

Where to save stuff to. This depends on a proper setting of the toplevel variable called @temp_directory.

#
TEMP_DIRECTORY
THE_PROGRAM_WAS_NOT_FOUND
#

EnvironmentInformation::THE_PROGRAM_WAS_NOT_FOUND

#
TRY_TO_MAKE_USE_OF_THE_OPN_GEM_IF_IT_IS_AVAILABLE
#

TRY_TO_MAKE_USE_OF_THE_OPN_GEM_IF_IT_IS_AVAILABLE

This gem is closely connected to the NAMESPACE constant, so it will also reside in this file here.

#
URL_TO_THE_DOCUMENTATION
#

URL_TO_THE_DOCUMENTATION

#
UTF_ENCODING
#

EnvironmentInformation::UTF_ENCODING

UTF-8 is the default encoding for the EnvironmentInformation namespace.

#
VERSION
#

VERSION

#
VERSION_STRING
#

EnvironmentInformation::VERSION_STRING

#

Public Class Methods

add_to_hash(a, b) click to toggle source
#

EnvironmentInformation.add_to_hash

#
# File lib/environment_information/toplevel_methods/hash.rb, line 42
def self.add_to_hash(a, b)
  b.strip! if b.is_a? String
  if b.nil?
    ::EnvironmentInformation.register_this_component_is_missing(a)
  end
  @hash_available_programs[a] = b
end
array_tracked_programs() click to toggle source
#

EnvironmentInformation.array_tracked_programs

This method will return all the programs that are currently tracked by the EnvironmentInformation project.

#
# File lib/environment_information/constants/array_tracked_components.rb, line 64
def self.array_tracked_programs
  ARRAY_TRACKED_PROGRAMS
end
autogenerate_all_relevant_methods( i = ARRAY_TRACKED_PROGRAMS+ ARRAY_XORG_COMPONENTS ) click to toggle source
#

EnvironmentInformation.autogenerate_all_relevant_methods

By default this method will scan for all tracked programs, and for the xorg-components.

#
# File lib/environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb, line 21
def self.autogenerate_all_relevant_methods(
    i = ARRAY_TRACKED_PROGRAMS+
        ARRAY_XORG_COMPONENTS
  )
  i.flatten!
  # ======================================================================= #
  # Add some aliases which will be defined next.
  # ======================================================================= #
  hash_aliases = {
    atk:   :libatk,   # === EnvironmentInformation.return_version_of_libatk
    pcre2: :libpcre2, # === EnvironmentInformation.return_version_of_libpcre2
    pcre:  :libpcre,  # === EnvironmentInformation.return_version_of_libpcre
    zlib:  :libzlib   # === EnvironmentInformation.return_version_of_libzlib
  }
  # ======================================================================= #
  # Iterate over our Array next:
  # ======================================================================= #
  i.each {|this_program|
    case this_program
    when :kde
      this_program = :kde_frameworks
    end
    self.class.instance_eval {
      # =================================================================== #
      # To test this method, try to do:
      #
      #   EnvironmentInformation.return_version_of_valgrind # => "3.15.0"
      #
      # =================================================================== #
      this_method = "return_version_of_#{this_program}"
      define_method(this_method) {
        return_version_of_this_program(this_program)
      }
      if hash_aliases.has_key?(this_program)
        # ================================================================= #
        # To test this, try:
        #
        #   EnvironmentInformation.return_version_of_libzlib
        #
        # ================================================================= #
        use_this_as_the_alias_target = "return_version_of_#{hash_aliases[this_program]}"
        define_method(use_this_as_the_alias_target) {
          return_version_of_this_program(this_program)
        }
      end
    }
  }
end
cd(i) click to toggle source
#

EnvironmentInformation.cd (cd tag)

#
# File lib/environment_information/toplevel_methods/cd.rb, line 12
def self.cd(i)
  Dir.chdir(i) if File.directory? i
end
cflags?() click to toggle source
#

EnvironmentInformation.cflags? (cflags tag)

The following is equivalent to the value stored in the variable $CFLAGS, which on unix-like systems may be obtained by issuing the following command:

echo $CFLAGS

The output may be like this:

-O2 -fPIC -fno-strict-overflow -Wno-error
#
# File lib/environment_information/misc_components/cflags.rb, line 24
def self.cflags?
  version = ENV['CFLAGS'].to_s.strip
  version = '<none>' if version.empty? # Display special status if it is empty.
  version
end
clear_hash() click to toggle source
#

EnvironmentInformation.clear_hash

This method can be used to clear the main (toplevel) Hash.

#
# File lib/environment_information/toplevel_methods/hash.rb, line 55
def self.clear_hash
  @hash_available_programs.clear
end
clear_missing_components() click to toggle source
#

EnvironmentInformation.clear_missing_components

#
# File lib/environment_information/toplevel_methods/register_this_component_is_missing.rb, line 28
def self.clear_missing_components
  @array_this_component_is_missing.clear
end
colour_for_program_not_found() click to toggle source
#

EnvironmentInformation.colour_for_program_not_found

#
# File lib/environment_information/colours/colours.rb, line 81
def self.colour_for_program_not_found
  @colour_for_program_not_found
end
colour_for_the_left_side() click to toggle source
#

EnvironmentInformation.colour_for_the_left_side (left tag)

This method will return the colour

This could also be :limegreen rather than :forestgreen or vice versa.

#
# File lib/environment_information/colours/colours.rb, line 67
def self.colour_for_the_left_side
  @colour_for_the_left_side
end
colour_for_the_right_side() click to toggle source
#

EnvironmentInformation.colour_for_the_right_side (right tag)

#
# File lib/environment_information/colours/colours.rb, line 74
def self.colour_for_the_right_side
  @colour_for_the_right_side
end
colourize_and_pad_the_left_side(i) click to toggle source
#

EnvironmentInformation.colourize_and_pad_the_left_side

#
# File lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb, line 75
def self.colourize_and_pad_the_left_side(i)
  left_side = i.to_s.ljust(32) # Pad to the left-hand side.
  if use_colours?
    "  #{Colours.send(::EnvironmentInformation.colour_for_the_left_side,  left_side)}"
  else
    "  #{left_side}"
  end
end
colourize_and_pad_the_right_side( i, colour_for_the_right_side = ::EnvironmentInformation.colour_for_the_right_side ) click to toggle source
#

EnvironmentInformation.colourize_and_pad_the_right_side

#
# File lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb, line 50
def self.colourize_and_pad_the_right_side(
    i,
    colour_for_the_right_side = ::EnvironmentInformation.colour_for_the_right_side
  )
  case colour_for_the_right_side
  # ======================================================================= #
  # === :notify_if_missing
  # ======================================================================= #
  when :notify_if_missing
    colour_for_the_right_side = ::EnvironmentInformation.colour_for_the_right_side
    if i.to_s.empty?
      i = '[Not found]'
      colour_for_the_right_side = :orange
    end
  end
  if use_colours?
    Colours.send(colour_for_the_right_side, i)
  else
    i
  end
end
consider_storing_these_results_into_a_local_file( be_verbose = true ) click to toggle source
#

EnvironmentInformation.consider_storing_these_results_into_a_local_file

This method will always take the dataset stored in the main Hash when saving the yaml file at hand.

#
# File lib/environment_information/toplevel_methods/misc.rb, line 61
def self.consider_storing_these_results_into_a_local_file(
    be_verbose = true
  )
  unless @hash_available_programs.empty?
    what = YAML.dump(@hash_available_programs)
    # ===================================================================== #
    # The file will be stored under the temp_directory.
    # ===================================================================== #
    into = ::EnvironmentInformation.return_path_to_the_all_programs_file
    e "#{rev}Storing these #{royalblue(@hash_available_programs.size)} "\
      "#{rev}components into: #{sfile(into)}" if be_verbose
    write_what_into(what, into)
  end
end
cpuinfo?() click to toggle source
#

EnvironmentInformation.cpuinfo? (cpuinfo tag)

This method currently relies on /proc/cpuinfo, thus favouring Linux-based systems.

The output will be similar to this:

AMD A8-7600 Radeon R7, 10 Compute Cores 4C+6G, 4 cores

It will become the display part of “CPU Model”.

#
# File lib/environment_information/misc_components/cpuinfo.rb, line 25
def self.cpuinfo?
  result = '/proc/cpuinfo'
  if File.exist? result
    readlines = File.readlines(result)
    _ = readlines.grep(/model name/).first.chomp
    splitted = _.split(':')
    _ = splitted[1].strip # => "model name\t: AMD Sempron(tm) 145 Processor"
    # ===================================================================== #
    # Next, add the amount of cores. We use "nproc" for this but "lscpu"
    # also contains this information. The following regex could be used
    # for lscpu:
    #
    #   Core\(s\) per socket:    (.+)
    #
    # Ok, we use lscpu for now.
    # ===================================================================== #
    n_cores = `nproc --all`.strip
    case n_cores.to_s
    when '1'
      n_cores << ' core'  # Singular.
    else
      n_cores << ' cores' # Plural then.
    end
    _ << ", #{n_cores}" unless n_cores.empty?
    result = _
  else
    result = nil
  end
  result
end
do_use_colours() click to toggle source
#

EnvironmentInformation.do_use_colours

#
# File lib/environment_information/colours/colours.rb, line 105
def self.do_use_colours
  @use_colours = i
end
e( i = '', hash = {} ) click to toggle source
#

EnvironmentInformation.e

#
# File lib/environment_information/toplevel_methods/e.rb, line 13
def self.e(
    i = '', hash = {}
  )
  if hash and
     hash.has_key?(:display_everything_in_short_format) and
     hash[:display_everything_in_short_format]
    # ===================================================================== #
    # Display the results in a single line in this case.
    # ===================================================================== #
    print "#{i}, "
  else
    puts i
  end
end
ee( i = '' ) click to toggle source
#

EnvironmentInformation.ee

This is simply a wrapper over print, as well as adding a ‘, ’ to that.

#
# File lib/environment_information/toplevel_methods/e.rb, line 33
def self.ee(
    i = ''
  )
  print "#{i}, "
end
environment_information?() click to toggle source
#

EnvironmentInformation.environment_information?

This method will return a very long string containing all information about the locally installed/available programs.

#
# File lib/environment_information/class/class.rb, line 2572
def self.environment_information?
  ::EnvironmentInformation::EnvironmentInformation.new(:full_be_silent).stringified
end
file_query_to_use_for_the_individual_components() click to toggle source
#

EnvironmentInformation.file_query_to_use_for_the_individual_components

#
# File lib/environment_information/constants/file_constants.rb, line 73
def self.file_query_to_use_for_the_individual_components
  "#{PROJECT_BASE_DIRECTORY}yaml/query_to_use_for_the_individual_components.yml"
end
forestgreen( i = '', use_colours = @use_colours ) click to toggle source
#

EnvironmentInformation.forestgreen

#
# File lib/environment_information/colours/colours.rb, line 152
def self.forestgreen(
    i = '', use_colours = @use_colours
  )
  return ::Colours.forestgreen(i) if use_colours
  return i
end
gtk_bindings() click to toggle source
#

EnvironmentInformation.gtk_bindings

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 394
def self.gtk_bindings
   ::EnvironmentInformation::EnvironmentInformation::GUI::Gtk::EnvironmentInformation.new
end
hash?() click to toggle source
#

EnvironmentInformation.hash?

This method will return the Hash of all available programs.

#
# File lib/environment_information/toplevel_methods/hash.rb, line 34
def self.hash?
  @hash_available_programs
end
internet_is_available?() click to toggle source
#

EnvironmentInformation.internet_is_available?

#
# File lib/environment_information/toplevel_methods/internet_is_available.rb, line 12
def self.internet_is_available?
  require 'resolv'
  dns_resolver = Resolv::DNS.new
  begin
    # ===================================================================== #
    # The first domain name ever. Will probably not be removed.
    # ===================================================================== #
    dns_resolver.getaddress('symbolics.com')
    return true
  rescue Resolv::ResolvError => _error
    return false
  end
end
is_on_roebe?() click to toggle source
#

EnvironmentInformation.is_on_roebe?

#
# File lib/environment_information/toplevel_methods/is_on_roebe.rb, line 12
def self.is_on_roebe?
  ENV['IS_ROEBE'].to_i == 1
end
is_this_component_included?(i) click to toggle source
#

EnvironmentInformation.is_this_component_included?

This is a more extensive check than .is_this_program_included?()

#
# File lib/environment_information/constants/array_tracked_components.rb, line 197
def self.is_this_component_included?(i)
  array = (
            ARRAY_TRACKED_PROGRAMS +
            ARRAY_XORG_COMPONENTS  +
            ARRAY_TRACKED_NON_PROGRAMS
          )
  array.flatten.include? i.to_sym # Need a Symbol as input.
end
is_this_component_missing?(i) click to toggle source
#

EnvironmentInformation.is_this_component_missing?

#
# File lib/environment_information/toplevel_methods/register_this_component_is_missing.rb, line 57
def self.is_this_component_missing?(i)
  !@array_this_component_is_missing.include?(i)
end
is_this_program_included?(i) click to toggle source
#

EnvironmentInformation.is_this_program_included?

This will include the two Arrays ARRAY_TRACKED_PROGRAMS and ARRAY_XORG_COMPONENTS, but it will NOT include ARRAY_TRACKED_NON_PROGRAMS.

#
# File lib/environment_information/constants/array_tracked_components.rb, line 185
def self.is_this_program_included?(i)
  (
    ARRAY_TRACKED_PROGRAMS +
    ARRAY_XORG_COMPONENTS
  ).flatten.include? i.to_sym # Need a symbol.
end
lfs_core_programs?() click to toggle source
#

EnvironmentInformation.lfs_core_programs?

#
# File lib/environment_information/constants/array_tracked_components.rb, line 175
def self.lfs_core_programs?
  ARRAY_LFS_CORE_PROGRAMS
end
lightseagreen(i = '', use_colours = @use_colours) click to toggle source
#

EnvironmentInformation.lightseagreen

#
# File lib/environment_information/colours/colours.rb, line 162
def self.lightseagreen(i = '', use_colours = @use_colours)
  if use_colours
    return ::Colours.lightseagreen(i)
  end
  return i
end
lightslategrey(i = '') click to toggle source
#

EnvironmentInformation.lightslategrey

#
# File lib/environment_information/colours/colours.rb, line 122
def self.lightslategrey(i = '')
  if @use_colours
    return ::Colours.lightslategrey(i)
  end
  return i
end
load_file_array_tracked_non_programs( i = FILE_ARRAY_TRACKED_NON_PROGRAMS ) click to toggle source
#

EnvironmentInformation.load_file_array_tracked_non_programs

#
# File lib/environment_information/constants/file_constants.rb, line 40
def self.load_file_array_tracked_non_programs(
    i = FILE_ARRAY_TRACKED_NON_PROGRAMS
  )
  YAML.load_file(i)
end
load_file_query_to_use_for_the_individual_components( i = FILE_QUERY_TO_USE_FOR_THE_INDIVIDUAL_COMPONENTS ) click to toggle source
#

EnvironmentInformation.load_file_query_to_use_for_the_individual_components

#
# File lib/environment_information/constants/file_constants.rb, line 80
def self.load_file_query_to_use_for_the_individual_components(
    i = FILE_QUERY_TO_USE_FOR_THE_INDIVIDUAL_COMPONENTS
  )
  @query_to_use_for_the_individual_components = YAML.load_file(i)
  return @query_to_use_for_the_individual_components
end
mediumaquamarine( i = '', use_colours = @use_colours ) click to toggle source
#

EnvironmentInformation.mediumaquamarine

#
# File lib/environment_information/colours/colours.rb, line 195
def self.mediumaquamarine(
    i           = '',
    use_colours = @use_colours
  )
  if use_colours
    return ::Colours.mediumaquamarine(i)
  end
  return i
end
mediumpurple(i = '') click to toggle source
#

EnvironmentInformation.mediumpurple

#
# File lib/environment_information/colours/colours.rb, line 112
def self.mediumpurple(i = '')
  if @use_colours
    return ::Colours.mediumpurple(i)
  end
  return i
end
menu( i = ARGV ) click to toggle source
#

EnvironmentInformation.menu

#
n_subcommands?() click to toggle source
#

EnvironmentInformation.n_subcommands?

Return how many subcommands are available/registered. These are the tracked programs; and the xorg-components.

The non-programs will not be gathered by this method, on purpose; they are not standalone programs after all.

As of August 2020, 167 programs were tracked by this gem.

#
# File lib/environment_information/toplevel_methods/n_subcommands.rb, line 22
def self.n_subcommands?
  ARRAY_TRACKED_PROGRAMS.size+
  ARRAY_XORG_COMPONENTS.size
end
operating_system() click to toggle source
#

EnvironmentInformation.operating_system (os tag)

This method is also known as “bit type”.

The return value of this method may be a String such as this one here:

"GNU/Linux"

This is then further modified a bit to drop the “GNU/” part specifically.

#
# File lib/environment_information/misc_components/operating_system.rb, line 25
def self.operating_system
  cmd = 'uname -mo'
  result = `#{cmd}`.chomp
  if result.start_with? 'GNU'
    # ===================================================================== #
    # The next part removes 'GNU/' specifically. It is a simpler name
    # than "GNU Linux" and variants, just as "BSD" is simpler than
    # e. g. "FreeBSD". You can reason that it may be "less accurate",
    # but it makes the notification-part of this gem simpler.
    # ===================================================================== #
    result.sub!(/^GNU\//,'') # Experimental as of Sep 2019.
  end
  if result.include? ' '
    result = result.split(' ').last
  end
  result
end
operating_system_bit_type_information() click to toggle source
#

EnvironmentInformation.operating_system_bit_type_information (bit tag, bit type tag)

This method will return the bit type in use, as a String, such as “x86_64” or “x86_64 (64 bit)” specifically. The reason why this method appends ‘ (64 bit)’ is mostly so that the user can quickly see whether a computer is on 32 bit or on 64 bit.

#
# File lib/environment_information/misc_components/operating_system_bit_type.rb, line 21
def self.operating_system_bit_type_information
  cmd = 'uname -m'
  result = `#{cmd}`.chomp
  result = result.split(' ')[-1] if result.include?(' ')
  result = result.dup if result.frozen?
  case result
  when 'x86_64'
    result << ' (64 bit)'
  end
  result
end
pink( i = '', use_colours = @use_colours ) click to toggle source
#

EnvironmentInformation.pink

#
# File lib/environment_information/colours/colours.rb, line 142
def self.pink(
    i = '', use_colours = @use_colours
  )
  return ::Colours.pink(i) if use_colours
  return i
end
prefix?() click to toggle source
#

EnvironmentInformation.prefix?

#
# File lib/environment_information/toplevel_methods/prefix_to_use.rb, line 35
def self.prefix?
  @prefix_to_use
end
project_base_directory?() click to toggle source
#

EnvironmentInformation.project_base_directory?

#
# File lib/environment_information/project/project.rb, line 23
def self.project_base_directory?
  PROJECT_BASE_DIRECTORY
end
query_pkgconfig_version_for(i = :gtk2) click to toggle source
#

EnvironmentInformation.query_pkgconfig_version_for

This is a simpler toplevel-query, for .pc files in general.

#
# File lib/environment_information/queries/pkg_config.rb, line 114
def self.query_pkgconfig_version_for(i = :gtk2)
  ::EnvironmentInformation::Queries::PkgConfig.new(i).version?
end
query_to_use_for_the_individual_components?() click to toggle source
#

EnvironmentInformation.query_to_use_for_the_individual_components?

#
# File lib/environment_information/constants/file_constants.rb, line 90
def self.query_to_use_for_the_individual_components?
  @query_to_use_for_the_individual_components
end
ram?() click to toggle source
#

EnvironmentInformation.ram? (ram tag)

This method will determine how much RAM the given computer host has.

The result will be given in n MB.

#
# File lib/environment_information/misc_components/ram.rb, line 17
def self.ram?
  result_in_n_mb = `free -m 2>&1`.split("\n")[1]
  if result_in_n_mb and result_in_n_mb.include?(' ')
    result_in_n_mb = result_in_n_mb.split(' ')[1]
  end
  result_in_n_mb
end
register_this_component_is_missing(i) click to toggle source
#

EnvironmentInformation.register_this_component_is_missing

The ideal input to this method is a Symbol, so that the Array stores only missing components that way.

#
# File lib/environment_information/toplevel_methods/register_this_component_is_missing.rb, line 38
def self.register_this_component_is_missing(i)
  if i.is_a? Symbol
    copy = i.to_s
    if copy.include?('_')
      i = copy.split('_').last.to_sym
    end
  end
  i = i.to_sym unless i.is_a? Symbol
  # ======================================================================= #
  # Do not register the same missing component twice:
  # ======================================================================= #
  unless @array_this_component_is_missing.include? i
    @array_this_component_is_missing << i
  end
end
replay_from_the_stored_file( _ = return_path_to_the_all_programs_file ) click to toggle source
#

EnvironmentInformation.replay_from_the_stored_file

To invoke this method from the commandline, try:

envi --replay
#
# File lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb, line 30
def self.replay_from_the_stored_file(
    _ = return_path_to_the_all_programs_file
  )
  if File.exist? _
    e "Loading from the file #{_}."
    @hash_available_programs = YAML.load_file(_)
    @hash_available_programs.each_pair {|key, value|
      e colourize_and_pad_the_left_side("#{key}:")+
        colourize_and_pad_the_right_side(
          value.to_s, :notify_if_missing
        )
    }
  else
    e "No file exists at #{_}."
  end
end
report_version() click to toggle source
#

EnvironmentInformation.report_version

#
# File lib/environment_information/toplevel_methods/menu.rb, line 64
def self.report_version
  e "#{rev}The version of the EnvironmentInformation project "\
    "in use is: #{simp(VERSION)}#{rev}"
end
require_all_individual_misc_components() click to toggle source
#

EnvironmentInformation.require_all_individual_misc_components

This method can be used to load all the individual misc-components that are part of the EnvironmentInformation project.

#
# File lib/environment_information/requires/require_the_individual_misc_components.rb, line 17
def self.require_all_individual_misc_components

  # ======================================================================= #
  # Batch-require the components in the misc_components/ directory next:
  # ======================================================================= #
  tracked_non_programs?.each {|this_component|
    require "environment_information/misc_components/#{this_component}.rb"
  }

end
require_the_toplevel_methods() click to toggle source
#

EnvironmentInformation.require_the_toplevel_methods

#
# File lib/environment_information/requires/require_the_toplevel_methods.rb, line 14
def self.require_the_toplevel_methods
  Dir["#{PROJECT_BASE_DIRECTORY}toplevel_methods/*.rb"].each {|this_file|
    require "environment_information/toplevel_methods/#{File.basename(this_file)}"
  }
end
return_alias_to(i) click to toggle source
#

EnvironmentInformation.return_alias_to

This method will return some abbreviations to programs.

#
# File lib/environment_information/toplevel_methods/return_alias_to.rb, line 15
def self.return_alias_to(i)
  if i.is_a? Array
    i = i.first
  end
  case i.to_sym
  when :find
    i = :findutils
  when :diff
    i = :diffutils
  when :yacc
    i = :bison
  end
  return i # Always return something.
end
return_array_of_outdated_programs( hash = ::EnvironmentInformation.hash? ) click to toggle source
#

EnvironmentInformation.return_array_of_outdated_programs

This method will return all programs that are outdated - this also includes missing programs, so the method name is a slight misnomer.

Usage example:

EnvironmentInformation.initialize
array = EnvironmentInformation.return_array_of_outdated_programs
#
# File lib/environment_information/toplevel_methods/misc.rb, line 263
def self.return_array_of_outdated_programs(
    hash = ::EnvironmentInformation.hash?
  )
  forbidden = ::EnvironmentInformation.load_file_array_tracked_non_programs
  # ======================================================================= #
  # Now find all entries that are either nil, or have a too low program
  # version.
  # ======================================================================= #
  array = hash.select {|key, value|
    if value and forbidden.include?(key) # ← we exclude entries here such as "rubygems_installation_dir".
      false
    else
      if value.nil? or value.include?('not found') or
         !(value =~ /\d+/) # ← check for at the least one number, such as "1".
        true
      else
        false
      end
    end
  }.keys
  # ======================================================================= #
  # Next, check these against the local program version:
  #  local_program_version = key
  # ======================================================================= #
  return array
end
return_everything() click to toggle source
#

EnvironmentInformation.return_everything

#
# File lib/environment_information/toplevel_methods/misc.rb, line 308
def self.return_everything
  require 'environment_information/class/class.rb'
  _ = ::EnvironmentInformation::EnvironmentInformation.new(:do_not_run_yet)
  _.disable_colours
  _.be_quiet
  _.menu('--really-everything')
  _.run
  return _.string
end
return_path_to_the_all_programs_file() click to toggle source
#

EnvironmentInformation.return_path_to_the_all_programs_file

#
# File lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb, line 18
def self.return_path_to_the_all_programs_file
  "#{temp_directory?}all_programs.yml"
end
return_pkgconfig_based_programs() click to toggle source
#

EnvironmentInformation.return_pkgconfig_based_programs

#
# File lib/environment_information/toplevel_methods/return_pkgconfig_based_programs.rb, line 14
def self.return_pkgconfig_based_programs
  dataset = YAML.load_file(file_query_to_use_for_the_individual_components)
  dataset.select {|key, value|
    # ===================================================================== #
    # The next query will select both :pkgconfig and :"pkg-config".
    # ===================================================================== #
    value.to_s.start_with? 'pkg'
  }.keys
end
return_remote_gtk2_version() click to toggle source
#

EnvironmentInformation.return_remote_gtk2_version

This method can be used to obtain the latest gtk2-version, from a remote URL.

The reason why this was necessary is because the RBT project may not always keep the latest gtk2 version, since gtk3 (and so forth) is more recent. Since we may still have to find out which gtk2 version is the most recent, we need a method to do so - which is precisely what this method here is doing.

#
# File lib/environment_information/toplevel_methods/return_remote_gtk2_version.rb, line 24
def self.return_remote_gtk2_version
  # ======================================================================= #
  # We will use a hardcoded URL pointing towards gtk2:
  # ======================================================================= #
  remote_url = 'https://ftp.gnome.org/pub/GNOME/sources/gtk+/2.24/?C=M;O=D'
  require 'open-uri'
  newest_version = ''
  # ======================================================================= #
  # We will next try to obtain the remote dataset, but this would
  # fail if we have no www-connection, so we must rescue this step.
  # ======================================================================= #
  if internet_is_available?
    begin
      dataset = URI.open(remote_url).read
      use_this_regex =
        /<a href="gtk\+\-(\d.\d\d.\d\d).tar.xz"><img src=/
      scanned = dataset.scan(use_this_regex).flatten
      newest_version = scanned.first
    rescue SocketError => error
      puts "It seems as if we have no working internet "\
           "connection (#{sfancy(error.class)})"
    end
  end
  return newest_version.strip # ← And return it here.
end
return_remote_url_of_this_program(i = ARGV) click to toggle source
#

EnvironmentInformation.return_remote_url_of_this_program

This method will try to return the remote URL of the given program.

Note that this functionality depends on the RBT project, which explains the rescued required statement in the method. While in theory we could create a stand-alone solution, I don’t want to duplicate code I already wrote for another project, so users are encouraged to install the rbt gem - it’s what I use on my home system as well.

#
# File lib/environment_information/toplevel_methods/remote_url_of_this_program.rb, line 21
def self.return_remote_url_of_this_program(i = ARGV)
  if i.is_a? Array
    i = i.first
  end
  begin
    require 'rbt/cookbooks/url/url.rb'
    i = RBT.return_url1_of_this_program(i)
  rescue LoadError; end
  i
end
return_simple_version_based_programs() click to toggle source
#

EnvironmentInformation.return_simple_version_based_programs

#
# File lib/environment_information/toplevel_methods/return_simple_version_based_programs.rb, line 14
def self.return_simple_version_based_programs
  dataset = YAML.load_file(file_query_to_use_for_the_individual_components)
  dataset.select {|key, value|
    # ===================================================================== #
    # The next query will select only for :version entries.
    # ===================================================================== #
    value == :version
  }.keys
end
return_the_most_important_info() click to toggle source
#

EnvironmentInformation.return_the_most_important_info

This method will just return a String that can be used right away in, for example, a sinatra application.

#
# File lib/environment_information/toplevel_methods/misc.rb, line 296
def self.return_the_most_important_info
  'Operating system:                '+
  ::EnvironmentInformation.operating_system+'<br>'+
  'Operating system bit type:       '+
  ::EnvironmentInformation.operating_system_bit_type+'<br>'+
  'CPU model:                       '+
  ::EnvironmentInformation.cpu_model+'<br>'
end
return_version_of_boost() click to toggle source
#

EnvironmentInformation.return_version_of_boost

This method will either return a String (the version of boost), or nil if boost was not found.

#
# File lib/environment_information/toplevel_methods/misc.rb, line 211
def self.return_version_of_boost
  target_file = '/usr/include/boost/version.hpp'
  if File.exist?('/System/Index/include/boost/version.hpp') and
    !File.exist?(target_file) # Custom fix.
    target_file = '/System/Index/include/boost/version.hpp'
  end
  if File.exist? target_file
    dataset = File.readlines(target_file)
    version = dataset.select {|line|
      line.include? '#define BOOST_LIB_VERSION'
    }.first.sub(/#define BOOST_LIB_VERSION/,'').
            strip.delete('"').tr('_','.')
    if version.count('.') < 2
      version << '.0'
    end
  else
    version = nil
  end
  return version
end
return_version_of_busybox() click to toggle source
#

EnvironmentInformation.return_version_of_busybox

#
# File lib/environment_information/toplevel_methods/misc.rb, line 191
def self.return_version_of_busybox
  result = `busybox #{ERROR_LINE}`
  if result and result.is_a?(String) and result.include?("\n")
    first_line = result.split("\n").first
    if first_line.include? ' v'
      # "BusyBox v1.32.0 (2020-11-08 04:41:56 Etc) multi-call binary.\n"
      use_this_regex = /v(\d{0,1}.\d{0,2}.\d{0,1})/ # See: https://rubular.com/r/MpnFXlalLCXXGI
      result = first_line.scan(use_this_regex).flatten.first.to_s
      return result
    end
  end
  return nil
end
return_version_of_mpc() click to toggle source
#

EnvironmentInformation.return_version_of_mpc

This method will read the version-string from a .h header file.

#
# File lib/environment_information/toplevel_methods/misc.rb, line 237
def self.return_version_of_mpc
  target_file = '/usr/include/mpc.h'
  if File.exist? target_file
    dataset = File.read(target_file)
    use_this_regex = /MPC_VERSION_STRING "([0-9\.]+)"$/
    dataset = dataset.scan(use_this_regex).flatten
    version = dataset.first
    return version
  else
    return THE_PROGRAM_WAS_NOT_FOUND
  end
end
return_version_of_this_program( this_program, prefix_to_use = @prefix_to_use ) click to toggle source
#

EnvironmentInformation.return_version_of_this_program

This is the general method that will return the version of a particular program at hand.

The method must be able to deal with using pkg-config, but also querying some program’s version via –version, via the commandline, Furthermore, some programs may require an ad-hoc fix.

#
# File lib/environment_information/toplevel_methods/return_version_of_this_program.rb, line 56
def self.return_version_of_this_program(
    this_program,
    prefix_to_use = @prefix_to_use
  )
  prefix_to_use = prefix_to_use.dup if prefix_to_use
  version = nil # ← This is the default.
  if this_program.is_a? Array
    this_program = this_program.flatten.first
  end
  # ======================================================================= #
  # Next define a few aliases.
  # ======================================================================= #
  this_program = ::EnvironmentInformation.return_alias_to(this_program)
  if ARRAY_TRACKED_NON_PROGRAMS.include? this_program
    return ::EnvironmentInformation.send(this_program)
  elsif @query_to_use_for_the_individual_components.has_key? this_program.to_sym
    use_this_command = @query_to_use_for_the_individual_components[this_program.to_sym]
    case use_this_command
    # ===================================================================== #
    # === :mate_desktop
    #
    # This entry is special.
    # ===================================================================== #
    when :mate_desktop
      return RBT.return_mate_desktop_version_array
    # ===================================================================== #
    # === :pkgconfig
    #
    # An invocation example for this would be:
    #
    #   x = EnvironmentInformation.return_version_of_this_program(:check) # => "0.15.2"
    #
    # ===================================================================== #
    when :pkgconfig
      version = ::EnvironmentInformation::Queries::PkgConfig.new(this_program).version?
    # ===================================================================== #
    # === :custom_gtk2
    # ===================================================================== #
    when :custom_gtk2
      version = ::EnvironmentInformation::Queries::PkgConfig.new('gtk+-2.0').version?
    # ===================================================================== #
    # === :custom_mpc
    #
    # We rely on the header called mpc.h.
    # ===================================================================== #
    when :custom_mpc
      version = ::EnvironmentInformation.return_version_of_mpc
    # ===================================================================== #
    # === :custom_boost
    # ===================================================================== #
    when :custom_boost
      version = ::EnvironmentInformation.return_version_of_boost
      if version.nil?
        register_this_component_is_missing(:boost)
      end
    # ===================================================================== #
    # === :version                                            (version tag)
    #
    # This entry point is typically for "program_name --version"
    # entries. Some of them require custom modifications.
    # ===================================================================== #
    when :version
      # =================================================================== #
      # Next enable support for AppDir layout, where programs will
      # ultimately reside in the same directory.
      # =================================================================== #
      unless prefix_to_use.empty?
        prefix_to_use << "#{this_program.to_s.capitalize}/Current/bin/"
      end
      cmd = "#{prefix_to_use}#{this_program} --version #{ERROR_LINE}"
      if @debug
        e Colours.crimson('DEBUG for the prefix-value in use: ')+
          Colours.steelblue(cmd)
      end
      version = ::EnvironmentInformation::Queries::SimpleVersion.new(this_program) {{
        prefix_to_use: prefix_to_use
      }}.version?
    # ===================================================================== #
    # Next we will handle special programs, such as "swig -v" and similar.
    # This is done by class ComplexVersion since as of 29.08.2020.
    # ===================================================================== #
    else # else tag
      if use_this_command.start_with?('pkg-config')
        version = ::EnvironmentInformation::Queries::PkgConfig.new(this_program).version?
      else
        cmd = "#{@prefix_to_use}#{use_this_command} #{ERROR_LINE}"
        version = ::EnvironmentInformation::Queries::ComplexVersion.new(this_program) {{
          prefix_to_use: prefix_to_use
        }}.version?
      end
    end
  else
    e 'Not registered any key for the program: '+this_program.to_s
    e 'This is currently not allowed - please add this missing information.'
    exit
  end
  result = version
  if result
    unless result.include? COMMAND_NOT_FOUND
      result = result.dup if result.frozen?
      result.strip!
    end
  end
  if result and (result == 'found' or result == 'foud')
    register_this_component_is_missing(this_program)
  elsif result and result.include?(COMMAND_NOT_FOUND)
    register_this_component_is_missing(this_program)
  # ======================================================================= #
  # Check whether pkg-config is available or not.
  # ======================================================================= #
  elsif result and (
          result.include?(PKGCONFIG_COMMAND_NOT_FOUND) or
          result.include?(NO_SUCH_FILE_OR_DIRECTORY)
        )
    register_this_component_is_missing(this_program)
  elsif result.nil?
    register_this_component_is_missing(this_program)
  end
  return result
end
return_version_of_xrandr() click to toggle source
#

EnvironmentInformation.return_version_of_xrandr

#
# File lib/environment_information/toplevel_methods/misc.rb, line 144
def self.return_version_of_xrandr
  _ = `xrandr --version #{ERROR_LINE}` # Need to use ERROR_LINE to avoid the code breaking down here.
  if _
    version = _.strip.split("\n")
    if version.is_a?(Array)
      version = version.first.split(' ').last.strip # Assume: "xrandr program version       1.5.1"
      return version
    end
  end
  return nil
end
return_version_of_xvid( target_file = '/usr/include/xvid.h' ) click to toggle source
#

EnvironmentInformation.return_version_of_xvid

#
# File lib/environment_information/toplevel_methods/misc.rb, line 159
def self.return_version_of_xvid(
    target_file = '/usr/include/xvid.h'
  )
  if File.exist?('/System/Index/include/'+File.basename(target_file)) and
    !File.exist?(target_file) # Custom fix.
    target_file = '/System/Index/include/'+File.basename(target_file)
  end
  if File.exist? target_file
    dataset = File.readlines(target_file)
    version = dataset.select {|line|
      line.include? '  XVID_MAKE_VERSION(' # #define XVID_VERSION             XVID_MAKE_VERSION(1,3,7)
    }
    if version.is_a? Array
      version = version.flatten.first.to_s
    end
    version = version.scan( # See:  https://rubular.com/r/4anuroBmb40yzh
      /XVID_MAKE_VERSION\((\d{0,1},\d{0,1},\d{0,1})/
      
    )
    if version.is_a? Array
      version = version.flatten.first.to_s
    end
    version.tr!(',','.')
  else
    version = nil
  end
  return version
end
rev() click to toggle source
#

EnvironmentInformation.rev (rev tag)

#
# File lib/environment_information/colours/colours.rb, line 219
def self.rev
  return ::Colours.rev if @use_colours
  '' # Else return an empty String.
end
royalblue( i = '', use_colours = @use_colours ) click to toggle source
#

EnvironmentInformation.royalblue

#
# File lib/environment_information/colours/colours.rb, line 182
def self.royalblue(
    i           = '',
    use_colours = @use_colours
  )
  if use_colours
    return ::Colours.royalblue(i)
  end
  return i
end
rubygems_installation_directory( prefix_to_use = @prefix_to_use ) click to toggle source
#

EnvironmentInformation.rubygems_installation_directory

This method will return the path to the rubygems installation directory, if possible (if it exists).

As this ought to be a directory, we will ensure that a trailing ‘/’ character exists.

This method may return a String such as “/root/.gem/”.

#
# File lib/environment_information/misc_components/rubygems_installation_directory.rb, line 25
def self.rubygems_installation_directory(
    prefix_to_use = @prefix_to_use
  )
  result = `#{prefix_to_use}gem env #{ERROR_LINE}` # We need the 2>&1 to check if gem is available.
  unless result.include? 'not found'
    # ===================================================================== #
    # Apply a regex next.
    # ===================================================================== #
    path_to_the_rubygem_directory = result.to_s.scan(
      /INSTALLATION DIRECTORY: (.+)/ # Obtain the proper match here.
    ).flatten.first.to_s
    if File.directory? path_to_the_rubygem_directory
      path_to_the_rubygem_directory << '/'
    end unless path_to_the_rubygem_directory.end_with? '/'
    result = path_to_the_rubygem_directory
  else
    result = nil
  end
  result
end
run(i = ARGV) click to toggle source
#

EnvironmentInformation.run

#
# File lib/environment_information/class/class.rb, line 2552
def self.run(i = ARGV)
  ::EnvironmentInformation::EnvironmentInformation.new(i)
end
run_gtk() click to toggle source
#

EnvironmentInformation.run_gtk

Use this method if you wish to run the gtk-component of the EnvironmentInformation project.

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 404
def self.run_gtk
  require 'gtk_paradise/run'
  _ = ::EnvironmentInformation.gtk_bindings
  r = ::Gtk.run
  r << _ # ← Add the widget here.
  r.add_shortcut(1, 'focus(:left)', :alt)
  r.modify_background(:normal, :white)
  r.automatic_title
  r.top_left_then_run
end
run_the_main_class(i = ARGV, &block) click to toggle source
#

EnvironmentInformation.run_the_main_class

#
# File lib/environment_information/class/class.rb, line 2559
def self.run_the_main_class(i = ARGV, &block)
  ::EnvironmentInformation::EnvironmentInformation.new(i, &block)
end
science_cluster?() click to toggle source
#

EnvironmentInformation.science_cluster?

#
# File lib/environment_information/constants/array_tracked_components.rb, line 101
def self.science_cluster?
  ARRAY_SCIENCE_CLUSTER
end
screen_resolution() click to toggle source
#

EnvironmentInformation.screen_resolution (screen tag)

This method will typically make use of xdpyinfo first, as it also works in a .cgi environment. For non-cgi environments, on linux, we could use xrandr, which is a bit more elegant.

On success, the method here will return a String such as “1920x1080”.

#
# File lib/environment_information/misc_components/screen_resolution.rb, line 22
def self.screen_resolution
  result = '(unknown)' # This is the default return-value, then.
  # ======================================================================= #
  # === Check for linux as host OS first
  # ======================================================================= #
  if RUBY_PLATFORM.downcase.include? 'linux'
    # ================================================================= #
    # We have to be careful as xdpyinfo may not be installed on the
    # given computer system.
    # ================================================================= #
    resolution = `xdpyinfo #{ERROR_LINE}`.scan(/dimensions:.+$/).first # The error here may be: "xdpyinfo:  unable to open display"
    if resolution and resolution.include? ':'
      result = resolution.split(':').last.strip.split('pixels').first.strip
    end
  # ======================================================================= #
  # === Else simply assume to be on windows here
  # ======================================================================= #
  else
    result = `wmic desktopmonitor get screenheight,screenwidth #{ERROR_LINE}`
  end
  result
end
set_prefix_to_use(i) click to toggle source
#

EnvironmentInformation.set_prefix_to_use

#
# File lib/environment_information/toplevel_methods/prefix_to_use.rb, line 28
def self.set_prefix_to_use(i)
  @prefix_to_use = i.to_s.dup
end
set_use_colours(i = true) click to toggle source
#

EnvironmentInformation.set_use_colours

Determine whether the EnvironmentInformation project will use colours or whether it will not.

#
# File lib/environment_information/colours/colours.rb, line 98
def self.set_use_colours(i = true)
  @use_colours = i
end
sfancy(i = '') click to toggle source
#

EnvironmentInformation

#
# File lib/environment_information/colours/sfancy.rb, line 14
def self.sfancy(i = '')
  return ::Colours.sfancy(i) if Object.const_defined? :Colours
  i
end
sfile(i = '') click to toggle source
#

EnvironmentInformation.sfile

#
# File lib/environment_information/colours/colours.rb, line 208
def self.sfile(i = '')
  if @use_colours
    ::Colours.sfile(i)
  else
    i
  end
end
show_all_available_components( n_ljust = 18, show_these_components = ARRAY_DEFAULT_PROGRAMS_ON_LINUX+ ARRAY_TRACKED_PROGRAMS, use_colours = use_colours? ) click to toggle source
#

EnvironmentInformation.show_all_available_components

This method will quickly and easily show all available (registered) components. If you need more fine-tuning when you wish to display the main dataset at hand, then you should use other methods that are also a bit more complex. This method here is really just a fast version-display overview.

The second argument to this method contains the programs that we wish to display through this method.

#
# File lib/environment_information/toplevel_methods/show_all_available_components.rb, line 46
def self.show_all_available_components(
    n_ljust               = 18,
    show_these_components = ARRAY_DEFAULT_PROGRAMS_ON_LINUX+
                            ARRAY_TRACKED_PROGRAMS,
    use_colours           = use_colours?
  )
  clear_main_hash
  if show_these_components.is_a? Array
    show_these_components.flatten!
  end
  # ======================================================================= #
  # The next variable determines whether we will also compare the
  # program versions.
  # ======================================================================= #
  compare_program_versions = false
  default_nljust_value = 30 # ← Detemine default padding.
  if n_ljust.is_a?(Array) and n_ljust.empty?
    n_ljust = default_nljust_value # Use the default value in this case.
  end
  # ======================================================================= #
  # First we will treat n_ljust as a commandline-flag if it is a String
  # and additionally begins with "--".
  # ======================================================================= #
  if n_ljust.is_a?(Array) and n_ljust.first.start_with?('--')
    _ = n_ljust.first
    case _
    # ===================================================================== #
    # === --help
    #
    # Invocation example:
    #
    #   showcomponents --help
    #
    # ===================================================================== #
    when /^-?-?help$/i
      e 'The following options are available for bin/fast_envi (fenvi):'
      e
      e '   --xorg                        # show only the xorg-components'
      e '   --compare-to-program-versions # also compare the program versions'
      e
      exit
    # ===================================================================== #
    # === --compare-to-program-versions
    #
    # To invoke this, try:
    #
    #   show_components --compare
    #   envi --compare-version
    #
    # ===================================================================== #
    when *ARRAY_COMPARE_PROGRAM_VERSIONS
      compare_program_versions = true
      n_ljust = default_nljust_value
    # ===================================================================== #
    # === --xorg
    # ===================================================================== #
    when /^-?-?xorg$/i
      show_these_components = ::EnvironmentInformation.xorg_components?
      n_ljust = default_nljust_value
    end
  end
  e
  uniq = show_these_components.uniq
  uniq.sort.each {|this_program|
    use_this_name_for_send = "return_version_of_#{this_program}"
    # ===================================================================== #
    # Next, add the name of the program at hand, onto the left hand side:
    # ===================================================================== #
    result = this_program.to_s.ljust(n_ljust)
    if use_colours
      result = ::EnvironmentInformation.colourize_and_pad_the_left_side(result)
    end
    # ===================================================================== #
    # Some components may not be installed on the user's computer system,
    # which we have to keep in mind in the following code. This is
    # why we will first apply the .send(), before checking whether
    # the program at hand is actually missing or not.
    # ===================================================================== #
    result_of_send = send(use_this_name_for_send)
    if result_of_send
      result_of_send = result_of_send.dup if result_of_send.frozen?
      result_of_send.strip!
    end
    @hash_available_programs[this_program.to_sym] = result_of_send.to_s
    right_component = ''.dup
    if @array_this_component_is_missing.include?(this_program.to_sym)
      right_component << "not installed (or otherwise not found)".ljust(12)
    else
      right_component << result_of_send.ljust(12) if result_of_send
    end
    if use_colours
      # =================================================================== #
      # We will distinguish between components that have been found and
      # components that have not been found.
      # =================================================================== #
      if right_component.include?('not installed')
        right_component = ::Colours.send(:mediumslateblue, right_component)
      else
        right_component = ::Colours.send(colour_for_the_right_side, right_component)
      end
    end
    result = result.dup if result.frozen?
    result << right_component
    if compare_program_versions
      if is_this_program_included?(this_program)
        registered_local_version = RBT.swift_return_version_of_this_program(this_program.to_sym).to_s.dup
        if registered_local_version.include? 'v'
          # =============================================================== #
          # Modify entries such as 'v12.15.0' into '12.15.0'.
          # =============================================================== #
          registered_local_version.delete!('v')
        end
        case this_program.to_s
        when 'gtk2'
          registered_local_version = query_pkgconfig_version_for(:gtk2)
        else
          if result_of_send.nil?
            # ^^^ This is missing, then, so it will be ignored.
          elsif registered_local_version <= result_of_send 
            # This is ok.
          else
            result << 
              royalblue(
                "\n    "\
                "^^^ This could be updated; the version in "\
                "RBT is: #{mediumpurple(registered_local_version)}"
              )
          end
        end
      end
    end
    # ===================================================================== #
    # Finally display our findings to the end user.
    # ===================================================================== #
    e result
  }
  e
  if is_on_roebe? # And store it on my home system too.
    ::EnvironmentInformation.store_relevant_files
  end
end
show_detailed_information_about_all_available_components() click to toggle source
#

EnvironmentInformation.show_detailed_information_about_all_available_components

This method is mostly for testing purposes only; for real use for the project you should consider making use of Environment.silent_run instead.

Do note that this method will always show all available components; if you need more fine-tuned control then you have to use the class EnvironmentInformation instead.

#
# File lib/environment_information/toplevel_methods/misc.rb, line 87
def self.show_detailed_information_about_all_available_components
  @hash_available_programs = {} # Clear it every time this method is run.
  work_on_these_programs = []
  work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_NON_PROGRAMS)
  work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_PROGRAMS)
  work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_XORG_COMPONENTS)
  work_on_these_programs << YAML.load_file(FILE_ARRAY_SCIENCE_CLUSTER)
  work_on_these_programs.flatten!
  work_on_these_programs.uniq!
  e
  work_on_these_programs.each {|this_program|
    version_of_this_program = ::EnvironmentInformation.return_version_of_this_program(this_program)
    # ===================================================================== #
    # Do a little sanitizing next:
    # ===================================================================== #
    case this_program.to_s
    when 'kde_frameworks'
      this_program = 'KDE Frameworks'.to_sym
    end
    left_side = colourize_and_pad_the_left_side(this_program)
    case version_of_this_program
    when COMMAND_NOT_FOUND,
         ''
      version_of_this_program = nil
      colour_for_the_right_side = :orange
    else
      colour_for_the_right_side = :notify_if_missing
    end
    # ===================================================================== #
    # Next register this program into the main hash.
    # ===================================================================== #
    @hash_available_programs[this_program] = version_of_this_program
    right_side = colourize_and_pad_the_right_side(
      version_of_this_program,
      colour_for_the_right_side
    )
    e "  #{left_side} #{right_side}"
  }
  e
  # ======================================================================= #
  # Report missing programs.
  # ======================================================================= #
  _ = missing_components?
  unless _.empty?
    e 'The following components were not found:'
    e
    _.each {|this_component|
      e lightseagreen("  #{this_component}")
    }
    e
  end
  consider_storing_these_results_into_a_local_file
end
show_remote_url_of_this_program(i = ARGV) click to toggle source
#

EnvironmentInformation.show_remote_url_of_this_program

This method will try to show the remote URL of the given program.

#
# File lib/environment_information/toplevel_methods/remote_url_of_this_program.rb, line 37
def self.show_remote_url_of_this_program(i = ARGV)
  puts return_remote_url_of_this_program(i)
end
silent_run( array_load_these_files = [ FILE_ARRAY_TRACKED_NON_PROGRAMS, FILE_ARRAY_TRACKED_PROGRAMS, FILE_ARRAY_TRACKED_XORG_COMPONENTS, FILE_ARRAY_SCIENCE_CLUSTER ] ) click to toggle source
#

Environment.silent_run

#
# File lib/environment_information/toplevel_methods/misc.rb, line 28
def self.silent_run(
    array_load_these_files = [
      FILE_ARRAY_TRACKED_NON_PROGRAMS,
      FILE_ARRAY_TRACKED_PROGRAMS,
      FILE_ARRAY_TRACKED_XORG_COMPONENTS,
      FILE_ARRAY_SCIENCE_CLUSTER
    ]
  ) 
  @hash_available_programs = {} # Clear it every time this method is run.
  work_on_these_programs = []
  array_load_these_files.each {|this_entry|
    work_on_these_programs << YAML.load_file(this_entry)
  }
  work_on_these_programs.flatten.each {|this_program|
    version_of_this_program = ::EnvironmentInformation.return_version_of_this_program(this_program)
    if version_of_this_program
      version_of_this_program = version_of_this_program.to_s
    end
    @hash_available_programs[this_program] = version_of_this_program
  }
  consider_storing_these_results_into_a_local_file(false)
  return @hash_available_programs
end
simp(i = '') click to toggle source
#

EnvironmentInformation

#
# File lib/environment_information/colours/simp.rb, line 14
def self.simp(i = '')
  return ::Colours.simp(i) if Object.const_defined? :Colours
  i
end
start_gtk_component() click to toggle source
#

EnvironmentInformation.start_gtk_component

We have to rescue the code so to notify the user what exactly may have failed.

#
# File lib/environment_information/toplevel_methods/menu.rb, line 75
def self.start_gtk_component
  begin
    this_file = 'environment_information/gui/gtk3/environment_information.rb'
    require this_file
  rescue LoadError => error
    e "An error happened - file #{sfile(this_file)} could not be found."
    pp error
  end
  ::EnvironmentInformation.run_gtk
end
start_sinatra_interface() click to toggle source
#

EnvironmentInformation.start_sinatra_interface

This method can be used to start the sinatra interface.

#
# File lib/environment_information/www/sinatra_interface.rb, line 204
def self.start_sinatra_interface
  puts 'Trying to start the sinatra-interface of EnvironmentInformation next.'
  ::EnvironmentInformation::Sinatra.run!
end
steelblue(i = '') click to toggle source
#

EnvironmentInformation.steelblue

#
# File lib/environment_information/colours/colours.rb, line 172
def self.steelblue(i = '')
  if @use_colours
    return ::Colours.steelblue(i)
  end
  return i
end
temp_directory?( i = @temp_directory ) click to toggle source
#

EnvironmentInformation.temp_directory?

This method will refer to the temp-directory in use for this project.

It is advised to make use of the method, rather than the TEMP_DIRECTORY constant, as that is more convenient in the long run.

#
# File lib/environment_information/constants/temp_directory.rb, line 46
def self.temp_directory?(
    i = @temp_directory
  )
  i.squeeze('/').dup
end
tomato( i = '', use_colours = @use_colours ) click to toggle source
#

EnvironmentInformation.tomato

#
# File lib/environment_information/colours/colours.rb, line 132
def self.tomato(
    i = '', use_colours = @use_colours
  )
  return ::Colours.tomato(i) if use_colours
  return i
end
tracked_non_programs?() click to toggle source
#

EnvironmentInformation.tracked_non_programs?

Simpler toplevel-method to find out which non-programs are registered within the EnvironmentInformation project.

#
# File lib/environment_information/constants/array_tracked_components.rb, line 168
def self.tracked_non_programs?
  ARRAY_TRACKED_NON_PROGRAMS
end
tracked_programs?() click to toggle source
#

EnvironmentInformation.tracked_programs?

Simpler toplevel-method to find out which programs are registered within the EnvironmentInformation project.

#
# File lib/environment_information/constants/array_tracked_components.rb, line 150
def self.tracked_programs?
  ARRAY_TRACKED_PROGRAMS
end
use_colours?() click to toggle source
#

EnvironmentInformation.use_colours?

#
# File lib/environment_information/colours/colours.rb, line 88
def self.use_colours?
  @use_colours
end
verbose_truth(i) click to toggle source
#

Environment.verbose_truth

#
# File lib/environment_information/toplevel_methods/misc.rb, line 16
def self.verbose_truth(i)
  case i
  when /true/
    'Yes.'
  when /false/
    'No.'
  end
end
which_components_are_missing?() click to toggle source
#

EnvironmentInformation.which_components_are_missing?

#
# File lib/environment_information/toplevel_methods/register_this_component_is_missing.rb, line 21
def self.which_components_are_missing?
  @array_this_component_is_missing
end
write_what_into(what, into) click to toggle source
#

EnvironmentInformation.write_what_into

#
# File lib/environment_information/toplevel_methods/write_what_into.rb, line 15
def self.write_what_into(what, into)
  what = what.join("\n") if what.is_a? Array
  File.open(into, 'w+') {|entry| entry.write(what) }
end
xorg_components?() click to toggle source
#

EnvironmentInformation.xorg_components?

#
# File lib/environment_information/constants/array_tracked_components.rb, line 157
def self.xorg_components?
  ARRAY_XORG_COMPONENTS
end