Sha256: 4f3d6331a43c8cc299c4717a9aa7b1da95b77f0c9dd272d154e3d9d8db54a5c6

Contents?: true

Size: 1.6 KB

Versions: 51

Compression:

Stored size: 1.6 KB

Contents

# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
#
# THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
# AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
# reproduction, modification, or disclosure of this program is
# strictly prohibited. Any use of this program by an authorized
# licensee is strictly subject to the terms and conditions,
# including confidentiality obligations, set forth in the applicable
# License Agreement between RightScale.com, Inc. and
# the licensee

require 'singleton'

module RightConf

  module Singleton

    module ClassMethods

      # Redirect class methods to singleton instance
      def method_missing(meth, *args, &blk)
        self.instance.__send__(meth, *args, &blk)
      end

    end

    # Upon inclusion, also include standard Singleton mixin
    def self.included(base)
      base.__send__(:include, ::Singleton)
      base.__send__(:extend, ClassMethods)
    end
  end

end


# Add ability to output colored text to console
# e.g.: puts "Hello".red
class String
  def bold; colorize("\e[1m\e[29m"); end
  def grey; colorize("\e[30m"); end
  def red; colorize("\e[1m\e[31m"); end
  def dark_red; colorize("\e[31m"); end
  def green; colorize("\e[1m\e[32m"); end
  def dark_green; colorize("\e[32m"); end
  def yellow; colorize("\e[1m\e[33m"); end
  def blue; colorize("\e[1m\e[34m"); end
  def dark_blue; colorize("\e[34m"); end
  def pur; colorize("\e[1m\e[35m"); end
  def colorize(color_code)  
    # Doesn't work with the Windows prompt...
    (RightConf::Platform.windows? || !$stdout.isatty) ? to_s : "#{color_code}#{to_s}\e[0m" 
  end
end


Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
rconf-0.8.3 lib/rconf/ruby_extensions.rb
rconf-0.8.2 lib/rconf/ruby_extensions.rb
rconf-0.8.1 lib/rconf/ruby_extensions.rb
rconf-0.8.0 lib/rconf/ruby_extensions.rb
rconf-0.7.15 lib/rconf/ruby_extensions.rb
rconf-0.7.13 lib/rconf/ruby_extensions.rb
rconf-0.7.12 lib/rconf/ruby_extensions.rb
rconf-0.7.11 lib/rconf/ruby_extensions.rb
rconf-0.7.10 lib/rconf/ruby_extensions.rb
rconf-0.7.9 lib/rconf/ruby_extensions.rb
rconf-0.7.8 lib/rconf/ruby_extensions.rb
rconf-0.7.6 lib/rconf/ruby_extensions.rb
rconf-0.7.5 lib/rconf/ruby_extensions.rb
rconf-0.7.4 lib/rconf/ruby_extensions.rb
rconf-0.7.3 lib/rconf/ruby_extensions.rb
rconf-0.7.2 lib/rconf/ruby_extensions.rb
rconf-0.7.1 lib/rconf/ruby_extensions.rb
rconf-0.7.0 lib/rconf/ruby_extensions.rb
rconf-0.6.35 lib/rconf/ruby_extensions.rb
rconf-0.6.34 lib/rconf/ruby_extensions.rb