panoramio 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,8 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ tmp/*
5
+ pkg/*
6
+ **/*.log
7
+ rdoc
8
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Christian Hellsten
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
File without changes
@@ -0,0 +1,72 @@
1
+ h1. Ruby Panoramio
2
+
3
+ h2. Introduction
4
+
5
+ The Ruby Panoramio gem is a small library that makes it easy to add photos from "Panoramio.com":http://www.panoramio.com/ to your site.
6
+
7
+ With the Ruby Panoramio you can do the following:
8
+ * Generate valid Panoramio API URLs easily
9
+ * Retrieve Panoramio photos in one call
10
+
11
+ Remember to read the "Panoramio API - Terms of Use":http://www.panoramio.com/api_terms/ before using their API.
12
+
13
+ h2. Installation
14
+
15
+ Via gemcutter.com:
16
+
17
+ <pre>
18
+ <code>
19
+ $ sudo gem install panoramio
20
+ </code>
21
+ </pre>
22
+
23
+ h3. Usage
24
+
25
+
26
+ <pre>
27
+ <code>
28
+ require 'rubygems'
29
+ require 'panoramio'
30
+ </code>
31
+ </pre>
32
+
33
+ h4. Generate a Panoramio API URL
34
+
35
+ <pre>
36
+ <code>
37
+ url = Panoramio.url(:minx => 60,
38
+ :maxx => 70,
39
+ :miny => 10,
40
+ :maxy => 20)
41
+
42
+ => "http://www.panoramio.com/map/get_panoramas.php?order=popularity&maxx=70&miny=10&set=public&maxy=20&from=0&size=thumbnail&to=20&minx=60"
43
+ </code>
44
+ </pre>
45
+
46
+ h4. Retrieve Panoramio photos
47
+
48
+ <pre>
49
+ <code>
50
+ photos = Panoramio.photos(:minx => 60,
51
+ :maxx => 70,
52
+ :miny => 10,
53
+ :maxy => 20)
54
+
55
+ photo = photos.first
56
+
57
+ photo.photo_title
58
+ photo.latitude
59
+ photo.longitude
60
+ </code>
61
+ </pre>
62
+
63
+ h2. Todo
64
+
65
+ * Rename min and max parameters to xyz
66
+ * Validate parameters
67
+ * Rename url method to photos_url?
68
+ * JavaScript widget?
69
+
70
+ h2. Author
71
+
72
+ "Christian Hellsten":http://christianhellsten.com ("Aktagon Ltd.":http://aktagon.com)
@@ -0,0 +1,59 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "panoramio"
8
+ gem.summary = %Q{Simple Panoramio API client written in Ruby}
9
+ gem.description = %Q{Simple Panoramio API client written in Ruby}
10
+ gem.email = "christian.hellsten@gmail.com"
11
+ gem.homepage = "http://github.com/christianhellsten/ruby-panoramio"
12
+ gem.authors = ["Christian Hellsten"]
13
+ gem.add_dependency "pauldix-typhoeus"
14
+ gem.add_dependency "json"
15
+ gem.add_development_dependency "thoughtbot-shoulda"
16
+ gem.add_development_dependency "jeremymcanally-matchy"
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
21
+ end
22
+
23
+ require 'rake/testtask'
24
+ Rake::TestTask.new(:test) do |test|
25
+ test.libs << 'lib' << 'test'
26
+ test.pattern = 'test/**/*_test.rb'
27
+ test.verbose = true
28
+ end
29
+
30
+ begin
31
+ require 'rcov/rcovtask'
32
+ Rcov::RcovTask.new do |test|
33
+ test.libs << 'test'
34
+ test.pattern = 'test/**/*_test.rb'
35
+ test.verbose = true
36
+ end
37
+ rescue LoadError
38
+ task :rcov do
39
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
40
+ end
41
+ end
42
+
43
+ task :test => :check_dependencies
44
+
45
+ task :default => :test
46
+
47
+ require 'rake/rdoctask'
48
+ Rake::RDocTask.new do |rdoc|
49
+ if File.exist?('VERSION')
50
+ version = File.read('VERSION')
51
+ else
52
+ version = ""
53
+ end
54
+
55
+ rdoc.rdoc_dir = 'rdoc'
56
+ rdoc.title = "panoramio #{version}"
57
+ rdoc.rdoc_files.include('README*')
58
+ rdoc.rdoc_files.include('lib/**/*.rb')
59
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,46 @@
1
+ require 'typhoeus'
2
+ require 'json'
3
+ #require 'ruby-debug'
4
+
5
+ #
6
+ # http://www.panoramio.com/api/
7
+ #
8
+ class Panoramio
9
+ include Typhoeus
10
+
11
+ URL = 'http://www.panoramio.com/map/get_panoramas.php'
12
+
13
+ class << self
14
+ def url(options = {})
15
+ "#{URL}?#{to_uri(options)}"
16
+ end
17
+
18
+ def photos(options = {})
19
+ to_photos(get_photos(:params => to_params(options)))
20
+ end
21
+
22
+ protected
23
+ def to_params(options)
24
+ options.merge!({ :order => :popularity,
25
+ :set => :public,
26
+ :size => :thumbnail,
27
+ :from => 0,
28
+ :to => 20 })
29
+ end
30
+
31
+ def to_uri(options)
32
+ to_params(options).map {|key, val| "#{key}=#{val}" }.join("&")
33
+ end
34
+
35
+ def to_photos(json)
36
+ struct = Struct.new('Photo', *json['photos'].first.keys)
37
+ json['photos'].map {|p| struct.new(*p.values) }
38
+ end
39
+ end
40
+
41
+ remote_defaults :on_success => lambda {|response| JSON.parse(response.body)},
42
+ :on_failure => lambda {|response| raise "Panoramio.com error: #{response.code}. Response #{response.body}"},
43
+ :cache_responses => 180
44
+ define_remote_method :get_photos, :base_uri => URL
45
+
46
+ end
@@ -0,0 +1,58 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{panoramio}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Christian Hellsten"]
12
+ s.date = %q{2009-10-03}
13
+ s.description = %q{Simple Panoramio API client written in Ruby}
14
+ s.email = %q{christian.hellsten@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/panoramio.rb",
27
+ "test/panoramio_test.rb",
28
+ "test/test_helper.rb"
29
+ ]
30
+ s.homepage = %q{http://github.com/christian.hellsten/ruby-panoramio}
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.5}
34
+ s.summary = %q{Simple Panoramio API client written in Ruby}
35
+ s.test_files = [
36
+ "test/panoramio_test.rb",
37
+ "test/test_helper.rb"
38
+ ]
39
+
40
+ if s.respond_to? :specification_version then
41
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<pauldix-typhoeus>, [">= 0"])
46
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
47
+ s.add_development_dependency(%q<jeremymcanally-matchy>, [">= 0"])
48
+ else
49
+ s.add_dependency(%q<pauldix-typhoeus>, [">= 0"])
50
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
51
+ s.add_dependency(%q<jeremymcanally-matchy>, [">= 0"])
52
+ end
53
+ else
54
+ s.add_dependency(%q<pauldix-typhoeus>, [">= 0"])
55
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
56
+ s.add_dependency(%q<jeremymcanally-matchy>, [">= 0"])
57
+ end
58
+ end
@@ -0,0 +1,43 @@
1
+ require 'test_helper'
2
+ require 'uri'
3
+
4
+ class PanoramioTest < Test::Unit::TestCase
5
+ should "generate Panoramio API URLs" do
6
+ url = Panoramio.url(:order => :popularity,
7
+ :set => :public,
8
+ :from => 0,
9
+ :to => 10,
10
+ :minx => 60,
11
+ :maxx => 70,
12
+ :miny => 10,
13
+ :maxy => 20,
14
+ :size => :medium)
15
+ expected = "http://www.panoramio.com/map/get_panoramas.php?order=popularity&maxx=70&miny=10&set=public&maxy=20&from=0&size=thumbnail&to=20&minx=60"
16
+ url.should == expected
17
+ URI.parse(url).to_s.should == expected
18
+ end
19
+
20
+ should "generate Panoramio API URLs with default parameters" do
21
+ url = Panoramio.url(:minx => 60,
22
+ :maxx => 70,
23
+ :miny => 10,
24
+ :maxy => 20)
25
+ expected = "http://www.panoramio.com/map/get_panoramas.php?order=popularity&maxx=70&miny=10&set=public&maxy=20&from=0&size=thumbnail&to=20&minx=60"
26
+ url.should == expected
27
+ URI.parse(url).to_s.should == expected
28
+ end
29
+
30
+ context "support Panoramio REST API" do
31
+ should "GET /get_panoramas.php" do
32
+ photos = Panoramio.photos(:minx => 60,
33
+ :maxx => 70,
34
+ :miny => 10,
35
+ :maxy => 20)
36
+
37
+ photos.size.should == 20
38
+ photos.first.photo_title.should_not == nil
39
+ photos.first.latitude.should_not == nil
40
+ photos.first.longitude.should_not == nil
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'matchy'
5
+
6
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
8
+ require 'panoramio'
9
+
10
+ class Test::Unit::TestCase
11
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: panoramio
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Christian Hellsten
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-04 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: pauldix-typhoeus
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
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: thoughtbot-shoulda
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: jeremymcanally-matchy
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ description: Simple Panoramio API client written in Ruby
56
+ email: christian.hellsten@gmail.com
57
+ executables: []
58
+
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - LICENSE
63
+ - README
64
+ - README.textile
65
+ files:
66
+ - .document
67
+ - .gitignore
68
+ - LICENSE
69
+ - README
70
+ - README.textile
71
+ - Rakefile
72
+ - VERSION
73
+ - lib/panoramio.rb
74
+ - panoramio.gemspec
75
+ - test/panoramio_test.rb
76
+ - test/test_helper.rb
77
+ has_rdoc: true
78
+ homepage: http://github.com/christianhellsten/ruby-panoramio
79
+ licenses: []
80
+
81
+ post_install_message:
82
+ rdoc_options:
83
+ - --charset=UTF-8
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
91
+ version:
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: "0"
97
+ version:
98
+ requirements: []
99
+
100
+ rubyforge_project:
101
+ rubygems_version: 1.3.5
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: Simple Panoramio API client written in Ruby
105
+ test_files:
106
+ - test/panoramio_test.rb
107
+ - test/test_helper.rb