wolframarnold-google-spreadsheet-ruby 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/google_spreadsheet.rb +28 -15
  2. metadata +2 -2
@@ -196,8 +196,7 @@ module GoogleSpreadsheet
196
196
  result = []
197
197
  for entry in doc.search("entry")
198
198
  title = as_utf8(entry.search("title").text)
199
- url = as_utf8(entry.search(
200
- "link[@rel='http://schemas.google.com/spreadsheets/2006#worksheetsfeed']")[0]["href"])
199
+ url = as_utf8(entry.search("content")[0]["src"])
201
200
  result.push(Spreadsheet.new(self, url, title))
202
201
  end
203
202
  return result
@@ -250,13 +249,13 @@ module GoogleSpreadsheet
250
249
  # session.create_spreadsheet("My new sheet")
251
250
  def create_spreadsheet(
252
251
  title = "Untitled",
253
- feed_url = "https://docs.google.com/feeds/documents/private/full")
252
+ feed_url = "https://docs.google.com/feeds/default/private/full")
254
253
  xml = <<-"EOS"
255
- <atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:docs="http://schemas.google.com/docs/2007">
256
- <atom:category scheme="http://schemas.google.com/g/2005#kind"
257
- term="http://schemas.google.com/docs/2007#spreadsheet" label="spreadsheet"/>
258
- <atom:title>#{h(title)}</atom:title>
259
- </atom:entry>
254
+ <entry xmlns="http://www.w3.org/2005/Atom">
255
+ <category scheme="http://schemas.google.com/g/2005#kind"
256
+ term="http://schemas.google.com/docs/2007#spreadsheet"/>
257
+ <title>#{h(title)}</title>
258
+ </entry>
260
259
  EOS
261
260
 
262
261
  doc = request(:post, feed_url, :data => xml, :auth => :writely)
@@ -275,6 +274,11 @@ module GoogleSpreadsheet
275
274
  else
276
275
  add_header = data ? {"Content-Type" => "application/atom+xml"} : {}
277
276
  end
277
+
278
+ add_header['GData-Version'] ||= '3.0'
279
+
280
+ #p add_header['GData-Version']
281
+
278
282
  response_type = params[:response_type] || :xml
279
283
 
280
284
  if @oauth_token
@@ -381,7 +385,7 @@ module GoogleSpreadsheet
381
385
 
382
386
  # URL of feed used in document list feed API.
383
387
  def document_feed_url
384
- return "https://docs.google.com/feeds/documents/private/full/spreadsheet%3A#{self.key}"
388
+ return "https://docs.google.com/feeds/default/private/full/spreadsheet%3A#{self.key}"
385
389
  end
386
390
 
387
391
  # Creates copy of this spreadsheet with the given name.
@@ -390,7 +394,7 @@ module GoogleSpreadsheet
390
394
  get_url = "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=#{key}&exportFormat=ods"
391
395
  ods = @session.request(:get, get_url, :response_type => :raw)
392
396
 
393
- url = "https://docs.google.com/feeds/documents/private/full"
397
+ url = "https://docs.google.com/feeds/default/private/full"
394
398
  header = {
395
399
  "Content-Type" => "application/x-vnd.oasis.opendocument.spreadsheet",
396
400
  "Slug" => URI.encode(new_name),
@@ -687,8 +691,8 @@ module GoogleSpreadsheet
687
691
  </entry>
688
692
  EOS
689
693
 
690
- @session.request(:put, edit_url, :data => xml)
691
-
694
+ @session.request(:put, edit_url, :data => xml, :header => {'If-Match' => '*', "Content-Type" => "application/atom+xml"})
695
+
692
696
  @meta_modified = false
693
697
  sent = true
694
698
 
@@ -703,12 +707,18 @@ module GoogleSpreadsheet
703
707
  cols = @modified.map(){ |r, c| c }
704
708
  url = "#{@cells_feed_url}?return-empty=true&min-row=#{rows.min}&max-row=#{rows.max}" +
705
709
  "&min-col=#{cols.min}&max-col=#{cols.max}"
706
- doc = @session.request(:get, url)
710
+ doc = @session.request(:get, url, :header => {'GData-Version' => '1'})
711
+
712
+ #puts doc.to_s
713
+ #puts @cells_feed_url
714
+
707
715
  for entry in doc.search("entry")
716
+ #p entry
708
717
  row = entry.search("gs:cell")[0]["row"].to_i()
709
718
  col = entry.search("gs:cell")[0]["col"].to_i()
710
719
  cell_entries[[row, col]] = entry
711
720
  end
721
+
712
722
 
713
723
  # Updates cell values using batch operation.
714
724
  # If the data is large, we split it into multiple operations, otherwise batch may fail.
@@ -727,8 +737,9 @@ module GoogleSpreadsheet
727
737
  edit_url = entry.search("link[@rel='edit']")[0]["href"]
728
738
  xml << <<-EOS
729
739
  <entry>
730
- <batch:id>#{h(row)},#{h(col)}</batch:id>
740
+ <batch:id>#{h(row)} #{h(col)}</batch:id>
731
741
  <batch:operation type="update"/>
742
+ <title>#{h(row)} #{h(col)}</title>
732
743
  <id>#{h(id)}</id>
733
744
  <link rel="edit" type="application/atom+xml"
734
745
  href="#{h(edit_url)}"/>
@@ -739,8 +750,10 @@ module GoogleSpreadsheet
739
750
  xml << <<-"EOS"
740
751
  </feed>
741
752
  EOS
753
+
754
+ #puts xml
742
755
 
743
- result = @session.request(:post, "#{@cells_feed_url}/batch", :data => xml)
756
+ result = @session.request(:post, "#{@cells_feed_url}/batch", :data => xml, :header => {'GData-Version' => '1', "Content-Type" => "application/atom+xml"})
744
757
  for entry in result.search("atom:entry")
745
758
  interrupted = entry.search("batch:interrupted")[0]
746
759
  if interrupted
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wolframarnold-google-spreadsheet-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Ichikawa
@@ -77,7 +77,7 @@ requirements: []
77
77
  rubyforge_project:
78
78
  rubygems_version: 1.3.5
79
79
  signing_key:
80
- specification_version: 3
80
+ specification_version: 2
81
81
  summary: This is a library to read/write Google Spreadsheet.
82
82
  test_files:
83
83
  - test/test_google_spreadsheet.rb