forthebadge forthebadge Gem Version

About the convert_global_env project

This project can convert string entries such as $FOO to their corresponding ENV['FOO'] counterpart. This will happen on a whole string, so multiple entries of $FOO can be replaced in one go.

The project was created so that I can batch-generate hardcoded shell variables or query the value of ENV variables from .cgi files and elsewhere.

In May 2022 when this project was rewritten, support for hashes other than the one stored in ENV was added too. This will allow us to properly work on windows as well, should ENV not contain any such values (if the rcfiles gem is available).

Structure of the convert_global_env gem

This subsection contains just a few noteworthy comments pertaining to the structure of this gem.

How to use the convert_global_env gem in your project

There are several different ways how this gem can be used, but let's describe the simplest variant.

First, require it via:

require 'convert_global_env'

Then, if your input-string contains a '$' character, convert it like so:

ConvertGlobalEnv.convert '$MY_SRC/ruby' # => "/home/x/src/ruby"

Note that this only works if your ENV (environment) contains such a value. So if the value $MY_SRC is not defined then the above logically will not work.

This can be a problem for some situations, such as in a .cgi file where no ENV variables exist, or on windows typically. For these reasons an alternative exists, if the rcfile gem is installed and available.

The method load_values_from_the_rcfiles_gem()

The method load_values_from_the_rcfiles_gem() is normally not used, but you can use it specifically to load ENV-like variables if the rcfiles gem is installed.

See the .cgi page in the test/ subdirectory at:

convert_global_env/test/testing_cgi_environment.cgi

Licence

In January of 2022 the licence of this gem was changed to MIT. The primary reason for this is because this gem is used by several other gems which are mostly MIT-based. So it seemed simpler to have the same licence for this gem as well.

Contact information

If your creative mind has ideas and specific suggestions to make this gem more useful in general, feel free to drop me an email at any time, via:

shevy@inbox.lt

Before that email I used an email account at Google gmail, but in 2021 I decided to slowly abandon gmail for various reasons. In part this is because the UI annoys me (on non-chrome browser loading takes too long), but also because of Google's attempt to establish mass surveillance via its federated cohorts sniffing (FLoC). I do not know what happened at Google, but enough is enough - there is only so much you can take while supporting greed. When it comes to data mining done by private groups, ultimately the user became the product.

Do keep in mind that responding to emails may take some time, depending on the amount of work I may have at that moment, due to reallife time constraints. I will, however had, read feedback eventually. Patches and code changes are welcome too, of course, as long as they are in the spirit of the project at hand, e. g. fitting to the general theme. For this I may make use of github as a discussion site, but this has a low priority right now.