Class: Arachni::Support::Buffer::AutoFlush

Inherits:
Base show all
Defined in:
lib/arachni/support/buffer/autoflush.rb

Overview

A buffer implementation which flushes itself when it gets full or a number of push attempts is reached between flushes.

Author:

Instance Attribute Summary collapse

Attributes inherited from Base

#max_size

Instance Method Summary collapse

Methods inherited from Base

#empty?, #full?, #on_batch_push, #on_flush, #on_push, #size

Methods included from Mixins::Observable

included

Methods included from Utilities

#available_port, #bytes_to_kilobytes, #bytes_to_megabytes, #caller_name, #caller_path, #cookie_decode, #cookie_encode, #cookies_from_document, #cookies_from_file, #cookies_from_response, #exception_jail, #exclude_path?, #follow_protocol?, #form_decode, #form_encode, #forms_from_document, #forms_from_response, #full_and_absolute_url?, #generate_token, #get_path, #hms_to_seconds, #html_decode, #html_encode, #include_path?, #links_from_document, #links_from_response, #normalize_url, #page_from_response, #page_from_url, #parse_set_cookie, #path_in_domain?, #path_too_deep?, #port_available?, #rand_port, #random_seed, #redundant_path?, #regexp_array_match, #remove_constants, #request_parse_body, #seconds_to_hms, #skip_page?, #skip_path?, #skip_resource?, #skip_response?, #to_absolute, #uri_decode, #uri_encode, #uri_parse, #uri_parse_query, #uri_parser, #uri_rewrite

Methods included from UI::Output

#debug?, #debug_off, #debug_on, #disable_only_positives, #included, #mute, #muted?, #only_positives, #only_positives?, #print_bad, #print_debug, #print_debug_backtrace, #print_debug_level_1, #print_debug_level_2, #print_debug_level_3, #print_error, #print_error_backtrace, #print_exception, #print_info, #print_line, #print_ok, #print_status, #print_verbose, #reroute_to_file, #reroute_to_file?, reset_output_options, #unmute, #verbose?, #verbose_on

Constructor Details

#initialize(max_size = nil, max_pushes = nil, type = Array) ⇒ AutoFlush

Returns a new instance of AutoFlush.

Parameters:

  • max_size (Integer) (defaults to: nil)

    Maximum buffer size – a flush will be triggered when that limit is reached.

  • max_pushes (Integer) (defaults to: nil)

    Maximum number of pushes between flushes.

  • type (#<<, #|, #clear, #size, #empty?) (defaults to: Array)

    Internal storage class to use.



27
28
29
30
31
32
# File 'lib/arachni/support/buffer/autoflush.rb', line 27

def initialize( max_size = nil, max_pushes = nil, type = Array )
    super( max_size, type )

    @max_pushes = max_pushes
    @pushes     = 0
end

Instance Attribute Details

#max_pushesObject (readonly)

Returns the value of attribute max_pushes.



18
19
20
# File 'lib/arachni/support/buffer/autoflush.rb', line 18

def max_pushes
  @max_pushes
end

Instance Method Details

#<<(*args) ⇒ Object



34
35
36
37
38
# File 'lib/arachni/support/buffer/autoflush.rb', line 34

def <<( *args )
    super( *args )
ensure
    handle_push
end

#batch_push(*args) ⇒ Object



40
41
42
43
44
# File 'lib/arachni/support/buffer/autoflush.rb', line 40

def batch_push( *args )
    super( *args )
ensure
    handle_push
end

#flushObject



46
47
48
49
50
# File 'lib/arachni/support/buffer/autoflush.rb', line 46

def flush
    super
ensure
    @pushes = 0
end