Sha256: af65c9680abca2c80ba2afd1f7874f6441bce218a19c71eac4d0bee7e3b385d2

Contents?: true

Size: 1.53 KB

Versions: 22

Compression:

Stored size: 1.53 KB

Contents

# Copyright (C) 2011-2012 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 black; colorize("\e[30m"); end
  def red; colorize("\e[31m"); end
  def green; colorize("\e[32m"); end
  def yellow; colorize("\e[33m"); end
  def blue; colorize("\e[34m"); end
  def purple; colorize("\e[35m"); end
  def cyan; colorize("\e[36m"); end
  def white; colorize("\e[37m"); 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

22 entries across 22 versions & 1 rubygems

Version Path
rconf-1.0.13 lib/rconf/ruby_extensions.rb
rconf-1.0.12 lib/rconf/ruby_extensions.rb
rconf-1.0.11 lib/rconf/ruby_extensions.rb
rconf-1.0.10 lib/rconf/ruby_extensions.rb
rconf-1.0.9 lib/rconf/ruby_extensions.rb
rconf-1.0.8 lib/rconf/ruby_extensions.rb
rconf-1.0.7 lib/rconf/ruby_extensions.rb
rconf-1.0.6 lib/rconf/ruby_extensions.rb
rconf-1.0.5 lib/rconf/ruby_extensions.rb
rconf-1.0.4 lib/rconf/ruby_extensions.rb
rconf-1.0.3 lib/rconf/ruby_extensions.rb
rconf-1.0.1 lib/rconf/ruby_extensions.rb
rconf-1.0.0 lib/rconf/ruby_extensions.rb
rconf-0.10.1 lib/rconf/ruby_extensions.rb
rconf-0.10.0 lib/rconf/ruby_extensions.rb
rconf-0.9.25 lib/rconf/ruby_extensions.rb
rconf-0.9.24 lib/rconf/ruby_extensions.rb
rconf-0.9.23 lib/rconf/ruby_extensions.rb
rconf-0.9.22 lib/rconf/ruby_extensions.rb
rconf-0.9.21 lib/rconf/ruby_extensions.rb