Given a bunch of ruby Hash, an ActiveRecord model class and a unique key, DataPatcher creates a Hash of the differences between the bunch of Hash and the table.
Have a look at the (very simple) spec/data_patcher.rb to get a better understanding of what’s possible.
This is useful if you are aggregating various data sources and what to have a good level of control on what is added or modified. I do that on Learnivore.com and for some of my clients data processing.
When doing this, I tend to parse all the sources again, compare the result to already registered data, and see what are the differences and if they should be applied.
Edit spec/database.yml and run rake spec.
Test data is recreated automatically when running rake spec.
- find another name – I don’t like DataPatcher
- find a better Hash patch format
- move the key outside the diff Hash ?
- support removed records ? (I don’t need that for the moment)
- add some way to apply the patch directly inside DataPatcher ?
Copyright © 2008 Thibaut Barrère. See LICENSE for details.