Created
December 10, 2009 00:56
-
-
Save nicholasf/253007 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'ruote/engine' | |
| require 'ruby-debug' | |
| # preparing the engine | |
| engine = Ruote::FsPersistedEngine.new | |
| # registering participants | |
| engine.register_participant :xml_to_hash do |workitem| | |
| url = workitem.fields[:url] | |
| file_name = "#{url.split(".").last}.#{Time.now.to_i}.xml" | |
| begin | |
| `curl -o /tmp/#{file_name} --compressed "#{url}"` | |
| rescue StandardError => boom | |
| puts "#{boom}.to_s" | |
| end | |
| f = File.open("/tmp/#{file_name}") | |
| data = Crack::XML.parse(f.read) | |
| workitem.fields[:xml_data] = data | |
| end | |
| engine.register_participant :hash_to_yml do | |
| puts 2 | |
| debugger | |
| puts workitem.fields[:xml_data] | |
| `echo #{hello} >> foo.txt` | |
| end | |
| # defining a process | |
| process_def = Ruote.process_definition :name => 'process_xml' do | |
| sequence do | |
| participant :xml_to_hash | |
| participant :hash_to_yml | |
| end | |
| end | |
| @url = "http://bonus.anu.edu.au:80/obj/fStudy/au.edu.anu.assda.ddi.00102-f@relatedMaterials" | |
| engine.launch(process_def, :fields => {:url => @url}) | |
| sleep 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment