idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
15,900 | def find_vlan_with_number ( vlan_number ) filter = SoftLayer :: ObjectFilter . new ( ) { | filter | filter . accept ( 'networkVlans.vlanNumber' ) . when_it is vlan_number } vlan_data = self . service . object_mask ( "mask[id,vlanNumber,primaryRouter,networkSpace]" ) . object_filter ( filter ) . getNetworkVlans return v... | Searches the account s list of VLANs for the ones with the given vlan number . This may return multiple results because a VLAN can span different routers and you will get a separate segment for each router . |
15,901 | def service_named ( service_name , service_options = { } ) raise ArgumentError , "Please provide a service name" if service_name . nil? || service_name . empty? full_name = service_name . to_s . strip if not full_name =~ / \A / full_name = "SoftLayer_#{service_name}" end service_key = full_name . to_sym if ! @services ... | Returns a service with the given name . |
15,902 | def call_softlayer_api_with_params ( method_name , parameters , args ) additional_headers = { } ; authentication_headers = self . client . authentication_headers additional_headers . merge! ( authentication_headers ) if parameters && parameters . server_object_filter additional_headers . merge! ( "#{@service_name}Objec... | Issue an HTTP request to call the given method from the SoftLayer API with the parameters and arguments given . |
15,903 | def set_bios_settings ( options , system_id = 1 ) r = response_handler ( rest_patch ( "/redfish/v1/Systems/#{system_id}/bios/Settings/" , body : options ) ) @logger . warn ( r ) if r [ 'error' ] true end | Set BIOS settings |
15,904 | def set_uefi_shell_startup ( uefi_shell_startup , uefi_shell_startup_location , uefi_shell_startup_url ) new_action = { 'UefiShellStartup' => uefi_shell_startup , 'UefiShellStartupLocation' => uefi_shell_startup_location , 'UefiShellStartupUrl' => uefi_shell_startup_url } response = rest_patch ( '/redfish/v1/Systems/1/... | Set the UEFI shell start up |
15,905 | def get_bios_dhcp response = rest_get ( '/redfish/v1/Systems/1/bios/Settings/' ) bios = response_handler ( response ) { 'Dhcpv4' => bios [ 'Dhcpv4' ] , 'Ipv4Address' => bios [ 'Ipv4Address' ] , 'Ipv4Gateway' => bios [ 'Ipv4Gateway' ] , 'Ipv4PrimaryDNS' => bios [ 'Ipv4PrimaryDNS' ] , 'Ipv4SecondaryDNS' => bios [ 'Ipv4Se... | Get the BIOS DHCP |
15,906 | def set_bios_dhcp ( dhcpv4 , ipv4_address = '' , ipv4_gateway = '' , ipv4_primary_dns = '' , ipv4_secondary_dns = '' , ipv4_subnet_mask = '' ) new_action = { 'Dhcpv4' => dhcpv4 , 'Ipv4Address' => ipv4_address , 'Ipv4Gateway' => ipv4_gateway , 'Ipv4PrimaryDNS' => ipv4_primary_dns , 'Ipv4SecondaryDNS' => ipv4_secondary_d... | Set the BIOS DHCP |
15,907 | def set_url_boot_file ( url_boot_file ) new_action = { 'UrlBootFile' => url_boot_file } response = rest_patch ( '/redfish/v1/Systems/1/bios/Settings/' , body : new_action ) response_handler ( response ) true end | Set the URL boot file |
15,908 | def set_bios_service ( name , email ) new_action = { 'ServiceName' => name , 'ServiceEmail' => email } response = rest_patch ( '/redfish/v1/Systems/1/bios/Settings/' , body : new_action ) response_handler ( response ) true end | Set the BIOS service |
15,909 | def clear_logs ( log_type ) new_action = { 'Action' => 'ClearLog' } response = rest_post ( uri_for_log_type ( log_type ) , body : new_action ) response_handler ( response ) true end | Clear the specified logs |
15,910 | def get_logs ( severity_level , duration , log_type ) response = rest_get ( "#{uri_for_log_type(log_type)}Entries/" ) entries = response_handler ( response ) [ 'Items' ] start_time = Time . now . utc - ( duration * 3600 ) if severity_level . nil? entries . select { | e | Time . parse ( e [ 'Created' ] ) > start_time } ... | Get the specified logs |
15,911 | def get_computer_details general_computer_details = get_general_computer_details computer_network_details = get_computer_network_details array_controller_details = get_array_controller_details general_computer_details . merge ( computer_network_details ) . merge ( array_controller_details ) end | Get all of the computer details |
15,912 | def get_general_computer_details response = rest_get ( '/redfish/v1/Systems/1/' ) details = response_handler ( response ) { 'GeneralDetails' => { 'manufacturer' => details [ 'Manufacturer' ] , 'model' => details [ 'Model' ] , 'AssetTag' => details [ 'AssetTag' ] , 'bios_version' => details [ 'Bios' ] [ 'Current' ] [ 'V... | Get the general computer details |
15,913 | def get_computer_network_details network_adapters = [ ] response = rest_get ( '/redfish/v1/Systems/1/NetworkAdapters/' ) networks = response_handler ( response ) [ 'links' ] [ 'Member' ] networks . each do | network | response = rest_get ( network [ 'href' ] ) detail = response_handler ( response ) physical_ports = [ ]... | Get the computer network details |
15,914 | def set_fw_upgrade ( uri , tpm_override_flag = true ) new_action = { 'Action' => 'InstallFromURI' , 'FirmwareURI' => uri , 'TPMOverrideFlag' => tpm_override_flag } response = rest_post ( '/redfish/v1/Managers/1/UpdateService/' , body : new_action ) response_handler ( response ) true end | Set the Firmware Upgrade |
15,915 | def asset_path ( source , options = { } ) uri = URI . parse ( source ) return source if uri . absolute? options [ :prefix ] = Sprockets :: Helpers . prefix unless options [ :prefix ] if Helpers . debug || options [ :debug ] options [ :manifest ] = false options [ :digest ] = false options [ :asset_host ] = false end so... | Returns the path to an asset either in the Sprockets environment or the public directory . External URIs are untouched . |
15,916 | def get_power_metrics chassis = rest_get ( '/redfish/v1/Chassis/' ) chassis_uri = response_handler ( chassis ) [ 'links' ] [ 'Member' ] [ 0 ] [ 'href' ] power_metrics_uri = response_handler ( rest_get ( chassis_uri ) ) [ 'links' ] [ 'PowerMetrics' ] [ 'href' ] response = rest_get ( power_metrics_uri ) metrics = respons... | Get the power metrics |
15,917 | def get_thermal_metrics chassis = rest_get ( '/redfish/v1/Chassis/' ) chassis_uri = response_handler ( chassis ) [ 'links' ] [ 'Member' ] [ 0 ] [ 'href' ] thermal_metrics_uri = response_handler ( rest_get ( chassis_uri ) ) [ 'links' ] [ 'ThermalMetrics' ] [ 'href' ] response = rest_get ( thermal_metrics_uri ) temperatu... | Get the thermal metrics |
15,918 | def set_time_zone ( time_zone ) time_response = rest_get ( '/redfish/v1/Managers/1/DateTime/' ) new_time_zone = response_handler ( time_response ) [ 'TimeZoneList' ] . select { | timezone | timezone [ 'Name' ] == time_zone } new_action = { 'TimeZone' => { 'Index' => new_time_zone [ 0 ] [ 'Index' ] } } response = rest_p... | Set the Time Zone |
15,919 | def set_ntp ( use_ntp ) new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'UseNTPServers' => use_ntp } } } } response = rest_patch ( '/redfish/v1/Managers/1/EthernetInterfaces/1/' , body : new_action ) response_handler ( response ) true end | Set whether or not ntp servers are being used |
15,920 | def set_ntp_servers ( ntp_servers ) new_action = { 'StaticNTPServers' => ntp_servers } response = rest_patch ( '/redfish/v1/Managers/1/DateTime/' , body : new_action ) response_handler ( response ) true end | Set the NTP Servers |
15,921 | def output ( data = { } , indent = 0 ) case @options [ 'format' ] when 'json' puts JSON . pretty_generate ( data ) when 'yaml' puts data . to_yaml else if data . class == Hash data . each do | k , v | if v . class == Hash || v . class == Array puts "#{' ' * indent}#{k.nil? ? 'nil' : k}:" output ( v , indent + 2 ) else ... | Print output in a given format . |
15,922 | def set_boot_order ( boot_order ) new_action = { 'PersistentBootConfigOrder' => boot_order } response = rest_patch ( '/redfish/v1/systems/1/bios/Boot/Settings/' , body : new_action ) response_handler ( response ) true end | Set the boot order |
15,923 | def set_temporary_boot_order ( boot_target ) response = rest_get ( '/redfish/v1/Systems/1/' ) boottargets = response_handler ( response ) [ 'Boot' ] [ 'BootSourceOverrideSupported' ] unless boottargets . include? boot_target raise "BootSourceOverrideTarget value - #{boot_target} is not supported. Valid values are: #{bo... | Set the temporary boot order |
15,924 | def get_schema ( schema_prefix ) response = rest_get ( '/redfish/v1/Schemas/' ) schemas = response_handler ( response ) [ 'Items' ] schema = schemas . select { | s | s [ 'Schema' ] . start_with? ( schema_prefix ) } raise "NO schema found with this schema prefix : #{schema_prefix}" if schema . empty? info = [ ] schema .... | Get the schema information with given prefix |
15,925 | def get_registry ( registry_prefix ) response = rest_get ( '/redfish/v1/Registries/' ) registries = response_handler ( response ) [ 'Items' ] registry = registries . select { | reg | reg [ 'Schema' ] . start_with? ( registry_prefix ) } info = [ ] registry . each do | reg | response = rest_get ( reg [ 'Location' ] [ 0 ]... | Get the Registry with given registry_prefix |
15,926 | def set_timeout ( timeout ) new_action = { 'SessionTimeoutMinutes' => timeout } response = rest_patch ( '/redfish/v1/Managers/1/NetworkService/' , body : new_action ) response_handler ( response ) true end | Set the Session Timeout Minutes |
15,927 | def set_ilo_ipv4_dhcp ( manager_id : 1 , ethernet_interface : 1 ) new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'Enabled' => true , 'UseDNSServers' => true , 'UseDomainName' => true , 'UseGateway' => true , 'UseNTPServers' => true , 'UseStaticRoutes' => true , 'UseWINSServers' => true } } } } response = rest_patch ... | Set EthernetInterface to obtain IPv4 settings from DHCP |
15,928 | def set_ilo_ipv4_static ( ip : , netmask : , gateway : '0.0.0.0' , manager_id : 1 , ethernet_interface : 1 ) new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'Enabled' => false } } } , 'IPv4Addresses' => [ 'Address' => ip , 'SubnetMask' => netmask , 'Gateway' => gateway ] } response = rest_patch ( "/redfish/v1/Manager... | Set EthernetInterface to static IPv4 address |
15,929 | def set_ilo_ipv4_dns_servers ( dns_servers : , manager_id : 1 , ethernet_interface : 1 ) new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'UseDNSServers' => false } , 'IPv4' => { 'DNSServers' => dns_servers } } } } response = rest_patch ( "/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/" ,... | Set EthernetInterface DNS servers |
15,930 | def set_ilo_hostname ( hostname : , domain_name : nil , manager_id : 1 , ethernet_interface : 1 ) new_action = { 'Oem' => { 'Hp' => { 'HostName' => hostname } } } new_action [ 'Oem' ] [ 'Hp' ] . merge! ( 'DHCPv4' => { } , 'DHCPv6' => { } ) if domain_name new_action [ 'Oem' ] [ 'Hp' ] [ 'DHCPv4' ] [ 'UseDomainName' ] = ... | Set iLO hostname and domain name |
15,931 | def rest_api ( type , path , options = { } ) raise InvalidRequest , 'Must specify path' unless path raise InvalidRequest , 'Must specify type' unless type @logger . debug "Making :#{type} rest call to #{@host}#{path}" uri = URI . parse ( URI . escape ( "#{@host}#{path}" ) ) http = @disable_proxy ? Net :: HTTP . new ( u... | Make a restful API request to the iLO |
15,932 | def response_handler ( response ) case response . code . to_i when RESPONSE_CODE_OK begin return JSON . parse ( response . body ) rescue JSON :: ParserError => e @logger . warn "Failed to parse JSON response. #{e}" return response . body end when RESPONSE_CODE_CREATED return JSON . parse ( response . body ) when RESPON... | Handle the response for rest call . If an asynchronous task was started this waits for it to complete . |
15,933 | def get_account_privileges ( username ) response = rest_get ( '/redfish/v1/AccountService/Accounts/' ) accounts = response_handler ( response ) [ 'Items' ] accounts . each do | account | if account [ 'Oem' ] [ 'Hp' ] [ 'LoginName' ] == username return account [ 'Oem' ] [ 'Hp' ] [ 'Privileges' ] end end end | Get the Privileges for a user |
15,934 | def set_account_privileges ( username , privileges ) response = rest_get ( '/redfish/v1/AccountService/Accounts/' ) accounts = response_handler ( response ) [ 'Items' ] id = '0' accounts . each do | account | if account [ 'Oem' ] [ 'Hp' ] [ 'LoginName' ] == username id = account [ 'Id' ] break end end new_action = { 'O... | Set the privileges for a user |
15,935 | def get_certificate uri = URI . parse ( URI . escape ( @host ) ) options = { use_ssl : true , verify_mode : OpenSSL :: SSL :: VERIFY_NONE } Net :: HTTP . start ( uri . host , uri . port , options ) do | http | http . peer_cert end end | Get the SSL Certificate |
15,936 | def generate_csr ( country , state , city , org_name , org_unit , common_name ) new_action = { 'Action' => 'GenerateCSR' , 'Country' => country , 'State' => state , 'City' => city , 'OrgName' => org_name , 'OrgUnit' => org_unit , 'CommonName' => common_name } response = rest_post ( '/redfish/v1/Managers/1/SecurityServi... | Generate a Certificate Signing Request |
15,937 | def set_uefi_secure_boot ( secure_boot_enable ) new_action = { 'SecureBootEnable' => secure_boot_enable } response = rest_patch ( '/redfish/v1/Systems/1/SecureBoot/' , body : new_action ) response_handler ( response ) true end | Set the UEFI secure boot true or false |
15,938 | def set_power_state ( state ) new_action = { 'Action' => 'Reset' , 'ResetType' => state } response = rest_post ( '/redfish/v1/Systems/1/' , body : new_action ) response_handler ( response ) true end | Set the Power State |
15,939 | def set_snmp ( snmp_mode , snmp_alerts ) new_action = { 'Mode' => snmp_mode , 'AlertsEnabled' => snmp_alerts } response = rest_patch ( '/redfish/v1/Managers/1/SnmpService/' , body : new_action ) response_handler ( response ) true end | Set the SNMP Mode and Alerts Enabled value |
15,940 | def get_virtual_media response = rest_get ( '/redfish/v1/Managers/1/VirtualMedia/' ) media = { } response_handler ( response ) [ 'links' ] [ 'Member' ] . each do | vm | response = rest_get ( vm [ 'href' ] ) virtual_media = response_handler ( response ) media [ virtual_media [ 'Id' ] ] = { 'Image' => virtual_media [ 'Im... | Get the Virtual Media Information |
15,941 | def insert_virtual_media ( id , image ) new_action = { 'Action' => 'InsertVirtualMedia' , 'Target' => '/Oem/Hp' , 'Image' => image } response = rest_post ( "/redfish/v1/Managers/1/VirtualMedia/#{id}/" , body : new_action ) response_handler ( response ) true end | Insert Virtual Media |
15,942 | def eject_virtual_media ( id ) new_action = { 'Action' => 'EjectVirtualMedia' , 'Target' => '/Oem/Hp' } response = rest_post ( "/redfish/v1/Managers/1/VirtualMedia/#{id}/" , body : new_action ) response_handler ( response ) true end | Eject Virtual Media |
15,943 | def set_asset_tag ( asset_tag ) @logger . warn '[Deprecated] `set_asset_tag` is deprecated. Please use `set_system_settings(AssetTag: <tag>)` instead.' new_action = { 'AssetTag' => asset_tag } response = rest_patch ( '/redfish/v1/Systems/1/' , body : new_action ) response_handler ( response ) true end | Set the Asset Tag |
15,944 | def set_indicator_led ( state ) @logger . warn '[Deprecated] `set_indicator_led` is deprecated. Please use `set_system_settings(IndicatorLED: <state>)` instead.' new_action = { 'IndicatorLED' => state } response = rest_patch ( '/redfish/v1/Systems/1/' , body : new_action ) response_handler ( response ) true end | Set the UID indicator LED |
15,945 | def userhref ( uri , username ) response = rest_get ( uri ) items = response_handler ( response ) [ 'Items' ] items . each do | it | return it [ 'links' ] [ 'self' ] [ 'href' ] if it [ 'UserName' ] == username end end | Get the HREF for a user with a specific username |
15,946 | def create_user ( username , password ) new_action = { 'UserName' => username , 'Password' => password , 'Oem' => { 'Hp' => { 'LoginName' => username } } } response = rest_post ( '/redfish/v1/AccountService/Accounts/' , body : new_action ) response_handler ( response ) true end | Create a user |
15,947 | def change_password ( username , password ) new_action = { 'Password' => password } userhref = userhref ( '/redfish/v1/AccountService/Accounts/' , username ) response = rest_patch ( userhref , body : new_action ) response_handler ( response ) true end | Change the password for a user |
15,948 | def delete_user ( username ) userhref = userhref ( '/redfish/v1/AccountService/Accounts/' , username ) response = rest_delete ( userhref ) response_handler ( response ) true end | Delete a specific user |
15,949 | def templates data = http_action_get "nodes/#{@node}/storage/local/content" template_list = { } data . each do | ve | name = ve [ 'volid' ] . gsub ( %r{ \/ } , '\1' ) template_list [ name ] = ve end template_list end | Get template list |
15,950 | def openvz_get data = http_action_get "nodes/#{@node}/openvz" ve_list = { } data . each do | ve | ve_list [ ve [ 'vmid' ] ] = ve end ve_list end | Get CT list |
15,951 | def openvz_post ( ostemplate , vmid , config = { } ) config [ 'vmid' ] = vmid config [ 'ostemplate' ] = "local%3Avztmpl%2F#{ostemplate}.tar.gz" vm_definition = config . to_a . map { | v | v . join '=' } . join '&' http_action_post ( "nodes/#{@node}/openvz" , vm_definition ) end | Create CT container |
15,952 | def create_ticket post_param = { username : @username , realm : @realm , password : @password } @site [ 'access/ticket' ] . post post_param do | response , _request , _result , & _block | if response . code == 200 extract_ticket response else @connection_status = 'error' end end end | Methods manages auth |
15,953 | def extract_ticket ( response ) data = JSON . parse ( response . body ) ticket = data [ 'data' ] [ 'ticket' ] csrf_prevention_token = data [ 'data' ] [ 'CSRFPreventionToken' ] unless ticket . nil? token = 'PVEAuthCookie=' + ticket . gsub! ( / / , '%3A' ) . gsub! ( / / , '%3D' ) end @connection_status = 'connected' { CS... | Method create ticket |
15,954 | def check_response ( response ) if response . code == 200 JSON . parse ( response . body ) [ 'data' ] else 'NOK: error code = ' + response . code . to_s end end | Extract data or return error |
15,955 | def http_action_post ( url , data = { } ) @site [ url ] . post data , @auth_params do | response , _request , _result , & _block | check_response response end end | Methods manage http dialogs |
15,956 | def next while @pos < @input . length if self . class . ignores_list [ @input [ @pos ] ] ignore_symbol next end m = self . class . token_regexps . match ( @input [ @pos .. - 1 ] ) if m && ! m [ 0 ] . empty? val = nil type = nil resolved_type = nil m . names . each do | n | if m [ n ] type = n . to_sym resolved_type = (... | Processes the next token in input |
15,957 | def auto_orient manipulate! do | image | o = image . get ( 'exif-Orientation' ) . to_i rescue nil o ||= image . get ( 'exif-ifd0-Orientation' ) . to_i rescue 1 case o when 1 when 6 image . rot270 when 8 image . rot180 when 3 image . rot90 else raise ( 'Invalid value for Orientation: ' + o . to_s ) end image . set_type ... | Read the camera EXIF data to determine orientation and adjust accordingly |
15,958 | def convert ( f , opts = { } ) opts = opts . dup f = f . to_s . downcase allowed = %w( jpeg jpg png ) raise ArgumentError , "Format must be one of: #{allowed.join(',')}" unless allowed . include? ( f ) self . format_override = f == 'jpeg' ? 'jpg' : f opts [ :Q ] = opts . delete ( :quality ) if opts . has_key? ( :qualit... | Convert the file to a different format |
15,959 | def resize_to_fill ( new_width , new_height ) manipulate! do | image | image = resize_image image , new_width , new_height , :max if image . width > new_width top = 0 left = ( image . width - new_width ) / 2 elsif image . height > new_height left = 0 top = ( image . height - new_height ) / 2 else left = 0 top = 0 end n... | Resize the image to fit within the specified dimensions while retaining the aspect ratio of the original image . If necessary crop the image in the larger dimension . |
15,960 | def resize_to_limit ( new_width , new_height ) manipulate! do | image | image = resize_image ( image , new_width , new_height ) if new_width < image . width || new_height < image . height image end end | Resize the image to fit within the specified dimensions while retaining the original aspect ratio . Will only resize the image if it is larger than the specified dimensions . The resulting image may be shorter or narrower than specified in the smaller dimension but will not be larger than the specified values . |
15,961 | def read_yaml ( base , name , alt = true ) _localization_original_read_yaml ( base , name ) read_alternate_language_content ( base , name ) if alt && content . empty? end | Overwrites the original method to optionally set the content of a file with no content in it to the content of a file with another language which does have content in it . |
15,962 | def destination ( dest ) path = File . join ( dest , @dir , CGI . unescape ( url ) ) if ext == '.html' && _localization_original_url !~ / \. \z / path . sub! ( Localization :: LANG_END_RE , '' ) File . join ( path , "index#{ext}#{@lang_ext}" ) else path end end | Overwrites the original method to cater for language extension in output file name . |
15,963 | def process ( name ) self . ext = File . extname ( name ) self . basename = name [ 0 .. - self . ext . length - 1 ] . sub ( Localization :: LANG_END_RE , '' ) end | Overwrites the original method to filter the language extension from basename |
15,964 | def stop ( wait_seconds_before_close = 2 , gracefully = true ) shutdown if gracefully sleep wait_seconds_before_close if connections? @connections_mutex . synchronize do @tcp_server_threads . each do | tcp_server_thread | tcp_server_thread . raise SmtpdStopServiceException if tcp_server_thread end end sleep wait_second... | Stop the server |
15,965 | def on_auth_event ( ctx , authorization_id , authentication_id , authentication ) logger . debug ( "Deny access from #{ctx[:server][:remote_ip]}:#{ctx[:server][:remote_port]} for #{authentication_id}" + ( authorization_id == '' ? '' : "/#{authorization_id}" ) + " with #{authentication}" ) raise Smtpd535Exception end | check the authentification on AUTH if any value returned that will be used for ongoing processing otherwise the original value will be used for authorization_id |
15,966 | def serve_service raise 'Service was already started' unless stopped? @shutdown = false @hosts . each_with_index do | host , index | ports_for_host = ( index < @ports . length ? @ports [ index ] : @ports . last ) . to_s . split ( ':' ) ports_for_host . each do | port | serve_service_on_host_and_port ( host , port ) end... | Start the listeners for all hosts |
15,967 | def serve_service_on_host_and_port ( host , port ) logger . info ( 'Running service on ' + ( host == '' ? '<any>' : host ) + ':' + port . to_s ) tcp_server = TCPServer . new ( host , port ) @tcp_servers << tcp_server @tcp_server_threads << Thread . new do begin until shutdown? client = tcp_server . accept Thread . new ... | Start the listener thread on single host and port |
15,968 | def process_reset_session ( session , connection_initialize = false ) session [ :cmd_sequence ] = connection_initialize ? :CMD_HELO : :CMD_RSET session [ :auth_challenge ] = { } session [ :ctx ] || session [ :ctx ] = { } if connection_initialize session [ :ctx ] . merge! ( server : { local_host : '' , local_ip : '' , l... | reset the context of current smtpd dialog |
15,969 | def process_auth_plain ( session , encoded_auth_response ) begin @auth_values = Base64 . decode64 ( encoded_auth_response ) . split ( "\x00" ) raise Smtpd500Exception unless @auth_values . length == 3 return_value = on_auth_event ( session [ :ctx ] , @auth_values [ 0 ] , @auth_values [ 1 ] , @auth_values [ 2 ] ) if ret... | handle plain authentification |
15,970 | def subscribe_to ( channel , opts = { } ) js_tag = opts . delete ( :include_js_tag ) { true } subscription = Danthes . subscription ( channel : channel ) content = raw ( "if (typeof Danthes != 'undefined') { Danthes.sign(#{subscription.to_json}) }" ) js_tag ? content_tag ( 'script' , content , type : 'text/javascript' ... | Subscribe the client to the given channel . This generates some JavaScript calling Danthes . sign with the subscription options . |
15,971 | def clear_cache_for ( * paths ) return unless Lacquer . configuration . enable_cache case Lacquer . configuration . job_backend when :delayed_job require 'lacquer/delayed_job_job' Delayed :: Job . enqueue ( Lacquer :: DelayedJobJob . new ( paths ) ) when :resque require 'lacquer/resque_job' Resque . enqueue ( Lacquer :... | Sends url . purge command to varnish to clear cache . |
15,972 | def incoming ( message , callback ) if message [ 'channel' ] == '/meta/subscribe' authenticate_subscribe ( message ) elsif message [ 'channel' ] !~ %r{ } authenticate_publish ( message ) end callback . call ( message ) end | Callback to handle incoming Faye messages . This authenticates both subscribe and publish calls . |
15,973 | def send_command ( command ) Lacquer . configuration . varnish_servers . collect do | server | retries = 0 response = nil begin retries += 1 connection = Net :: Telnet . new ( 'Host' => server [ :host ] , 'Port' => server [ :port ] , 'Timeout' => server [ :timeout ] || 5 ) if ( server [ :secret ] ) connection . waitfor... | Sends commands over telnet to varnish servers listed in the config . |
15,974 | def start ( io ) ssl = OpenSSL :: SSL :: SSLSocket . new ( io , @ctx ) ssl . accept ssl . sync_close = true return ssl end | start ssl connection over existing tcpserver socket |
15,975 | def responsive_image_tag image , options = { } sizes = ResponsiveImages . options . deep_merge ( options ) data_sizes = alternative_sizes ( image , sizes ) image_src = src_path ( image , sizes ) return image_tag image_src , data_sizes . merge ( options ) end | Create a image tag with our responsive image data attributes |
15,976 | def alternative_sizes image , sizes data_sizes = { } sizes [ :sizes ] . each do | size , value | if value . present? data_sizes [ "data-#{size}-src" ] = ( value == :default ? image . url : image . send ( value ) ) else false end end data_sizes end | Loop over the images sizes and create our data attributes hash |
15,977 | def load_continent_defs ( name , more_attribs = { } ) reader = create_values_reader ( name , more_attribs ) reader . each_line do | attribs , values | values . each_with_index do | value , index | logger . warn "unknown type for value >#{value}<" end rec = Continent . find_by_key ( attribs [ :key ] ) if rec . present? ... | use ContinentDef Reader |
15,978 | def all if @side if @round seats = by_round @round , @side else side_root = @bracket . root . send ( @side ) seats = [ ] @bracket . top_down ( side_root ) do | node | seats << node end end else if @round seats = by_round ( @round , :left ) + by_round ( @round , :right ) else seats = [ ] @bracket . top_down ( @bracket .... | Retrieves all seats based on the stored relation conditions |
15,979 | def by_round round , side depth = @bracket . depth [ side ] - ( round - 1 ) seats = [ ] side_root = @bracket . root . send ( side ) @bracket . top_down ( side_root ) do | node | if node . depth == depth seats << node end end seats end | Retrieves an Array of Nodes for a given round on a given side |
15,980 | def configure ( xcodeproj_path , scheme , options : { } ) require 'slather' @project = Slather :: Project . open ( xcodeproj_path ) @project . scheme = scheme @project . workspace = options [ :workspace ] @project . build_directory = options [ :build_directory ] @project . ignore_list = options [ :ignore_list ] @projec... | Required method to configure slather . It s required at least the path to the project and the scheme used with code coverage enabled |
15,981 | def total_coverage unless @project . nil? @total_coverage ||= begin total_project_lines = 0 total_project_lines_tested = 0 @project . coverage_files . each do | coverage_file | total_project_lines_tested += coverage_file . num_lines_tested total_project_lines += coverage_file . num_lines_testable end @total_coverage = ... | Total coverage of the project |
15,982 | def notify_if_coverage_is_less_than ( options ) minimum_coverage = options [ :minimum_coverage ] notify_level = options [ :notify_level ] || :fail if total_coverage < minimum_coverage notify_message = "Total coverage less than #{minimum_coverage}%" if notify_level == :fail fail notify_message else warn notify_message e... | Method to check if the coverage of the project is at least a minumum |
15,983 | def notify_if_modified_file_is_less_than ( options ) minimum_coverage = options [ :minimum_coverage ] notify_level = options [ :notify_level ] || :fail if all_modified_files_coverage . count > 0 files_to_notify = all_modified_files_coverage . select do | file | file . percentage_lines_tested < minimum_coverage end noti... | Method to check if the coverage of modified files is at least a minumum |
15,984 | def modified_files_coverage_table unless @project . nil? line = '' if all_modified_files_coverage . count > 0 line << "File | Coverage\n" line << "-----|-----\n" all_modified_files_coverage . each do | coverage_file | file_name = coverage_file . source_file_pathname_relative_to_repo_root . to_s percentage = @project . ... | Build a coverage markdown table of the modified files coverage |
15,985 | def show_coverage unless @project . nil? line = "## Code coverage\n" line << total_coverage_markdown line << modified_files_coverage_table line << '> Powered by [Slather](https://github.com/SlatherOrg/slather)' markdown line end end | Show a header with the total coverage and coverage table |
15,986 | def all_modified_files_coverage unless @project . nil? all_modified_files_coverage ||= begin modified_files = git . modified_files . nil? ? [ ] : git . modified_files added_files = git . added_files . nil? ? [ ] : git . added_files all_changed_files = modified_files | added_files @project . coverage_files . select do |... | Array of files that we have coverage information and was modified |
15,987 | def diff_iterator @images . first . height . times do | y | @images . first . row ( y ) . each_with_index do | pixel , x | unless pixel == @images . last [ x , y ] @diff_index << [ x , y ] pixel_difference_filter ( pixel , x , y ) end end end end | Run through all of the pixels on both org image and fresh image . Change the pixel color accordingly . |
15,988 | def pixel_difference_filter ( pixel , x , y ) chans = [ ] [ :r , :b , :g ] . each do | chan | chans << channel_difference ( chan , pixel , x , y ) end @images . last [ x , y ] = ChunkyPNG :: Color . rgb ( chans [ 0 ] , chans [ 1 ] , chans [ 2 ] ) end | Changes the pixel color to be the opposite RGB value |
15,989 | def channel_difference ( chan , pixel , x , y ) ChunkyPNG :: Color . send ( chan , pixel ) + ChunkyPNG :: Color . send ( chan , @images . last [ x , y ] ) - 2 * [ ChunkyPNG :: Color . send ( chan , pixel ) , ChunkyPNG :: Color . send ( chan , @images . last [ x , y ] ) ] . min end | Interface to run the R G B methods on ChunkyPNG |
15,990 | def percentage_diff ( org , fresh ) diff_images ( org , fresh ) @total_px = @images . first . pixels . length @changed_px = @diff_index . length @percentage_changed = ( ( @diff_index . length . to_f / @images . first . pixels . length ) * 100 ) . round ( 2 ) end | Returns the numeric results of the diff of 2 images |
15,991 | def save_visual_diff ( org , fresh ) x , y = @diff_index . map { | xy | xy [ 0 ] } , @diff_index . map { | xy | xy [ 1 ] } @diffed_image = org . insert ( - 5 , '_diff' ) begin @images . last . rect ( x . min , y . min , x . max , y . max , ChunkyPNG :: Color . rgb ( 0 , 255 , 0 ) ) rescue NoMethodError puts "Both skins... | Saves the visual diff as a separate file |
15,992 | def get ( key , opts = { } ) response = api_execute ( key_endpoint + key , :get , params : opts ) Response . from_http_response ( response ) end | Retrives a key with its associated data if key is not present it will return with message Key Not Found |
15,993 | def set ( key , opts = nil ) fail ArgumentError , 'Second argument must be a hash' unless opts . is_a? ( Hash ) path = key_endpoint + key payload = { } [ :ttl , :value , :dir , :prevExist , :prevValue , :prevIndex ] . each do | k | payload [ k ] = opts [ k ] if opts . key? ( k ) end response = api_execute ( path , :put... | Create or update a new key |
15,994 | def compare_and_swap ( key , opts = { } ) fail ArgumentError , 'Second argument must be a hash' unless opts . is_a? ( Hash ) fail ArgumentError , 'You must pass prevValue' unless opts . key? ( :prevValue ) set ( key , opts ) end | Set a new value for key if previous value of key is matched |
15,995 | def watch ( key , opts = { } ) params = { wait : true } fail ArgumentError , 'Second argument must be a hash' unless opts . is_a? ( Hash ) timeout = opts [ :timeout ] || @read_timeout index = opts [ :waitIndex ] || opts [ :index ] params [ :waitIndex ] = index unless index . nil? params [ :consistent ] = opts [ :consis... | Gives a notification when specified key changes |
15,996 | def receive_message ( msg ) response = Oj . load ( msg . data ) if response [ 'requestId' ] == @request_id if @response . nil? @response = response else @response [ 'result' ] [ 'data' ] . concat response [ 'result' ] [ 'data' ] @response [ 'result' ] [ 'meta' ] . merge! response [ 'result' ] [ 'meta' ] @response [ 'st... | this has to be public so the websocket client thread sees it |
15,997 | def treat_response ok_status = [ :success , :no_content , :partial_content ] . map { | st | STATUS [ st ] } unless ok_status . include? ( @response [ 'status' ] [ 'code' ] ) fail :: GremlinClient :: ServerError . new ( @response [ 'status' ] [ 'code' ] , @response [ 'status' ] [ 'message' ] ) end @response [ 'result' ]... | we validate our response here to make sure it is going to be raising exceptions in the right thread |
15,998 | def request_external_payment ( payment_options ) payment_options [ :instance_id ] = @instance_id request = self . class . send_external_payment_request ( "/api/request-external-payment" , payment_options ) RecursiveOpenStruct . new request . parsed_response end | Requests a external payment |
15,999 | def process_external_payment ( payment_options ) payment_options [ :instance_id ] = @instance_id request = self . class . send_external_payment_request ( "/api/process-external-payment" , payment_options ) RecursiveOpenStruct . new request . parsed_response end | Confirms a payment that was created using the request - extenral - payment method |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.