idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
4,000 | def begin_delete_with_http_info ( resource_group_name , managed_instance_name , key_name , custom_headers : nil ) begin_delete_async ( resource_group_name , managed_instance_name , key_name , custom_headers : custom_headers ) . value! end | Deletes the managed instance key with the given name . |
4,001 | def update_with_http_info ( resource_group_name , diagnostic_settings_name , parameters , custom_headers : nil ) update_async ( resource_group_name , diagnostic_settings_name , parameters , custom_headers : custom_headers ) . value! end | Updates guest diagnostics settings . |
4,002 | def delete ( resource_group_name , diagnostic_settings_name , custom_headers : nil ) response = delete_async ( resource_group_name , diagnostic_settings_name , custom_headers : custom_headers ) . value! nil end | Delete guest diagnostics settings . |
4,003 | def to_json ( * a ) res_dict = response ? { body : response . body , headers : response . headers , status : response . status } : nil { message : @msg , request : request , response : res_dict } . to_json ( * a ) end | Creates and initialize new instance of the HttpOperationException class . |
4,004 | def check_name_availability_local ( location , check_name_availability , custom_headers : nil ) response = check_name_availability_local_async ( location , check_name_availability , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Check Name Availability for global uniqueness |
4,005 | def get_with_http_info ( resource_group_name , managed_instance_name , recoverable_database_name , custom_headers : nil ) get_async ( resource_group_name , managed_instance_name , recoverable_database_name , custom_headers : custom_headers ) . value! end | Gets a recoverable managed database . |
4,006 | def list_skus_by_resource ( resource_group_name , cluster_name , custom_headers : nil ) response = list_skus_by_resource_async ( resource_group_name , cluster_name , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Returns the SKUs available for the provided resource . |
4,007 | def begin_create_or_update_with_http_info ( resource_group_name , cluster_name , parameters , custom_headers : nil ) begin_create_or_update_async ( resource_group_name , cluster_name , parameters , custom_headers : custom_headers ) . value! end | Create or update a Kusto cluster . |
4,008 | def begin_update_with_http_info ( resource_group_name , virtual_cluster_name , parameters , custom_headers : nil ) begin_update_async ( resource_group_name , virtual_cluster_name , parameters , custom_headers : custom_headers ) . value! end | Updates a virtual cluster . |
4,009 | def get_with_http_info ( resource_group_name , server_name , dns_alias_name , custom_headers : nil ) get_async ( resource_group_name , server_name , dns_alias_name , custom_headers : custom_headers ) . value! end | Gets a server DNS alias . |
4,010 | def begin_create_or_update_with_http_info ( resource_group_name , server_name , dns_alias_name , custom_headers : nil ) begin_create_or_update_async ( resource_group_name , server_name , dns_alias_name , custom_headers : custom_headers ) . value! end | Creates a server dns alias . |
4,011 | def begin_delete_with_http_info ( resource_group_name , server_name , dns_alias_name , custom_headers : nil ) begin_delete_async ( resource_group_name , server_name , dns_alias_name , custom_headers : custom_headers ) . value! end | Deletes the server DNS alias with the given name . |
4,012 | def get_by_id ( appliance_definition_id , custom_headers : nil ) response = get_by_id_async ( appliance_definition_id , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Gets the appliance definition . |
4,013 | def begin_create_or_update_with_http_info ( resource_group_name , appliance_definition_name , parameters , custom_headers : nil ) begin_create_or_update_async ( resource_group_name , appliance_definition_name , parameters , custom_headers : custom_headers ) . value! end | Creates a new appliance definition . |
4,014 | def get_with_http_info ( resource_group_name , cluster_name , database_name , event_hub_connection_name , custom_headers : nil ) get_async ( resource_group_name , cluster_name , database_name , event_hub_connection_name , custom_headers : custom_headers ) . value! end | Returns an Event Hub connection . |
4,015 | def begin_delete_with_http_info ( resource_group_name , cluster_name , database_name , event_hub_connection_name , custom_headers : nil ) begin_delete_async ( resource_group_name , cluster_name , database_name , event_hub_connection_name , custom_headers : custom_headers ) . value! end | Deletes the Event Hub connection with the given name . |
4,016 | def get_with_http_info ( location , environment , cluster_version , custom_headers : nil ) get_async ( location , environment , cluster_version , custom_headers : custom_headers ) . value! end | Get cluster code versions by environment and version |
4,017 | def list_by_api ( resource_group_name , service_name , api_id , custom_headers : nil ) response = list_by_api_async ( resource_group_name , service_name , api_id , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Get the policy configuration at the API level . |
4,018 | def list_by_vaults ( resource_group_name , vault_name , custom_headers : nil ) response = list_by_vaults_async ( resource_group_name , vault_name , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Fetches the usages of the vault . |
4,019 | def list_query_results_for_policy_set_definition_with_http_info ( subscription_id , policy_set_definition_name , query_options : nil , custom_headers : nil ) list_query_results_for_policy_set_definition_async ( subscription_id , policy_set_definition_name , query_options : query_options , custom_headers : custom_headers ) . value! end | Queries policy events for the subscription level policy set definition . |
4,020 | def list_query_results_for_policy_definition_with_http_info ( subscription_id , policy_definition_name , query_options : nil , custom_headers : nil ) list_query_results_for_policy_definition_async ( subscription_id , policy_definition_name , query_options : query_options , custom_headers : custom_headers ) . value! end | Queries policy events for the subscription level policy definition . |
4,021 | def delete_with_http_info ( resource_group_name , namespace_name , topic_name , custom_headers : nil ) delete_async ( resource_group_name , namespace_name , topic_name , custom_headers : custom_headers ) . value! end | Deletes a topic from the specified namespace and resource group . |
4,022 | def list_authorization_rules_with_http_info ( resource_group_name , namespace_name , topic_name , custom_headers : nil ) list_authorization_rules_async ( resource_group_name , namespace_name , topic_name , custom_headers : custom_headers ) . value! end | Gets authorization rules for a topic . |
4,023 | def post_authorization_rule_with_http_info ( resource_group_name , namespace_name , topic_name , authorization_rule_name , custom_headers : nil ) post_authorization_rule_async ( resource_group_name , namespace_name , topic_name , authorization_rule_name , custom_headers : custom_headers ) . value! end | Returns the specified authorization rule . |
4,024 | def create_or_update ( network_resource_name , network_resource_description , custom_headers : nil ) response = create_or_update_async ( network_resource_name , network_resource_description , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Creates or updates a Network resource . |
4,025 | def patch ( application_object_id , parameters , custom_headers : nil ) response = patch_async ( application_object_id , parameters , custom_headers : custom_headers ) . value! nil end | Update an existing application . |
4,026 | def list_owners ( application_object_id , custom_headers : nil ) response = list_owners_async ( application_object_id , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Directory objects that are owners of the application . |
4,027 | def list_key_credentials ( application_object_id , custom_headers : nil ) response = list_key_credentials_async ( application_object_id , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Get the keyCredentials associated with an application . |
4,028 | def update_key_credentials ( application_object_id , parameters , custom_headers : nil ) response = update_key_credentials_async ( application_object_id , parameters , custom_headers : custom_headers ) . value! nil end | Update the keyCredentials associated with an application . |
4,029 | def list_password_credentials ( application_object_id , custom_headers : nil ) response = list_password_credentials_async ( application_object_id , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Get the passwordCredentials associated with an application . |
4,030 | def update_password_credentials ( application_object_id , parameters , custom_headers : nil ) response = update_password_credentials_async ( application_object_id , parameters , custom_headers : custom_headers ) . value! nil end | Update passwordCredentials associated with an application . |
4,031 | def get_by_id ( deny_assignment_id , custom_headers : nil ) response = get_by_id_async ( deny_assignment_id , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Gets a deny assignment by ID . |
4,032 | def check_subdomain_availability ( operation_inputs , custom_headers : nil ) response = check_subdomain_availability_async ( operation_inputs , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Check if an IoT Central application subdomain is available . |
4,033 | def check_entity_exists_with_http_info ( resource_group_name , service_name , notification_name , email , custom_headers : nil ) check_entity_exists_async ( resource_group_name , service_name , notification_name , email , custom_headers : custom_headers ) . value! end | Determine if Notification Recipient Email subscribed to the notification . |
4,034 | def create_or_update_with_http_info ( resource_group_name , service_name , notification_name , email , custom_headers : nil ) create_or_update_async ( resource_group_name , service_name , notification_name , email , custom_headers : custom_headers ) . value! end | Adds the Email address to the list of Recipients for the Notification . |
4,035 | def delete_with_http_info ( resource_group_name , service_name , notification_name , email , custom_headers : nil ) delete_async ( resource_group_name , service_name , notification_name , email , custom_headers : custom_headers ) . value! end | Removes the email from the list of Notification . |
4,036 | def begin_update_tags_with_http_info ( resource_group_name , network_interface_name , parameters , custom_headers : nil ) begin_update_tags_async ( resource_group_name , network_interface_name , parameters , custom_headers : custom_headers ) . value! end | Updates a network interface tags . |
4,037 | def unregister ( resource_provider_namespace , custom_headers : nil ) response = unregister_async ( resource_provider_namespace , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Unregisters provider from a subscription . |
4,038 | def register ( resource_provider_namespace , custom_headers : nil ) response = register_async ( resource_provider_namespace , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Registers provider to be used with a subscription . |
4,039 | def get_with_http_info ( resource_provider_namespace , expand : nil , custom_headers : nil ) get_async ( resource_provider_namespace , expand : expand , custom_headers : custom_headers ) . value! end | Gets a resource provider . |
4,040 | def get_with_http_info ( resource_group_name , integration_account_name , certificate_name , custom_headers : nil ) get_async ( resource_group_name , integration_account_name , certificate_name , custom_headers : custom_headers ) . value! end | Gets an integration account certificate . |
4,041 | def delete_with_http_info ( resource_group_name , integration_account_name , certificate_name , custom_headers : nil ) delete_async ( resource_group_name , integration_account_name , certificate_name , custom_headers : custom_headers ) . value! end | Deletes an integration account certificate . |
4,042 | def get_with_http_info ( resource_group_name , load_balancer_name , outbound_rule_name , custom_headers : nil ) get_async ( resource_group_name , load_balancer_name , outbound_rule_name , custom_headers : custom_headers ) . value! end | Gets the specified load balancer outbound rule . |
4,043 | def create_with_http_info ( scope , policy_assignment_name , parameters , custom_headers : nil ) create_async ( scope , policy_assignment_name , parameters , custom_headers : custom_headers ) . value! end | Creates a policy assignment . |
4,044 | def delete_by_id ( policy_assignment_id , custom_headers : nil ) response = delete_by_id_async ( policy_assignment_id , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Deletes a policy assignment by ID . |
4,045 | def get_by_id ( policy_assignment_id , custom_headers : nil ) response = get_by_id_async ( policy_assignment_id , custom_headers : custom_headers ) . value! response . body unless response . nil? end | Gets a policy assignment by ID . |
4,046 | def prepare fail "No value field set up for numeric tracker #{inspect}" unless options [ :value ] fail "No categorizer set up for numeric tracker #{inspect}" unless options [ :category ] unless options [ :multiple ] @categorizer = create_lambda ( options [ :category ] ) @valueizer = create_lambda ( options [ :value ] ) end @number_of_buckets = options [ :number_of_buckets ] || 1000 @min_bucket_value = options [ :min_bucket_value ] ? options [ :min_bucket_value ] . to_f : 0.000001 @max_bucket_value = options [ :max_bucket_value ] ? options [ :max_bucket_value ] . to_f : 1_000_000_000 @bucket_size = ( Math . log ( @max_bucket_value ) - Math . log ( @min_bucket_value ) ) / @number_of_buckets . to_f @categories = { } end | Sets up the numeric value tracker . It will check whether the value and category options are set that are used to extract and categorize the values during parsing . Two lambda procedures are created for these tasks |
4,047 | def update ( request ) if options [ :multiple ] found_categories = request . every ( options [ :category ] ) found_values = request . every ( options [ :value ] ) fail 'Capture mismatch for multiple values in a request' unless found_categories . length == found_values . length found_categories . each_with_index do | cat , index | update_statistics ( cat , found_values [ index ] ) if cat && found_values [ index ] . is_a? ( Numeric ) end else category = @categorizer . call ( request ) value = @valueizer . call ( request ) update_statistics ( category , value ) if ( value . is_a? ( Numeric ) || value . is_a? ( Array ) ) && category end end | Get the value information from the request and store it in the respective categories . |
4,048 | def display_value ( value ) return '- ' if value . nil? return '0 ' if value . zero? case [ Math . log10 ( value . abs ) . floor , 0 ] . max when 0 ... 4 then '%d ' % value when 4 ... 7 then '%dk' % ( value / 1000 ) when 7 ... 10 then '%dM' % ( value / 1_000_000 ) when 10 ... 13 then '%dG' % ( value / 1_000_000_000 ) when 13 ... 16 then '%dT' % ( value / 1_000_000_000_000 ) else '%dP' % ( value / 1_000_000_000_000_000 ) end end | Display a value |
4,049 | def title @title ||= begin if options [ :title ] options [ :title ] else title_builder = '' title_builder << "#{options[:value]} " if options [ :value ] . is_a? ( Symbol ) title_builder << ( options [ :category ] . is_a? ( Symbol ) ? "per #{options[:category]}" : 'per request' ) title_builder end end end | Returns the title of this tracker for reports |
4,050 | def to_yaml_object return nil if @categories . empty? @categories . each do | cat , info | info [ :stddev ] = stddev ( cat ) info [ :median ] = median ( cat ) if info [ :buckets ] info [ :interval_95_percent ] = percentile_interval ( cat , 95 ) if info [ :buckets ] end @categories end | Returns all the categories and the tracked duration as a hash than can be exported to YAML |
4,051 | def bucket_index ( value ) return 0 if value < @min_bucket_value return @number_of_buckets - 1 if value >= @max_bucket_value ( ( Math . log ( value ) - Math . log ( @min_bucket_value ) ) / @bucket_size ) . floor end | Returns the bucket index for a value |
4,052 | def bucket_value ( index , type = nil ) case type when :begin , :start , :lower , :lower_bound then bucket_lower_bound ( index ) when :end , :finish , :upper , :upper_bound then bucket_upper_bound ( index ) else bucket_average_value ( index ) end end | Returns a single value representing a bucket . |
4,053 | def percentile_index ( category , x , inclusive = false ) total_encountered = 0 @categories [ category ] [ :buckets ] . each_with_index do | count , index | total_encountered += count percentage = ( ( total_encountered . to_f / hits ( category ) . to_f ) * 100 ) . floor return index if ( inclusive && percentage >= x ) || ( ! inclusive && percentage > x ) end end | Returns the upper bound value that would include x% of the hits . |
4,054 | def percentile_interval ( category , x ) case x when Range lower , upper = percentile_indices ( category , x . begin , x . end ) Range . new ( bucket_lower_bound ( lower ) , bucket_upper_bound ( upper ) ) when Numeric percentile_interval ( category , Range . new ( ( 100 - x ) / 2 , ( 100 - ( 100 - x ) / 2 ) ) ) else fail 'What does it mean?' end end | Returns a percentile interval i . e . the lower bound and the upper bound of the values that represent the x% - interval for the bucketized dataset . |
4,055 | def statistics_header ( options ) [ { title : options [ :title ] , width : :rest } , { title : 'Hits' , align : :right , highlight : ( options [ :highlight ] == :hits ) , min_width : 4 } , { title : 'Sum' , align : :right , highlight : ( options [ :highlight ] == :sum ) , min_width : 6 } , { title : 'Mean' , align : :right , highlight : ( options [ :highlight ] == :mean ) , min_width : 6 } , { title : 'StdDev' , align : :right , highlight : ( options [ :highlight ] == :stddev ) , min_width : 6 } , { title : 'Min' , align : :right , highlight : ( options [ :highlight ] == :min ) , min_width : 6 } , { title : 'Max' , align : :right , highlight : ( options [ :highlight ] == :max ) , min_width : 6 } , { title : '95 %tile' , align : :right , highlight : ( options [ :highlight ] == :percentile_interval ) , min_width : 11 } ] end | Returns the column header for a statistics table to report on the statistics result |
4,056 | def statistics_row ( cat ) [ cat , hits ( cat ) , display_value ( sum ( cat ) ) , display_value ( mean ( cat ) ) , display_value ( stddev ( cat ) ) , display_value ( min ( cat ) ) , display_value ( max ( cat ) ) , display_value ( percentile_interval ( cat , 95 ) . begin ) + '-' + display_value ( percentile_interval ( cat , 95 ) . end ) ] end | Returns a row of statistics information for a report table given a category |
4,057 | def decompress_file? ( filename ) nice_command = 'nice -n 5' return "#{nice_command} gunzip -c -d #{filename}" if filename . match ( / \. / ) || filename . match ( / \. / ) || filename . match ( / \. / ) return "#{nice_command} bunzip2 -c -d #{filename}" if filename . match ( / \. / ) return "#{nice_command} unzip -p #{filename}" if filename . match ( / \. / ) '' end | Check if a file has a compressed extention in the filename . If recognized return the command string used to decompress the file |
4,058 | def parse_file ( file , options = { } , & block ) if File . directory? ( file ) parse_files ( Dir [ "#{ file }/*" ] , options , & block ) return end @current_source = File . expand_path ( file ) @source_changes_handler . call ( :started , @current_source ) if @source_changes_handler if decompress_file? ( file ) . empty? @progress_handler = @dormant_progress_handler @progress_handler . call ( :started , file ) if @progress_handler File . open ( file , 'rb' ) { | f | parse_io ( f , options , & block ) } @progress_handler . call ( :finished , file ) if @progress_handler @progress_handler = nil @processed_files . push ( @current_source . dup ) else IO . popen ( decompress_file? ( file ) , 'rb' ) { | f | parse_io ( f , options , & block ) } end @source_changes_handler . call ( :finished , @current_source ) if @source_changes_handler @current_source = nil end | Parses a log file . Creates an IO stream for the provided file and sends it to parse_io for further handling . This method supports progress updates that can be used to display a progressbar |
4,059 | def update_current_request ( request_data , & block ) if alternative_header_line? ( request_data ) if @current_request @current_request << request_data else @current_request = @file_format . request ( request_data ) end elsif header_line? ( request_data ) if @current_request case options [ :parse_strategy ] when 'assume-correct' handle_request ( @current_request , & block ) @current_request = @file_format . request ( request_data ) when 'cautious' @skipped_lines += 1 warn ( :unclosed_request , "Encountered header line (#{request_data[:line_definition].name.inspect}), but previous request was not closed!" ) @current_request = nil end elsif footer_line? ( request_data ) handle_request ( @file_format . request ( request_data ) , & block ) else @current_request = @file_format . request ( request_data ) end else if @current_request @current_request << request_data if footer_line? ( request_data ) handle_request ( @current_request , & block ) @current_request = nil end else @skipped_lines += 1 warn ( :no_current_request , "Parseable line (#{request_data[:line_definition].name.inspect}) found outside of a request!" ) end end end | Combines the different lines of a request into a single Request object . It will start a new request when a header line is encountered en will emit the request when a footer line is encountered . |
4,060 | def handle_request ( request , & _block ) @parsed_requests += 1 request . validate accepted = block_given? ? yield ( request ) : true @skipped_requests += 1 unless accepted end | Handles the parsed request by sending it into the pipeline . |
4,061 | def hostname_or_ip_address ( blank = false ) regexp = Regexp . union ( hostname , ip_address ) add_blank_option ( regexp , blank ) end | Creates a regular expression to match a hostname or ip address |
4,062 | def timestamp ( format_string , blank = false ) regexp = '' format_string . scan ( / / ) do | literal , variable | regexp << Regexp . quote ( literal ) if variable if TIMESTAMP_PARTS . key? ( variable ) regexp << TIMESTAMP_PARTS [ variable ] else fail "Unknown variable: %#{variable}" end end end add_blank_option ( Regexp . new ( regexp ) , blank ) end | Create a regular expression for a timestamp generated by a strftime call . Provide the format string to construct a matching regular expression . Set blank to true to allow and empty string or set blank to a string to set a substitute for the nil value . |
4,063 | def add_blank_option ( regexp , blank ) case blank when String then Regexp . union ( regexp , Regexp . new ( Regexp . quote ( blank ) ) ) when true then Regexp . union ( regexp , / / ) else regexp end end | Allow the field to be blank if this option is given . This can be true to allow an empty string or a string alternative for the nil value . |
4,064 | def valid_line_definitions? line_definitions . any? { | ( _ , ld ) | ld . header } && line_definitions . any? { | ( _ , ld ) | ld . footer } end | Checks whether the line definitions form a valid language . A file format should have at least a header and a footer line type |
4,065 | def parse_line ( line , & warning_handler ) line_definitions . each do | _lt , definition | match = definition . matches ( line , & warning_handler ) return match if match end nil end | Parses a line by trying to parse it using every line definition in this file format |
4,066 | def to_yaml require 'yaml' trackers_export = @trackers . reduce ( { } ) do | export , tracker | export [ tracker . title ] = tracker . to_yaml_object ; export end YAML . dump ( trackers_export ) end | Exports all the tracker results to YAML . It will call the to_yaml_object method for every tracker and combines these into a single YAML export . |
4,067 | def prepare options [ :category ] = options [ :value ] if options [ :value ] && ! options [ :category ] fail "No categorizer set up for category tracker #{inspect}" unless options [ :category ] @categorizer = create_lambda ( options [ :category ] ) unless options [ :multiple ] @categories = { } options [ :all_categories ] . each { | cat | @categories [ cat ] = 0 } if options [ :all_categories ] . is_a? ( Enumerable ) end | Check if categories are set up |
4,068 | def setup_should_update_checks! @should_update_checks = [ ] @should_update_checks . push ( lambda { | request | request . has_line_type? ( options [ :line_type ] ) } ) if options [ :line_type ] @should_update_checks . push ( options [ :if ] ) if options [ :if ] . respond_to? ( :call ) @should_update_checks . push ( lambda { | request | request [ options [ :if ] ] } ) if options [ :if ] . is_a? ( Symbol ) @should_update_checks . push ( lambda { | request | ! options [ :unless ] . call ( request ) } ) if options [ :unless ] . respond_to? ( :call ) @should_update_checks . push ( lambda { | request | ! request [ options [ :unless ] ] } ) if options [ :unless ] . is_a? ( Symbol ) end | Initialize the class Note that the options are only applicable if should_update? is not overwritten by the inheriting class . |
4,069 | def create_lambda ( arg ) case arg when Proc then arg when Symbol then lambda { | request | request [ arg ] } else fail "Canot create a lambda expression from this argument: #{arg.inspect}!" end end | Creates a lambda expression to return a static field from a request . If the argument already is a lambda exprssion it will simply return the argument . |
4,070 | def match_for ( line , request , & warning_handler ) if match_info = matches ( line , & warning_handler ) convert_captured_values ( match_info [ :captures ] , request ) else false end end | matches the line and converts the captured values using the request s convert_value function . |
4,071 | def add_parsed_line ( parsed_line ) value_hash = parsed_line [ :line_definition ] . convert_captured_values ( parsed_line [ :captures ] , self ) value_hash [ :line_type ] = parsed_line [ :line_definition ] . name value_hash [ :lineno ] = parsed_line [ :lineno ] value_hash [ :source ] = parsed_line [ :source ] value_hash [ :compound ] = parsed_line [ :line_definition ] . compound add_line_hash ( value_hash ) end | Adds another line to the request when it is parsed in the LogParser . |
4,072 | def add_line_hash ( value_hash ) @lines << value_hash if value_hash [ :compound ] value_hash . each do | key , value | if value_hash [ :compound ] . include? ( key ) @attributes [ key ] = [ ] if @attributes [ key ] . nil? @attributes [ key ] = [ @attributes [ key ] ] unless @attributes [ key ] . is_a? ( Array ) @attributes [ key ] << value else @attributes [ key ] = value unless key == :compound || @attributes [ key ] end end else @attributes = value_hash . merge ( @attributes ) end end | Adds another line to the request using a plain hash . |
4,073 | def has_line_type? ( line_type ) return true if @lines . length == 1 && @lines [ 0 ] [ :line_type ] == line_type . to_sym @lines . find { | l | l [ :line_type ] == line_type . to_sym } end | Checks whether the given line type was parsed from the log file for this request |
4,074 | def every ( field ) @lines . reduce ( [ ] ) { | result , fields | result << fields [ field ] if fields . key? ( field ) ; result } end | Returns an array of all the field values that were captured for this request |
4,075 | def completed? header_found , footer_found = false , false @lines . each do | line | line_def = file_format . line_definitions [ line [ :line_type ] ] header_found = true if line_def . header footer_found = true if line_def . footer end header_found && footer_found end | Checks whether this request is completed . A completed request contains both a parsed header line and a parsed footer line . Not that calling this function in single line mode will always return false . |
4,076 | def prepare options [ :value ] = options [ :traffic ] if options [ :traffic ] options [ :total ] = true super @number_of_buckets = options [ :number_of_buckets ] || 1000 @min_bucket_value = options [ :min_bucket_value ] ? options [ :min_bucket_value ] . to_f : 1 @max_bucket_value = options [ :max_bucket_value ] ? options [ :max_bucket_value ] . to_f : 1_000_000_000_000 @bucket_size = ( Math . log ( @max_bucket_value ) - Math . log ( @min_bucket_value ) ) / @number_of_buckets . to_f end | Check if duration and catagory option have been received |
4,077 | def filter ( request ) found_field = request . every ( @field ) . any? { | value | @value === value . to_s } return nil if ! found_field && @mode == :select return nil if found_field && @mode == :reject request end | Keep request if |
4,078 | def header @io . content_type = content_type if @io . respond_to? ( :content_type ) @io << '<html>' @io << tag ( :head ) do | headers | headers << tag ( :title , 'Request-log-analyzer report' ) headers << tag ( :style , ' body { font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; color: #4f6b72; background: #E6EAE9; padding-left:20px; padding-top:20px; padding-bottom:20px; } a { color: #c75f3e; } .color_bar { border: 1px solid; height:10px; background: #CAE8EA; } .rla-report-table { width: 700px; padding: 0; margin: 0; padding-bottom:10px; } caption { padding: 0 0 5px 0; width: 700px; font: italic 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; text-align: right; } th { font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; color: #4f6b72; border-right: 1px solid #C1DAD7; border-bottom: 1px solid #C1DAD7; border-top: 1px solid #C1DAD7; letter-spacing: 2px; text-transform: uppercase; text-align: left; padding: 6px 6px 6px 12px; background: #CAE8EA url(images/bg_header.jpg) no-repeat; } td { font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; border-right: 1px solid #C1DAD7; border-bottom: 1px solid #C1DAD7; background: #fff; padding: 6px 6px 6px 12px; color: #4f6b72; } td.alt { background: #F5FAFA; color: #797268; } ' , type : 'text/css' ) end @io << '<body>' @io << tag ( :h1 , 'Request-log-analyzer summary report' ) @io << tag ( :p , "Version #{RequestLogAnalyzer::VERSION} - written by Willem van Bergen and Bart ten Brinke" ) end | Genrate HTML header and associated stylesheet |
4,079 | def handle_source_change ( change , filename ) @aggregators . each { | agg | agg . source_change ( change , File . expand_path ( filename , Dir . pwd ) ) } end | Source change handler |
4,080 | def add_filter ( filter , filter_options = { } ) filter = RequestLogAnalyzer :: Filter . const_get ( RequestLogAnalyzer . to_camelcase ( filter ) ) if filter . is_a? ( Symbol ) @filters << filter . new ( source . file_format , @options . merge ( filter_options ) ) end | Adds a request filter to the controller . |
4,081 | def filter_request ( request ) @filters . each do | filter | request = filter . filter ( request ) return nil if request . nil? end request end | Push a request through the entire filterchain ( |
4,082 | def aggregate_request ( request ) return false unless request @aggregators . each { | agg | agg . aggregate ( request ) } true end | Push a request to all the aggregators ( |
4,083 | def run! @aggregators . each { | agg | agg . prepare } install_signal_handlers @source . each_request do | request | break if @interrupted aggregate_request ( filter_request ( request ) ) end @aggregators . each { | agg | agg . finalize } @output . header @aggregators . each { | agg | agg . report ( @output ) } @output . footer @source . finalize if @output . io . is_a? ( File ) unless @options [ :silent ] puts puts 'Report written to: ' + File . expand_path ( @output . io . path ) puts 'Need an expert to analyze your application?' puts 'Mail to contact@railsdoctors.com or visit us at http://railsdoctors.com' puts 'Thanks for using request-log-analyzer!' end @output . io . close elsif @output . io . is_a? ( RequestLogAnalyzer :: Mailer ) @output . io . mail end end | Runs RequestLogAnalyzer 1 . Call prepare on every aggregator 2 . Generate requests from source object 3 . Filter out unwanted requests 4 . Call aggregate for remaning requests on every aggregator 4 . Call finalize on every aggregator 5 . Call report on every aggregator 6 . Finalize Source |
4,084 | def display_value ( time ) case time when nil then '-' when 0 ... 1 then '%0ims' % ( time * 1000 ) when 1 ... 60 then '%0.02fs' % time when 60 ... 3600 then '%dm%02ds' % [ time / 60 , ( time % 60 ) . round ] else '%dh%02dm%02ds' % [ time / 3600 , ( time % 3600 ) / 60 , ( time % 60 ) . round ] end end | Display a duration |
4,085 | def prepare require 'request_log_analyzer/database' @sources = { } @database = RequestLogAnalyzer :: Database . new ( options [ :database ] ) @database . file_format = source . file_format database . drop_database_schema! if options [ :reset_database ] database . create_database_schema! end | Establishes a connection to the database and creates the necessary database schema for the current file format |
4,086 | def aggregate ( request ) @request_object = RequestLogAnalyzer :: Database :: Request . new ( first_lineno : request . first_lineno , last_lineno : request . last_lineno ) request . lines . each do | line | class_columns = database . get_class ( line [ :line_type ] ) . column_names . reject { | column | %w( id source_id request_id ) . include? ( column ) } attributes = Hash [ * line . select { | ( key , _ ) | class_columns . include? ( key . to_s ) } . flatten ] attributes . each do | k , v | attributes [ k ] = v . force_encoding ( 'UTF-8' ) if v . is_a? ( String ) end @request_object . send ( "#{line[:line_type]}_lines" ) . build ( attributes ) end @request_object . save! rescue SQLite3 :: SQLException => e raise Interrupt , e . message end | Aggregates a request into the database This will create a record in the requests table and create a record for every line that has been parsed in which the captured values will be stored . |
4,087 | def warning ( type , message , lineno ) RequestLogAnalyzer :: Database :: Warning . create! ( warning_type : type . to_s , message : message , lineno : lineno ) end | Records w warining in the warnings table . |
4,088 | def source_change ( change , filename ) if File . exist? ( filename ) case change when :started @sources [ filename ] = RequestLogAnalyzer :: Database :: Source . create! ( filename : filename ) when :finished @sources [ filename ] . update_attributes! ( filesize : File . size ( filename ) , mtime : File . mtime ( filename ) ) end end end | Records source changes in the sources table |
4,089 | def report ( output ) output . title ( 'Request database created' ) output << "A database file has been created with all parsed request information.\n" output << "#{@request_count} requests have been added to the database.\n" output << "\n" output << "To open a Ruby console to inspect the database, run the following command.\n" output << output . colorize ( " $ request-log-analyzer console -d #{options[:database]}\n" , :bold ) output << "\n" end | Prints a short report of what has been inserted into the database |
4,090 | def add ( * args ) args . flatten! args . each do | arg | arg = arg . to_sym if arg . is_a? String @set << arg unless @set . include? arg end end | the way to add items to the set . |
4,091 | def exclude ( * args ) args . flatten! args . collect! ( & :to_sym ) @set . reject! { | c | c . respond_to? ( :to_sym ) && args . include? ( c . to_sym ) } end | the way to remove items from the set . |
4,092 | def attributes_hash_is_empty? ( hash , klass ) hash . all? do | key , value | column_name = key . to_s . split ( '(' , 2 ) [ 0 ] next true if mulitpart_ignored? ( key , klass ) next true if default_value? ( column_name , klass , value ) if params_hash? value attributes_hash_is_empty? ( value , klass ) elsif value . is_a? ( Array ) value . all? ( & :blank? ) else value . respond_to? ( :empty? ) ? value . empty? : false end end end | Determines whether the given attributes hash is empty . This isn t a literal emptiness - it s an attempt to discern whether the user intended it to be empty or not . |
4,093 | def do_add_existing parent_record = nested_parent_record ( :update ) @record = active_scaffold_config . model . find ( params [ :associated_id ] ) if parent_record && @record parent_record . send ( nested . association . name ) << @record parent_record . save else false end end | The actual add_existing algorithm |
4,094 | def render ( * args , & block ) if args . first . is_a? ( Hash ) && args . first [ :active_scaffold ] render_embedded args . first elsif args . first == :super @_view_paths ||= lookup_context . view_paths . clone @_last_template ||= lookup_context . last_template parts = @virtual_path . split ( '/' ) template = parts . pop prefix = parts . join ( '/' ) options = args [ 1 ] || { } options [ :locals ] ||= { } if view_stack . last options [ :locals ] = view_stack . last [ :locals ] . merge! ( options [ :locals ] ) if view_stack . last [ :locals ] options [ :object ] ||= view_stack . last [ :object ] if view_stack . last [ :object ] end options [ :template ] = template if prefix != 'active_scaffold_overrides' options [ :prefixes ] = lookup_context . prefixes . drop ( ( lookup_context . prefixes . find_index ( prefix ) || - 1 ) + 1 ) else options [ :prefixes ] = [ 'active_scaffold_overrides' ] last_view_path = File . expand_path ( File . dirname ( File . dirname ( lookup_context . last_template . inspect ) ) , Rails . root ) lookup_context . view_paths = view_paths . drop ( view_paths . find_index { | path | path . to_s == last_view_path } + 1 ) end result = super options lookup_context . view_paths = @_view_paths if @_view_paths lookup_context . last_template = @_last_template if @_last_template result else @_view_paths ||= lookup_context . view_paths . clone last_template = lookup_context . last_template current_view = if args [ 0 ] . is_a? ( Hash ) { :locals => args [ 0 ] [ :locals ] , :object => args [ 0 ] [ :object ] } else { :locals => args [ 1 ] } end view_stack << current_view if current_view lookup_context . view_paths = @_view_paths result = super view_stack . pop if current_view . present? lookup_context . last_template = last_template result end end | Adds two rendering options . |
4,095 | def initialize_copy ( action_link ) self . parameters = parameters . clone if action_link . instance_variable_get ( :@parameters ) self . html_options = html_options . clone if action_link . instance_variable_get ( :@html_options ) end | provides a quick way to set any property of the object from a hash |
4,096 | def add_link ( attribute , options = { } ) column = @core . columns [ attribute . to_sym ] raise ArgumentError , "unknown column #{attribute}" if column . nil? raise ArgumentError , "column #{attribute} is not an association" if column . association . nil? label = if column . association . polymorphic? column . label else column . association . klass . model_name . human ( :count => column . association . singular? ? 1 : 2 , :default => column . association . klass . name . pluralize ) end options . reverse_merge! :security_method => :nested_authorized? , :label => label action_group = options . delete ( :action_group ) || self . action_group action_link = @core . link_for_association ( column , options ) @core . action_links . add_to_group ( action_link , action_group ) unless action_link . nil? action_link end | Add a nested ActionLink |
4,097 | def do_create ( options = { } ) attributes = options [ :attributes ] || params [ :record ] active_scaffold_config . model . transaction do @record = update_record_from_params ( new_model , active_scaffold_config . create . columns , attributes ) apply_constraints_to_record ( @record , :allow_autosave => true ) create_association_with_parent ( @record ) if nested? before_create_save ( @record ) self . successful = [ @record . keeping_errors { @record . valid? } , @record . associated_valid? ] . all? create_save ( @record ) unless options [ :skip_save ] end rescue ActiveRecord :: ActiveRecordError => ex flash [ :error ] = ex . message self . successful = false @record ||= new_model end | A somewhat complex method to actually create a new record . The complexity is from support for subforms and associated records . If you want to customize this behavior consider using the + before_create_save + and + after_create_save + callbacks . |
4,098 | def _configure_sti column = model . inheritance_column if sti_create_links columns [ column ] . form_ui ||= :hidden else columns [ column ] . form_ui ||= :select columns [ column ] . options ||= { } columns [ column ] . options [ :options ] = sti_children . collect do | model_name | [ model_name . to_s . camelize . constantize . model_name . human , model_name . to_s . camelize ] end end end | To be called after your finished configuration |
4,099 | def add ( column_name , direction = nil ) direction ||= 'ASC' direction = direction . to_s . upcase column = get_column ( column_name ) raise ArgumentError , "Could not find column #{column_name}" if column . nil? raise ArgumentError , 'Sorting direction unknown' unless %i[ ASC DESC ] . include? direction . to_sym @clauses << [ column , direction . untaint ] if column . sortable? raise ArgumentError , "Can't mix :method- and :sql-based sorting" if mixed_sorting? end | add a clause to the sorting assuming the column is sortable |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.