Sha256: 43df95356ebd7513480bd507ecddba59337b89103c6302d6109c7affa5aff151

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 KB

Contents

=begin
                  Arachni
  Copyright (c) 2010-2012 Tasos "Zapotek" Laskos <tasos.laskos@gmail.com>

  This is free software; you can copy and distribute and modify
  this program under the term of the GPL v2.0 License
  (See LICENSE file for details)

=end

module Arachni
module UI
module Web

    #
    # This used to be a stream in the past, now it's just a compat class.
    #
    class OutputStream

        def initialize( output, lines, &block )
            @lines  = lines
            @output = output
            @buffer = []

            @icon_whitelist = {}
            [ 'status', 'ok', 'error', 'info', 'bad' ].each {
                |icon|
                @icon_whitelist[icon] = "<img src='/icons/#{icon}.png' />"
            }

        end

        def format
            str = ''
            cnt = 0

            while( ( out = @output.pop ) && ( ( cnt += 1 ) < @lines ) )

                type = out.keys[0]
                msg  = out.values[0]

                next if out.values[0].empty?

                icon = @icon_whitelist[type.to_s] || ''
                str += icon + CGI.escapeHTML( " #{out.values[0]}" ) + "<br/>"
            end

            return str
        end

    end
end
end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
arachni-0.4.0.4 lib/arachni/ui/web/output_stream.rb
arachni-0.4.0.3 lib/arachni/ui/web/output_stream.rb
arachni-0.4.0.2 lib/arachni/ui/web/output_stream.rb
arachni-0.4.0.1 lib/arachni/ui/web/output_stream.rb
arachni-0.4 lib/arachni/ui/web/output_stream.rb