ppe-panoramio 0.0.1

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.
@@ -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,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,47 @@
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.reverse_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
+ return [] if json['count'] == 0 || json['photos'].size == 0
37
+ struct = Struct.new('Photo', *json['photos'].first.keys)
38
+ json['photos'].map {|p| struct.new(*p.values) }
39
+ end
40
+ end
41
+
42
+ remote_defaults :on_success => lambda {|response| JSON.parse(response.body)},
43
+ :on_failure => lambda {|response| raise "Panoramio.com error: #{response.code}. Response #{response.body}"},
44
+ :cache_responses => 180
45
+ define_remote_method :get_photos, :base_uri => URL
46
+
47
+ 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,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ppe-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-10-03 00:00:00 +01: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: thoughtbot-shoulda
27
+ type: :development
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: jeremymcanally-matchy
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
+ description: Simple Panoramio API client written in Ruby
46
+ email: christian.hellsten@gmail.com
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - LICENSE
53
+ - README
54
+ files:
55
+ - .document
56
+ - .gitignore
57
+ - LICENSE
58
+ - README
59
+ - Rakefile
60
+ - VERSION
61
+ - lib/panoramio.rb
62
+ - test/panoramio_test.rb
63
+ - test/test_helper.rb
64
+ has_rdoc: true
65
+ homepage: http://github.com/christian.hellsten/ruby-panoramio
66
+ licenses: []
67
+
68
+ post_install_message:
69
+ rdoc_options:
70
+ - --charset=UTF-8
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ version:
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
85
+ requirements: []
86
+
87
+ rubyforge_project:
88
+ rubygems_version: 1.3.5
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: Simple Panoramio API client written in Ruby
92
+ test_files:
93
+ - test/panoramio_test.rb
94
+ - test/test_helper.rb