Skip to content

Instantly share code, notes, and snippets.

@youpy
Created November 13, 2009 05:56
Show Gist options
  • Select an option

  • Save youpy/233631 to your computer and use it in GitHub Desktop.

Select an option

Save youpy/233631 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'pit'
require 'gdata'
title = 'ieijiroflashcards'
config = Pit.get('google.com', :require => {
'username' => 'your google.com username',
'password' => 'your google.com password'
})
client = GData::Client::DocList.new
client.clientlogin(config['username'], config['password'])
xml = client.get('http://docs.google.com/feeds/documents/private/full').to_xml
entry = xml.get_elements('//title[text()="%s"]/..' % title).first
src = entry.elements['content'].
attributes['src'].
sub('Export?', 'Export?exportFormat=txt&')
edit_link = entry.get_elements('link[@rel="edit-media"]').first.attributes['href']
# export
body = client.get(src).body
# update
client.headers['Content-Type'] = 'text/plain'
client.headers['If-Match'] = '*'
client.put(edit_link, body + "\nbaz_;_1_;_1_;_")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment