google-picasa 0.0.6 → 0.0.7

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.
data/lib/google-picasa.rb CHANGED
@@ -26,9 +26,11 @@ module Google
26
26
  request = Net::HTTP.new(uri.host, uri.port)
27
27
  request.use_ssl = true
28
28
  request.verify_mode = OpenSSL::SSL::VERIFY_NONE
29
- response, data = request.post(uri.path, "accountType=HOSTED_OR_GOOGLE&Email=#{email}&Passwd=#{password}&service=lh2&source=#{source}")
29
+ response = request.post(uri.path, "accountType=HOSTED_OR_GOOGLE&Email=#{email}&Passwd=#{password}&service=lh2&source=#{source}")
30
+ data = response.body
30
31
 
31
32
  authMatch = Regexp.compile("(Auth=)([A-Za-z0-9_\-]+)\n").match(data.to_s)
33
+
32
34
  if authMatch
33
35
  authorizationKey = authMatch[2].to_s # substring that matched the pattern ([A-Za-z0-9_\-]+)
34
36
  end
@@ -41,7 +43,6 @@ module Google
41
43
  end
42
44
 
43
45
  def album(options = {})
44
-
45
46
  if(options[:name] == nil)
46
47
  return nil
47
48
  end
@@ -57,7 +58,6 @@ module Google
57
58
  end
58
59
 
59
60
  def albums(options = {})
60
-
61
61
  userId = options[:user_id] == nil ? self.picasa_session.user_id : options[:user_id]
62
62
  access = options[:access] == nil ? "public" : options[:access]
63
63
  url = "http://picasaweb.google.com/data/feed/api/user/#{userId}?kind=album&access=#{access}"
@@ -67,16 +67,15 @@ module Google
67
67
 
68
68
  headers = {"Authorization" => "GoogleLogin auth=#{self.picasa_session.auth_key}"}
69
69
 
70
- response, xml_response = http.get(uri.path, headers)
70
+ response = http.get(uri.path, headers)
71
+ xml_response = response.body
71
72
 
72
- #xml_response = Net::HTTP.get_response(URI.parse(url)).body.to_s
73
73
  albums = create_albums_from_xml(xml_response)
74
74
 
75
75
  return albums
76
76
  end
77
77
 
78
78
  def photos(options = {})
79
-
80
79
  options[:user_id] = options[:user_id].nil? ? self.picasa_session.user_id : options[:user_id]
81
80
  options[:album] = options[:album].nil? ? "" : options[:album]
82
81
 
@@ -88,7 +87,6 @@ module Google
88
87
  end
89
88
 
90
89
  def create_album(options = {})
91
-
92
90
  title = options[:title].nil? ? "" : options[:title]
93
91
  summary = options[:summary].nil? ? "" : options[:summary]
94
92
  location = options[:location].nil? ? "" : options[:location]
@@ -120,7 +118,8 @@ module Google
120
118
 
121
119
  headers = {"Content-Type" => "application/atom+xml", "Authorization" => "GoogleLogin auth=#{self.picasa_session.auth_key}"}
122
120
 
123
- response, data = http.post(uri.path, createAlbumRequestXml, headers)
121
+ response = http.post(uri.path, createAlbumRequestXml,headers)
122
+ data = response.body
124
123
 
125
124
  album = create_album_from_xml(data)
126
125
  return album
@@ -132,10 +131,11 @@ module Google
132
131
 
133
132
  headers = {"Authorization" => "GoogleLogin auth=#{self.picasa_session.auth_key}"}
134
133
 
135
- response, album_entry_xml_response = http.get(uri.path, headers)
134
+ response = http.get(uri.path, headers)
135
+ album_entry_xml_response = response.body
136
136
 
137
137
  if(response.code == "200")
138
- #parse the entry xml element and get the photo object
138
+ # parse the entry xml element and get the photo object
139
139
  album = self.create_album_from_xml(album_entry_xml_response)
140
140
  return album
141
141
  else
@@ -155,10 +155,11 @@ module Google
155
155
 
156
156
  headers = {"Authorization" => "GoogleLogin auth=#{self.picasa_session.auth_key}"}
157
157
 
158
- response, photo_entry_xml_response = http.get(uri.path, headers)
158
+ response = http.get(uri.path,headers)
159
+ photo_entry_xml_response = response.body
159
160
 
160
161
  if(response.code == "200")
161
- #parse the entry xml element and get the photo object
162
+ # parse the entry xml element and get the photo object
162
163
  photo = self.create_photo_from_xml(photo_entry_xml_response)
163
164
  return photo
164
165
  else
@@ -197,7 +198,9 @@ module Google
197
198
  "Authorization" => "GoogleLogin auth=#{self.picasa_session.auth_key}",
198
199
  "Slug" => title, "Content-Transfer-Encoding" => "binary"}
199
200
 
200
- response, data = http.post(uri.path, image_data, headers)
201
+ response = http.post(uri.path, image_data, headers)
202
+ data = response.body
203
+
201
204
  photo = self.create_photo_from_xml(data)
202
205
 
203
206
  return photo
@@ -211,7 +214,7 @@ module Google
211
214
 
212
215
  headers = {"Authorization" => "GoogleLogin auth=#{self.picasa_session.auth_key}"}
213
216
 
214
- response, data = http.delete(uri.path, headers)
217
+ response = http.delete(uri.path, headers)
215
218
 
216
219
  if(response.code == "200")
217
220
  return true
@@ -229,7 +232,7 @@ module Google
229
232
 
230
233
  headers = {"Authorization" => "GoogleLogin auth=#{self.picasa_session.auth_key}"}
231
234
 
232
- response, data = http.delete(uri.path, headers)
235
+ response = http.delete(uri.path, headers)
233
236
 
234
237
  if(response.code == "200")
235
238
  return true
@@ -241,14 +244,12 @@ module Google
241
244
 
242
245
  def create_albums_from_xml(xml_response)
243
246
  albums = []
244
- #response_hash = XmlSimple.xml_in(xml_response, { 'ForceArray' => false })
245
- #puts response_hash.inspect
246
247
 
247
248
  Picasa.entries(xml_response).each do |entry|
248
- #parse the entry xml element and get the album object
249
+ # parse the entry xml element and get the album object
249
250
  album = Picasa.parse_album_entry(entry)
250
251
 
251
- #enter session values in album object
252
+ # enter session values in album object
252
253
  album.picasa_session = PicasaSession.new
253
254
  album.picasa_session.auth_key = self.picasa_session.auth_key
254
255
  album.picasa_session.user_id = self.picasa_session.user_id
@@ -262,10 +263,10 @@ module Google
262
263
  def create_album_from_xml(xml_response)
263
264
  album = nil
264
265
 
265
- #parse the entry xml element and get the album object
266
+ # parse the entry xml element and get the album object\
266
267
  album = Picasa.parse_album_entry(XmlSimple.xml_in(xml_response, { 'ForceArray' => false }))
267
268
 
268
- #enter session values in album object
269
+ # enter session values in album object
269
270
  album.picasa_session = PicasaSession.new
270
271
  album.picasa_session.auth_key = self.picasa_session.auth_key
271
272
  album.picasa_session.user_id = self.picasa_session.user_id
@@ -276,10 +277,10 @@ module Google
276
277
  def create_photo_from_xml(xml_response)
277
278
  photo = nil
278
279
 
279
- #parse the entry xml element and get the photo object
280
+ # parse the entry xml element and get the photo object
280
281
  photo = Picasa.parse_photo_entry(XmlSimple.xml_in(xml_response, { 'ForceArray' => false }))
281
282
 
282
- #enter session values in photo object
283
+ # enter session values in photo object
283
284
  photo.picasa_session = PicasaSession.new
284
285
  photo.picasa_session.auth_key = self.picasa_session.auth_key
285
286
  photo.picasa_session.user_id = self.picasa_session.user_id
@@ -296,7 +297,6 @@ module Google
296
297
  end
297
298
 
298
299
  def self.parse_album_entry(album_entry_xml)
299
- #album_hash = XmlSimple.xml_in(album_entry_xml.to_s, { 'ForceArray' => false })
300
300
  album_hash = album_entry_xml
301
301
 
302
302
  album = Album.new
@@ -343,7 +343,6 @@ module Google
343
343
  end
344
344
 
345
345
  def self.parse_photo_entry(photo_entry_xml)
346
- #photo_hash = XmlSimple.xml_in(photo_entry_xml.to_s, { 'ForceArray' => false })
347
346
  photo_hash = photo_entry_xml
348
347
 
349
348
  photo = Photo.new
@@ -420,7 +419,6 @@ module Google
420
419
  end
421
420
 
422
421
  def photos(options = {})
423
-
424
422
  userId = options[:user_id].nil? ? self.user : options[:user_id]
425
423
  albumName = options[:album].nil? ? self.name : options[:album]
426
424
  albumId = options[:album_id].nil? ? self.id : options[:album_id]
@@ -436,7 +434,9 @@ module Google
436
434
 
437
435
  headers = {"Authorization" => "GoogleLogin auth=#{self.picasa_session.auth_key}"}
438
436
 
439
- response, xml_response = http.get(uri.path, headers)
437
+ response = http.get(uri.path, headers)
438
+ xml_response = response.body
439
+
440
440
  photos = self.create_photos_from_xml(xml_response)
441
441
 
442
442
  return photos
@@ -444,14 +444,12 @@ module Google
444
444
 
445
445
  def create_photos_from_xml(xml_response)
446
446
  photos = []
447
- #response_hash = XmlSimple.xml_in(xml_response, { 'ForceArray' => false })
448
- #puts response_hash.inspect
449
447
 
450
448
  Picasa.entries(xml_response).each do |entry|
451
- #parse the entry xml element and get the photo object
449
+ # parse the entry xml element and get the photo object
452
450
  photo = Picasa.parse_photo_entry(entry)
453
451
 
454
- #enter session values in photo object
452
+ # enter session values in photo object
455
453
  photo.picasa_session = PicasaSession.new
456
454
  photo.picasa_session.auth_key = self.picasa_session.auth_key
457
455
  photo.picasa_session.user_id = self.picasa_session.user_id
@@ -484,7 +482,6 @@ module Google
484
482
  end
485
483
 
486
484
  def update()
487
-
488
485
  updatePhotoXml = "<entry xmlns='http://www.w3.org/2005/Atom'
489
486
  xmlns:media='http://search.yahoo.com/mrss/'
490
487
  xmlns:gphoto='http://schemas.google.com/photos/2007'>
@@ -506,11 +503,11 @@ module Google
506
503
 
507
504
  headers = {"Content-Type" => "application/atom+xml", "Authorization" => "GoogleLogin auth=#{self.picasa_session.auth_key}"}
508
505
 
509
- response, data = http.put(uri.path, updatePhotoXml, headers)
506
+ response = http.put(uri.path, updatePhotoXml, headers)
507
+ data = response.body
510
508
 
511
509
  if(response.code == "200")
512
- #parse the entry xml element and get the photo object
513
- #new_photo = Picasa.parse_photo_entry(data)
510
+ # parse the entry xml element and get the photo object
514
511
  new_photo = Picasa.parse_photo_entry(XmlSimple.xml_in(data.to_s, { 'ForceArray' => false }))
515
512
  self.version_number = new_photo.version_number
516
513
 
@@ -521,7 +518,6 @@ module Google
521
518
  end
522
519
 
523
520
  def move_to_album(picasa_album_id)
524
-
525
521
  updatePhotoXml = "<entry xmlns='http://www.w3.org/2005/Atom'
526
522
  xmlns:media='http://search.yahoo.com/mrss/'
527
523
  xmlns:gphoto='http://schemas.google.com/photos/2007'>
@@ -544,10 +540,11 @@ module Google
544
540
 
545
541
  headers = {"Content-Type" => "application/atom+xml", "Authorization" => "GoogleLogin auth=#{self.picasa_session.auth_key}"}
546
542
 
547
- response, data = http.put(uri.path, updatePhotoXml, headers)
543
+ response = http.put(uri.path, updatePhotoXml,headers)
544
+ data = response.body
548
545
 
549
546
  if(response.code == "200")
550
- #parse the entry xml element and get the photo object
547
+ # parse the entry xml element and get the photo object
551
548
  new_photo = Picasa.parse_photo_entry(XmlSimple.xml_in(data.to_s, { 'ForceArray' => false }))
552
549
  self.version_number = new_photo.version_number
553
550
  self.album_id = new_photo.album_id
@@ -564,7 +561,6 @@ module Google
564
561
  class Thumbnail
565
562
  attr_accessor :url, :width, :height
566
563
  end
567
-
568
564
  end
569
565
  end
570
566
 
@@ -1,5 +1,5 @@
1
1
  module Google
2
2
  module Picasa
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-picasa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-26 00:00:00.000000000Z
12
+ date: 2012-10-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xml-simple
16
- requirement: &86282960 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *86282960
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: mime-types
27
- requirement: &86282750 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *86282750
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  description: Access Picasa Web Album using pure Ruby code.
37
47
  email:
38
48
  - dmitry@trager.ru
@@ -68,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
78
  version: '0'
69
79
  requirements: []
70
80
  rubyforge_project: google-picasa
71
- rubygems_version: 1.8.10
81
+ rubygems_version: 1.8.24
72
82
  signing_key:
73
83
  specification_version: 3
74
84
  summary: Ruby wrapper for Picasa API