Sha256: 62b8402143a71c4d1c5b1cd28920cd1d98c1373117abf47ae4a43a9365a34121

Contents?: true

Size: 1.04 KB

Versions: 62

Compression:

Stored size: 1.04 KB

Contents

module Pfm
  # Module of common functions that are used frequently in every namespace
  module Helpers
    module_function

    # Runs given commands using mixlib-shellout
    #
    # @param command_args [String] the system command to run
    def system_command(*command_args)
      cmd = Mixlib::ShellOut.new(*command_args)
      cmd.run_command
      err(cmd.stderr)
      msg(cmd.stdout)
      cmd
    end

    # Print the given string to stderr
    #
    # @param message [String] the string to print
    def err(message)
      stderr.print("#{message}\n")
    end

    # Print the given string to stdout
    #
    # @param message [String] the string to print
    def msg(message)
      stdout.print("#{message}\n")
    end

    # Only prints the given string to stdout when the environment variable
    # DEBUG = true
    #
    # @param message [String] the string to print
    def debug(message)
      stdout.print("#{message}\n") if ENV['DEBUG']
    end

    private

    def stdout
      $stdout
    end

    def stderr
      $stderr
    end
  end
end

Version data entries

62 entries across 62 versions & 2 rubygems

Version Path
iapi-idlc-sdk-pfm-1.0.18 lib/iapi-idlc-sdk-pfm/helpers.rb
iapi-idlc-sdk-pfm-1.0.17 lib/iapi-idlc-sdk-pfm/helpers.rb
iapi-idlc-sdk-pfm-1.0.16 lib/iapi-idlc-sdk-pfm/helpers.rb
iapi-idlc-sdk-pfm-1.0.15 lib/iapi-idlc-sdk-pfm/helpers.rb
iapi-idlc-sdk-pfm-1.0.14 lib/iapi-idlc-sdk-pfm/helpers.rb
iapi-idlc-sdk-pfm-1.0.13 lib/iapi-idlc-sdk-pfm/helpers.rb
iapi-idlc-sdk-pfm-1.0.12 lib/iapi-idlc-sdk-pfm/helpers.rb
iapi-idlc-sdk-pfm-1.0.11 lib/iapi-idlc-sdk-pfm/helpers.rb
iapi-idlc-sdk-pfm-1.0.10 lib/iapi-idlc-sdk-pfm/helpers.rb
iapi-idlc-sdk-pfm-1.0.9 lib/iapi-idlc-sdk-pfm/helpers.rb
iapi-idlc-sdk-pfm-1.0.8 lib/iapi-idlc-sdk-pfm/helpers.rb
iapi-idlc-sdk-pfm-1.0.7 lib/iapi-idlc-sdk-pfm/helpers.rb
iapi-idlc-sdk-pfm-1.0.6 lib/iapi-idlc-sdk-pfm/helpers.rb
iapi-idlc-sdk-pfm-1.0.5 lib/iapi-idlc-sdk-pfm/helpers.rb
iapi-idlc-sdk-pfm-1.0.4 lib/iapi-idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.2.2 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.2.1 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.2.0 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.1.4 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.1.3 lib/idlc-sdk-pfm/helpers.rb