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
| #* | |
| How would you refactor this? | |
| This code is workflow, which moves through a set of tasks: the config hash is a list of XML documents to convert into the database kept in YAML, before() does some setup work, download_xmls fetches hundreds of XML documents based on the config, the convert method does a lot of transformation work from xml into AR (and sometimes fetches further XML documents). Finally a report is generated and emailed to recipients to represent how the run went. | |
| It began as a practical way to code an integration between an XML service and the app., now it's smelly. I obviously need a task based DSL, probably a state machine lib.. Any other ideas of a good DSL or library which could be adopted for it? | |
| *# | |
| def self.run | |
| config = YAML.load_file(@@datasets_file) |
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' | |
| # preparing the engine | |
| engine = Ruote::FsPersistedEngine.new | |
| # registering participants | |
| engine.register_participant :xml_to_hash do |
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 |
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
| X-Account-Key: account2 | |
| X-UIDL: GmailId1249437288202175 | |
| X-Mozilla-Status: 0001 | |
| X-Mozilla-Status2: 00000000 | |
| X-Mozilla-Keys: | |
| Delivered-To: nicholas.faiz@gmail.com | |
| Received: by 10.142.163.21 with SMTP id l21cs30420wfe; | |
| Mon, 26 Oct 2009 21:18:16 -0700 (PDT) | |
| Received: by 10.211.146.5 with SMTP id y5mr3225541ebn.41.1256617094586; | |
| Mon, 26 Oct 2009 21:18:14 -0700 (PDT) |
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' | |
| df = Ruote.process_definition :name => 'foo' do |workitem| | |
| puts "testing" | |
| end | |
| engine = Ruote::FsPersistedEngine.new | |
| wfid = engine.launch(df) | |
| p = engine.process(wfid) |
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
| == worker intercepted error == | |
| F#<RuntimeError: unknown expression 'include'> | |
| /opt/local/lib/ruby/gems/1.8/gems/ruote-2.1.0/lib/ruote/worker.rb:337:in `raise_unknown_expression_error' | |
| 1)/opt/local/lib/ruby/gems/1.8/gems/ruote-2.1.0/lib/ruote/worker.rb:322:in `launch' | |
| NoMethodError in 'Nesstar::Services an attempt to spec ruote process definitions should initialize a directoriy' |
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
| #the rspec | |
| require File.dirname(__FILE__) + '/../spec_helper' | |
| require 'nesstar/ruotes' | |
| require 'nesstar/initialize_directory_participant' | |
| # require 'ruote/engine' | |
| # require 'ruote/storage/hash_storage' | |
| require 'ruote/storage/base' | |
| require 'ruote/storage/fs_storage' | |
| require 'ruote/worker' | |
| # require 'ruote/context' |
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
| dataset_process_def = Ruote.process_definition :name => 'convert_datasets' do | |
| sequence do | |
| participant :ref => 'load_dataset_ids', :datasets_yaml => $datasets_file | |
| iterator :on_field => 'urls', :to_var => 'url' do | |
| participant :convert_dataset, :xml => '$url' | |
| end | |
| end | |
| end |
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
| # the sitemap portlet | |
| # takes two inputs via the form - a top level section to map beneath (defaults to root section) and a list of sections to exclude from map | |
| class SitemapPortlet < Portlet | |
| # render_inline false | |
| def render | |
| top_level = self.section | |
| if top_level.empty? or top_level.nil? |
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
| #A list of Australian websites and developers using Rails, to indicate the depth of the pool in .au. | |
| #I need to build a list for a potential client, but it occurred to me others might need to do the same thing. | |
| Websites | |
| -------- | |
| http://yellowpages.com.au | |
| http://sensis.com.au | |
| http://huggies.com.au | |
| http://yates.com.au (NZ) |