picasawebalbums 1.4.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +48 -0
- data/README.md +10 -5
- data/lib/PicasaWebAlbums.rb +1 -2
- data/lib/PicasaWebAlbums/version.rb +2 -2
- data/lib/repositories/albums_repository.rb +7 -10
- data/lib/repositories/photos_repository.rb +6 -7
- data/lib/repositories/repository.rb +2 -4
- data/lib/repositories/tags_repository.rb +17 -17
- data/test/integration/test_albums.rb +1 -1
- data/test/integration/test_tags.rb +1 -2
- metadata +4 -3
data/.rvmrc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p125@picasawebalbums"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.10.3" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
else
|
29
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
+
rvm --create "$environment_id" || {
|
31
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
+
return 1
|
33
|
+
}
|
34
|
+
fi
|
35
|
+
|
36
|
+
# If you use bundler, this might be useful to you:
|
37
|
+
# if [[ -s Gemfile ]] && {
|
38
|
+
# ! builtin command -v bundle >/dev/null ||
|
39
|
+
# builtin command -v bundle | grep $rvm_path/bin/bundle >/dev/null
|
40
|
+
# }
|
41
|
+
# then
|
42
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
+
# gem install bundler
|
44
|
+
# fi
|
45
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
+
# then
|
47
|
+
# bundle install | grep -vE '^Using|Your bundle is complete'
|
48
|
+
# fi
|
data/README.md
CHANGED
@@ -13,8 +13,8 @@ Rails/Application Integration
|
|
13
13
|
|
14
14
|
Add one of the below lines to the Gemfile:
|
15
15
|
|
16
|
-
- `gem 'picasawebalbums
|
17
|
-
- `gem 'picasawebalbums', :git => 'git@github.com:mkraft/PicasaWebAlbums.git'`
|
16
|
+
- `gem 'picasawebalbums, :require => 'PicasaWebAlbums'`
|
17
|
+
- `gem 'picasawebalbums', :require => 'PicasaWebAlbums', :git => 'git@github.com:mkraft/PicasaWebAlbums.git'`
|
18
18
|
|
19
19
|
Then run `bundle install`
|
20
20
|
|
@@ -39,8 +39,13 @@ Get photos with specific tags
|
|
39
39
|
repo = PicasaWebAlbums.get_repository('someperson@gmail.com', 'somepassword')
|
40
40
|
photos = repo.get_photos_by_tags(['cat', 'dog'])
|
41
41
|
# returns photos tagged with 'cat' AND 'dog'
|
42
|
-
|
43
|
-
|
42
|
+
|
43
|
+
Testing
|
44
|
+
-------
|
45
|
+
|
46
|
+
To run integration tests, replace the values in `/test/config/test_account.yml` with known values from a real Picasa Web Albums account. The `album` can be any album in the account (no changes will be made to it). The `photo` must be from the chosen `album`. Run:
|
47
|
+
|
48
|
+
ruby test/tests.rb
|
44
49
|
|
45
50
|
Methods
|
46
51
|
-------
|
@@ -140,4 +145,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
140
145
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
141
146
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
142
147
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
143
|
-
SOFTWARE.
|
148
|
+
SOFTWARE.
|
data/lib/PicasaWebAlbums.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module PicasaWebAlbums
|
2
|
-
VERSION = "1.4.
|
3
|
-
end
|
2
|
+
VERSION = "1.4.5"
|
3
|
+
end
|
@@ -22,25 +22,22 @@ module AlbumsRepository
|
|
22
22
|
gallery.edit_url = get_edit_url_from_entry(entry)
|
23
23
|
albums << gallery
|
24
24
|
end
|
25
|
-
|
25
|
+
albums
|
26
26
|
end
|
27
27
|
|
28
28
|
def get_album_by_id(id)
|
29
29
|
albums = get_all_albums
|
30
|
-
|
31
|
-
return album_to_return
|
30
|
+
albums[albums.find_index{|album| album.id == id.to_s}]
|
32
31
|
end
|
33
32
|
|
34
33
|
def get_album_by_title(title)
|
35
34
|
albums = get_all_albums
|
36
|
-
|
37
|
-
return album_to_return
|
35
|
+
albums[albums.find_index{|album| album.title == title.to_s}]
|
38
36
|
end
|
39
37
|
|
40
38
|
def get_album_by_slug(slug)
|
41
39
|
albums = get_all_albums
|
42
|
-
|
43
|
-
return album_to_return
|
40
|
+
albums[albums.find_index{|album| album.slug == slug.to_s}]
|
44
41
|
end
|
45
42
|
|
46
43
|
def create_album(new_album)
|
@@ -57,7 +54,7 @@ module AlbumsRepository
|
|
57
54
|
req = Net::HTTP::Delete.new(url.request_uri)
|
58
55
|
req['Authorization'] = @authentication_token
|
59
56
|
res = http.request(req)
|
60
|
-
|
57
|
+
res.code
|
61
58
|
end
|
62
59
|
|
63
60
|
#def update_album(modified_album)
|
@@ -88,7 +85,7 @@ module AlbumsRepository
|
|
88
85
|
href = link.attributes["href"]
|
89
86
|
end
|
90
87
|
end
|
91
|
-
|
88
|
+
href
|
92
89
|
end
|
93
90
|
|
94
91
|
def post_new_album(data)
|
@@ -102,6 +99,6 @@ module AlbumsRepository
|
|
102
99
|
response = http.request(request)
|
103
100
|
status = response.code
|
104
101
|
end
|
105
|
-
|
102
|
+
status
|
106
103
|
end
|
107
104
|
end
|
@@ -8,7 +8,7 @@ module PhotosRepository
|
|
8
8
|
photo = get_photo_from_xml_element(entry)
|
9
9
|
photos << photo
|
10
10
|
end
|
11
|
-
|
11
|
+
photos
|
12
12
|
end
|
13
13
|
|
14
14
|
def get_photo_by_album_id_and_photo_id(album_id, photo_id)
|
@@ -19,7 +19,7 @@ module PhotosRepository
|
|
19
19
|
photo_to_return = photo
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
photo_to_return
|
23
23
|
end
|
24
24
|
|
25
25
|
def get_photos_by_tags(tags)
|
@@ -30,7 +30,7 @@ module PhotosRepository
|
|
30
30
|
photo = get_photo_from_xml_element(entry)
|
31
31
|
photos << photo
|
32
32
|
end
|
33
|
-
|
33
|
+
photos
|
34
34
|
end
|
35
35
|
|
36
36
|
private
|
@@ -52,7 +52,7 @@ module PhotosRepository
|
|
52
52
|
photo.height = entry.elements["media:group/media:content"].attributes["height"].to_i
|
53
53
|
photo.caption = entry.elements["media:group/media:description"].text
|
54
54
|
photo.file_name = entry.elements["media:group/media:title"].text
|
55
|
-
|
55
|
+
photo
|
56
56
|
end
|
57
57
|
|
58
58
|
def get_tags_string(tags)
|
@@ -61,14 +61,13 @@ module PhotosRepository
|
|
61
61
|
tags_string += URI.escape(tag.strip)
|
62
62
|
tags_string += '%2C' unless tag == tags.last
|
63
63
|
end
|
64
|
-
|
64
|
+
tags_string
|
65
65
|
end
|
66
66
|
|
67
67
|
def get_photo_id_from_photo_id_url(photo_id_url)
|
68
68
|
start_index = photo_id_url.index('/photoid/') + 9
|
69
69
|
slice_of_id_url_to_end = photo_id_url[start_index..-1]
|
70
70
|
end_index = slice_of_id_url_to_end.index(/[?|\/]/)
|
71
|
-
|
72
|
-
return id
|
71
|
+
slice_of_id_url_to_end[0...end_index]
|
73
72
|
end
|
74
73
|
end
|
@@ -25,8 +25,7 @@ module PicasaWebAlbums
|
|
25
25
|
response = Net::HTTP.start(uri.hostname, uri.port) { |http|
|
26
26
|
http.request(request)
|
27
27
|
}
|
28
|
-
|
29
|
-
return xml
|
28
|
+
REXML::Document.new(response.body)
|
30
29
|
end
|
31
30
|
|
32
31
|
def get_authentication_token(email, password)
|
@@ -42,8 +41,7 @@ module PicasaWebAlbums
|
|
42
41
|
slice_of_auth_to_end = body[start_index..-1]
|
43
42
|
end_index = slice_of_auth_to_end.index("\n")
|
44
43
|
auth_string = slice_of_auth_to_end[0...end_index]
|
45
|
-
|
46
|
-
return auth_token
|
44
|
+
"GoogleLogin #{auth_string}"
|
47
45
|
end
|
48
46
|
end
|
49
47
|
end
|
@@ -1,22 +1,22 @@
|
|
1
1
|
require_relative '../domain/tag'
|
2
2
|
|
3
3
|
module TagsRepository
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
return tags
|
13
|
-
end
|
14
|
-
|
15
|
-
def get_tags_by_album_id(album_id)
|
16
|
-
xml = get_xml("http://picasaweb.google.com/data/feed/api/user/userID/albumid/#{album_id}?kind=tag")
|
17
|
-
end
|
18
|
-
|
19
|
-
def get_tags_by_album_id_and_photo_id(album_id, photo_id)
|
20
|
-
xml = get_xml("http://picasaweb.google.com/data/feed/api/user/default/albumid/#{album_id}/photoid/#{photo_id}?kind=tag")
|
4
|
+
def get_all_tags
|
5
|
+
xml = get_xml("http://picasaweb.google.com/data/feed/api/user/#{@email}?kind=tag")
|
6
|
+
tags = []
|
7
|
+
xml.root.elements.each("//entry") do |entry|
|
8
|
+
tag = PicasaWebAlbums::Tag.new
|
9
|
+
tag.text = entry.elements["title"].text
|
10
|
+
tags << tag
|
21
11
|
end
|
12
|
+
tags
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_tags_by_album_id(album_id)
|
16
|
+
get_xml("http://picasaweb.google.com/data/feed/api/user/userID/albumid/#{album_id}?kind=tag")
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_tags_by_album_id_and_photo_id(album_id, photo_id)
|
20
|
+
get_xml("http://picasaweb.google.com/data/feed/api/user/default/albumid/#{album_id}/photoid/#{photo_id}?kind=tag")
|
21
|
+
end
|
22
22
|
end
|
@@ -6,7 +6,7 @@ module PicasaWebAlbums
|
|
6
6
|
|
7
7
|
def setup
|
8
8
|
@test_account = YAML::load(File.open(File.expand_path('test/config/test_account.yml')))
|
9
|
-
@repo = PicasaWebAlbums.get_repository(
|
9
|
+
@repo = PicasaWebAlbums.get_repository(@test_account["email"], @test_account["password"])
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_get_all_albums
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'test/unit'
|
2
|
-
require 'shoulda'
|
3
2
|
require_relative '../../lib/picasawebalbums'
|
4
3
|
|
5
4
|
module PicasaWebAlbums
|
@@ -7,7 +6,7 @@ module PicasaWebAlbums
|
|
7
6
|
|
8
7
|
def setup
|
9
8
|
@test_account = YAML::load(File.open(File.expand_path('test/config/test_account.yml')))
|
10
|
-
@repo = PicasaWebAlbums.get_repository(
|
9
|
+
@repo = PicasaWebAlbums.get_repository(@test_account["email"], @test_account["password"])
|
11
10
|
end
|
12
11
|
|
13
12
|
def test_get_all_tags
|
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.4.
|
4
|
+
version: 1.4.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A simple way to retrieve albums, photos, tags, etc. from Picasa Web Albums.
|
15
15
|
email:
|
@@ -19,6 +19,7 @@ extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
21
|
- .gitignore
|
22
|
+
- .rvmrc
|
22
23
|
- Gemfile
|
23
24
|
- PicasaWebAlbums.gemspec
|
24
25
|
- README.md
|
@@ -58,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
59
|
version: '0'
|
59
60
|
requirements: []
|
60
61
|
rubyforge_project: picasawebalbums
|
61
|
-
rubygems_version: 1.8.
|
62
|
+
rubygems_version: 1.8.21
|
62
63
|
signing_key:
|
63
64
|
specification_version: 3
|
64
65
|
summary: Provides programmatic access to Picasa Web Albums data.
|