Module: Pfm::Helpers

Included in:
CLI, Command::Base
Defined in:
lib/idlc-sdk-pfm/helpers.rb

Overview

Module of common functions that are used frequently in every namespace

Class Method Summary collapse

Class Method Details

.debug(message) ⇒ Object

Only prints the given string to stdout when the environment variable DEBUG = true

Parameters:

  • message (String)

    the string to print



35
36
37
# File 'lib/idlc-sdk-pfm/helpers.rb', line 35

def debug(message)
  stdout.print("#{message}\n") if ENV['DEBUG']
end

.err(message) ⇒ Object

Print the given string to stderr

Parameters:

  • message (String)

    the string to print



20
21
22
# File 'lib/idlc-sdk-pfm/helpers.rb', line 20

def err(message)
  stderr.print("#{message}\n")
end

.msg(message) ⇒ Object

Print the given string to stdout

Parameters:

  • message (String)

    the string to print



27
28
29
# File 'lib/idlc-sdk-pfm/helpers.rb', line 27

def msg(message)
  stdout.print("#{message}\n")
end

.system_command(*command_args) ⇒ Object

Runs given commands using mixlib-shellout

Parameters:

  • command_args (String)

    the system command to run



9
10
11
12
13
14
15
# File 'lib/idlc-sdk-pfm/helpers.rb', line 9

def system_command(*command_args)
  cmd = Mixlib::ShellOut.new(*command_args)
  cmd.run_command
  err(cmd.stderr)
  msg(cmd.stdout)
  cmd
end