google-spreadsheet-ruby 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/google_spreadsheet.rb +17 -16
- metadata +4 -4
data/lib/google_spreadsheet.rb
CHANGED
@@ -192,7 +192,7 @@ module GoogleSpreadsheet
|
|
192
192
|
# session.spreadsheets("title" => "hoge")
|
193
193
|
def spreadsheets(params = {})
|
194
194
|
query = encode_query(params)
|
195
|
-
doc = request(:get, "
|
195
|
+
doc = request(:get, "https://spreadsheets.google.com/feeds/spreadsheets/private/full?#{query}")
|
196
196
|
result = []
|
197
197
|
for entry in doc.search("entry")
|
198
198
|
title = as_utf8(entry.search("title").text)
|
@@ -209,7 +209,7 @@ module GoogleSpreadsheet
|
|
209
209
|
# # http://spreadsheets.google.com/ccc?key=pz7XtlQC-PYx-jrVMJErTcg&hl=ja
|
210
210
|
# session.spreadsheet_by_key("pz7XtlQC-PYx-jrVMJErTcg")
|
211
211
|
def spreadsheet_by_key(key)
|
212
|
-
url = "
|
212
|
+
url = "https://spreadsheets.google.com/feeds/worksheets/#{key}/private/full"
|
213
213
|
return Spreadsheet.new(self, url)
|
214
214
|
end
|
215
215
|
|
@@ -221,7 +221,7 @@ module GoogleSpreadsheet
|
|
221
221
|
# session.spreadsheet_by_url(
|
222
222
|
# "http://spreadsheets.google.com/ccc?key=pz7XtlQC-PYx-jrVMJErTcg&hl=en")
|
223
223
|
# session.spreadsheet_by_url(
|
224
|
-
# "
|
224
|
+
# "https://spreadsheets.google.com/feeds/worksheets/pz7XtlQC-PYx-jrVMJErTcg/private/full")
|
225
225
|
def spreadsheet_by_url(url)
|
226
226
|
# Tries to parse it as URL of human-readable spreadsheet.
|
227
227
|
uri = URI.parse(url)
|
@@ -250,7 +250,7 @@ module GoogleSpreadsheet
|
|
250
250
|
# session.create_spreadsheet("My new sheet")
|
251
251
|
def create_spreadsheet(
|
252
252
|
title = "Untitled",
|
253
|
-
feed_url = "
|
253
|
+
feed_url = "https://docs.google.com/feeds/documents/private/full")
|
254
254
|
xml = <<-"EOS"
|
255
255
|
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:docs="http://schemas.google.com/docs/2007">
|
256
256
|
<atom:category scheme="http://schemas.google.com/g/2005#kind"
|
@@ -266,7 +266,8 @@ module GoogleSpreadsheet
|
|
266
266
|
end
|
267
267
|
|
268
268
|
def request(method, url, params = {}) #:nodoc:
|
269
|
-
|
269
|
+
# Always uses HTTPS.
|
270
|
+
uri = URI.parse(url.gsub(%r{^http://}, "https://"))
|
270
271
|
data = params[:data]
|
271
272
|
auth = params[:auth] || :wise
|
272
273
|
if params[:header]
|
@@ -279,16 +280,16 @@ module GoogleSpreadsheet
|
|
279
280
|
if @oauth_token
|
280
281
|
|
281
282
|
if method == :delete || method == :get
|
282
|
-
response = @oauth_token.__send__(method, url)
|
283
|
+
response = @oauth_token.__send__(method, url, add_header)
|
283
284
|
else
|
284
|
-
response = @oauth_token.__send__(method, url, data)
|
285
|
+
response = @oauth_token.__send__(method, url, data, add_header)
|
285
286
|
end
|
286
287
|
return convert_response(response, response_type)
|
287
288
|
|
288
289
|
else
|
289
290
|
|
290
291
|
http = Net::HTTP.new(uri.host, uri.port)
|
291
|
-
http.use_ssl =
|
292
|
+
http.use_ssl = true
|
292
293
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
293
294
|
http.start() do
|
294
295
|
while true
|
@@ -366,7 +367,7 @@ module GoogleSpreadsheet
|
|
366
367
|
# Key of the spreadsheet.
|
367
368
|
def key
|
368
369
|
if !(@worksheets_feed_url =~
|
369
|
-
%r{
|
370
|
+
%r{^https?://spreadsheets.google.com/feeds/worksheets/(.*)/private/full$})
|
370
371
|
raise(GoogleSpreadsheet::Error,
|
371
372
|
"worksheets feed URL is in unknown format: #{@worksheets_feed_url}")
|
372
373
|
end
|
@@ -375,21 +376,21 @@ module GoogleSpreadsheet
|
|
375
376
|
|
376
377
|
# Tables feed URL of the spreadsheet.
|
377
378
|
def tables_feed_url
|
378
|
-
return "
|
379
|
+
return "https://spreadsheets.google.com/feeds/#{self.key}/tables"
|
379
380
|
end
|
380
381
|
|
381
382
|
# URL of feed used in document list feed API.
|
382
383
|
def document_feed_url
|
383
|
-
return "
|
384
|
+
return "https://docs.google.com/feeds/documents/private/full/spreadsheet%3A#{self.key}"
|
384
385
|
end
|
385
386
|
|
386
387
|
# Creates copy of this spreadsheet with the given name.
|
387
388
|
def duplicate(new_name = nil)
|
388
389
|
new_name ||= (@title ? "Copy of " + @title : "Untitled")
|
389
|
-
get_url = "
|
390
|
+
get_url = "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=#{key}&exportFormat=ods"
|
390
391
|
ods = @session.request(:get, get_url, :response_type => :raw)
|
391
392
|
|
392
|
-
url = "
|
393
|
+
url = "https://docs.google.com/feeds/documents/private/full"
|
393
394
|
header = {
|
394
395
|
"Content-Type" => "application/x-vnd.oasis.opendocument.spreadsheet",
|
395
396
|
"Slug" => URI.encode(new_name),
|
@@ -527,18 +528,18 @@ module GoogleSpreadsheet
|
|
527
528
|
# Probably it would be cleaner to keep worksheet feed URL and get cells feed URL
|
528
529
|
# from it.
|
529
530
|
if !(@cells_feed_url =~
|
530
|
-
%r{^
|
531
|
+
%r{^https?://spreadsheets.google.com/feeds/cells/(.*)/(.*)/private/full$})
|
531
532
|
raise(GoogleSpreadsheet::Error,
|
532
533
|
"cells feed URL is in unknown format: #{@cells_feed_url}")
|
533
534
|
end
|
534
|
-
return "
|
535
|
+
return "https://spreadsheets.google.com/feeds/worksheets/#{$1}/private/full/#{$2}"
|
535
536
|
end
|
536
537
|
|
537
538
|
# GoogleSpreadsheet::Spreadsheet which this worksheet belongs to.
|
538
539
|
def spreadsheet
|
539
540
|
if !@spreadsheet
|
540
541
|
if !(@cells_feed_url =~
|
541
|
-
%r{^
|
542
|
+
%r{^https?://spreadsheets.google.com/feeds/cells/(.*)/(.*)/private/full$})
|
542
543
|
raise(GoogleSpreadsheet::Error,
|
543
544
|
"cells feed URL is in unknown format: #{@cells_feed_url}")
|
544
545
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-spreadsheet-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi Ichikawa
|
@@ -9,12 +9,12 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-31 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hpricot
|
17
|
-
type: :
|
17
|
+
type: :runtime
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: oauth
|
27
|
-
type: :
|
27
|
+
type: :runtime
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|