ruote quickstart

Ruote 2.2 is tested with Ruby 1.8.7 and Ruby 1.9.2.

This quickstart aims at showing a minimal process instance run. It’s a very limited example.

getting ruote

Provided that you have a recent version of git, you can do from your command line :

            $ git clone git://github.com/jmettraux/ruote.git
            $ cd ruote
            $ rake build
            $ gem install pkg/ruote-2.2.1.gem
            

Installing as a gem will draw in the necessary gem dependencies, except a JSON gem.

If you want to avoid “gitting” ruote, you can install it as a gem :

            $ gem install ruote
            
            # if you're using C (MRI) Ruby :
            $ gem install yajl-ruby
            
            # if you're using JRuby :
            $ gem install json-jruby
            
            # on windows :
            $ gem install json_pure
            
            # if you're using C (MRI) Ruby :
            $ gem install yajl-ruby
            
            # if you're using JRuby :
            $ gem install json-jruby
            
            # on windows :
            $ gem install json_pure
            

first run

This piece of code passes a workitem from participant Alpha to participant Bravo :

            require 'rubygems'
            require 'ruote'
            require 'ruote/storage/fs_storage'
            
            # preparing the engine
            
            engine = Ruote::Engine.new(
              Ruote::Worker.new(
                Ruote::FsStorage.new('ruote_work')))
            
            # registering participants
            #
            # two simplistic "block participants"
            #
            # 'alpha' adds a piece of information to the workitem, while 'bravo'
            # outputs that same part of that information
            
            engine.register_participant :alpha do |workitem|
              workitem.fields['message'] = { 'text' => 'hello !', 'author' => 'Alice' }
            end
            
            engine.register_participant :bravo do |workitem|
              puts "I received a message from #{workitem.fields['message']['author']}"
            end
            
            # defining a process
            
            pdef = Ruote.process_definition :name => 'test' do
              sequence do
                participant :alpha
                participant :bravo
              end
            end
            
            # launching, creating a process instance
            
            wfid = engine.launch(pdef)
            
            engine.wait_for(wfid)
              # blocks current thread until our process instance terminates
            
            # => 'I received a message from Alice'
            

This quickstart can be found in examples/ruote_quickstart.rb

Run it with :

            $ ruby examples/ruote_quickstart.rb
            

It will exit after the process instance terminated.