Sha256: 1fb1be1eef804a5c97a096563c5acccacb3125554029ec7d41efeb6c9b979c1f

Contents?: true

Size: 729 Bytes

Versions: 28

Compression:

Stored size: 729 Bytes

Contents

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

28 entries across 28 versions & 1 rubygems

Version Path
rake-funnel-0.9.1.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.9.0.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.8.0.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.7.0.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.6.1.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.6.0.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.5.0.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.4.0.pre lib/rake/funnel/extensions/disable_colors.rb