yarl 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.gitignore +7 -0
 - data/Gemfile +5 -0
 - data/LICENSE +21 -0
 - data/lib/yarl/version.rb +3 -0
 - data/lib/yarl.rb +133 -0
 - data/tests/benchmarks.rb +58 -0
 - data/tests/colors.rb +72 -0
 - data/tests/levels.rb +23 -0
 - data/yarl.gemspec +25 -0
 - metadata +83 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 8667a010c10f84b711d176e9fa7c905fd0b935c1
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9c9538e32bd3bd85c1ab7792058345951d8dfb4a
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: aeca54c95ceff332b61058cfb5b28350517fbdb73a1e90285cb75090b752c5701fc92780228f9b33a48801dc3455b038fbd8fc488a3668203502a8d77f418f38
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: ce028eeef43c42e65ce26ba2fa0379398be65a609adaac460c6ac7d6c25016e28fd3d32d097ed6d37cc4a4707713d9b44dda369680029a72c684544c3eefc72f
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            MIT License
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Copyright (c) 2019 David Massey
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         
     | 
| 
      
 6 
     | 
    
         
            +
            of this software and associated documentation files (the "Software"), to deal
         
     | 
| 
      
 7 
     | 
    
         
            +
            in the Software without restriction, including without limitation the rights
         
     | 
| 
      
 8 
     | 
    
         
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         
     | 
| 
      
 9 
     | 
    
         
            +
            copies of the Software, and to permit persons to whom the Software is
         
     | 
| 
      
 10 
     | 
    
         
            +
            furnished to do so, subject to the following conditions:
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in all
         
     | 
| 
      
 13 
     | 
    
         
            +
            copies or substantial portions of the Software.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         
     | 
| 
      
 16 
     | 
    
         
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         
     | 
| 
      
 17 
     | 
    
         
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         
     | 
| 
      
 18 
     | 
    
         
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         
     | 
| 
      
 19 
     | 
    
         
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         
     | 
| 
      
 20 
     | 
    
         
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         
     | 
| 
      
 21 
     | 
    
         
            +
            SOFTWARE.
         
     | 
    
        data/lib/yarl/version.rb
    ADDED
    
    
    
        data/lib/yarl.rb
    ADDED
    
    | 
         @@ -0,0 +1,133 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'logger'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class YARL < Logger # Yet Another Ruby Logger
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Severity
         
     | 
| 
      
 5 
     | 
    
         
            +
                include Logger::Severity
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                # For that time you need more messages that annoy the hell out of everyone else.
         
     | 
| 
      
 8 
     | 
    
         
            +
                # These should rarely -- if ever -- be displayed.
         
     | 
| 
      
 9 
     | 
    
         
            +
                SPAM = -1
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              include Severity
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              def initialize(progname = nil, **kwargs)
         
     | 
| 
      
 15 
     | 
    
         
            +
                destination = kwargs[:destination] || STDOUT
         
     | 
| 
      
 16 
     | 
    
         
            +
                super destination
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                @progname  = progname.nil? ? self.class : progname
         
     | 
| 
      
 19 
     | 
    
         
            +
                @level = kwargs[:level] || INFO
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                # Header colors
         
     | 
| 
      
 22 
     | 
    
         
            +
                @color      =       text_color(kwargs[:color] || :light_white)
         
     | 
| 
      
 23 
     | 
    
         
            +
                @background = background_color(kwargs[:background] || :black)
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                # Body colors
         
     | 
| 
      
 26 
     | 
    
         
            +
                @fatal_color = background_color(kwargs[:fatal_color] || :red)
         
     | 
| 
      
 27 
     | 
    
         
            +
                @error_color =       text_color(kwargs[:error_color] || :red)
         
     | 
| 
      
 28 
     | 
    
         
            +
                @spam_color  =       text_color(kwargs[:spam_color]  || :bright_black)
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                # Log formatting
         
     | 
| 
      
 31 
     | 
    
         
            +
                @datetime_format = kwargs[:datetime_format] || '%Y-%m-%dT%H:%M:%S.%3NZ'
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                if kwargs[:formatter].is_a?(Proc)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  @formatter = kwargs[:formatter]
         
     | 
| 
      
 35 
     | 
    
         
            +
                else
         
     | 
| 
      
 36 
     | 
    
         
            +
                  @formatter ||= proc { |severity, datetime, progname, message|
         
     | 
| 
      
 37 
     | 
    
         
            +
                    datetime = datetime.strftime(@datetime_format)
         
     | 
| 
      
 38 
     | 
    
         
            +
                    "\e[#{@color};#{@background}m#{datetime} #{severity[0]} #{progname}\e[0m #{message}\n"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  }
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              # A basic rewrite of Logger.add to support message body colors.
         
     | 
| 
      
 44 
     | 
    
         
            +
              def add(severity, message = nil, progname = nil)
         
     | 
| 
      
 45 
     | 
    
         
            +
                severity ||= UNKNOWN
         
     | 
| 
      
 46 
     | 
    
         
            +
                return true if @logdev.nil? or severity < @level
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                progname  ||= @progname
         
     | 
| 
      
 49 
     | 
    
         
            +
                message   ||= block_given? ? yield : progname
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                progname = @progname if message == progname
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                case severity
         
     | 
| 
      
 54 
     | 
    
         
            +
                when FATAL
         
     | 
| 
      
 55 
     | 
    
         
            +
                  message = "\e[#{@fatal_color}m#{message}\e[0m"
         
     | 
| 
      
 56 
     | 
    
         
            +
                when ERROR
         
     | 
| 
      
 57 
     | 
    
         
            +
                  message = "\e[#{@error_color}m#{message}\e[0m"
         
     | 
| 
      
 58 
     | 
    
         
            +
                when SPAM
         
     | 
| 
      
 59 
     | 
    
         
            +
                  message = "\e[#{@spam_color}m#{message}\e[0m"
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                @logdev.write(
         
     | 
| 
      
 63 
     | 
    
         
            +
                  format_message(
         
     | 
| 
      
 64 
     | 
    
         
            +
                    format_severity(severity),
         
     | 
| 
      
 65 
     | 
    
         
            +
                    Time.now.utc,
         
     | 
| 
      
 66 
     | 
    
         
            +
                    progname,
         
     | 
| 
      
 67 
     | 
    
         
            +
                    message
         
     | 
| 
      
 68 
     | 
    
         
            +
                  )
         
     | 
| 
      
 69 
     | 
    
         
            +
                )
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                true
         
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
              # SPAM support
         
     | 
| 
      
 75 
     | 
    
         
            +
              # Add SPAM to level setter
         
     | 
| 
      
 76 
     | 
    
         
            +
              def level=(severity)
         
     | 
| 
      
 77 
     | 
    
         
            +
                severity = severity.to_s if severity.is_a?(Symbol)
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                case severity
         
     | 
| 
      
 80 
     | 
    
         
            +
                when 'spam'
         
     | 
| 
      
 81 
     | 
    
         
            +
                  @level = SPAM
         
     | 
| 
      
 82 
     | 
    
         
            +
                else
         
     | 
| 
      
 83 
     | 
    
         
            +
                  super
         
     | 
| 
      
 84 
     | 
    
         
            +
                end
         
     | 
| 
      
 85 
     | 
    
         
            +
              end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
              # Returns +true+ iff the current severity level allows for the printing of SPAM
         
     | 
| 
      
 88 
     | 
    
         
            +
              def spam?; @level <= SPAM; end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
              # Sets the severity to SPAM.
         
     | 
| 
      
 91 
     | 
    
         
            +
              def spam!; self.level = SPAM; end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
              # Log a +DEBUG+ message.
         
     | 
| 
      
 94 
     | 
    
         
            +
              def spam(progname = nil, &block)
         
     | 
| 
      
 95 
     | 
    
         
            +
                add(SPAM, nil, progname, &block)
         
     | 
| 
      
 96 
     | 
    
         
            +
              end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
              private
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
              SEV_LABEL = {
         
     | 
| 
      
 101 
     | 
    
         
            +
                SPAM    => 'SPAM',
         
     | 
| 
      
 102 
     | 
    
         
            +
                DEBUG   => 'DEBUG',
         
     | 
| 
      
 103 
     | 
    
         
            +
                INFO    => 'INFO',
         
     | 
| 
      
 104 
     | 
    
         
            +
                WARN    => 'WARN',
         
     | 
| 
      
 105 
     | 
    
         
            +
                ERROR   => 'ERROR',
         
     | 
| 
      
 106 
     | 
    
         
            +
                FATAL   => 'FATAL',
         
     | 
| 
      
 107 
     | 
    
         
            +
                UNKNOWN => 'UNKWN'
         
     | 
| 
      
 108 
     | 
    
         
            +
              }
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
              def format_severity(severity)
         
     | 
| 
      
 111 
     | 
    
         
            +
                SEV_LABEL[severity] || 'ANY'
         
     | 
| 
      
 112 
     | 
    
         
            +
              end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
              # Color Methods
         
     | 
| 
      
 115 
     | 
    
         
            +
              def text_color(color)
         
     | 
| 
      
 116 
     | 
    
         
            +
                (COLOR_CODES[color] || 67) + 30
         
     | 
| 
      
 117 
     | 
    
         
            +
              end
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
              def background_color(color)
         
     | 
| 
      
 120 
     | 
    
         
            +
                (COLOR_CODES[color] ||  0) + 40
         
     | 
| 
      
 121 
     | 
    
         
            +
              end
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
              COLOR_CODES = {
         
     | 
| 
      
 124 
     | 
    
         
            +
                :black    => 0, :bright_black   => 60,
         
     | 
| 
      
 125 
     | 
    
         
            +
                :red      => 1, :bright_red     => 61,
         
     | 
| 
      
 126 
     | 
    
         
            +
                :green    => 2, :bright_green   => 62,
         
     | 
| 
      
 127 
     | 
    
         
            +
                :yellow   => 3, :bright_yellow  => 63,
         
     | 
| 
      
 128 
     | 
    
         
            +
                :blue     => 4, :bright_blue    => 64,
         
     | 
| 
      
 129 
     | 
    
         
            +
                :magenta  => 5, :bright_magenta => 65,
         
     | 
| 
      
 130 
     | 
    
         
            +
                :cyan     => 6, :bright_cyan    => 66,
         
     | 
| 
      
 131 
     | 
    
         
            +
                :white    => 7, :bright_gray    => 67,
         
     | 
| 
      
 132 
     | 
    
         
            +
              }
         
     | 
| 
      
 133 
     | 
    
         
            +
            end
         
     | 
    
        data/tests/benchmarks.rb
    ADDED
    
    | 
         @@ -0,0 +1,58 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'logger'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require_relative '../lib/yarl'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            times = 1_000_000
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            def benchmark(method, times = 1000)
         
     | 
| 
      
 7 
     | 
    
         
            +
              destination = STDOUT
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              start_time = Time.now
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              case method
         
     | 
| 
      
 12 
     | 
    
         
            +
              when :puts
         
     | 
| 
      
 13 
     | 
    
         
            +
                (1..times).each do |message_number|
         
     | 
| 
      
 14 
     | 
    
         
            +
                  puts "puts Message #{message_number}"
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              when :logger
         
     | 
| 
      
 17 
     | 
    
         
            +
                logger = Logger.new(destination)
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                (1..times).each do |message_number|
         
     | 
| 
      
 20 
     | 
    
         
            +
                  logger.info "logger Message #{message_number}"
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
              when :yarl
         
     | 
| 
      
 23 
     | 
    
         
            +
                yarl = YARL.new "YARL"
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                (1..times).each do |message_number|
         
     | 
| 
      
 26 
     | 
    
         
            +
                  yarl.info "yarl Message #{message_number}"
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
              when :yarl_color
         
     | 
| 
      
 29 
     | 
    
         
            +
                yarl = YARL.new "YARL", color: :blue
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                (1..times).each do |message_number|
         
     | 
| 
      
 32 
     | 
    
         
            +
                  yarl.info "yarl Message #{message_number}"
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
              when :destination
         
     | 
| 
      
 35 
     | 
    
         
            +
                (1..times).each do |message_number|
         
     | 
| 
      
 36 
     | 
    
         
            +
                  destination << "#{destination} << Message #{message_number}\n"
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              end_time = Time.now
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              return end_time - start_time
         
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            elapsed = {}
         
     | 
| 
      
 46 
     | 
    
         
            +
            elapsed[:puts]        = benchmark(:puts, times)
         
     | 
| 
      
 47 
     | 
    
         
            +
            elapsed[:logger]      = benchmark(:logger, times)
         
     | 
| 
      
 48 
     | 
    
         
            +
            elapsed[:yarl]        = benchmark(:yarl, times)
         
     | 
| 
      
 49 
     | 
    
         
            +
            elapsed[:yarl_color]  = benchmark(:yarl_color, times)
         
     | 
| 
      
 50 
     | 
    
         
            +
            elapsed[:stdout]      = benchmark(:destination, times)
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            shortest = elapsed.values.min
         
     | 
| 
      
 53 
     | 
    
         
            +
            puts "#{times} messages. #{elapsed.key shortest} took the least time (#{shortest}s)."
         
     | 
| 
      
 54 
     | 
    
         
            +
            puts "puts        => #{elapsed[:puts]}s"        # =>  4.348134s
         
     | 
| 
      
 55 
     | 
    
         
            +
            puts "logger      => #{elapsed[:logger]}s"      # => 11.266948s
         
     | 
| 
      
 56 
     | 
    
         
            +
            puts "yarl        => #{elapsed[:yarl]}s"        # => 10.685384s
         
     | 
| 
      
 57 
     | 
    
         
            +
            puts "yarl_color  => #{elapsed[:yarl_color]}s"  # => 10.699868s
         
     | 
| 
      
 58 
     | 
    
         
            +
            puts "`STDOUT <<` => #{elapsed[:stdout]}s"      # =>  5.835941s
         
     | 
    
        data/tests/colors.rb
    ADDED
    
    | 
         @@ -0,0 +1,72 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require '../lib/yarl'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Mocks
         
     | 
| 
      
 4 
     | 
    
         
            +
              class Klass
         
     | 
| 
      
 5 
     | 
    
         
            +
                def initialize(**kwargs)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  if kwargs.empty?
         
     | 
| 
      
 7 
     | 
    
         
            +
                    klass_color = self.class.to_s.split('::')[1]
         
     | 
| 
      
 8 
     | 
    
         
            +
                    color = klass_color.downcase.sub(/\Abright/, 'bright_').to_sym
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  color ||= kwargs[:color] || :invalid
         
     | 
| 
      
 12 
     | 
    
         
            +
                  background = kwargs[:background] || :invalid
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  @logger = YARL.new self.class, color: color, background: background
         
     | 
| 
      
 15 
     | 
    
         
            +
                  @logger.info "Initialized"
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              class Black         < Klass ; end
         
     | 
| 
      
 20 
     | 
    
         
            +
              class BrightBlack   < Klass ; end
         
     | 
| 
      
 21 
     | 
    
         
            +
              class White         < Klass ; end
         
     | 
| 
      
 22 
     | 
    
         
            +
              class BrightWhite   < Klass ; end
         
     | 
| 
      
 23 
     | 
    
         
            +
              class Red           < Klass ; end
         
     | 
| 
      
 24 
     | 
    
         
            +
              class BrightRed     < Klass ; end
         
     | 
| 
      
 25 
     | 
    
         
            +
              class Green         < Klass ; end
         
     | 
| 
      
 26 
     | 
    
         
            +
              class BrightGreen   < Klass ; end
         
     | 
| 
      
 27 
     | 
    
         
            +
              class Yellow        < Klass ; end
         
     | 
| 
      
 28 
     | 
    
         
            +
              class BrightYellow  < Klass ; end
         
     | 
| 
      
 29 
     | 
    
         
            +
              class Blue          < Klass ; end
         
     | 
| 
      
 30 
     | 
    
         
            +
              class BrightBlue    < Klass ; end
         
     | 
| 
      
 31 
     | 
    
         
            +
              class Magenta       < Klass ; end
         
     | 
| 
      
 32 
     | 
    
         
            +
              class BrightMagenta < Klass ; end
         
     | 
| 
      
 33 
     | 
    
         
            +
              class Cyan          < Klass ; end
         
     | 
| 
      
 34 
     | 
    
         
            +
              class BrightCyan    < Klass ; end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            # Text Colors
         
     | 
| 
      
 38 
     | 
    
         
            +
            Mocks::Klass.new
         
     | 
| 
      
 39 
     | 
    
         
            +
            Mocks::Black.new
         
     | 
| 
      
 40 
     | 
    
         
            +
            Mocks::BrightBlack.new
         
     | 
| 
      
 41 
     | 
    
         
            +
            Mocks::White.new
         
     | 
| 
      
 42 
     | 
    
         
            +
            Mocks::BrightWhite.new
         
     | 
| 
      
 43 
     | 
    
         
            +
            Mocks::Red.new
         
     | 
| 
      
 44 
     | 
    
         
            +
            Mocks::BrightRed.new
         
     | 
| 
      
 45 
     | 
    
         
            +
            Mocks::Green.new
         
     | 
| 
      
 46 
     | 
    
         
            +
            Mocks::BrightGreen.new
         
     | 
| 
      
 47 
     | 
    
         
            +
            Mocks::Yellow.new
         
     | 
| 
      
 48 
     | 
    
         
            +
            Mocks::BrightYellow.new
         
     | 
| 
      
 49 
     | 
    
         
            +
            Mocks::Blue.new
         
     | 
| 
      
 50 
     | 
    
         
            +
            Mocks::BrightBlue.new
         
     | 
| 
      
 51 
     | 
    
         
            +
            Mocks::Magenta.new
         
     | 
| 
      
 52 
     | 
    
         
            +
            Mocks::BrightMagenta.new
         
     | 
| 
      
 53 
     | 
    
         
            +
            Mocks::Cyan.new
         
     | 
| 
      
 54 
     | 
    
         
            +
            Mocks::BrightCyan.new
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            # Background Colors
         
     | 
| 
      
 57 
     | 
    
         
            +
            Mocks::Black.new          background: :black
         
     | 
| 
      
 58 
     | 
    
         
            +
            Mocks::BrightBlack.new    background: :bright_black
         
     | 
| 
      
 59 
     | 
    
         
            +
            Mocks::White.new          background: :white
         
     | 
| 
      
 60 
     | 
    
         
            +
            Mocks::BrightWhite.new    background: :bright_white
         
     | 
| 
      
 61 
     | 
    
         
            +
            Mocks::Red.new            background: :red
         
     | 
| 
      
 62 
     | 
    
         
            +
            Mocks::BrightRed.new      background: :bright_red
         
     | 
| 
      
 63 
     | 
    
         
            +
            Mocks::Green.new          background: :green
         
     | 
| 
      
 64 
     | 
    
         
            +
            Mocks::BrightGreen.new    background: :bright_green
         
     | 
| 
      
 65 
     | 
    
         
            +
            Mocks::Yellow.new         background: :yellow
         
     | 
| 
      
 66 
     | 
    
         
            +
            Mocks::BrightYellow.new   background: :bright_yellow
         
     | 
| 
      
 67 
     | 
    
         
            +
            Mocks::Blue.new           background: :blue
         
     | 
| 
      
 68 
     | 
    
         
            +
            Mocks::BrightBlue.new     background: :bright_blue
         
     | 
| 
      
 69 
     | 
    
         
            +
            Mocks::Magenta.new        background: :magenta
         
     | 
| 
      
 70 
     | 
    
         
            +
            Mocks::BrightMagenta.new  background: :bright_magenta
         
     | 
| 
      
 71 
     | 
    
         
            +
            Mocks::Cyan.new           background: :cyan
         
     | 
| 
      
 72 
     | 
    
         
            +
            Mocks::BrightCyan.new     background: :bright_cyan
         
     | 
    
        data/tests/levels.rb
    ADDED
    
    | 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require '../lib/yarl'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            logger = YARL.new color: :green
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            def test_levels(logger)
         
     | 
| 
      
 6 
     | 
    
         
            +
              logger.fatal  "It's just a flesh wound!"
         
     | 
| 
      
 7 
     | 
    
         
            +
              logger.error  'PC LOAD LETTER'
         
     | 
| 
      
 8 
     | 
    
         
            +
              logger.warn   'Danger Will Robinson!'
         
     | 
| 
      
 9 
     | 
    
         
            +
              logger.info   'The more you know'
         
     | 
| 
      
 10 
     | 
    
         
            +
              logger.debug  'Better call Terminex'
         
     | 
| 
      
 11 
     | 
    
         
            +
              logger.spam   'Nobody likes spam'
         
     | 
| 
      
 12 
     | 
    
         
            +
            end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            puts "YARL logger level defaults to INFO"
         
     | 
| 
      
 15 
     | 
    
         
            +
            test_levels logger
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            puts "\nAfter level changes to debug"
         
     | 
| 
      
 18 
     | 
    
         
            +
            logger.level = :debug
         
     | 
| 
      
 19 
     | 
    
         
            +
            test_levels logger
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            puts "\nAfter level changes to spam"
         
     | 
| 
      
 22 
     | 
    
         
            +
            logger.level = :spam
         
     | 
| 
      
 23 
     | 
    
         
            +
            test_levels logger
         
     | 
    
        data/yarl.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'yarl/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.name          = 'yarl'
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.version       = YARL::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.authors       = ['David Massey']
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ['ominousskitter@protonmail.com']
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.summary       = %q{Logger extension that provides colors and clean, default formatting.}
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.description   = %q{Yet Another Ruby Logger (YARL) extends ruby/logger to provide header colors and a severity level below DEBUG. The default formatting has been changed to provide a cleaner (subjective) look.}
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.homepage      = "https://github.com/david-massey/yarl"
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.license       = "MIT"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              spec.files         = `git ls-files -z`.split("\x0")
         
     | 
| 
      
 17 
     | 
    
         
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
      
 18 
     | 
    
         
            +
              spec.require_paths = ["lib"]
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              spec.required_ruby_version = '>= 2.3.0'
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              spec.add_dependency "logger", "~> 1.3"
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              spec.add_development_dependency "bundler"
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,83 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: yarl
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - David Massey
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-03-23 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: logger
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '1.3'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '1.3'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            description: Yet Another Ruby Logger (YARL) extends ruby/logger to provide header
         
     | 
| 
      
 42 
     | 
    
         
            +
              colors and a severity level below DEBUG. The default formatting has been changed
         
     | 
| 
      
 43 
     | 
    
         
            +
              to provide a cleaner (subjective) look.
         
     | 
| 
      
 44 
     | 
    
         
            +
            email:
         
     | 
| 
      
 45 
     | 
    
         
            +
            - ominousskitter@protonmail.com
         
     | 
| 
      
 46 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 47 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 48 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 49 
     | 
    
         
            +
            files:
         
     | 
| 
      
 50 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 51 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 52 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 53 
     | 
    
         
            +
            - lib/yarl.rb
         
     | 
| 
      
 54 
     | 
    
         
            +
            - lib/yarl/version.rb
         
     | 
| 
      
 55 
     | 
    
         
            +
            - tests/benchmarks.rb
         
     | 
| 
      
 56 
     | 
    
         
            +
            - tests/colors.rb
         
     | 
| 
      
 57 
     | 
    
         
            +
            - tests/levels.rb
         
     | 
| 
      
 58 
     | 
    
         
            +
            - yarl.gemspec
         
     | 
| 
      
 59 
     | 
    
         
            +
            homepage: https://github.com/david-massey/yarl
         
     | 
| 
      
 60 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 61 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 62 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 63 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 64 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 65 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 66 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 67 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 68 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 69 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 70 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 71 
     | 
    
         
            +
                  version: 2.3.0
         
     | 
| 
      
 72 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 73 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 74 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 75 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 76 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 77 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 78 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 79 
     | 
    
         
            +
            rubygems_version: 2.5.2.3
         
     | 
| 
      
 80 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 81 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 82 
     | 
    
         
            +
            summary: Logger extension that provides colors and clean, default formatting.
         
     | 
| 
      
 83 
     | 
    
         
            +
            test_files: []
         
     |