idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
9,900 | def pre_apply_child ( child_index , workitem , forget ) child_fei = h . fei . merge ( 'expid' => "#{h.fei['expid']}_#{child_index}" , 'subid' => Ruote . generate_subid ( h . fei . inspect ) ) h . children << child_fei unless forget msg = { 'fei' => child_fei , 'tree' => tree . last [ child_index ] , 'parent_id' => forg... | Used locally but also by ConcurrenceExpression when preparing children before they get applied . |
9,901 | def apply_child ( child_index , workitem , forget = false ) msg = pre_apply_child ( child_index , workitem , forget ) persist_or_raise unless forget @context . storage . put_msg ( 'apply' , msg ) end | Used by expressions when well applying a child expression of theirs . |
9,902 | def leave_tag ( workitem ) unset_variable ( h . tagname ) Ruote :: Workitem . new ( workitem ) . send ( :remove_tag , h . tagname ) @context . storage . put_msg ( 'left_tag' , 'tag' => h . tagname , 'full_tag' => h . full_tagname , 'fei' => h . fei , 'workitem' => workitem ) return unless h . full_tagname r = root retu... | Called when the expression is about to reply to its parent and wants to get rid of its tags . |
9,903 | def do_merge ( field , target , value ) value = Rufus :: Json . dup ( value ) if target . is_a? ( Array ) target . push ( value ) elsif value . is_a? ( Hash ) target . merge! ( value ) else target [ field . split ( '.' ) . last ] = value end target . delete ( '~' ) target . delete ( '~~' ) end | Used by both _merge_to and _merge_from |
9,904 | def tags variables ? Hash [ variables . select { | k , v | Ruote . is_a_fei? ( v ) } ] : nil end | Returns a hash tagname = > fei of tags set at the root of the process instance . |
9,905 | def all_tags all_variables . remap do | ( fei , vars ) , h | vars . each { | k , v | ( h [ k ] ||= [ ] ) << v if Ruote . is_a_fei? ( v ) } end end | Returns a hash tagname = > array of feis of all the tags set in the process instance . |
9,906 | def wfid l = [ @expressions , @errors , @stored_workitems ] . find { | l | l . any? } l ? l . first . fei . wfid : nil end | Returns the unique identifier for this process instance . |
9,907 | def position workitems . collect { | wi | r = [ wi . fei . sid , wi . participant_name ] params = ( wi . fields [ 'params' ] || { } ) . dup params . delete ( 'ref' ) if err = errors . find { | e | e . fei == wi . fei } params [ 'error' ] = err . message end r << params r } end | Returns the position of the process . |
9,908 | def leaves expressions . inject ( [ ] ) { | a , exp | a . select { | e | ! exp . ancestor? ( e . fei ) } + [ exp ] } end | Returns the expressions where the flow is currently ak the leaves of the execution tree . |
9,909 | def workitems @expressions . select { | fexp | fexp . h . name == 'participant' } . collect { | fexp | Ruote :: Workitem . new ( fexp . h . applied_workitem ) } end | Returns a list of the workitems currently out to participants |
9,910 | def to_dot ( opts = { } ) s = [ "digraph \"process wfid #{wfid}\" {" ] @expressions . each { | e | s . push ( * e . send ( :to_dot , opts ) ) } @errors . each { | e | s . push ( * e . send ( :to_dot , opts ) ) } s << '}' s . join ( "\n" ) end | Returns a dot representation of the process . A graph describing the tree of flow expressions that compose the process . |
9,911 | def render_template ( template , flow_expression , workitem ) template = ( File . read ( template ) rescue nil ) if is_a_file? ( template ) return render_default_template ( workitem ) unless template template = template . to_s workitem = workitem . to_h if workitem . respond_to? ( :to_h ) @context . dollar_sub . s ( te... | Do the rendering . |
9,912 | def render_default_template ( workitem ) workitem = workitem . to_h if workitem . respond_to? ( :to_h ) s = [ ] s << "workitem for #{workitem['participant_name']}" s << '' s << Rufus :: Json . pretty_encode ( workitem [ 'fei' ] ) s << '' workitem [ 'fields' ] . keys . sort . each do | key | s << " - '#{key}' ==> #{Ru... | Simply returns a pretty - printed view of the workitem |
9,913 | def consider_participant_timers ( p_info ) return if h . has_timers timers = nil [ :rtimers , :timers , :rtimeout ] . each do | meth | pa = @context . plist . instantiate ( p_info , :if_respond_to? => meth ) next unless pa timers = Ruote . participant_send ( pa , meth , 'workitem' => Ruote :: Workitem . new ( h . appli... | Determines and schedules timeout if any . |
9,914 | def re_dispatch ( wi = nil , opts = nil ) wi , opts = [ nil , wi ] if wi . is_a? ( Hash ) && opts . nil? wi ||= workitem ( ) opts ||= { } wi . h . re_dispatch_count = wi . h . re_dispatch_count . to_s . to_i + 1 msg = { 'action' => 'dispatch' , 'fei' => wi . h . fei , 'workitem' => wi . to_h , 'participant_name' => wi ... | Use this method to re_dispatch the workitem . |
9,915 | def msg_handle ( msg , err ) fexp = Ruote :: Exp :: FlowExpression . fetch ( @context , msg [ 'fei' ] || msg [ 'workitem' ] [ 'fei' ] ) rescue nil handle ( msg , fexp , err ) end | As used by the dispatch pool and the worker . |
9,916 | def msg_raise ( msg , err ) fei = msg [ 'fei' ] wfid = msg [ 'wfid' ] || msg . fetch ( 'fei' , { } ) [ 'wfid' ] @context . storage . put_msg ( 'raise' , 'fei' => fei , 'wfid' => wfid , 'msg' => msg , 'error' => deflate ( err , fei ) ) end | Packages the error in a raise msg and places it in the storage for a worker to pick it up . |
9,917 | def handle ( msg , fexp , err ) err = RaisedError . new ( err ) unless err . respond_to? ( :backtrace ) meta = err . is_a? ( Ruote :: MetaError ) fei = msg [ 'fei' ] || ( fexp . h . fei rescue nil ) wfid = msg [ 'wfid' ] || ( fei || { } ) [ 'wfid' ] return if ( ! meta ) && fexp && fexp . handle_on_error ( msg , err ) h... | Called by msg_handle or action_handle . |
9,918 | def deflate ( err , fei , fexp = nil ) return err unless err . respond_to? ( :backtrace ) fexp ||= Ruote :: Exp :: FlowExpression . dummy ( 'fei' => fei , 'original_tree' => nil ) fexp . deflate ( err ) end | Returns a serializable hash with all the details of the error . |
9,919 | def expected_count if h . ccount . nil? count_list_size elsif h . ccount >= 0 [ h . ccount , count_list_size ] . min else i = count_list_size + h . ccount i < 1 ? 1 : i end end | How many branch replies are expected before the concurrence is over ? |
9,920 | def merge_workitems ( workitems , merge_type ) workitems . inject ( nil ) do | t , wi | Ruote . merge_workitem ( workitem_index ( wi ) , t , wi , merge_type ) end end | Given a list of workitems and a merge_type will merge according to the merge type . |
9,921 | def as_json ( pretty = false ) pretty ? Rufus :: Json . pretty_encode ( @h ) : Rufus :: Json . encode ( @h ) end | Encodes this workitem as JSON . If pretty is set to true will output prettified JSON . |
9,922 | def remove_tag ( tag ) tags = ( h . fields [ '__tags__' ] || [ ] ) if index = tags . rindex ( tag ) tags . delete_at ( index ) end h . fields [ '__left_tag__' ] = tag end | Used by FlowExpression when leaving a tag . |
9,923 | def dispatch ( msg ) participant = @context . plist . lookup ( msg [ 'participant' ] || msg [ 'participant_name' ] , msg [ 'workitem' ] ) if @context [ 'participant_threads_enabled' ] == false || do_not_thread? ( participant , msg ) then do_dispatch ( participant , msg ) else do_threaded_dispatch ( participant , msg ) ... | Dispatching the msg . |
9,924 | def do_dispatch ( participant , msg ) do_raw_dispatch ( participant , msg ) rescue => err @context . error_handler . msg_handle ( msg , err ) end | The raw dispatch work wrapped in error handling . |
9,925 | def do_threaded_dispatch ( participant , msg ) msg = Rufus :: Json . dup ( msg ) Thread . new { do_dispatch ( participant , msg ) } end | Wraps the call to do_dispatch in a thread . |
9,926 | def dispatch_cancel ( msg ) flavour = msg [ 'flavour' ] participant = @context . plist . instantiate ( msg [ 'participant' ] ) result = begin Ruote . participant_send ( participant , [ :on_cancel , :cancel ] , 'fei' => Ruote :: FlowExpressionId . new ( msg [ 'fei' ] ) , 'flavour' => flavour ) rescue => e raise ( e ) if... | Instantiates the participant and calls its cancel method . |
9,927 | def receive ( workitem ) workitem = workitem . to_h if workitem . respond_to? ( :to_h ) @context . storage . put_msg ( 'receive' , 'fei' => workitem [ 'fei' ] , 'workitem' => workitem , 'participant_name' => workitem [ 'participant_name' ] , 'receiver' => sign ) end | This method pipes back a workitem into the engine letting it resume in its flow hopefully . |
9,928 | def flunk ( workitem , error_class_or_instance_or_message , * err_arguments ) err = error_class_or_instance_or_message trace = Ruote . pop_trace ( err_arguments ) err = case err when Exception err when Class err . new ( * err_arguments ) when String begin Ruote . constantize ( err ) . new ( * err_arguments ) rescue Run... | Can be used to raise an error in the workflow instance . |
9,929 | def launch ( process_definition , fields = { } , variables = { } , root_stash = nil ) wfid = fields [ :wfid ] || @context . wfidgen . generate fields = Rufus :: Json . dup ( fields ) variables = Rufus :: Json . dup ( variables ) root_stash = Rufus :: Json . dup ( root_stash ) @context . storage . put_msg ( 'launch' , '... | Given a process definitions and optional initial fields and variables launches a new process instance . |
9,930 | def fetch_flow_expression ( workitem_or_fei ) Ruote :: Exp :: FlowExpression . fetch ( @context , Ruote :: FlowExpressionId . extract_h ( workitem_or_fei ) ) end | Convenience method given a workitem or a fei returns the corresponding flow expession . |
9,931 | def stash_get ( workitem_or_fei , key = nil ) stash = fetch_flow_expression ( workitem_or_fei ) . h [ 'stash' ] rescue nil stash ||= { } key ? stash [ key ] : stash end | Fetches back a stashed value . |
9,932 | def inactive? return false if @msgs . size > 0 return false unless @context . storage . empty? ( 'schedules' ) return false unless @context . storage . empty? ( 'msgs' ) wfids = @context . storage . get_many ( 'expressions' ) . collect { | exp | exp [ 'fei' ] [ 'wfid' ] } error_wfids = @context . storage . get_many ( '... | Returns true if the engine system is inactive ie if all the process instances are terminated or are stuck in an error . |
9,933 | def turn_schedule_to_msg ( schedule ) return false unless @storage . reserve ( schedule ) msg = Ruote . fulldup ( schedule [ 'msg' ] ) @storage . put_msg ( msg . delete ( 'action' ) , msg ) true end | Given a schedule attempts to trigger it . |
9,934 | def process ( msg ) return false unless @storage . reserve ( msg ) begin @context . pre_notify ( msg ) case msg [ 'action' ] when 'launch' , 'apply' , 'regenerate' launch ( msg ) when * EXP_ACTIONS Ruote :: Exp :: FlowExpression . do_action ( @context , msg ) when * DISP_ACTIONS @context . dispatch_pool . handle ( msg ... | Processes one msg . |
9,935 | def launch ( msg ) tree = msg [ 'tree' ] variables = msg [ 'variables' ] wi = msg [ 'workitem' ] exp_class = @context . expmap . expression_class ( tree . first ) if is_launch? ( msg , exp_class ) name = tree [ 1 ] [ 'name' ] || tree [ 1 ] . keys . find { | k | tree [ 1 ] [ k ] == nil } revision = tree [ 1 ] [ 'revisio... | Works for both the launch and the apply msgs . |
9,936 | def pause_process ( msg ) root = @storage . find_root_expression ( msg [ 'wfid' ] ) return unless root @storage . put_msg ( msg [ 'action' ] == 'pause_process' ? 'pause' : 'resume' , 'fei' => root [ 'fei' ] , 'wfid' => msg [ 'wfid' ] ) end | Handles pause_process and resume_process . |
9,937 | def reput ( msg ) if doc = msg [ 'doc' ] r = @storage . put ( doc ) return unless r . is_a? ( Hash ) doc [ '_rev' ] = r [ '_rev' ] reput ( msg ) elsif msg = msg [ 'msg' ] @storage . put_msg ( msg [ 'action' ] , msg ) end end | Reputs a doc or a msg . |
9,938 | def block_filter return nil if tree . last . empty? tree . last . collect { | line | next 'or' if line . first == 'or' rule = line [ 1 ] . remap { | ( k , v ) , h | if v == nil h [ 'field' ] = k else h [ k ] = v end } rule [ 'field' ] ||= line . first rule } end | Filter is passed in a block ( which is not evaluted as a ruote branch but immediately translated into a filter . |
9,939 | def one_line_filter if ( attributes . keys - COMMON_ATT_KEYS - %w[ ref original_ref ] ) . empty? return nil end [ attributes . remap { | ( k , v ) , h | if v . nil? h [ 'field' ] = k else h [ k ] = v end } ] end | Filter thanks to the attributes of the expression . |
9,940 | def compile_variables vars = h . parent_id ? parent . compile_variables : { } vars . merge! ( h . variables ) if h . variables vars end | Returns a fresh hash of all the variables visible from this expression . |
9,941 | def unset_variable ( var , override = false ) fexp , v = locate_set_var ( var , override ) || locate_var ( var ) fexp . un_set_variable ( :unset , v , nil , ( fexp . h . fei != h . fei ) ) if fexp end | Unbinds a variables . |
9,942 | def split_prefix ( var , prefix ) if prefix . nil? m = VAR_PREFIX_REGEX . match ( var . to_s ) prefix = m [ 1 ] var = m [ 2 ] end [ var , prefix ] end | Used by lookup_variable and set_variable to extract the prefix in a variable name |
9,943 | def walk ( fexp , tree ) ftree = Ruote . compact_tree ( @ps . current_tree ( fexp ) ) if ftree [ 0 ] != tree [ 0 ] || ftree [ 1 ] != tree [ 1 ] register ( MutationPoint . new ( fexp . fei , tree , :re_apply ) ) elsif ftree [ 2 ] == tree [ 2 ] return else register ( MutationPoint . new ( fexp . fei , tree , :update ) ) ... | Look for mutation points in an expression and its children . |
9,944 | def walk_sequence ( fexp , ftree , tree ) i = fexp . child_ids . first ehead = ftree [ 2 ] . take ( i ) ecurrent = ftree [ 2 ] [ i ] etail = ftree [ 2 ] . drop ( i + 1 ) head = tree [ 2 ] . take ( i ) current = tree [ 2 ] [ i ] tail = tree [ 2 ] . drop ( i + 1 ) if ehead != head register ( MutationPoint . new ( fexp . ... | Look for mutation points in any non - concurrent expression . |
9,945 | def move_on ( workitem = h . applied_workitem ) position = workitem [ 'fei' ] == h . fei ? - 1 : Ruote :: FlowExpressionId . child_id ( workitem [ 'fei' ] ) position += 1 com , arg = get_command ( workitem ) return reply_to_parent ( workitem ) if com == 'break' case com when 'rewind' , 'continue' , 'reset' then positio... | Determines which child expression of the cursor is to be applied next . |
9,946 | def jump_to ( workitem , position , arg ) pos = Integer ( arg ) rescue nil return pos if pos != nil tree_children . each_with_index do | c , i | found = [ c [ 0 ] , c [ 1 ] [ 'ref' ] , c [ 1 ] [ 'tag' ] , ( c [ 1 ] . find { | k , v | v . nil? } || [ ] ) . first ] . find do | v | v ? ( dsub ( v , workitem ) == arg ) : f... | Jumps to an integer position or the name of an expression or a tag name of a ref name . |
9,947 | def clear %w[ msgs schedules errors expressions workitems ] . each do | type | purge_type! ( type ) end end | Used when doing integration tests removes all msgs schedules errors expressions and workitems . |
9,948 | def remove_process ( wfid ) 2 . times do Thread . pass %w[ schedules expressions errors workitems ] . each do | type | get_many ( type , wfid ) . each { | d | delete ( d ) } end doc = get_trackers doc [ 'trackers' ] . delete_if { | k , v | k . end_with? ( "!#{wfid}" ) } @context . storage . put ( doc ) end end | Removes a process by removing all its schedules expressions errors workitems and trackers . |
9,949 | def prepare_msg_doc ( action , options ) @counter ||= 0 t = Time . now . utc ts = "#{t.strftime('%Y-%m-%d')}!#{t.to_i}.#{'%06d' % t.usec}" _id = "#{$$}!#{Thread.current.object_id}!#{ts}!#{'%03d' % @counter}" @counter = ( @counter + 1 ) % 1000 msg = options . merge! ( 'type' => 'msgs' , '_id' => _id , 'action' => action... | Used by put_msg |
9,950 | def prepare_schedule_doc ( flavour , owner_fei , s , msg ) at = if s . is_a? ( Time ) s elsif Ruote . cron_string? ( s ) Rufus :: Scheduler :: CronLine . new ( s ) . next_time ( Time . now + 1 ) else Ruote . s_to_at ( s ) end at = at . utc if at <= Time . now . utc && flavour == 'at' put_msg ( msg . delete ( 'action' )... | Used by put_schedule |
9,951 | def handle_on_error ( msg , error ) return false if h . state == 'failing' err = deflate ( error ) oe_parent = lookup_on_error ( err ) return false unless oe_parent handler = oe_parent . local_on_error ( err ) return false if handler . to_s == '' workitem = msg [ 'workitem' ] workitem [ 'fields' ] [ '__error__' ] = err... | Looks up parent with on_error attribute and triggers it |
9,952 | def local_on_error ( err ) if h . on_error . is_a? ( String ) or Ruote . is_tree? ( h . on_error ) return h . on_error end if h . on_error . is_a? ( Array ) h . on_error . each do | oe | if ( he = HandlerEntry . new ( oe ) ) . match ( err ) return he . narrow end end end nil end | Given an error returns the on_error registered for it or nil if none . |
9,953 | def remove ( tracker_ids , wfid ) return if tracker_ids . empty? doc ||= @context . storage . get_trackers ( wfid ) return if ( doc [ 'trackers' ] . keys & tracker_ids ) . empty? doc [ 'wfid' ] = wfid tracker_ids . each { | ti | doc [ 'trackers' ] . delete ( ti ) } r = @context . storage . put ( doc ) remove ( tracker_... | Removes a set of tracker ids and updated the tracker document . |
9,954 | def on_message ( pre , message ) m_wfid = message [ 'wfid' ] || ( message [ 'fei' ] [ 'wfid' ] rescue nil ) m_error = message [ 'error' ] m_action = message [ 'action' ] m_action = "pre_#{m_action}" if pre msg = m_action == 'error_intercepted' ? message [ 'msg' ] : message ids_to_remove = [ ] trackers . each do | track... | The method behind on_pre_msg and on_msg . Filters msgs against trackers . Triggers trackers if there is a match . |
9,955 | def alter ( m_wfid , m_error , m_action , msg , tracker ) case tracker [ 'msg' ] . delete ( '_alter' ) when 'merge' then msg . merge! ( tracker [ 'msg' ] ) end end | Alters the msg only called in pre mode . |
9,956 | def trigger ( m_wfid , m_error , m_action , msg , tracker ) t_action = tracker [ 'action' ] tracker_id = tracker [ 'id' ] m = Ruote . fulldup ( tracker [ 'msg' ] ) action = m . delete ( 'action' ) m [ 'wfid' ] = m_wfid if m [ 'wfid' ] == 'replace' m [ 'wfid' ] ||= @context . wfidgen . generate m [ 'workitem' ] = msg [ ... | Prepares the message that gets placed on the ruote msg queue . |
9,957 | def does_match? ( msg , conditions ) return true unless conditions conditions . each do | k , v | return false unless Array ( v ) . find do | vv | vv = Ruote . regex_or_s ( vv ) val = case k when 'class' then msg [ 'error' ] [ 'class' ] when 'message' then msg [ 'error' ] [ 'message' ] else Ruote . lookup ( msg , k ) e... | Given a msg and a hash of conditions returns true if the msg matches the conditions . |
9,958 | def on_msg ( msg ) puts ( fancy_print ( msg , @noisy ) ) if @noisy return if msg [ 'action' ] == 'noop' @mutex . synchronize do @seen << msg @log << msg while @log . size > @log_max ; @log . shift ; end while @seen . size > @log_max ; @seen . shift ; end end end | The context will call this method for each msg sucessfully processed by the worker . |
9,959 | def wait_for ( interests , opts = { } ) @waiting << [ Thread . current , interests ] Thread . current [ '__result__' ] = nil start = Time . now to = opts [ :timeout ] || @timeout to = nil if to . nil? || to <= 0 loop do raise ( Ruote :: LoggerTimeout . new ( interests , to ) ) if to && ( Time . now - start ) > to @mute... | Blocks until one or more interests are satisfied . |
9,960 | def matches ( interests , msg ) action = msg [ 'action' ] interests . each do | interest | satisfied = case interest when :or_error interests . clear if action == 'error_intercepted' when :inactive ( FINAL_ACTIONS . include? ( action ) && @context . worker . inactive? ) when :empty ( action == 'terminated' && @context ... | Checks whether message msg matches any of interests being waited for . |
9,961 | def has_service? ( service_name ) service_name = service_name . to_s service_name = "s_#{service_name}" if ! SERVICE_PREFIX . match ( service_name ) @services . has_key? ( service_name ) end | Returns true if this context has a given service registered . |
9,962 | def do_p ( pers ) case r = pers ? try_persist : try_unpersist when true false when Hash self . h = r self . send ( "do_#{@msg['action']}" , @msg ) if @msg false else true end end | Does persist or unpersist if successful then returns true . If the expression is gone returns false . If there is a fresher version of the expression re - attempt and returns false . |
9,963 | def on_workitem doc = workitem . to_h doc . merge! ( 'type' => 'workitems' , '_id' => to_id ( doc [ 'fei' ] ) , 'participant_name' => doc [ 'participant_name' ] , 'wfid' => doc [ 'fei' ] [ 'wfid' ] ) doc [ 'store_name' ] = @store_name if @store_name @context . storage . put ( doc , :update_rev => true ) end | This is the method called by ruote when passing a workitem to this participant . |
9,964 | def proceed ( workitem ) r = remove_workitem ( 'proceed' , workitem ) return proceed ( workitem ) if r != nil workitem . h . delete ( '_rev' ) reply_to_engine ( workitem ) end | Removes the workitem from the storage and replies to the engine . |
9,965 | def flunk ( workitem , err_class_or_instance , * err_arguments ) r = remove_workitem ( 'reject' , workitem ) return flunk ( workitem ) if r != nil workitem . h . delete ( '_rev' ) super ( workitem , err_class_or_instance , * err_arguments ) end | Removes the workitem and hands it back to the flow with an error to raise for the participant expression that emitted the workitem . |
9,966 | def all ( opts = { } ) res = fetch_all ( opts ) res . is_a? ( Array ) ? res . map { | hwi | Ruote :: Workitem . new ( hwi ) } : res end | Returns all the workitems stored in here . |
9,967 | def by_wfid ( wfid , opts = { } ) if @context . storage . respond_to? ( :by_wfid ) return @context . storage . by_wfid ( 'workitems' , wfid , opts ) end wis ( @context . storage . get_many ( 'workitems' , wfid , opts ) ) end | Return all workitems for the specified wfid |
9,968 | def by_participant ( participant_name , opts = { } ) return @context . storage . by_participant ( 'workitems' , participant_name , opts ) if @context . storage . respond_to? ( :by_participant ) do_select ( opts ) do | hwi | hwi [ 'participant_name' ] == participant_name end end | Returns all workitems for the specified participant name |
9,969 | def query ( criteria ) cr = Ruote . keys_to_s ( criteria ) if @context . storage . respond_to? ( :query_workitems ) return @context . storage . query_workitems ( cr ) end opts = { } opts [ :skip ] = cr . delete ( 'offset' ) || cr . delete ( 'skip' ) opts [ :limit ] = cr . delete ( 'limit' ) opts [ :count ] = cr . delet... | Queries the store participant for workitems . |
9,970 | def per_participant_count per_participant . remap { | ( k , v ) , h | h [ k ] = v . size } end | Mostly a test method . Returns a Hash were keys are participant names and values are integers the count of workitems for a given participant name . |
9,971 | def delegate ( workitem , new_owner ) hwi = fetch ( workitem ) fail ArgumentError . new ( "workitem not found" ) if hwi == nil fail ArgumentError . new ( "cannot delegate, workitem doesn't belong to anyone" ) if hwi [ 'owner' ] == nil fail ArgumentError . new ( "cannot delegate, " + "workitem owned by '#{hwi['owner']}'... | Delegates a currently owned workitem to a new owner . |
9,972 | def do_select ( opts , & block ) skip = opts [ :offset ] || opts [ :skip ] limit = opts [ :limit ] count = opts [ :count ] hwis = fetch_all ( { } ) hwis = hwis . select ( & block ) hwis = hwis [ skip .. - 1 ] if skip hwis = hwis [ 0 , limit ] if limit return hwis . size if count hwis . collect { | hwi | Ruote :: Workit... | Given a few options and a block returns all the workitems that match the block |
9,973 | def to_id ( fei ) a = [ Ruote . to_storage_id ( fei ) ] a . unshift ( @store_name ) if @store_name a . unshift ( 'wi' ) a . join ( '!' ) end | Computes the id for the document representing the document in the storage . |
9,974 | def fetch_command_target ( exp = parent ) case exp when nil then nil when Ruote :: Exp :: CommandedExpression then exp else fetch_command_target ( exp . parent ) end end | Walks up the expression tree ( process instance and returns the first expression that includes the CommandMixin |
9,975 | def lookup_code wi = workitem rev = wi . params [ 'revision' ] || wi . params [ 'rev' ] [ [ wi . wf_name , wi . wf_revision , wi . participant_name , rev ] , [ wi . wf_name , wi . wf_revision , wi . participant_name ] , [ wi . wf_name , '' , wi . participant_name ] , [ wi . participant_name , rev ] , [ wi . participant... | Maybe lookup_real_participant_code would be a better name ... |
9,976 | def reply ( workitem ) if workitem [ 'fei' ] == h . fei h . test = attribute ( :test ) h . test = attribute ( :t ) if h . test . nil? h . test = attribute_text if h . test . nil? h . test = nil if h . test == '' offset = ( h . test . nil? || Condition . true? ( h . test ) ) ? 0 : 1 apply_child ( offset , workitem ) els... | called by else then or perhaps equals |
9,977 | def unregister ( name_or_participant ) code = nil entry = nil list = get_list name_or_participant = name_or_participant . to_s entry = list [ 'list' ] . find { | re , pa | name_or_participant . match ( re ) } return nil unless entry code = entry . last if entry . last . is_a? ( String ) list [ 'list' ] . delete ( entry... | Removes a participant given via its name or directly from this participant list . |
9,978 | def lookup ( participant_name , workitem , opts = { } ) pinfo = participant_name . is_a? ( String ) ? lookup_info ( participant_name , workitem ) : participant_name instantiate ( pinfo , opts ) end | Returns a participant instance or nil if there is no participant for the given participant name . |
9,979 | def lookup_info ( pname , workitem ) return nil unless pname wi = workitem ? Ruote :: Workitem . new ( workitem . merge ( 'participant_name' => pname ) ) : nil get_list [ 'list' ] . each do | regex , pinfo | next unless pname . match ( regex ) return pinfo if workitem . nil? pa = instantiate ( pinfo , :if_respond_to? =... | Given a participant name returns participant details . |
9,980 | def instantiate ( pinfo , opts = { } ) return nil unless pinfo pa_class_name , options = pinfo if rp = options [ 'require_path' ] require ( rp ) end if lp = options [ 'load_path' ] load ( lp ) end pa_class = Ruote . constantize ( pa_class_name ) pa_m = pa_class . instance_methods irt = opts [ :if_respond_to? ] if irt &... | Returns an instance of a participant . |
9,981 | def create_user_playlist ( user_id , name , is_public = true ) run ( :post , "/v1/users/#{user_id}/playlists" , [ 201 ] , JSON . dump ( name : name , public : is_public ) , false ) end | Create a playlist for a Spotify user . The playlist will be empty until you add tracks . |
9,982 | def add_user_tracks_to_playlist ( user_id , playlist_id , uris = [ ] , position = nil ) params = { uris : Array . wrap ( uris ) [ 0 .. 99 ] . join ( ',' ) } if position params . merge! ( position : position ) end run ( :post , "/v1/users/#{user_id}/playlists/#{playlist_id}/tracks" , [ 201 ] , JSON . dump ( params ) , f... | Add an Array of track uris to an existing playlist . |
9,983 | def follow ( type , ids ) params = { type : type , ids : Array . wrap ( ids ) . join ( ',' ) } run ( :put , "/v1/me/following" , [ 204 ] , params ) end | Follow artists or users |
9,984 | def url url_params = { :host => @host , :port => @port , :path => "/_status" , :query => "format=xml" } @ssl ? URI :: HTTPS . build ( url_params ) : URI :: HTTP . build ( url_params ) end | Create a new instance of the status class with the given options |
9,985 | def get uri = self . url http = Net :: HTTP . new ( uri . host , uri . port ) if @ssl http . use_ssl = true http . verify_mode = OpenSSL :: SSL :: VERIFY_NONE end request = Net :: HTTP :: Get . new ( uri . request_uri ) if @auth request . basic_auth ( @username , @password ) end request [ "User-Agent" ] = "Monit Ruby c... | Get the status from Monit . |
9,986 | def parse ( xml ) @hash = Hash . from_xml ( xml ) @server = Server . new ( @hash [ "monit" ] [ "server" ] ) @platform = Platform . new ( @hash [ "monit" ] [ "platform" ] ) options = { :host => @host , :port => @port , :ssl => @ssl , :auth => @auth , :username => @username , :password => @password } if @hash [ "monit" ]... | Parse the XML from Monit into a hash and into a Ruby representation . |
9,987 | def artifact ( name , version ) unless artifact? ( name , version ) artifact = Artifact . new ( self , name , version ) @artifacts [ "#{name}-#{version}" ] = artifact @artifacts_by_name [ name ] << artifact end @artifacts [ "#{name}-#{version}" ] end | Add an artifact to the graph |
9,988 | def versions ( name , constraint = Semverse :: DEFAULT_CONSTRAINT ) constraint = Semverse :: Constraint . coerce ( constraint ) if constraint == Semverse :: DEFAULT_CONSTRAINT @artifacts_by_name [ name ] else @artifacts_by_name [ name ] . select do | artifact | constraint . satisfies? ( artifact . version ) end end end | Return all the artifacts from the collection of artifacts with the given name . |
9,989 | def satisfies? ( target ) target = Semverse :: Version . coerce ( target ) return false if ! ( version == 0 ) && greedy_match? ( target ) compare ( target ) end | Returns true or false if the given version would be satisfied by the version constraint . |
9,990 | def solve_demands ( demands_as_constraints ) selector = DepSelector :: Selector . new ( ds_graph , ( timeout_ms / 1000.0 ) ) selector . find_solution ( demands_as_constraints , all_artifacts ) rescue DepSelector :: Exceptions :: InvalidSolutionConstraints => e report_invalid_constraints_error ( e ) rescue DepSelector :... | Runs the solver with the set of demands given . If any DepSelector exceptions are raised they are rescued and re - raised |
9,991 | def requirement_satisfied_by? ( requirement , activated , spec ) version = spec . version return false unless requirement . constraint . satisfies? ( version ) shared_possibility_versions = possibility_versions ( requirement , activated ) return false if ! shared_possibility_versions . empty? && ! shared_possibility_ve... | Callback required by Molinillo Determines whether the given requirement is satisfied by the given spec in the context of the current activated dependency graph . |
9,992 | def possibility_versions ( requirement , activated ) activated . vertices . values . flat_map do | vertex | next unless vertex . payload next unless vertex . name == requirement . name if vertex . payload . respond_to? ( :possibilities ) vertex . payload . possibilities . map ( & :version ) else vertex . payload . vers... | Searches the current dependency graph to find previously activated requirements for the current artifact . |
9,993 | def clock ( frequency ) options = { 4000 => 0 , 8000 => 32768 , 15625 => 16384 , 31250 => 8192 , 62500 => 4096 , 125000 => 2048 , 250000 => 1024 , 500000 => 512 , 1000000 => 256 , 2000000 => 128 , 4000000 => 64 , 8000000 => 32 , 20000000 => 16 } divider = options [ frequency ] PiPiper . driver . spi_clock ( divider ) e... | Sets the SPI clock frequency |
9,994 | def chip_select ( chip = CHIP_SELECT_0 ) chip = @chip if @chip PiPiper . driver . spi_chip_select ( chip ) if block_given? begin yield ensure PiPiper . driver . spi_chip_select ( CHIP_SELECT_NONE ) end end end | Activate a specific chip so that communication can begin |
9,995 | def chip_select_active_low ( active_low , chip = nil ) chip = @chip if @chip chip = CHIP_SELECT_0 unless chip PiPiper . driver . spi_chip_select_polarity ( chip , active_low ? 0 : 1 ) end | Configure the active state of the chip select line |
9,996 | def write ( * args ) case args . count when 0 raise ArgumentError , "missing arguments" when 1 data = args . first else data = args end enable do case data when Numeric PiPiper . driver . spi_transfer ( data ) when Enumerable PiPiper . driver . spi_transfer_bytes ( data ) else raise ArgumentError , "#{data.class} is no... | Write to the bus |
9,997 | def add_subview ( view_or_constant , opts = { } ) subviews_added = [ ] selected . each do | selected_view | created = false appended = false built = false if view_or_constant . is_a? ( UIView ) new_view = view_or_constant else created = true new_view = create_view ( view_or_constant , opts ) end rmq_data = new_view . r... | This is used by build create and append . You really shouldn t use it directly . Although it s totally fine if you do |
9,998 | def find_or_append ( view_or_constant , style = nil , opts = { } , & block ) if style && ( q = self . find ( style ) ) && q . length > 0 view_or_constant = q . get end append ( view_or_constant , style , opts , & block ) end | Same as append but will look for a view with the same name and reapply styles to it if it finds one . If it doesn t it ll append as normal . |
9,999 | def find_or_append! ( view_or_constant , style = nil , opts = { } , & block ) find_or_append ( view_or_constant , style , opts , & block ) . get end | Same as append! but will look for a view with the same name and reapply styles to it if it finds one . If it doesn t it ll append! as normal . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.