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
idlc-sdk-pfm-1.1.2 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.1.1 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.1.0 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.21 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.20 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.19 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.18 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.17 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.16 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.15 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.14 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.13 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.12 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.11 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.10 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.8 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.7 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.6 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.5 lib/idlc-sdk-pfm/helpers.rb
idlc-sdk-pfm-1.0.4 lib/idlc-sdk-pfm/helpers.rb