Sha256: 94a5bc6dfe9877d2baa11667fb7c8121e73ad79ebccfb111c6e7d310d06b3532

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

require 'papa/helper/logger'

module Papa
  module Helper
    class Output
      REDIRECT_TO_NULL = '> /dev/null 2>&1'

      def self.stdout(message, options = {})
        message = build_output(message)
        puts message
        Helper::Logger.log(message)
      end

      def self.stderr(message, options = {})
        message = build_output(message)
        STDERR.puts message
        Helper::Logger.log(message)
      end

      def self.error(message)
        message = "ERROR: #{message}"
        stderr(message)
        Helper::Logger.log(message)
      end

      def self.success(message)
        message.strip!
        puts
        puts message.green
        Helper::Logger.log(message)
      end

      def self.failure(message)
        message.strip!
        STDERR.puts
        STDERR.puts message.red
        Helper::Logger.log(message)
      end

      def self.success_info(message)
        puts message
        Helper::Logger.log(message)
      end

      def self.failure_info(message)
        STDERR.puts message
        Helper::Logger.log(message)
      end

      def self.info(message)
        puts message
        Helper::Logger.log(message)
      end

      def self.build_output(message)
        "[#{timestamp}] - #{message}"
      end

      def self.timestamp
        Time.now.strftime('%I:%M:%S %p')
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
papa-1.2.0 lib/papa/helper/output.rb
papa-1.1.0 lib/papa/helper/output.rb
papa-1.0.0 lib/papa/helper/output.rb
papa-0.7.2 lib/papa/helper/output.rb
papa-0.7.1 lib/papa/helper/output.rb
papa-0.7.0 lib/papa/helper/output.rb