convert_global_env 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of convert_global_env might be problematic. Click here for more details.

checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 647ef771ad8f4af766e740d94f79b672aaa808d71a647a79f6dd1084c73fd728
4
+ data.tar.gz: cac46517ccec1e9ad8c81b68afb19a6924875bfad48a33352a07baf9e2f6410d
5
+ SHA512:
6
+ metadata.gz: e43ff6f763ba946deedaeac7e7d9af374551b8f91fe439cc1da0380f3c6e126f29c49a96f81f9080a0e7aaf6e34bcfe6d67fbbd8181f4320a056ac9e42d222f8
7
+ data.tar.gz: 82dcff57cb4bebaa6109640d4b47a720cd7d005fc131eabb79ef2af784bef2980ff7604dadb7159abc258b3b76c4ec310976b22608d6f6cacca32e681f67d57c
data/USAGE.md ADDED
@@ -0,0 +1,15 @@
1
+ = Usage of Library
2
+
3
+ == Description
4
+
5
+ This small module converts a $FOO variable into an
6
+ ENV variable.
7
+
8
+ == Requiring it
9
+
10
+ require 'convert_global_env'
11
+
12
+ == Using it in a project
13
+
14
+ ConvertGlobalEnv.convert('$FOO/BAR')
15
+ ConvertGlobalEnv['$FOO/BAR']
@@ -0,0 +1,56 @@
1
+ # =========================================================================== #
2
+ # Gemspec for Project ConvertGlobalEnv.
3
+ # =========================================================================== #
4
+ require 'convert_global_env/version/version.rb'
5
+
6
+ Gem::Specification.new { |s|
7
+
8
+ s.name = 'convert_global_env'
9
+ s.version = ConvertGlobalEnv::VERSION
10
+ s.date = Time.now.strftime('%Y-%m-%d')
11
+
12
+ s.summary = <<-EOF
13
+
14
+ This module translates a string like $FOO/bar into the corresponding
15
+ ENV variable, i.e. ENV['FOO']+'/bar'.
16
+ It has no external dependencies.
17
+
18
+ If you have specific suggestions to make this gem more useful
19
+ for others, please drop me an email at:
20
+
21
+ shevegen@gmail.com.
22
+
23
+ Thank you.
24
+
25
+ EOF
26
+
27
+ s.description = <<-EOF
28
+
29
+ This module translates a string like $FOO/bar into the corresponding
30
+ ENV variable, i.e. ENV['FOO']+'/bar'.
31
+ It has no external dependencies.
32
+
33
+ If you have specific suggestions to make this gem more useful
34
+ for others, please drop me an email at:
35
+
36
+ shevegen@gmail.com.
37
+
38
+ Thank you.
39
+
40
+ EOF
41
+
42
+ s.extra_rdoc_files = %w(
43
+ USAGE.md
44
+ )
45
+
46
+ s.authors = ['Robert A. Heiler']
47
+ s.email = 'shevegen@gmail.com'
48
+ s.files = Dir['**/*']
49
+ s.licenses = 'GPL-2.0'
50
+ s.homepage = 'http://rubygems.org/gems/convert_global_env'
51
+
52
+ s.required_ruby_version = '>= 2.3.1'
53
+ s.required_rubygems_version = '>= 2.6.6'
54
+ s.rubygems_version = '>= 2.6.6'
55
+
56
+ }
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'convert_global_env/convert_global_env.rb'
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'convert_global_env/convert_global_env.rb'
6
+
7
+ include ConvertGlobalEnv
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module ConvertGlobalEnv
6
+
7
+ # ========================================================================= #
8
+ # === ENCODING_ISO
9
+ # ========================================================================= #
10
+ ENCODING_ISO = 'ISO-8859-1'
11
+
12
+ # ========================================================================= #
13
+ # === ENCODING_UTF
14
+ # ========================================================================= #
15
+ ENCODING_UTF = 'UTF-8'
16
+
17
+ # ========================================================================= #
18
+ # === ConvertGlobalEnv::USE_THIS_ENCODING
19
+ # ========================================================================= #
20
+ USE_THIS_ENCODING = ENCODING_UTF
21
+
22
+ # ========================================================================= #
23
+ # === REGEX_TO_CHECK_FOR_GLOBAL_ENV
24
+ #
25
+ # The regex to check for the global env.
26
+ #
27
+ # See:
28
+ #
29
+ # https://rubular.com/r/tTX6lVBpSa
30
+ #
31
+ # ========================================================================= #
32
+ REGEX_TO_CHECK_FOR_GLOBAL_ENV =
33
+ /\$([A-Za-z_]+)+/
34
+
35
+ end
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # How would you use this software in your project?
6
+ #
7
+ # Well, first require it:
8
+ #
9
+ # require 'convert_global_env'
10
+ #
11
+ # Then, feed it the string that contains a '$' character, like so:
12
+ #
13
+ # ConvertGlobalEnv.convert '$SRC/RUBY'
14
+ #
15
+ # =========================================================================== #
16
+ module ConvertGlobalEnv
17
+
18
+ require 'convert_global_env/module_methods.rb'
19
+ require 'convert_global_env/constants.rb'
20
+ require 'convert_global_env/version/version.rb'
21
+
22
+ alias e puts
23
+
24
+ # ========================================================================= #
25
+ # === @report_errors
26
+ # ========================================================================= #
27
+ @report_errors = true
28
+
29
+ # ========================================================================= #
30
+ # === @use_this_target_encoding
31
+ #
32
+ # This denotes the encoding in use. If we use the wrong encoding
33
+ # then failures may happen.
34
+ #
35
+ # Since as of 28.08.2020 we will default to UTF as encoding.
36
+ # ========================================================================= #
37
+ @use_this_target_encoding = USE_THIS_ENCODING
38
+
39
+ # ========================================================================= #
40
+ # === ConvertGlobalEnv.encoding?
41
+ # ========================================================================= #
42
+ def self.encoding?
43
+ @use_this_target_encoding
44
+ end
45
+
46
+ end
47
+
48
+ if __FILE__ == $PROGRAM_NAME
49
+ puts ConvertGlobalEnv.convert(ARGV.first)
50
+ end # cgenv
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module ConvertGlobalEnv
6
+
7
+ # ========================================================================= #
8
+ # === ConvertGlobalEnv.filename?
9
+ # ========================================================================= #
10
+ def self.filename?
11
+ _ = 'convert_global_env.rb'
12
+ _ = sfancy(_) if Object.const_defined? :Colours
13
+ _ # This is the result.
14
+ end
15
+
16
+ # ========================================================================= #
17
+ # === ConvertGlobalEnv.e
18
+ # ========================================================================= #
19
+ def self.e(i = '')
20
+ puts i
21
+ end
22
+
23
+ # ========================================================================= #
24
+ # === ConvertGlobalEnv.report_errors?
25
+ # ========================================================================= #
26
+ def self.report_errors?
27
+ @report_errors
28
+ end
29
+
30
+ # ========================================================================= #
31
+ # === ConvertGlobalEnv.be_quiet
32
+ # ========================================================================= #
33
+ def self.be_quiet
34
+ @report_errors = false
35
+ end
36
+
37
+ # ========================================================================= #
38
+ # === ConvertGlobalEnv[]
39
+ #
40
+ # Easier conversion variant. Will also honour the @report_errors
41
+ # class-instance variable.
42
+ # ========================================================================= #
43
+ def self.[](i)
44
+ ConvertGlobalEnv.convert(i, ConvertGlobalEnv.report_errors?)
45
+ end
46
+
47
+ # ========================================================================= #
48
+ # === ConvertGlobalEnv.convert(i)
49
+ #
50
+ # Use this method to convert from $FOO to ENV['FOO'], if $FOO exists.
51
+ #
52
+ # Specific usage examples:
53
+ #
54
+ # ConvertGlobalEnv.convert '$SRC/RUBY'
55
+ # ConvertGlobalEnv.convert '$MY_SRC/RUBY'
56
+ #
57
+ # ========================================================================= #
58
+ def self.convert(
59
+ i,
60
+ shall_we_report_errors = ConvertGlobalEnv.report_errors?
61
+ )
62
+ if shall_we_report_errors == :do_not_report_errors
63
+ shall_we_report_errors = false
64
+ end
65
+ if i.is_a? Array
66
+ i.map {|entry|
67
+ ConvertGlobalEnv.convert(entry, shall_we_report_errors)
68
+ } # Call recursively here.
69
+ else # Here come strings only.
70
+ # i.sub!(/\{/, '') # get rid of any { - Not a good idea. Disabled Sep 2012.
71
+ # i.sub!(/\}/, '') # get rid of any }
72
+ # ===================================================================== #
73
+ # We prefer ISO encoding here. No, we no longer do as of August 2020.
74
+ # ===================================================================== #
75
+ # case i.encoding.to_s
76
+ # # =================================================================== #
77
+ # # === ENCODING_UTF
78
+ # # =================================================================== #
79
+ # when ENCODING_UTF
80
+ # i = i.dup if i.frozen?
81
+ # i = i.force_encoding(ENCODING_ISO)
82
+ # end if File.exist?(i.to_s) # But only if the file exists.
83
+ unless i.encoding.to_s == ConvertGlobalEnv.encoding?
84
+ i = i.dup if i.frozen?
85
+ i = i.force_encoding(ConvertGlobalEnv.encoding?)
86
+ end
87
+ i =~ REGEX_TO_CHECK_FOR_GLOBAL_ENV # defined in this file here.
88
+ if $1 and ENV[$1]
89
+ i = i.to_s.dup # We want a clean String here.
90
+ i.gsub!("$#{$1}", ENV[$1]) unless ENV[$1].nil? # + "#{$2}"
91
+ else # Do nothing, except if you wish to debug.
92
+ # puts "The input: #{i} does not match against `#{REGEX_TO_CHECK_FOR_GLOBAL_ENV}`"
93
+ # pp $1; pp ENV[$1]
94
+ end
95
+ return i
96
+ end
97
+ end
98
+
99
+ end
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module ConvertGlobalEnv
6
+
7
+ # ========================================================================= #
8
+ # === ConvertGlobalEnv::VERSION
9
+ # ========================================================================= #
10
+ VERSION = '1.0.22'
11
+
12
+ end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'colours/colours_e_autoinclude.rb'
6
+ require 'convert_global_env/autoinclude'
7
+
8
+ input = '$BIORUBY/bioshell/bio_shell.rb'
9
+
10
+ e
11
+ e 'Now testing some stuff. (Note that some of the variables will not exist.)'
12
+ e
13
+ e 'First, we test '+sfancy(input)
14
+ e ' -> '+ConvertGlobalEnv.convert(input)
15
+ e ' -> '+ConvertGlobalEnv.convert('test $IMG/rubyconvention2012')
16
+ e ' -> '+ConvertGlobalEnv.convert('$SRC/RUBY')
17
+ e ' -> '+ConvertGlobalEnv.convert('$T ee')
18
+ e ' -> '+ConvertGlobalEnv.convert('$MY_PHP')
19
+ e ' -> '+ConvertGlobalEnv.convert('--enable-bcmath --enable-calendar '\
20
+ '--enable-cli --enable-dba=shared --enable-fastcgi --enable-force-redirect '\
21
+ '--enable-force-cgi-redirect --enable-inline-optimization '\
22
+ '--with-config-file-path=$MY_PHP '\
23
+ '--with-iconv-dir=/Programs/Libiconv/Current/ '\
24
+ '--with-gdbm --with-gmp --without-gd '\
25
+ '--without-iconv --without-sqlite --disable-debug')
26
+ e
27
+ e "Next, we test Array as input, aka: %w( a b c )+['$MY_SRC/RUBY']:"
28
+ e
29
+ this_array = %w( a b c ) + ['$MY_SRC/RUBY']
30
+ this_array = ConvertGlobalEnv.convert(this_array)
31
+ e ' -> '+this_array.join("\n")
32
+ e
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: convert_global_env
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.22
5
+ platform: ruby
6
+ authors:
7
+ - Robert A. Heiler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-08-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2+
14
+
15
+ This module translates a string like $FOO/bar into the corresponding
16
+ ENV variable, i.e. ENV['FOO']+'/bar'.
17
+ It has no external dependencies.
18
+
19
+ If you have specific suggestions to make this gem more useful
20
+ for others, please drop me an email at:
21
+
22
+ shevegen@gmail.com.
23
+
24
+ Thank you.
25
+
26
+ email: shevegen@gmail.com
27
+ executables: []
28
+ extensions: []
29
+ extra_rdoc_files:
30
+ - USAGE.md
31
+ files:
32
+ - USAGE.md
33
+ - convert_global_env.gemspec
34
+ - lib/convert_global_env.rb
35
+ - lib/convert_global_env/autoinclude.rb
36
+ - lib/convert_global_env/constants.rb
37
+ - lib/convert_global_env/convert_global_env.rb
38
+ - lib/convert_global_env/module_methods.rb
39
+ - lib/convert_global_env/version/version.rb
40
+ - test/testing_convert_global_env.rb
41
+ homepage: http://rubygems.org/gems/convert_global_env
42
+ licenses:
43
+ - GPL-2.0
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.3.1
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 2.6.6
59
+ requirements: []
60
+ rubygems_version: 3.1.4
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: 'This module translates a string like $FOO/bar into the corresponding ENV
64
+ variable, i.e. ENV[''FOO'']+''/bar''. It has no external dependencies. If you have
65
+ specific suggestions to make this gem more useful for others, please drop me an
66
+ email at: shevegen@gmail.com. Thank you.'
67
+ test_files: []
68
+ ...