Sha256: 29b27d8bc190772d5cc278b0efa2a5da4821b771522073b4dd3eace723a920d0

Contents?: true

Size: 672 Bytes

Versions: 11

Compression:

Stored size: 672 Bytes

Contents

require 'smart_colored'
require 'smart_colored/extend'

module Rake::Funnel::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

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

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rake-funnel-0.3.2.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.3.1.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.3.0.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.2.0.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.1.0.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.0.6.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.0.5.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.0.4.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.0.3.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.0.2.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.0.1.pre lib/rake/funnel/extensions/disable_colors.rb