morgoth-picasa 0.1.0

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/README.rdoc ADDED
@@ -0,0 +1,26 @@
1
+ = Picasa
2
+
3
+ Simple google picasa managment.
4
+ Only for public albums so far.
5
+
6
+ = Installation
7
+
8
+ gem sources -a http://gems.github.com
9
+ sudo gem install morgoth-picasa
10
+
11
+ In RAILS_ROOT/config/environment.rb
12
+
13
+ config.gem "morgoth-picasa", :lib => "picasa"
14
+
15
+ == Usage
16
+
17
+ Picasa.albums(google_username)
18
+ #=> [ {:id => "666", :title => "satan-album", :photos_count => '6'}, {another one} ]
19
+
20
+ Picasa.photos(google_username, album_id)
21
+ #=> {:photos => [{ :title, :thumbnail_1, :thumbnail_2, :thumbnail_3, :photo },{}],
22
+ # :slideshow => "link to picasa slideshow"}
23
+
24
+ = Copyright
25
+
26
+ Copyright (c) 2009 Wojciech Wnętrzak, released under the MIT license.
data/Rakefile ADDED
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "picasa"
8
+ gem.summary = %Q{simple google picasa managment}
9
+ gem.email = "w.wnetrzak@gmail.com"
10
+ gem.homepage = "http://github.com/morgoth/picasa"
11
+ gem.authors = ["Wojciech Wnętrzak"]
12
+ gem.add_dependency('xml-simple')
13
+
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ rescue LoadError
17
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/*_test.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+
41
+ task :default => :test
42
+
43
+ require 'rake/rdoctask'
44
+ Rake::RDocTask.new do |rdoc|
45
+ if File.exist?('VERSION.yml')
46
+ config = YAML.load(File.read('VERSION.yml'))
47
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
48
+ else
49
+ version = ""
50
+ end
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "picasa #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
57
+
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :minor: 1
3
+ :patch: 0
4
+ :major: 0
data/lib/picasa.rb ADDED
@@ -0,0 +1,41 @@
1
+ module Picasa
2
+ require 'net/http'
3
+ require "xmlsimple"
4
+
5
+ def albums(google_user)
6
+ #returns [ {:id => "id", :title => "title"}, {another one} ]
7
+ http=Net::HTTP.new('picasaweb.google.com')
8
+ resp, data = http.get("/data/feed/api/user/#{google_user}")
9
+ xml=XmlSimple.xml_in(data, 'KeyAttr' => 'name')
10
+ albums = []
11
+ xml['entry'].each do |album|
12
+ attribute = {}
13
+ attribute[:id] = album['id'][1]
14
+ attribute[:title] = album['title'][0]['content']
15
+ attribute[:photos_count] = album['numphotos'][0]
16
+ albums << attribute
17
+ end
18
+ albums
19
+ end
20
+
21
+ def photos(google_user, album_id)
22
+ #returns {:photos => [:title, :thumbnail, :photo], :slideshow => "link to picasa slideshow"}
23
+ http=Net::HTTP.new('picasaweb.google.com')
24
+ resp, data = http.get("/data/feed/api/user/#{google_user}/albumid/#{album_id}")
25
+ xml=XmlSimple.xml_in(data, 'KeyAttr' => 'name')
26
+ photos = []
27
+ xml['entry'].each do |photo|
28
+ attribute = {}
29
+ attribute[:title] = photo['group'][0]['description'][0]['content'] #returns nil if empty
30
+ attribute[:thumbnail_1] = photo['group'][0]['thumbnail'][0]['url']
31
+ attribute[:thumbnail_2] = photo['group'][0]['thumbnail'][1]['url']
32
+ attribute[:thumbnail_3] = photo['group'][0]['thumbnail'][2]['url']
33
+ #attributes[:photo] << photo['group'][0]['content']['url']
34
+ attribute[:photo] = photo['content']['src']
35
+ photos << attribute
36
+ end
37
+ { :photos => photos, :slideshow => xml['link'][2]['href'] }
38
+ end
39
+
40
+ module_function :albums, :photos
41
+ end
@@ -0,0 +1,11 @@
1
+ require 'test_helper'
2
+
3
+ class PicasaTest < Test::Unit::TestCase
4
+ context 'with xml page' do
5
+ setup {}
6
+
7
+ should 'parse it' do
8
+ assert true
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'picasa'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: morgoth-picasa
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - "Wojciech Wn\xC4\x99trzak"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-12 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: xml-simple
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description:
26
+ email: w.wnetrzak@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.rdoc
33
+ files:
34
+ - README.rdoc
35
+ - Rakefile
36
+ - VERSION.yml
37
+ - lib/picasa.rb
38
+ - test/picasa_test.rb
39
+ - test/test_helper.rb
40
+ has_rdoc: true
41
+ homepage: http://github.com/morgoth/picasa
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --charset=UTF-8
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.2.0
63
+ signing_key:
64
+ specification_version: 2
65
+ summary: simple google picasa managment
66
+ test_files:
67
+ - test/picasa_test.rb
68
+ - test/test_helper.rb