Sha256: 21ed9bb99940f3e70ed5b00810bb5f5a7317bdceb4617f6fb61e88fe10521770

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

require "airbrussh/colors"
require "airbrussh/console_formatter"
require "airbrussh/log_file_formatter"

module Airbrussh
  class Configuration
    attr_accessor :log_file, :monkey_patch_rake, :color, :truncate, :banner,
                  :command_output

    def initialize
      self.log_file = nil
      self.monkey_patch_rake = false
      self.color = :auto
      self.truncate = :auto
      self.banner = :auto
      self.command_output = false
    end

    def banner_message
      return nil unless banner
      return banner unless banner == :auto
      msg = "Using airbrussh format."
      if log_file
        msg << "\n"
        msg << "Verbose output is being written to #{Colors.blue(log_file)}."
      end
      msg
    end

    # This returns an array of formatters appropriate for the configuration.
    # Depending on whether a log file is configured, this could be just the
    # Airbrussh:ConsoleFormatter, or that plus the LogFileFormatter.
    def formatters(io)
      fmts = [Airbrussh::ConsoleFormatter.new(io, self)]
      fmts.unshift(Airbrussh::LogFileFormatter.new(log_file)) if log_file
      fmts
    end

    def show_command_output?(sym)
      command_output == true || Array(command_output).include?(sym)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
airbrussh-0.8.0 lib/airbrussh/configuration.rb
airbrussh-0.7.0 lib/airbrussh/configuration.rb
airbrussh-0.6.0 lib/airbrussh/configuration.rb