Sha256: 48a95062ccc104d33bcf1ebb1335d953712cc47f44af00872622d2132cdaaa34

Contents?: true

Size: 1.53 KB

Versions: 28

Compression:

Stored size: 1.53 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 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

28 entries across 28 versions & 1 rubygems

Version Path
rconf-0.9.18 lib/rconf/ruby_extensions.rb
rconf-0.9.17 lib/rconf/ruby_extensions.rb
rconf-0.9.12 lib/rconf/ruby_extensions.rb
rconf-0.9.11 lib/rconf/ruby_extensions.rb
rconf-0.9.10 lib/rconf/ruby_extensions.rb
rconf-0.9.9 lib/rconf/ruby_extensions.rb
rconf-0.9.8 lib/rconf/ruby_extensions.rb
rconf-0.9.7 lib/rconf/ruby_extensions.rb
rconf-0.9.6 lib/rconf/ruby_extensions.rb
rconf-0.9.4 lib/rconf/ruby_extensions.rb
rconf-0.8.30 lib/rconf/ruby_extensions.rb
rconf-0.8.29 lib/rconf/ruby_extensions.rb
rconf-0.8.21 lib/rconf/ruby_extensions.rb
rconf-0.8.20 lib/rconf/ruby_extensions.rb
rconf-0.8.19 lib/rconf/ruby_extensions.rb
rconf-0.8.18 lib/rconf/ruby_extensions.rb
rconf-0.8.17 lib/rconf/ruby_extensions.rb
rconf-0.8.16 lib/rconf/ruby_extensions.rb
rconf-0.8.15 lib/rconf/ruby_extensions.rb
rconf-0.8.14 lib/rconf/ruby_extensions.rb