Created
November 13, 2009 05:56
-
-
Save youpy/233631 to your computer and use it in GitHub Desktop.
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
| #!/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