Module Ruote
In: lib/ruote/engine.rb
lib/ruote/merge.rb
lib/ruote/fei.rb
lib/ruote/util/filter.rb
lib/ruote/util/process_observer.rb
lib/ruote/util/misc.rb
lib/ruote/util/deep.rb
lib/ruote/util/lookup.rb
lib/ruote/util/time.rb
lib/ruote/util/ometa.rb
lib/ruote/util/hashdot.rb
lib/ruote/util/subprocess.rb
lib/ruote/util/look.rb
lib/ruote/util/tree.rb
lib/ruote/context.rb
lib/ruote/workitem.rb
lib/ruote/version.rb
lib/ruote/id/mnemo_wfid_generator.rb
lib/ruote/id/wfid_generator.rb
lib/ruote/receiver/base.rb
lib/ruote/svc/dollar_sub.rb
lib/ruote/svc/treechecker.rb
lib/ruote/svc/participant_list.rb
lib/ruote/svc/expression_map.rb
lib/ruote/svc/dispatch_pool.rb
lib/ruote/svc/error_handler.rb
lib/ruote/svc/tracker.rb
lib/ruote/tree_dot.rb
lib/ruote/reader/json.rb
lib/ruote/reader/xml.rb
lib/ruote/reader/ruby_dsl.rb
lib/ruote/reader/radial.rb
lib/ruote/log/storage_history.rb
lib/ruote/log/default_history.rb
lib/ruote/log/wait_logger.rb
lib/ruote/observer.rb
lib/ruote/worker.rb
lib/ruote/extract.rb
lib/ruote/exp/fe_error.rb
lib/ruote/dashboard.rb
lib/ruote/dboard/mutation.rb
lib/ruote/dboard/process_status.rb
lib/ruote/dboard/process_error.rb
lib/ruote/reader.rb
lib/ruote/part/template.rb
lib/ruote/part/participant.rb
lib/ruote/part/smtp_participant.rb
lib/ruote/part/rev_participant.rb
lib/ruote/part/no_op_participant.rb
lib/ruote/part/block_participant.rb
lib/ruote/part/storage_participant.rb
lib/ruote/part/local_participant.rb
lib/ruote/part/engine_participant.rb
lib/ruote/part/null_participant.rb
lib/ruote/part/code_participant.rb
lib/ruote/storage/base.rb
lib/ruote/storage/composite_storage.rb
lib/ruote/storage/fs_storage.rb
lib/ruote/storage/hash_storage.rb

Methods

Classes and Modules

Module Ruote::Dollar
Module Ruote::Exp
Module Ruote::HashDot
Module Ruote::JsonReader
Module Ruote::LocalParticipant
Module Ruote::Look
Module Ruote::Mem
Module Ruote::RadialReader
Module Ruote::ReceiverMixin
Module Ruote::RubyDsl
Module Ruote::RubyReader
Module Ruote::StorageBase
Module Ruote::TemplateMixin
Module Ruote::WithH
Module Ruote::WithMeta
Module Ruote::XmlReader
Class Ruote::BlankSlate
Class Ruote::BlockParticipant
Class Ruote::CodeParticipant
Class Ruote::CompositeStorage
Class Ruote::Context
Class Ruote::Dashboard
Class Ruote::DefaultHistory
Class Ruote::DispatchPool
Class Ruote::DollarSubstitution
Class Ruote::Engine
Class Ruote::EngineParticipant
Class Ruote::EngineVariables
Class Ruote::ErrorHandler
Class Ruote::ExpressionMap
Class Ruote::FlowExpressionId
Class Ruote::ForcedError
Class Ruote::FsStorage
Class Ruote::HashStorage
Class Ruote::LoggerTimeout
Class Ruote::MetaError
Class Ruote::MnemoWfidGenerator
Class Ruote::Mutation
Class Ruote::MutationPoint
Class Ruote::NoOpParticipant
Class Ruote::NullParticipant
Class Ruote::Observer
Class Ruote::Participant
Class Ruote::ParticipantEntry
Class Ruote::ParticipantList
Class Ruote::ParticipantRegistrationProxy
Class Ruote::ProcessError
Class Ruote::ProcessObserver
Class Ruote::ProcessStatus
Class Ruote::Reader
Class Ruote::Receiver
Class Ruote::RevParticipant
Class Ruote::RuleSession
Class Ruote::SmtpParticipant
Class Ruote::StorageHistory
Class Ruote::StorageParticipant
Class Ruote::TestContext
Class Ruote::Tracker
Class Ruote::TreeChecker
Class Ruote::ValidationError
Class Ruote::WaitLogger
Class Ruote::WfidGenerator
Class Ruote::Worker
Class Ruote::Workitem

Constants

WIN = (RUBY_PLATFORM.match(/mswin|mingw/) != nil)   Will be set to true if the Ruby runtime is on Windows
JAVA = (RUBY_PLATFORM.match(/java/) != nil)   Will be set to true if the Ruby runtime is JRuby
REGEX_IN_STRING = /^\s*\/(.*)\/\s*$/
VERSION = '2.3.0.3'
DUMMY_WORKER = OpenStruct.new( :name => 'worker', :identity => 'unknown', :state => 'running')   A helper for the worker method, it returns that dummy worker when there is no reference to the calling worker in the current thread‘s local variables.
SUBS = %w[ subid sub_wfid ]
IDS = %w[ engine_id expid wfid ]

External Aliases

deep_delete -> delete_all
to_tree -> tree

Public Class methods

Our own quick camelize implementation (no need to require active support).

Returns an array. If the argument is an array, return it as is. Else turns the argument into a string and "comma splits" it.

Compacts

  [ 'participant', { 'ref' => 'sam' }, [] ] # and
  [ 'subprocess', { 'ref' => 'compute_prime' }, [] ]

into

  [ 'sam', {}, [] ] # and
  [ 'compute_prime', {}, [] ]

to simplify tree comparisons.

(simpler than the one from active_support)

Waiting for a better implementation of it in rufus-scheduler 2.0.4

Warning, this is not equivalent to doing @context.worker, this method fetches the worker from the local thread variables.

Quick decamelize implementation.

Used by some projects, used to be called from Ruote::ProcessStatus.

Given a tree

  [ 'define', { 'name' => 'nada' }, [
    [ 'sequence', {}, [ [ 'alpha', {}, [] ], [ 'bravo', {}, [] ] ] ]
  ] ]

will output something like

  { '0' => [ 'define', { 'name' => 'nada' } ],
    '0_0' => [ 'sequence', {} ],
    '0_0_0' => [ 'alpha', {} ],
    '0_0_1' => [ 'bravo', {} ] },

An initial offset can be specifid with the ‘pos’ argument.

Don‘t touch ‘h’, it‘s an accumulator.

Given a hash and a key, deletes all the entries with that key, in child hashes too.

Note: this method is not related to the "dot notation" methods in this lookup.rb file.

example

  h = { 'a' => 1, 'b' => { 'a' => 2 } }
  Ruote.deep_delete(h, 'a')
    # => { 'b' => {} }

Inspired by the one found in ActiveSupport, though not strictly equivalent.

Dives into a nested structure of hashes and arrays to find match hash keys.

The method expects a block with 3 or 4 arguments.

3 arguments: collection, key and value 4 arguments: parent collection, collection, key and value

Warning: .deep_mutate forces hash keys to be strings. It‘s a JSON world.

example

  h = {
    'a' => 0,
    'b' => 1,
    'c' => { 'a' => 2, 'b' => { 'a' => 3 } },
    'd' => [ { 'a' => 0 }, { 'b' => 4 } ] }

  Ruote.deep_mutate(h, 'a') do |coll, k, v|
    coll['a'] = 10
  end

  h # =>
    { 'a' => 10,
      'b' => 1,
      'c' => { 'a' => 10, 'b' => { 'a' => 10 } },
      'd' => [ { 'a' => 10 }, { 'b' => 4 } ] }

variations

Instead of a single key, it‘s OK to pass an array of keys:

  Ruote.deep_mutate(a, [ 'a', 'b' ]) do |coll, k, v|
    # ...
  end

Regular expressions are made to match:

  Ruote.deep_mutate(a, [ 'a', /^a\./ ]) do |coll, k, v|
    # ...
  end

A single regular expression is OK:

  Ruote.deep_mutate(a, /^user\./) do |coll, k, v|
    # ...
  end

Not really a reader, more an AST builder.

  pdef = Ruote.define :name => 'take_out_garbage' do
    sequence do
      take_out_regular_garbage
      take_out_glass
      take_out_paper
    end
  end

  engine.launch(pdef)

Given something that might be a fei, extract the child_id (the last portion of the expid in the fei).

Given something, tries to return the fei (Ruote::FlowExpressionId) in it.

Given a context and a fei (FlowExpressionId or Hash) or a flow expression (Ruote::Exp::FlowExpression or Hash) return the desired Ruote::Exp::FlowExpression instance.

Will do its best to return a wfid (String) or a fei (Hash instance) extract from the given o argument.

Given an object, will return the wfid (workflow instance id) nested into it (or nil if it can‘t find or doesn‘t know how to find).

The wfid is a String instance.

Given a filter (a list of rules) and a hash (probably workitem fields) performs the validations / transformations dictated by the rules.

See the Ruote::Exp::FilterExpression for more information.

Ruote.flatten_keys({ ‘a’ => ‘b’, ‘c’ => [ 1, 2, 3 ] })

  # =>

[ ‘a’, ‘c’, ‘c.0’, ‘c.1’, ‘c.2’ ]

Deep object duplication

This function is used to generate the subids. Each flow expression receives such an id (it‘s useful for cursors, loops and forgotten branches).

h = { ‘a’ => { ‘b’ => [ 1, 3, 4 ] } }

p Ruote.lookup(h, ‘a.b.1’) # => true

A bit like inspect but produces a tighter output (ambiguous to machines).

Returns true if the h is a representation of a FlowExpressionId instance.

Returns true if the argument is a process definition tree (whose root is ‘define’, ‘process_definition’ or ‘workflow_definition’.

Mainly used by Ruote.lookup_subprocess, returns true if the argument is is an array [ position, tree ].

Returns true if the given argument is a process definition tree (its root doesn‘t need to be ‘define’ or ‘process_definition’ though).

Returns true if the string seems to correpond to a URI

TODO : wouldn‘t it be better to simply use URI.parse() ?

Makes sure all they keys in the given hash are turned into strings in the resulting hash.

Makes sure all they keys in the given hash are turned into symbols in the resulting hash.

Mostly used in ruote-amqp.

From coderrr.wordpress.com/2008/05/28/get-your-local-ip-address/

Returns the (one of the) local IP address.

h = { ‘a’ => { ‘b’ => [ 1, 3, 4 ] } }

p Ruote.lookup(h, ‘a.b.1’) # => 3

This method is used by the ‘subprocess’ expression and by the EngineParticipant.

Merge workitem ‘source’ into workitem ‘target’.

If type is ‘override’, the source will prevail and be returned.

If type is ‘mix’, the source fields will be merged into the target fields.

If type is ‘isolate’, the source fields will be placed in a separte field in the target workitem. The name of this field is the child_id of the source workitem (a string from ‘0’ to ‘99999’ and beyond)

The ‘concat’ type merges hashes and concats arrays. The ‘union’ type behaves much like ‘concat’, but it makes sure to remove duplicates.

Warning: ‘union’ will remove duplicates that were present before the merge.

Tries to return an Integer or a Float from the given input. Returns

Returns a neutralized version of s, suitable as a filename.

Returns a parseable representation of the UTC time now.

like "2009/11/23 11:11:50.947109 UTC"

Prints the current call stack to stdout

Attempts to parse a string of Ruby code (and return the AST).

Given a participant, a method name or an array of method names and a hash of arguments, will do its best to set the instance variables corresponding to the arguments (if possible) and to call the method with the right number of arguments…

Made it a Ruote module method so that RevParticipant might use it independently.

If the arguments hash contains a value keyed :default, that value is returned when none of the methods is responded to by the participant. Else if :default is not set or is set to nil, a NoMethodError.

Same as Ruote.define()

  pdef = Ruote.process_definition :name => 'take_out_garbage' do
    sequence do
      take_out_regular_garbage
      take_out_paper
    end
  end

  engine.launch(pdef)

Used by some projects, used to be called from Ruote::ProcessStatus.

Given a decomposed tree like

  { '0' => [ 'define', { 'name' => 'nada' } ],
    '0_0' => [ 'sequence', {} ],
    '0_0_0' => [ 'alpha', {} ],
    '0_0_1' => [ 'bravo', {} ] },

will recompose it to

  [ 'define', { 'name' => 'nada' }, [
    [ 'sequence', {}, [ [ 'alpha', {}, [] ], [ 'bravo', {}, [] ] ] ]
  ] ]

A starting point in the recomposition can be given with the ‘pos’ argument.

regex_or_s("/nada/") #==> /nada/ regex_or_s("nada") #==> "nada" regex_or_s(/nada/) #==> /nada/

Turns a date or a duration to a Time object pointing AT a point in time…

(my prose is weak)

Refines a schedule as found in the ruote storage into something a bit easier to present.

h = { ‘customer’ => { ‘name’ => ‘alpha’ } }

Ruote.set(h, ‘customer.name’, ‘bravo’)

h #=> { ‘customer’ => { ‘name’ => ‘bravo’ } }

A shorter shortcut for

  Ruote::FlowExpressionId.to_storage_id(fei)

Produces the UTC string representation of a Time

like "2009/11/23 11:11:50.947109 UTC"

A shortcut for

  Ruote::FlowExpressionId.to_storage_id(fei)

Similar in purpose to Ruote.define and Ruote.process_definition but instead of returning a [process] definition, returns the tree.

  tree = Ruote.process_definition :name => 'take_out_garbage' do
    sequence do
      take_out_regular_garbage
      take_out_paper
    end
  end

  p tree
    # => [ 'sequence', {}, [ [ 'take_out_regular_garbage', {}, [] ], [ 'take_out_paper', {}, [] ] ] ],

This is useful when modifying a process instance via methods like re_apply :

  engine.re_apply(
    fei,
    :tree => Ruote.to_tree {
      sequence do
        participant 'alfred'
        participant 'bob'
      end
    })
      #
      # cancels the segment of process at fei and replaces it with
      # a simple alfred-bob sequence.

Turns a process definition tree to a graphviz dot representation.

www.graphviz.org

Turning a tree into a numbered string view

  require 'ruote/util/tree'
  require 'ruote/reader/ruby_dsl'

  pdef = Ruote.process_definition :name => 'def0' do
    sequence do
      alpha
      bravo
    end
  end

  p pdef
    # => ["define", {"name"=>"def0"}, [
    #      ["sequence", {}, [
    #        ["alpha", {}, []],
    #        ["bravo", {}, []]]]]]

  puts Ruote.tree_to_s(pdef)
    # =>
    #    0  define {"name"=>"def0"}
    #      0_0  sequence {}
    #        0_0_0  alpha {}
    #        0_0_1  bravo {}

h = { ‘customer’ => { ‘name’ => ‘alpha’, ‘rank’ => ‘1st’ } } r = Ruote.unset(h, ‘customer.rank’)

h # => { ‘customer’ => { ‘name’ => ‘alpha’ } } r # => ‘1st‘

Protected Class methods

Given a collection and a key returns the corresponding value

  Ruote.fetch([ 12, 13, 24 ], 1) # => 13
  Ruote.fetch({ '1' => 13 }, 1) # => 13
  Ruote.fetch({ 1 => 13 }, 1) # => 13

If the key holds an integer returns it, else return the key as is.

Pops the first key in a path key.

  Ruote.pop_key('a.b.c') # => 'a'
  Ruote.pop_key('1.2.3') # => 1

(note the narrowing to an int that happens)

[Validate]