Are there any example specs for content importers to learn from


#1

Hi guys,

This is my first post to the mailing list, so apologies if this kind
of question comes up alot already.

I’ve been working through the Peepcode screencasts on RSpec, and I’m
trying to what I’ve been learning into practice to make an importer on
a rails app that takes an xml feed, and imports each entry in the xml
feed into the database, skipping imports if they already exist in the
db.

The thing is, I don’t know the best way to do this, as most examples
I’ve seen only refer to handing objects one at a time.

Could someone point me to a couple of code examples of what importer
specs should look like when written in rspec, or tell me roughly how I
should be approaching this ?

I’ve put the generic version of the code in this gist, to give an idea
of where I’m headed at the mo, but any feedback would be greatly
appreciated.

Thanks and have a good weekend,

Chris

I’m currently only checking my email at 9am, midday and at 4pm.
If you need a response from me urgently, please call or text my
mobile, or contact me via Skype (chris.d.adams).

Chris Adams
Stemcel Studios
The Hub
5 Torrens Street
London
EC1V 1NQ

email: removed_email_address@domain.invalid
web: www.stemcel.co.uk
twitter:chris_d_adams
skype: chris.d.adams
mob: 07974 368 229
tel: 0207 558 8971


#2

That’s basically what I do. http://gist.github.com/82981 shows one I
wrote a couple days ago. I yield each object because there are like
400k records and I can’t keep them in memory. Might be a little nicer
to yield the params hash and let the caller build the object, but I
don’t need that flexibility at this point.

Pat