idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
14,600 | def get_server_info params = MagicParams . format ( user_id : @allscripts_username ) results = magic ( "GetServerInfo" , magic_params : params ) results [ "getserverinfoinfo" ] [ 0 ] end | a wrapper around GetServerInfo which returns the time zone of the server unity version and date and license key |
14,601 | def balance ( options = { } ) if self . class == Borutus :: Account raise ( NoMethodError , "undefined method 'balance'" ) else if self . normal_credit_balance ^ contra credits_balance ( options ) - debits_balance ( options ) else debits_balance ( options ) - credits_balance ( options ) end end end | The balance of the account . This instance method is intended for use only on instances of account subclasses . |
14,602 | def shutdown ( exception ) begin notify_event ( :shutdown , { :exception_message => exception . message } ) rescue => e $stderr . puts ( [ e . message , e . backtrace ] . join ( "\n" ) ) rescue nil end @config = default_config @config [ :enabled ] = false end | Anytime an exception happens we want to skedaddle out of the way and let life roll on without any tracking in the loop . |
14,603 | def add_itemprop ( itemprop ) properties = Itemprop . parse ( itemprop , @page_url ) properties . each { | name , value | ( @properties [ name ] ||= [ ] ) << value } end | Add an itemprop to the properties |
14,604 | def add_itemref_properties ( element ) itemref = element . attribute ( 'itemref' ) if itemref itemref . value . split ( ' ' ) . each { | id | parse_elements ( find_with_id ( id ) ) } end end | Add any properties referred to by itemref |
14,605 | def replacements nodes . reject { | node | method_order_correct? ( node ) } . each_with_object ( { } ) do | node , obj | node_to_replace = nodes [ expected_method_index ( node ) ] obj [ node ] = { node => node_to_replace , node_to_replace => nodes [ expected_method_index ( node_to_replace ) ] } end end | Build a hash for every node that is not at the correct final position which includes any nodes that need to be moved . Used for autocorrecting . |
14,606 | def class_for ( n ) class_mapping = { "#{schema_namespace_prefix}schema" => Schema , "#{schema_namespace_prefix}element" => Element , "#{schema_namespace_prefix}attribute" => Attribute , "#{schema_namespace_prefix}choice" => Choice , "#{schema_namespace_prefix}complexType" => ComplexType , "#{schema_namespace_prefix}se... | Node to class mapping |
14,607 | def full_messages violations . inject ( [ ] ) do | list , ( attribute_name , violations ) | messages = violations messages = violations . full_messages if violations . respond_to? ( :full_messages ) list . concat ( messages ) end end | Collect all violations into a single list . |
14,608 | def get_unit ( key ) @assigned_factories [ key ] ||= source_factories [ rand ( source_factories . length ) ] @assigned_factories [ key ] . get_unit ( key ) end | Returns the value of get_unit from the Factory assigned to the given key . When a key is needed that a Factory is not already assigned to one will be assigned at random from the pool of source factories . |
14,609 | def generate_factories random_factory = RubyOnAcid :: RandomFactory . new factories = [ ] 5 . times do factory = RubyOnAcid :: LoopFactory . new factory . interval = random_factory . get ( :increment , :min => - 0.1 , :max => 0.1 ) factories << factory end 3 . times do factory = RubyOnAcid :: ConstantFactory . new fact... | Takes a hash with all keys supported by Factory . |
14,610 | def validates_acceptance_of ( * attribute_names ) options = Macros . extract_options ( attribute_names ) validation_rules . add ( Rule :: Acceptance , attribute_names , options ) end | Validates that the attributes s value is in the set of accepted values . |
14,611 | def validates_confirmation_of ( * attribute_names ) options = Macros . extract_options ( attribute_names ) validation_rules . add ( Rule :: Confirmation , attribute_names , options ) end | Validates that the given attribute is confirmed by another attribute . A common use case scenario is when you require a user to confirm their password for which you use both password and password_confirmation attributes . |
14,612 | def validates_numericalness_of ( * attribute_names ) options = Macros . extract_options ( attribute_names ) validation_rules . add ( Rule :: Value , attribute_names , options ) validation_rules . add ( Rule :: Numericalness , attribute_names , options ) end | Validate whether a field is numeric . |
14,613 | def validates_presence_of ( * attribute_names ) options = Macros . extract_options ( attribute_names ) validation_rules . add ( Rule :: Presence :: NotBlank , attribute_names , options ) end | Validates that the specified attribute is present . |
14,614 | def validates_primitive_type_of ( * attribute_names ) options = Macros . extract_options ( attribute_names ) validation_rules . add ( Rule :: PrimitiveType , attribute_names , options ) end | Validates that the specified attribute is of the correct primitive type . |
14,615 | def all_recordings opts = { headers : true , header_converters : :symbol , encoding : 'utf-8' } CSV . read ( DIFILE , opts ) . map ( & :to_hash ) end | Returns hash array of all recordings in DIANE file |
14,616 | def play abort %(None from #{@user}. Fuck off.) . magenta if @recordings . empty? stdout = preface @recordings . each do | r | stdout += "\n#{r[:time]} : " . cyan + "@#{r[:user]}" . yellow stdout += "\n#{r[:message]}\n\n" end puts stdout stdout end | returns and puts formatted recordings returned by query |
14,617 | def rule_hits ( results_doc , instance_doc , rule_type , xpath ) results = [ ] results_doc . root . find ( xpath , NS_PREFIXES ) . each do | hit | context = instance_doc . root . find_first hit [ 'location' ] hit . find ( 'svrl:text/text()' , NS_PREFIXES ) . each do | message | results << { :rule_type => rule_type , :t... | Look for reported or failed rules of a particular type in the instance doc |
14,618 | def limit ( key , count , duration ) @key = key . to_s @duration = duration . to_i if incr_count > count return false if @duration - elapsed > 0 reset end true end | Initializes and returns a Redis object . |
14,619 | def next_in ( key , count , duration ) @key = key @duration = duration return 0 if current_count ( key ) < count [ @duration - elapsed , 0 ] . max end | Gets the ETA for the next window start only if the limit has been breached . Returns 0 if the limit has not been breached . |
14,620 | def get_unit ( key ) @prior_values [ key ] ||= 0.0 begin key , value = @space . take ( [ key , Float ] , @timeout ) @prior_values [ key ] = value rescue Rinda :: RequestExpiredError => exception if source_factories . empty? value = @prior_values [ key ] else value = super end end value end | Get key from Rinda server . |
14,621 | def matching_attributes? ( attribute , filter ) attribute . to_s . downcase == filter . to_s . delete ( '_' ) . downcase end | Parse the ids to the same string format . contentfulAttribute == ruby_attribute |
14,622 | def add_to ( ec2 ) ec2_template = ec2 . template @instance_name = ec2 . name chef_client_template = template ec2 . template . inner_merge ( chef_client_template ) end | Initialize an ChefClient configuration |
14,623 | def validate ( resource ) rules = rules_for_resource ( resource ) rules . map { | rule | rule . validate ( resource ) } . compact end | Execute all rules in this context against the resource . |
14,624 | def template ( options = { } ) require_options ( options , [ :resources ] ) resources = options [ :resources ] description = options [ :description ] || 'This stack is created by Cloudster' resource_template = { } output_template = { } resources . each do | resource | resource_template . merge! ( resource . template [ ... | Initialize a Cloud instance |
14,625 | def get_rds_details ( options = { } ) stack_resources = resources ( options ) rds_resource_ids = get_resource_ids ( stack_resources , "AWS::RDS::DBInstance" ) rds = Fog :: AWS :: RDS . new ( :aws_access_key_id => @access_key_id , :aws_secret_access_key => @secret_access_key , :region => @region ) rds_details = { } rds_... | Get details of all RDS resources in a stack |
14,626 | def get_ec2_details ( options = { } ) stack_resources = resources ( options ) ec2_resource_ids = get_resource_ids ( stack_resources , "AWS::EC2::Instance" ) ec2 = Fog :: Compute :: AWS . new ( :aws_access_key_id => @access_key_id , :aws_secret_access_key => @secret_access_key , :region => @region ) ec2_details = { } ec... | Get details of all EC2 instances in a stack |
14,627 | def get_elb_details ( options = { } ) stack_resources = resources ( options ) elb_resource_ids = get_resource_ids ( stack_resources , "AWS::ElasticLoadBalancing::LoadBalancer" ) elb = Fog :: AWS :: ELB . new ( :aws_access_key_id => @access_key_id , :aws_secret_access_key => @secret_access_key , :region => @region ) elb... | Get details of all Elastic Load Balancers in the stack |
14,628 | def outputs ( options = { } ) require_options ( options , [ :stack_name ] ) stack_description = describe ( :stack_name => options [ :stack_name ] ) outputs = stack_description [ "Outputs" ] rescue [ ] outputs_hash = { } outputs . each do | output | outputs_hash [ output [ "OutputKey" ] ] = parse_outputs ( output [ "Out... | Returns a hash containing the output values of each resource in the Stack |
14,629 | def is_s3_bucket_name_available? ( bucket_name ) s3 = Fog :: Storage :: AWS . new ( :aws_access_key_id => @access_key_id , :aws_secret_access_key => @secret_access_key ) begin response = s3 . get_bucket ( bucket_name ) rescue Exception => e response = e . response end not_found_status = 404 return response [ :status ] ... | Returns true if S3 bucket name is available else returns false |
14,630 | def to_h output = { } instance_variables . each do | var | output . merge! ( { var [ 1 .. - 1 ] => instance_variable_get ( var ) } ) unless var == '@xml' end output end | output as hash |
14,631 | def get_devices devices = [ ] run_adb ( "devices" ) do | pout | pout . each do | line | line = line . strip if ( ! line . empty? && line !~ / / ) parts = line . split device = AndroidAdb :: Device . new ( parts [ 0 ] , parts [ 1 ] ) devices << device end end end return devices end | Contructs an Adb object for issuing commands to the connected device or emulator . |
14,632 | def get_packages ( adb_opts = { } ) packages = [ ] run_adb_shell ( "pm list packages -f" , adb_opts ) do | pout | pout . each do | line | @log . debug ( "{stdout} #{line}" ) unless @log . nil? parts = line . split ( ":" ) if ( parts . length > 1 ) info = parts [ 1 ] . strip . split ( "=" ) package = AndroidAdb :: Packa... | Returns a list of all installed packages on the device . |
14,633 | def setup_celluloid_logger return if ! debug_enabled? || ( respond_to? ( :log_file_path ) && log_file_path . blank? ) setup_log_file Celluloid . logger = :: Logger . new ( log_file_path . present? ? log_file_path : STDOUT ) setup_celluloid_exception_handler end | sets the celluloid logger and the celluloid exception handler |
14,634 | def setup_celluloid_exception_handler Celluloid . task_class = defined? ( Celluloid :: TaskThread ) ? Celluloid :: TaskThread : Celluloid :: Task :: Threaded Celluloid . exception_handler do | ex | puts ex unless filtered_error? ( ex ) end end | sets the celluloid exception handler |
14,635 | def setup_log_file return if ! debug_enabled? || ( respond_to? ( :log_file_path ) && log_file_path . blank? ) FileUtils . mkdir_p ( File . dirname ( log_file_path ) ) unless File . directory? ( log_file_path ) log_file = File . open ( log_file_path , 'w' ) log_file . sync = true end | creates the log file where the debug messages will be printed |
14,636 | def parse_options ( options ) options = options . is_a? ( Array ) ? options . first : options options = options . is_a? ( Hash ) ? options . stringify_keys : { } options end | receives a list of options that need to be parsed if it is an Array will return the first element otherwise if it is an Hash will return the hash with string keys otherwise an empty hash |
14,637 | def resolve list = dependency_list . sort { | a , b | a . last . size <=> b . last . size } resolve_list ( list ) end | Constructor accepts an array of files |
14,638 | def make_absolute_url ( url ) return url unless URI . parse ( url ) . relative? begin URI . parse ( @page_url ) . merge ( url ) . to_s rescue URI :: Error url end end | This returns an empty string if can t form a valid absolute url as per the Microdata spec . |
14,639 | def []= ( k , i = nil , v = nil ) if v insert ( i , k , v ) else store ( k , i ) end end | Store operator . |
14,640 | def request method , path , opts = { } conn_options = connection_options opts opts [ 'api_key' ] = api_key unless opts . has_key? 'api_key' opts [ 'file_type' ] = file_type unless opts . has_key? 'file_type' response = connection ( conn_options ) . send ( method ) do | request | case method when :get request . url path... | Perform a request |
14,641 | def enter! @state_machine . current_state = self @entry_actions . each do | entry_action | entry_action . call ( @state_machine ) end @transition_map . each do | type , events_to_transition_arrays | events_to_transition_arrays . each do | event , transitions | transitions . each ( & :arm ) end end end | Sets the state machine s current_state to self calls all entry actions and activates triggering mechanisms of all outgoing transitions . |
14,642 | def exit! map = @transition_map map . each do | type , events_to_transition_arrays | events_to_transition_arrays . each do | event , transitions | transitions . each ( & :unarm ) end end @exit_actions . each do | exit_action | exit_action . call ( @state_machine ) end @state_machine . current_state = nil end | Sets the state machine s current_state to nil calls all exit actions and deactivates triggering mechanisms of all outgoing transitions . |
14,643 | def cleanup @transition_map . each do | type , events_to_transition_arrays | events_to_transition_arrays . each do | event , transitions | transitions . clear end end @transition_map = nil @state_machine = nil @entry_actions = nil @exit_actions = nil end | Cleans up references to allow easier GC . |
14,644 | def guarded_execute ( event_type , event_trigger_value ) @state_machine . raise_outside_initial_queue return if terminating? if @transition_map [ event_type ] . nil? || @transition_map [ event_type ] [ event_trigger_value ] . nil? raise ArgumentError , "No registered transition found " "for event #{event_type}:#{event_... | Executes the registered transition for the given event type and event trigger value if such a transition exists and it is allowed . |
14,645 | def validate raise GatticaError :: InvalidEmail , "The email address '#{@email}' is not valid" if not @email . match ( / \. \. \- \. \. /i ) raise GatticaError :: InvalidPassword , "The password cannot be blank" if @password . empty? || @password . nil? end | Determine whether or not this is a valid user |
14,646 | def options OPTION_KEYS . inject ( { } ) { | o , k | o . merge! ( k => send ( k ) ) } end | Convert option_keys to hash and return |
14,647 | def recent_updates ( options ) default_options = { path : nil , limit : 10 } options = default_options . merge ( options ) limit = [ options [ :limit ] , 1 ] . max paging_window = limit * 2 updates_hash = { } offset = 0 until updates_hash . count >= limit changes = recent_changes ( options [ :path ] , paging_window , o... | one entry for each file |
14,648 | def supervise_actors current_actor = Actor . current @actor . link current_actor if @actor . respond_to? ( :link ) current_actor . link connection end | the method will link the current actor to the actor that is attached to and the connection to the current actor |
14,649 | def on_message ( data ) message = JSON . parse ( data ) log_debug ( "#{@actor.class} received JSON #{message}" ) if @actor . respond_to? ( :async ) @actor . async . on_message ( message ) else @actor . on_message ( message ) end end | callback executes when actor receives a message from a subscribed channel and parses the message using JSON . parse and dispatches the parsed message to the original actor that made the connection |
14,650 | def on_close ( code , reason ) connection . terminate terminate log_debug ( "#{@actor.class} dispatching on close #{code} #{reason}" ) if @actor . respond_to? ( :async ) @actor . async . on_close ( code , reason ) else @actor . on_close ( code , reason ) end end | callback executes when connection closes |
14,651 | def send_action ( action , channel = nil , data = { } ) data = data . is_a? ( Hash ) ? data : { } publishing_data = { 'client_action' => action , 'channel' => channel , 'data' => data } . reject { | _key , value | value . blank? } async . chat ( publishing_data ) end | method used to send an action to the webserver reactor to a chanel and with data |
14,652 | def chat ( message ) final_message = message . is_a? ( Hash ) ? message . to_json : JSON . dump ( action : 'message' , message : message ) log_debug ( "#{@actor.class} sends JSON #{final_message}" ) connection . text final_message end | method used to send messages to the webserver checks too see if the message is a hash and if it is it will transform it to JSON and send it to the webser otherwise will construct a JSON object that will have the key action with the value message and the key message witth the parameter s value |
14,653 | def handle_parsed_websocket_message ( json_data ) data = json_data . is_a? ( Hash ) ? json_data . stringify_keys : { } if CelluloidPubsub :: Reactor :: AVAILABLE_ACTIONS . include? ( data [ 'client_action' ] . to_s ) log_debug "#{self.class} finds actions for #{json_data}" delegate_action ( data ) if data [ 'client_ac... | method that checks if the data is a Hash |
14,654 | def unsubscribe ( channel , _json_data ) log_debug "#{self.class} runs 'unsubscribe' method with #{channel}" return unless channel . present? forget_channel ( channel ) delete_server_subscribers ( channel ) end | the method will unsubscribe a client by closing the websocket connection if has unscribed from all channels and deleting the reactor from the channel list on the server |
14,655 | def delete_server_subscribers ( channel ) @server . mutex . synchronize do ( @server . subscribers [ channel ] || [ ] ) . delete_if do | hash | hash [ :reactor ] == Actor . current end end end | the method will delete the reactor from the channel list on the server |
14,656 | def unsubscribe_clients ( channel , _json_data ) log_debug "#{self.class} runs 'unsubscribe_clients' method with #{channel}" return if channel . blank? unsubscribe_from_channel ( channel ) @server . subscribers [ channel ] = [ ] end | the method will unsubscribe all clients subscribed to a channel by closing the |
14,657 | def add_subscriber_to_channel ( channel , message ) registry_channels = CelluloidPubsub :: Registry . channels @channels << channel registry_channels << channel unless registry_channels . include? ( channel ) @server . mutex . synchronize do @server . subscribers [ channel ] = channel_subscribers ( channel ) . push ( r... | adds the curent actor the list of the subscribers for a particular channel and registers the new channel |
14,658 | def publish ( current_topic , json_data ) message = json_data [ 'data' ] . to_json return if current_topic . blank? || message . blank? server_pusblish_event ( current_topic , message ) rescue => exception log_debug ( "could not publish message #{message} into topic #{current_topic} because of #{exception.inspect}" ) e... | method for publishing data to a channel |
14,659 | def server_pusblish_event ( current_topic , message ) @server . mutex . synchronize do ( @server . subscribers [ current_topic ] . dup || [ ] ) . pmap do | hash | hash [ :reactor ] . websocket << message end end end | the method will publish to all subsribers of a channel a message |
14,660 | def unsubscribe_all ( _channel , json_data ) log_debug "#{self.class} runs 'unsubscribe_all' method" CelluloidPubsub :: Registry . channels . dup . pmap do | channel | unsubscribe_clients ( channel , json_data ) end log_debug 'clearing connections' shutdown end | unsubscribes all actors from all channels and terminates the curent actor |
14,661 | def server_kill_reactors ( channel ) @server . mutex . synchronize do ( @server . subscribers [ channel ] . dup || [ ] ) . pmap do | hash | reactor = hash [ :reactor ] reactor . websocket . close Celluloid :: Actor . kill ( reactor ) end end end | kills all reactors registered on a channel and closes their websocket connection |
14,662 | def send ( options ) response = EmailDirect . post "/RelaySends/#{category_id}" , :body => options . to_json Hashie :: Mash . new ( response ) end | Sends a custom message . See the docs for all the possible options |
14,663 | def concat ( other ) other . rule_sets . each do | context_name , rule_set | add_rules_to_context ( context_name , rule_set ) end self end | Assimilate all rules contained in + other + into the receiver |
14,664 | def define_context ( context_name ) rule_sets . fetch ( context_name ) do | context_name | rule_sets [ context_name ] = RuleSet . new end self end | Initialize and assign a RuleSet for the named context |
14,665 | def do_http_get ( query_string ) response , data = @http . get ( query_string , @headers ) if response . code != '200' case response . code when '400' raise GatticaError :: AnalyticsError , response . body + " (status code: #{response.code})" when '401' raise GatticaError :: InvalidToken , "Your authorization token is ... | Does the work of making HTTP calls and then going through a suite of tests on the response to make sure it s valid and not an error |
14,666 | def build_query_string ( args , profile ) query_params = args . clone ga_start_date = query_params . delete ( :start_date ) ga_end_date = query_params . delete ( :end_date ) ga_dimensions = query_params . delete ( :dimensions ) ga_metrics = query_params . delete ( :metrics ) ga_sort = query_params . delete ( :sort ) ga... | Creates a valid query string for GA |
14,667 | def get_token full_path = build_request_path ( "/GetToken" ) response = conn . post do | req | req . url ( full_path ) req . body = { Username : @username , Password : @password } . to_json end raise ( GetTokenError , response . body ) unless response . status == 200 @token = response . body end | Instantiation of the Client |
14,668 | def get_user_authentication ( username , password ) @allscripts_username = username params = MagicParams . format ( user_id : username , parameter1 : password ) response = magic ( "GetUserAuthentication" , magic_params : params ) response [ "getuserauthenticationinfo" ] [ 0 ] end | Assign a security token from get_token to a specific Allscripts user . This creates a link on the Allscripts server that allows that token to be used in subsequent magic calls passed that user s username . |
14,669 | def validate_sso_token ( sso_token = nil ) sso_token ||= @sso_token params = MagicParams . format ( parameter1 : sso_token ) response = magic ( "GetTokenValidation" , magic_params : params ) response [ "Table" ] [ 0 ] end | Validate a token generated and passed by Allscripts during SSO Falls back and looks for sso_token on the client if not passed one Note that sso_token is not the token from get_token |
14,670 | def magic ( action , magic_params : MagicParams . format ) full_path = build_request_path ( "/MagicJson" ) body = build_magic_body ( action , magic_params ) response = conn . post do | req | req . url ( full_path ) req . body = body end read_magic_response ( action , response ) end | Main method for interacting with the Allscripts UnityAPI |
14,671 | def initialize_for_speed ( hash ) hash . each_pair do | k , v | key = key_as_sym ( k ) case v when Array value = v . map { | element | translate_value ( element ) } container . store ( key , value ) when Hash container . store ( key , NestedResult . new ( v ) ) else container . store ( key , v ) end end end | Don t create methods until first access |
14,672 | def set_proxy ( proxy_server_and_port = "" ) begin @proxy = URI . parse ( "http://" + ( ( proxy_server_and_port . empty? ) ? ENV [ 'HTTP_PROXY' ] : string_proxy ) ) @http = Net :: HTTP :: Proxy ( @proxy . host , @proxy . port ) rescue @proxy = nil @http = Net :: HTTP end end | Specify where your AirVideo Server lives . If your HTTP_PROXY environment variable is set it will be honoured . |
14,673 | def output_template ( outputs ) resource_name = outputs . keys [ 0 ] outputs_array = outputs . values [ 0 ] . collect each_output_join = outputs_array . collect { | output | { "Fn::Join" => [ "|" , output ] } } return resource_name => { 'Value' => { "Fn::Join" => [ "," , each_output_join ] } } end | Returns the Output template for resources |
14,674 | def configure_pagination ( page , options ) page = super ( page , options ) raise :: Folio :: InvalidPage unless page . current_page . is_a? ( Integer ) raise :: Folio :: InvalidPage if page . out_of_bounds? page rescue :: WillPaginate :: InvalidPage raise :: Folio :: InvalidPage end | validate the configured page before returning it |
14,675 | def add_to ( ec2 ) ec2_template = ec2 . template @instance_name = ec2 . name elastic_ip_template = template ec2 . template . inner_merge ( elastic_ip_template ) end | Initialize an ElasticIp |
14,676 | def put ( key , value ) value = value . to_f @input_values [ key ] = value @smallest_seen_values [ key ] ||= 0.0 if @largest_seen_values [ key ] == nil or @smallest_seen_values [ key ] > @largest_seen_values [ key ] @largest_seen_values [ key ] = @smallest_seen_values [ key ] + 1.0 end @smallest_seen_values [ key ] = v... | Store a value for the given key . Values will be scaled to the range 0 to 1 - the largest value yet seen will be scaled to 1 . 0 the smallest yet seen to 0 . 0 . |
14,677 | def assigned_key ( key ) return @key_assignments [ key ] if @key_assignments [ key ] available_keys = @input_values . keys - @key_assignments . values return nil if available_keys . empty? if available_keys . include? ( key ) @key_assignments [ key ] = key else @key_assignments [ key ] = available_keys [ rand ( availab... | Returns the input key assigned to the given get_unit key . If none is assigned randomly assigns one of the available input keys . |
14,678 | def search ( query ) query_vector = make_query_vector ( query ) ranks = @documents . map do | document | document_vector = make_vector ( document ) cosine_rank ( query_vector , document_vector ) end @records . each_with_index do | record , i | record . instance_eval %{def rank; #{ranks[i]}; end} end @records . reject {... | documentizer just takes a record and converts it to a string |
14,679 | def _init_event_data ( params ) @state = { reloaded : ! params [ :evnt ] . nil? , saved : true } initial_options = { exceptions : false , silent : false } default_options = _safe_default_options || { } params_options = params [ :_options ] || { } @options = initial_options . merge ( default_options ) . merge ( params_o... | This function initializes the event required data . |
14,680 | def add ( severity , message = nil , progname_or_message = nil , & block ) @logger . add ( severity , message , progname_or_message , & block ) if @logger end | Log a message at the given level if the logger is present |
14,681 | def _identify begin product = nil { "sfcb" => [ "root/interop" , "CIM_ObjectManager" ] , "pegasus" => [ "root/PG_Internal" , "PG_ConfigSetting" ] } . each do | cimom , op | obj = objectpath * op @client . instances ( obj ) . each do | inst | product = inst . Description || cimom break end break if product end rescue Sf... | identify client return identification string on error return nil and set |
14,682 | def each_instance ( namespace_or_objectpath , classname = nil ) op = if namespace_or_objectpath . is_a? Sfcc :: Cim :: ObjectPath namespace_or_objectpath else objectpath namespace_or_objectpath , classname end begin @client . instances ( op ) . each do | inst | yield inst end rescue Sfcc :: Cim :: ErrorInvalidClass , S... | Return instances for namespace and classname |
14,683 | def class_names op , deep_inheritance = false ret = [ ] unless op . is_a? Sfcc :: Cim :: ObjectPath op = Sfcc :: Cim :: ObjectPath . new ( op . to_s , nil ) end flags = deep_inheritance ? Sfcc :: Flags :: DeepInheritance : 0 begin @client . class_names ( op , flags ) . each do | name | ret << name . to_s end rescue Sfc... | Return list of classnames for given object_path |
14,684 | def each_association ( objectpath ) begin @client . associators ( objectpath ) . each do | assoc | yield assoc end rescue Sfcc :: Cim :: ErrorInvalidClass , Sfcc :: Cim :: ErrorInvalidNamespace end end | Return associations for instance |
14,685 | def get_token_from_hash ( hash ) access_token = hash . delete ( 'access_token' ) || hash . delete ( :access_token ) || hash . delete ( 'oauth_token' ) || hash . delete ( :oauth_token ) opts = { :expires_at => hash [ "expires" ] || hash [ :expires ] , :header_format => "OAuth2 %s" , :param_name => "access_token" } @toke... | Initializes an AccessToken from a hash |
14,686 | def epr_uri_for ( namespace , classname ) case @product when :winrm Openwsman :: epr_uri_for ( namespace , classname ) rescue "http://schema.suse.com/wbem/wscim/1/cim-schema/2/#{namespace}/#{classname}" else ( Openwsman :: epr_prefix_for ( classname ) + "/#{classname}" ) rescue "http://schema.suse.com/wbem/wscim/1/cim-... | create end point reference URI |
14,687 | def _handle_fault client , result if result . nil? STDERR . puts "Client connection failed:\n\tResult code #{client.response_code}, Fault: #{client.fault_string}" if Wbem . debug return true end if result . fault? fault = Openwsman :: Fault . new result if Wbem . debug STDERR . puts "Client protocol failed for (#{clien... | Handle client connection or protocol fault |
14,688 | def namespaces ns = "root" , cn = "__Namespace" result = [ ] each_instance ( ns , cn ) do | inst | name = "#{ns}/#{inst.Name}" result << name result . concat namespaces name , cn end result . uniq end | return list of namespaces |
14,689 | def class_names op , deep_inheritance = false @options . flags = Openwsman :: FLAG_ENUMERATION_OPTIMIZATION @options . max_elements = 999 namespace = ( op . is_a? Sfcc :: Cim :: ObjectPath ) ? op . namespace : op classname = ( op . is_a? Sfcc :: Cim :: ObjectPath ) ? op . classname : nil case @product when :openwsman i... | Enumerate class names |
14,690 | def download ( output_filename , options = { target_backup : nil } ) raise "Please specify a filename" if output_filename . length . eql? ( 0 ) HerokuCLI . cmd ( "pg:backups:download #{target_backup} --output #{output_filename}" , @app_name ) end | Download the latest backup |
14,691 | def store_on_s3 ( backup_location , backup_filename ) prod_backup_folder = AWS_S3 ( ) . buckets . find ( ENV [ "S3_PRODUCTION_BACKUP_BUCKET" ] ) . objects ( prefix : backup_location ) backup_obj = prod_backup_folder . build ( "#{backup_location}/#{backup_filename}" ) backup_obj . content = open ( @backup_filename ) bac... | Stores the recently backed up file in a specified S3 bucket |
14,692 | def gen_method_parameters direction , parameters , file return if parameters . empty? file . print "#{direction.inspect} => [" first = true parameters . each do | p | if first first = false else file . print ", " end file . print "#{p.name.inspect}, #{p.type.to_sym.inspect}" end file . print "]" return true end | generate method parameter information return nil if no parameters |
14,693 | def generate name , file require 'erb' template = File . read ( File . join ( File . dirname ( __FILE__ ) , "class_template.erb" ) ) erb = ERB . new ( template ) code = erb . result ( binding ) Dir . mkdir ( @basedir ) unless File . directory? ( @basedir ) File . open ( file , "w+" ) do | f | f . puts code end end | generate . rb class declaration |
14,694 | def classmap return @classmap if @classmap @classmap = Hash . new @includes = [ Pathname . new ( "." ) ] SCHEMATA . each do | base , file | @includes << base allow_cim = ( file =~ / / ) File . open ( File . join ( base , file ) ) do | f | f . each do | l | if l =~ / \# \s \s \( \" \w \/ \. \" \) / path = $1 names = $2 ... | classmap - generate map of classes and their . mof files |
14,695 | def query ( word ) node = @the_node results = [ ] word . split ( "" ) . each do | letter | next_node = node [ letter ] if next_node != nil node = next_node next else return [ '' ] end end results << Word . new ( word , node . final ) results += get_childs ( node ) . map { | s | Word . new ( word ) + s } results . selec... | get all words with given prefix |
14,696 | def _add ( v : nil , dupit : nil , oc : nil , patch : { } ) unless _pairs? case when self . kind_of? ( :: Set ) when self . kind_of? ( :: Array ) self << _ob_maybe_repl ( v : v , dupit : dupit , oc : oc , patch : patch ) else raise DeepDiveException . new ( "Don't know how to add new elements for class #{self.class}" )... | add a single element to the enumerable . You may pass a single parameter or a key value . In any case all will added . |
14,697 | def start self . sort_queues! for i in ( 1 .. max_threads ) @threads << Thread . new ( i ) do worker = QueueWorker . new worker . delay = @delay worker . retry_count = @retry_count worker . run end end end | Start up queue runners |
14,698 | def push ( g , w ) raise "no group specified" unless g create_group ( g ) if not ChimpQueue [ g ] ChimpQueue [ g ] . push ( w ) unless ChimpQueue [ g ] . get_job ( w . job_id ) end | Push a task into the queue |
14,699 | def shift r = nil @semaphore . synchronize do @group . values . each do | group | if group . ready? r = group . shift Log . debug "Shifting job '#{r.job_id}' from group '#{group.group_id}'" unless r . nil? break end end end return ( r ) end | Grab the oldest work item available |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.