geoplanet 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +3 -1
- data/geoplanet.gemspec +10 -10
- data/lib/geoplanet.rb +4 -4
- data/lib/geoplanet/base.rb +2 -1
- data/lib/geoplanet/place.rb +11 -11
- data/lib/geoplanet/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 541c8406d8b069526b90a0d107fe69077d1bce66
|
4
|
+
data.tar.gz: bd1b20bba88e035d7bd4b1ec591489e98796471a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cb3bc646df6394e049c9e2230a3ab00cf75f96cc75c055f9ad2b9ebd184f92868fa54adfa02c8e7dd4c44645ab8a8d20669bc6602492e30da2c430953240867
|
7
|
+
data.tar.gz: 1ecef6f061c9ebb86182225701ff1d8f37589d3f345f881fa68cbe7383271bf46a6309680c5a02e6255f01b70dc6e5f1c3083326549548d44945e60d57c49819
|
data/README.rdoc
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
{<img src="https://badge.fury.io/rb/geoplanet.svg" alt="Gem Version" />}[http://badge.fury.io/rb/geoplanet]
|
2
|
+
|
1
3
|
= geoplanet
|
2
4
|
|
3
5
|
A Ruby wrapper for the Yahoo! GeoPlanet APIs. It's inspired on Mattt Thompson's yahoo-geoplanet gem,
|
@@ -140,4 +142,4 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
140
142
|
|
141
143
|
Carlos Paramio
|
142
144
|
|
143
|
-
http://
|
145
|
+
http://carlosparamio.com
|
data/geoplanet.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
|
-
s.name
|
3
|
-
s.version
|
4
|
-
s.date
|
5
|
-
s.summary
|
6
|
-
s.email
|
7
|
-
s.homepage
|
2
|
+
s.name = "geoplanet"
|
3
|
+
s.version = "0.2.8"
|
4
|
+
s.date = "2014-05-09"
|
5
|
+
s.summary = "A Ruby wrapper for the Yahoo! GeoPlanet API."
|
6
|
+
s.email = "carlosparamio@gmail.com"
|
7
|
+
s.homepage = "http://github.com/carlosparamio/geoplanet/"
|
8
8
|
s.description = "A Ruby wrapper for the Yahoo! GeoPlanet API. It uses JSON format by default to minimize bandwidth usage. See http://developer.yahoo.com/geo/ for more information about the API."
|
9
|
-
s.authors
|
9
|
+
s.authors = ["Carlos Paramio"]
|
10
10
|
|
11
|
-
s.files
|
11
|
+
s.files = [
|
12
12
|
"README.rdoc",
|
13
13
|
"CONTRIBUTORS",
|
14
14
|
"geoplanet.gemspec",
|
@@ -18,8 +18,8 @@ Gem::Specification.new do |s|
|
|
18
18
|
"lib/geoplanet/version.rb"
|
19
19
|
]
|
20
20
|
|
21
|
-
s.
|
22
|
-
s.
|
21
|
+
s.add_runtime_dependency 'rest-client', '~> 0.9'
|
22
|
+
s.add_runtime_dependency 'json', '~> 1.1'
|
23
23
|
|
24
24
|
s.has_rdoc = false
|
25
25
|
s.rdoc_options = ["--main", "README.rdoc"]
|
data/lib/geoplanet.rb
CHANGED
@@ -7,12 +7,12 @@ require 'geoplanet/place'
|
|
7
7
|
module GeoPlanet
|
8
8
|
API_VERSION = "v1"
|
9
9
|
API_URL = "http://where.yahooapis.com/#{API_VERSION}/"
|
10
|
-
|
10
|
+
|
11
11
|
class << self
|
12
12
|
attr_accessor :appid, :debug
|
13
13
|
end
|
14
14
|
|
15
|
-
class BadRequest
|
16
|
-
class NotFound
|
17
|
-
class NotAcceptable
|
15
|
+
class BadRequest < StandardError; end
|
16
|
+
class NotFound < StandardError; end
|
17
|
+
class NotAcceptable < StandardError; end
|
18
18
|
end
|
data/lib/geoplanet/base.rb
CHANGED
data/lib/geoplanet/place.rb
CHANGED
@@ -25,8 +25,8 @@ module GeoPlanet
|
|
25
25
|
|
26
26
|
def self.get_then_parse(url)
|
27
27
|
results = JSON.parse get(url).to_s
|
28
|
-
return results['places']['place'].map{|attrs|
|
29
|
-
return
|
28
|
+
return results['places']['place'].map{|attrs| self.new attrs} if results['places']
|
29
|
+
return self.new(results['place']) if results['place']
|
30
30
|
nil
|
31
31
|
rescue
|
32
32
|
nil
|
@@ -34,11 +34,11 @@ module GeoPlanet
|
|
34
34
|
|
35
35
|
%w(parent ancestors belongtos neighbors siblings children descendants).each do |association|
|
36
36
|
self.instance_eval <<-RUBY, __FILE__, __LINE__ + 1
|
37
|
-
|
37
|
+
def self.#{association}_of(woeid, options = {})
|
38
38
|
url = build_url("place/\#{woeid}/#{association}", options.merge(:format => "json"))
|
39
39
|
puts "Yahoo GeoPlanet: GET \#{url}" if GeoPlanet.debug
|
40
|
-
|
41
|
-
|
40
|
+
get_then_parse(url)
|
41
|
+
end
|
42
42
|
RUBY
|
43
43
|
end
|
44
44
|
|
@@ -55,7 +55,7 @@ module GeoPlanet
|
|
55
55
|
def initialize_with_woe(woe, options = {})
|
56
56
|
url = self.class.build_url("place/#{woe}", options.merge(:format => "json"))
|
57
57
|
puts "Yahoo GeoPlanet: GET #{url}" if GeoPlanet.debug
|
58
|
-
initialize_with_attrs JSON.parse(
|
58
|
+
initialize_with_attrs JSON.parse(self.class.get(url))['place']
|
59
59
|
end
|
60
60
|
|
61
61
|
|
@@ -78,7 +78,7 @@ module GeoPlanet
|
|
78
78
|
attrs['boundingBox']['southWest']['longitude'] ],
|
79
79
|
[ attrs['boundingBox']['northEast']['latitude'],
|
80
80
|
attrs['boundingBox']['northEast']['longitude'] ],
|
81
|
-
|
81
|
+
]
|
82
82
|
@country = attrs['country']
|
83
83
|
@country_code = attrs['country attrs']['code'] rescue nil
|
84
84
|
@postal = attrs['postal']
|
@@ -104,9 +104,9 @@ module GeoPlanet
|
|
104
104
|
# Association Collections
|
105
105
|
%w(parent ancestors belongtos neighbors siblings children descendants).each do |association|
|
106
106
|
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
107
|
-
|
108
|
-
|
109
|
-
|
107
|
+
def #{association}(options = {})
|
108
|
+
self.class.send("#{association}_of", self.woeid, options)
|
109
|
+
end
|
110
110
|
RUBY
|
111
111
|
end
|
112
112
|
|
@@ -119,7 +119,7 @@ module GeoPlanet
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def inspect
|
122
|
-
"
|
122
|
+
"#<#{self.class} #{instance_variables.map{|ivar| "#{ivar}: #{instance_variable_get(ivar).inspect}"}.join(', ')}>"
|
123
123
|
end
|
124
124
|
|
125
125
|
end
|
data/lib/geoplanet/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoplanet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Paramio
|
@@ -14,30 +14,30 @@ dependencies:
|
|
14
14
|
name: rest-client
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.9'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.1
|
33
|
+
version: '1.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.1
|
40
|
+
version: '1.1'
|
41
41
|
description: A Ruby wrapper for the Yahoo! GeoPlanet API. It uses JSON format by default
|
42
42
|
to minimize bandwidth usage. See http://developer.yahoo.com/geo/ for more information
|
43
43
|
about the API.
|