Applying a diff-patch to a string/file

For an offline-capable smartphone app, I'm creating a one-way text sync for Xml files. I'd like my server to send the delta/difference (e.g. a GNU diff-patch) to the target device.

This is the plan:

Time = 0
Server: has version_1 of Xml file (~800 kiB)
Client: has version_1 of Xml file (~800 kiB)

Time = 1
Server: has version_1 and version_2 of Xml file (each ~800 kiB)
        computes delta of these versions (=patch) (~10 kiB) 
        sends patch to Client (~10 kiB transferred)

Client: computes version_2 from version_1 and patch  <= this is the problem =>

Is there a Ruby library that can do this last step to apply a text patch to files/strings? The patch can be formatted as required by the library.

Thanks for your help!

(I'm using the Rhodes Cross-Platform Framework, which uses Ruby as programming language.)

5
задан Felix Alcala 16 April 2011 в 16:04
поделиться