Sha256: 747996bf6c692d95de569f15284bf688c56e2b6a0a97a644dbcc936aa6f615f0

Contents?: true

Size: 1.38 KB

Versions: 9

Compression:

Stored size: 1.38 KB

Contents

require 'ruote'

pdef = Ruote.process_definition :name => 'work' do
  cursor do
    concurrence do
      reviewer1
      reviewer2
    end
    editor
    rewind :if => '${not_ok}' # back to the reviewers if editor not happy
    publish # the document
  end
end

# engine

require 'ruote/storage/fs_storage'

engine = Ruote::Engine.new(Ruote::Worker.new(Ruote::FsStorage.new('work')))

# participants

engine.register_participant 'reviewer.+' do |workitem|
  puts "reviewing document #{workitem.fields['doc_url']}"
  print "approve ?"
  workitem.fields["#{workitem.participant_name}_reply"] = gets
end

engine.register_participant 'editor' do |workitem|
  puts "doc : #{workitem.fields['doc_url']}"
  puts "reviewers approval :"
  workitem.fields.entries.each do |k, v|
    puts "#{k} : #{v}" if k.match(/\_reply$/)
  end
  print "should we publish ?"
  workitem.fields['not_ok'] = (gets.strip == 'no')
end

engine.register_participant 'publish' do |workitem|
  PublicationService.post(workitem.fields['doc_url'])
end

wfid0 = engine.launch(pdef, 'doc_url' => 'http://en.wikipedia.org/wiki/File:Bundesbrief.jpg')
wfid1 = engine.launch(pdef, 'doc_url' => 'http://en.wikipedia.org/wiki/File:Constitution_Pg1of4_AC.jpg')

# querying

[ wfid0, wfid1 ].each do |wfid|
  ps = engine.process(wfid)
  puts "errors for #{wfid} ? #{ps.errors.size > 0}"
end

# cancelling a process instance

engine.cancel_process(wfid1)

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruote-2.1.9 examples/web_first_page.rb
ruote-2.1.8 examples/web_first_page.rb
ruote-2.1.7 examples/web_first_page.rb
ruote-2.1.6 examples/web_first_page.rb
ruote-2.1.5 examples/web_first_page.rb
ruote-2.1.4 examples/web_first_page.rb
ruote-2.1.3 examples/web_first_page.rb
ruote-2.1.2 examples/web_first_page.rb
ruote-2.1.1 examples/web_first_page.rb