picasawebalbums 1.3.3 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -50,6 +50,7 @@ Methods
50
50
  - `get_album_by_title(title)`
51
51
  - `get_album_by_slug(slug)`
52
52
  - `create_album(album)`
53
+ - `delete_album_by_id(album_id)`
53
54
 
54
55
  ### Photo(s)
55
56
 
@@ -110,9 +111,9 @@ Coming Down the Pike
110
111
 
111
112
  The goal is to completely mirror all of the Picasa Web Albums API features including
112
113
 
113
- - Create, update, delete albums
114
- - CUD photos
115
- - CUD tags
114
+ - Update albums
115
+ - Create, Update, Delete photos
116
+ - Create, Update, Delete tags
116
117
  - CRUD comments
117
118
  - CRUD geolocation data
118
119
 
@@ -1,3 +1,3 @@
1
1
  module PicasaWebAlbums
2
- VERSION = "1.3.3"
2
+ VERSION = "1.4.3"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  module PicasaWebAlbums
2
2
  class Album
3
- attr_accessor :id, :photos, :title, :slug, :date_created, :date_updated, :cover_photo_url, :description, :access, :number_of_photos, :number_of_comments, :number_of_photos_remaining, :total_bytes
4
-
3
+ attr_accessor :id, :photos, :title, :slug, :date_created, :date_updated, :cover_photo_url, :description, :access, :number_of_photos, :number_of_comments, :number_of_photos_remaining, :total_bytes, :edit_url
4
+
5
5
  def initialize
6
6
  @photos = []
7
7
  end
@@ -19,6 +19,7 @@ module AlbumsRepository
19
19
  gallery.total_bytes = entry.elements["gphoto:bytesUsed"].text.to_i
20
20
  gallery.cover_photo_url = entry.elements["media:group/media:content"].attributes["url"]
21
21
  gallery.description = entry.elements["media:group/media:description"].text
22
+ gallery.edit_url = get_edit_url_from_entry(entry)
22
23
  albums << gallery
23
24
  end
24
25
  return albums
@@ -47,19 +48,30 @@ module AlbumsRepository
47
48
  post_new_album(entry)
48
49
  end
49
50
 
50
- #def delete_album_by_id(album_id)
51
- # url = URI.parse("https://picasaweb.google.com/data/entry/api/user/#{@email}/albumid/#{album_id}")
52
- # http = Net::HTTP.new(url.host, url.port)
53
- # http.use_ssl = (url.scheme == 'https')
54
- # http.verify_mode = OpenSSL::SSL::VERIFY_NONE
55
- # req = Net::HTTP::Delete.new(url.request_uri)
56
- # req['Authorization'] = @authentication_token
57
- # res = http.request(req)
58
- # return res.code
59
- #end
51
+ def delete_album_by_id(album_id)
52
+ album = get_album_by_id(album_id)
53
+ url = URI.parse(album.edit_url)
54
+ http = Net::HTTP.new(url.host, url.port)
55
+ http.use_ssl = (url.scheme == 'https')
56
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
57
+ req = Net::HTTP::Delete.new(url.request_uri)
58
+ req['Authorization'] = @authentication_token
59
+ res = http.request(req)
60
+ return res.code
61
+ end
60
62
 
61
63
  private
62
64
 
65
+ def get_edit_url_from_entry(entry)
66
+ href = ""
67
+ entry.elements.each("link") do |link|
68
+ if (link.attributes["rel"] == "edit")
69
+ href = link.attributes["href"]
70
+ end
71
+ end
72
+ return href
73
+ end
74
+
63
75
  def post_new_album(data)
64
76
  uri = URI("https://picasaweb.google.com/data/feed/api/user/#{@email}")
65
77
  status = ""
@@ -10,7 +10,7 @@ module PicasaWebAlbums
10
10
 
11
11
  def test_get_all_albums
12
12
  albums = @repo.get_all_albums
13
- assert_equal 4, albums.count
13
+ assert_equal 3, albums.count
14
14
  end
15
15
 
16
16
  def test_get_album_by_id
@@ -20,7 +20,7 @@ module PicasaWebAlbums
20
20
 
21
21
  def test_get_album_by_title
22
22
  album = @repo.get_album_by_title("Bio Profile Pics")
23
- assert_equal "5455332611886090353", album.id
23
+ assert_equal "5689734429356072049", album.id
24
24
  end
25
25
 
26
26
  def test_get_album_by_slug
@@ -28,20 +28,23 @@ module PicasaWebAlbums
28
28
  assert_equal "5577380987485671713", album.id
29
29
  end
30
30
 
31
- #def test_create_new_album
32
- # album = Album.new
33
- # album.title = "Programmatic album title"
34
- # album.description = "This is my programmatic album description!"
35
- # album.access = "private"
36
- # status_code = @repo.create_album(album)
37
- # assert_equal "201", status_code
38
- #end
31
+ def test_create_new_album
32
+ album = Album.new
33
+ album.title = "Programmatic album title"
34
+ album.description = "This is my programmatic album description!"
35
+ album.access = "private"
36
+ status_code = @repo.create_album(album)
37
+ assert_equal "201", status_code
38
+ delete_album
39
+ end
39
40
 
40
- #def test_delete_album
41
- # album = @repo.get_album_by_title("Programmatic album title")
42
- # status_code = @repo.delete_album_by_id(album.id)
43
- # assert_equal "201", status_code
44
- #end
41
+ def delete_album
42
+ album = @repo.get_album_by_title("Programmatic album title")
43
+ if (album != nil)
44
+ status_code = @repo.delete_album_by_id(album.id)
45
+ assert_equal "200", status_code
46
+ end
47
+ end
45
48
 
46
49
  end
47
50
  end
@@ -21,7 +21,7 @@ module PicasaWebAlbums
21
21
  end
22
22
 
23
23
  def test_get_photos_by_tags
24
- photos = @repo.get_photos_by_tags(['leonard'])
24
+ photos = @repo.get_photos_by_tags(['brick'])
25
25
  assert photos.count > 0
26
26
  end
27
27
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picasawebalbums
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: