Sha256: ce00c2c4d1d08f48b375dbe64cc33f1a8d4010bbd17824c0e0c9e691dc59f38d
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
#-- # Author:: Tyler Rick # Copyright:: Copyright (c) 2007 QualitySmith, Inc. # License:: Ruby License # Submit to Facets?:: # Developer notes:: #++ require 'rubygems' gem 'colored' require 'colored' gem 'facets' require 'facets/core/module/alias_method_chain' gem 'qualitysmith_extensions' require 'qualitysmith_extensions/module/guard_method' class String def colorize_with_toggleability(string, options = {}) if @@colorize_enabled colorize_without_toggleability(string, options) else string end end alias_method_chain :colorize, :toggleability mguard_method :color_on!, :@@colorize_enabled, :color_off! end unless String.instance_methods.include?('colorize_with_toggleability') # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TheTest < Test::Unit::TestCase def test_color_on! String.color_on! assert_equal "\e[31mfoo\e[0m", 'foo'.red end def test_color_off! String.color_off! assert_equal "foo", 'foo'.red end def test_color_off_with_block String.color_on! assert_equal "\e[31mfoo\e[0m", 'foo'.red String.color_off! do assert_equal "foo", 'foo'.red end assert_equal "\e[31mfoo\e[0m", 'foo'.red end end =end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
qualitysmith_extensions-0.0.24 | lib/qualitysmith_extensions/colored/toggleability.rb |