Sha256: 1e6db5db3f80ee3c521c25fcc71ceb9362f5e82453bfdb404efdec303a48131a
Contents?: true
Size: 1.98 KB
Versions: 3
Compression:
Stored size: 1.98 KB
Contents
require_relative 'puppet-repl/cli' require_relative 'version' require 'awesome_print' require_relative 'awesome_print/ext/awesome_puppet' require_relative 'trollop' require 'puppet/util/log' require_relative 'puppet-repl/repl_code' require_relative 'puppet-repl/support/errors' # monkey patch in some color effects string methods class String def red; "\033[31m#{self}\033[0m" end def green; "\033[32m#{self}\033[0m" end def cyan; "\033[36m#{self}\033[0m" end def yellow; "\033[33m#{self}\033[0m" end def warning; yellow end def fatal; red end def info; green end def camel_case return self if self !~ /_/ && self =~ /[A-Z]+.*/ split('_').map(&:capitalize).join end end Puppet::Util::Log.newdesttype :buffer do require 'puppet/util/colors' include Puppet::Util::Colors attr_accessor :err_buffer, :out_buffer def initialize(err=$stderr, out=$stdout) @err_buffer = err @out_buffer = out end def handle(msg) levels = { :emerg => { :name => 'Emergency', :color => :hred, :stream => err_buffer }, :alert => { :name => 'Alert', :color => :hred, :stream => err_buffer }, :crit => { :name => 'Critical', :color => :hred, :stream => err_buffer }, :err => { :name => 'Error', :color => :hred, :stream => err_buffer }, :warning => { :name => 'Warning', :color => :hred, :stream => err_buffer }, :notice => { :name => 'Notice', :color => :reset, :stream => out_buffer }, :info => { :name => 'Info', :color => :green, :stream => out_buffer }, :debug => { :name => 'Debug', :color => :cyan, :stream => out_buffer }, } str = msg.respond_to?(:multiline) ? msg.multiline : msg.to_s str = msg.source == "Puppet" ? str : "#{msg.source}: #{str}" level = levels[msg.level] level[:stream].puts colorize(level[:color], "#{level[:name]}: #{str}") end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
puppet-repl-0.3.4 | lib/puppet-repl.rb |
puppet-repl-0.3.3 | lib/puppet-repl.rb |
puppet-repl-0.3.2 | lib/puppet-repl.rb |