Module: Pantheios::Util::ProcessUtil

Defined in:
lib/pantheios/util/process_util.rb

Overview

process utilities

Class Method Summary collapse

Class Method Details

.derive_process_name(dollar0 = nil, **options) ⇒ Object

  • Options:

    • :style

      (:script, :script_basename, :script_dirname, :script_realpath, :script_stem) directs

    the inference of the process name. If none specified, :script_stem is assumed



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pantheios/util/process_util.rb', line 12

def self.derive_process_name dollar0 = nil, **options

	dollar0	||=	$0

	style	=	options[:style] || :script_stem

	case style
	when :script

		dollar0
	when :script_basename

		File.basename(dollar0)
	when :script_dirname

		File.basename(File.realpath(File.dirname(dollar0)))
	when :script_realpath

		File.realpath(File.dirname(dollar0))
	when :script_stem

		bn = File.basename(dollar0)

		bn =~ /\.rb$/ ? $` : bn
	else

		warn "#{self.class}##{__method__}: ignoring unrecognised type/value for ':style': '#{style}' (#{style.class})"

		dollar0
	end
end