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.22.2 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.22.1 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.22.0 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.21.2 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.21.1 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.21.0 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.20.2 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.20.1 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.20.0 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.19.0 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.18.0 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.17.0 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.16.1 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.16.0 lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.15.0.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.14.0.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.13.0.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.12.0.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.11.0.pre lib/rake/funnel/extensions/disable_colors.rb
rake-funnel-0.10.0.pre lib/rake/funnel/extensions/disable_colors.rb