module Esystem

#
#

Constants

VERSION
#

VERSION

#

Public Class Methods

esystem( i, optional_try_to_colourize_the_result = false ) { || ... } click to toggle source
#

Esystem.esystem

This method combines output via the e() method, and a system call through the inbuilt method system().

If the optional colourize-argument is given, then we will invoke sfancy(), which will colourize the command that is to be run.

#
# File lib/esystem/esystem.rb, line 16
def self.esystem(
    i,
    optional_try_to_colourize_the_result = false
  )
  i = i.to_s # Seems more useful to have that in a String all the time.
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :do_colourize_the_result
    # ===================================================================== #
    when :do_colourize_the_result
      optional_try_to_colourize_the_result = true
    end
  end
  case optional_try_to_colourize_the_result
  when :colourize_output, :use_colours, :do_colourize,
       :do_colourize_the_result
    optional_try_to_colourize_the_result = true
  end
  if Object.const_defined? :Colours # Use Colours if it is available.
    _ = i # Work on a copy of the input here.
    _ = sfancy(_) if optional_try_to_colourize_the_result
    Colours.e(_)
  else
    puts i
  end
  begin
    system i
  rescue Errno::ENOENT => e
    puts 'The base-directory seems to have been deleted.'
    pp e
  end
end

Public Instance Methods

esystem(i, optional_try_to_colourize_the_result = false) click to toggle source
#

esystem

Simply delegate towards the above.

#
# File lib/esystem/esystem.rb, line 56
def esystem(i, optional_try_to_colourize_the_result = false)
  Esystem.esystem(i, optional_try_to_colourize_the_result)
end