Class: Kibuvits_krl171bt4_shell

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/kibuvits_ruby_library_krl171bt4_.rb

Overview


Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeKibuvits_krl171bt4_shell

Returns a new instance of Kibuvits_krl171bt4_shell.



7760
7761
7762
7763
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 7760

def initialize
   @s_lc_which="which ".freeze
   @s_lc_1="[/]".freeze
end

Class Method Details

.b_available_on_path(s_program_name) ⇒ Object

b_available_on_path



7875
7876
7877
7878
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 7875

def Kibuvits_krl171bt4_shell.b_available_on_path(s_program_name)
   b_out=Kibuvits_krl171bt4_shell.instance.b_available_on_path(s_program_name)
   return b_out
end

.b_stderr_has_content_t1(ht_stdstreams) ⇒ Object

b_stderr_has_content_t1



7902
7903
7904
7905
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 7902

def Kibuvits_krl171bt4_shell.b_stderr_has_content_t1(ht_stdstreams)
   b_out=Kibuvits_krl171bt4_shell.instance.b_stderr_has_content_t1(ht_stdstreams)
   return b_out
end

.s_exc_system_specific_path_by_caching_t1(s_program_name, b_throw_if_not_found = true) ⇒ Object



7850
7851
7852
7853
7854
7855
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 7850

def Kibuvits_krl171bt4_shell.s_exc_system_specific_path_by_caching_t1(
   s_program_name,b_throw_if_not_found=true)
   s_out=Kibuvits_krl171bt4_shell.instance.s_exc_system_specific_path_by_caching_t1(
   s_program_name,b_throw_if_not_found)
   return s_out
end

.throw_if_stderr_has_content_t1(ht_stdstreams, s_optional_error_message_suffix = nil) ⇒ Object

throw_if_stderr_has_content_t1



7926
7927
7928
7929
7930
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 7926

def Kibuvits_krl171bt4_shell.throw_if_stderr_has_content_t1(ht_stdstreams,
   s_optional_error_message_suffix=nil)
   Kibuvits_krl171bt4_shell.instance.throw_if_stderr_has_content_t1(
   ht_stdstreams,s_optional_error_message_suffix)
end

Instance Method Details

#b_available_on_path(s_program_name) ⇒ Object

Returns boolean true, if the script or binary named valueof(s_executable_name) is available on the path.

The semantics of it is that it always studies the PATH and does not cache the results.



7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 7864

def b_available_on_path(s_program_name) # like "which", "grep", "vim", etc.
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, String, s_program_name
   end # if
   b_out=false
   s_fp=s_exc_system_specific_path_by_caching_t1_look_from_system(s_program_name)
   b_out=true if 0<s_fp.length
   return b_out
end

#b_stderr_has_content_t1(ht_stdstreams) ⇒ Object




7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 7882

def b_stderr_has_content_t1(ht_stdstreams)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Hash, ht_stdstreams
      kibuvits_krl171bt4_assert_ht_has_keys(bn,ht_stdstreams,
      [$kibuvits_krl171bt4_lc_s_stderr,$kibuvits_krl171bt4_lc_s_stdout],
      "\nGUID='dc52465c-448d-4c4e-b17e-c13290a118e7'")
   end # if
   s_err=ht_stdstreams[$kibuvits_krl171bt4_lc_s_stderr]
   if s_err.class!=String
      # s_err==nil, if the key is missing from the hashtable and
      # there is a flaw somewhere, if s_err is a number or
      # some custom instance, etc.
      kibuvits_krl171bt4_throw("The ht_stdstreams does not seem to have the "+
      "right content. \nGUID='d26fbd58-9537-4a0f-856e-c13290a118e7'")
   end # if
   return false if s_err.length==0
   return true
end

#s_exc_system_specific_path_by_caching_t1(s_program_name, b_throw_if_not_found = true) ⇒ Object

A pooling wrapper to the /usr/bin/env

If the s_program_name is found on PATH, returns the full path of the s_program_name

If the s_program_name is NOT found on PATH, returns an empty string or throws an exception.



7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 7814

def s_exc_system_specific_path_by_caching_t1(s_program_name,b_throw_if_not_found=true)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      i_min_length=2 # May be it should be 1?
      # The i_min_length can be changed to 1, after problems emerge.
      kibuvits_krl171bt4_assert_string_min_length(bn,s_program_name,i_min_length,
      "GUID='25a41711-ada3-4928-81ae-c13290a118e7'")
      kibuvits_krl171bt4_typecheck bn, [TrueClass,FalseClass], b_throw_if_not_found
   end # if
   if !defined? @ht_s_exc_system_specific_path_by_caching_t1_cache
      @ht_s_exc_system_specific_path_by_caching_t1_cache=Hash.new
   end # if
   #---------------
   # s_fp is a string in stead of nil to match the
   # s_exc_system_specific_path_by_caching_t1_look_from_system output format.
   s_fp=$kibuvits_krl171bt4_lc_emptystring
   if @ht_s_exc_system_specific_path_by_caching_t1_cache.has_key? s_program_name
      s_fp=@ht_s_exc_system_specific_path_by_caching_t1_cache[s_program_name]
   else
      s_fp=s_exc_system_specific_path_by_caching_t1_look_from_system(s_program_name)
      if 0<s_fp.length
         @ht_s_exc_system_specific_path_by_caching_t1_cache[s_program_name]=s_fp.freeze
      end # if
   end # if
   #---------------
   if s_fp.length==0
      if b_throw_if_not_found
         kibuvits_krl171bt4_throw("Program \""+ s_program_name+
         "\" could not be found on the PATH."+
         "\nGUID='e2c3d448-f8ef-415a-a39e-c13290a118e7'")
      end # if
   end # if
   return s_fp
end

#throw_if_stderr_has_content_t1(ht_stdstreams, s_optional_error_message_suffix = nil) ⇒ Object



7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 7908

def throw_if_stderr_has_content_t1(ht_stdstreams,
   s_optional_error_message_suffix=nil)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Hash, ht_stdstreams
      kibuvits_krl171bt4_typecheck bn, [NilClass,String], s_optional_error_message_suffix
      kibuvits_krl171bt4_assert_ht_has_keys(bn,ht_stdstreams,
      [$kibuvits_krl171bt4_lc_s_stderr,$kibuvits_krl171bt4_lc_s_stdout],
      "\nGUID='5a10fda5-0286-42e4-a35e-c13290a118e7'")
   end # if
   return if !b_stderr_has_content_t1(ht_stdstreams)
   s_msg=ht_stdstreams[$kibuvits_krl171bt4_lc_s_stderr]+$kibuvits_krl171bt4_lc_linebreak
   if s_optional_error_message_suffix!=nil
      s_msg=s_msg+s_optional_error_message_suffix+$kibuvits_krl171bt4_lc_linebreak
   end # if
   kibuvits_krl171bt4_throw(s_msg)
end