geekq / workflow

Ruby finite-state-machine-inspired API for modeling workflow
MIT License
1.75k stars 207 forks source link

Json load #186

Closed danielmacho72 closed 5 years ago

danielmacho72 commented 7 years ago

Hi, I have been working in this change for some time in order to be able to read and write workflow configuration from externalized json files.

This is something I find quite valuable for a personal project I am working on. This functionality I am sending will leverage (not in this PR yet) to update and maintain the workflow design using a UI (e.g a browser HTML5 canvas component that could generate json format that will ultimately update the workflow definition)

This PR reads json workflow configuration from files but future PRs could keep external models in NOSQL databases (e.g MongoDB)

I hope you like this PR and you accept to merge it in the main branch. I have created specific tests for this functionality available under tests/json_load_test.rb

Usage from test/json_load_test.rb

Order.workflow_spec.from_json_file!('workflows/order.wf') Order.reassign_workflow!