Sha256: 8814d94a6125ceda0d7ec72f7df0a03684848a63bfddc132fce56aebf962c660

Contents?: true

Size: 760 Bytes

Versions: 3

Compression:

Stored size: 760 Bytes

Contents

# frozen_string_literal: true

require 'smart_colored'
require 'smart_colored/extend'

module Rake
  module Funnel
    module Extensions
      module DisableColors
        def self.included(klass)
          original_apply_format = klass.instance_method(:apply_format)

          define_method(:apply_format) do |format|
            return self unless $stdout.tty?

            bind_to = self
            bind_to = SmartColored::String.new(self) if klass == SmartColored::String

            original_apply_format.bind(bind_to).call(format)
          end
        end
      end
    end
  end
end

module SmartColored
  class String
    include Rake::Funnel::Extensions::DisableColors
  end
end

class String
  include Rake::Funnel::Extensions::DisableColors
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rake-funnel-0.24.0 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.23.0 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.22.3 lib/rake/funnel/extensions/disable_colors.rb