Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 example.rb
Octocat-spinner-32 ruote-jig.gemspec
README.rdoc

ruote-jig

Ruote 2.0 participant which does a HTTP call using rufus-jig (rufus.rubyforge.org/rufus-jig/), a HTTP client, greedy with JSON content.

By default, it POSTs received workitems as JSON to a HTTP server and stores the answer back into the workitem. If the answer is in JSON, it is automatically converted into Ruby data types (this magic is thanks to rufus-jig).

The handling of outgoing and incoming data may be customized by Procs.

usage

require 'yajl' # by default, you will need some JSON lib (yajl-ruby or json_pure or ActiveSupport)

# require this lib
require 'ruote/jig/part/jig_participant'

# let's assume you have a ruote engine in '''engine'''
engine.register_participant :jig_default, Ruote::Jig::JigParticipant
engine.register_participant :jig_advanced, Ruote::Jig::JigParticipant.new(
  :host              => 'somehost',
  :port              => 80,
  :path              => '/path/to/the/magic',
  :method            => :post,
  :content_type      => 'foo/bar',
  :data_preparition  => Proc.new {|workitem| workitem.fields['foo_bar'].to_s},
  :response_handling => Proc.new do |response, workitem|
    workitem.set_field('incoming_foo_bar', FooBar.from_str(response.body))
  end
)

# in a workflow definition...
participant :ref => 'jig_default' # will POST the current workitem as JSON
                                  # to http://127.0.0.1:3000/ and save the
                                  # responded data in the workitem field
                                  # \_\_jig_response__

participant :ref => 'jig_advanced', # will PUT the the string returned by
  :host   => 'anotherhost',         # workitem.fields['foo_bar'].to_s to
  :path   => '/path/to/bar',        # http://anotherhost:80/path/to/bar,
  :method => :put                   # processes the response body and
                                    # saves the result in the workitem
                                    # field 'incoming_foo_bar'

running tests

to run unit tests

ruby test/test.rb

fakeweb and yajl-ruby have to be installed.

license

MIT

links

feedback

mailing list

groups.google.com/group/openwferu-users

irc

irc.freenode.net #ruote

credits

Many thanks to John Mettraux (jmettraux.wordpress.com) for his tireless work on Ruote and the many rufus libs. Thanks to Kenneth Kalmer (github.com/kennethkalmer) for his work on rufus-jig.

Something went wrong with that request. Please try again.