yilp 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +16 -0
- data/README.rdoc +29 -0
- data/Rakefile +15 -0
- data/config/yilp_appid.yml +12 -0
- data/lib/yilp.rb +58 -0
- data/spec/fixtures/places_sydney.xml +2 -0
- data/spec/fixtures/placetypes.xml +2 -0
- data/spec/fixtures/woid_1105779.xml +2 -0
- data/spec/fixtures/woid_1105779_ancestors.xml +2 -0
- data/spec/fixtures/woid_1105779_belongto.xml +2 -0
- data/spec/fixtures/woid_1105779_children.xml +2 -0
- data/spec/fixtures/woid_1105779_neighbors.xml +2 -0
- data/spec/fixtures/woid_1105779_parent.xml +2 -0
- data/spec/fixtures/woid_1105779_siblings.xml +2 -0
- data/spec/specs.html +209 -0
- data/spec/yilp_spec.rb +99 -0
- data/yilp.gemspec +34 -0
- metadata +84 -0
data/Manifest
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
config/yilp_appid.yml
|
2
|
+
lib/yilp.rb
|
3
|
+
Rakefile
|
4
|
+
README.rdoc
|
5
|
+
spec/fixtures/places_sydney.xml
|
6
|
+
spec/fixtures/placetypes.xml
|
7
|
+
spec/fixtures/woid_1105779.xml
|
8
|
+
spec/fixtures/woid_1105779_ancestors.xml
|
9
|
+
spec/fixtures/woid_1105779_belongto.xml
|
10
|
+
spec/fixtures/woid_1105779_children.xml
|
11
|
+
spec/fixtures/woid_1105779_neighbors.xml
|
12
|
+
spec/fixtures/woid_1105779_parent.xml
|
13
|
+
spec/fixtures/woid_1105779_siblings.xml
|
14
|
+
spec/specs.html
|
15
|
+
spec/yilp_spec.rb
|
16
|
+
Manifest
|
data/README.rdoc
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
In simple terms, the Service allows you to look up the unique identifier - called the Where on Earth ID, or WOEID - for
|
2
|
+
almost any named place on the Earth; it also allows you to resolve a WOEID you have received from a third party - such as
|
3
|
+
Fire Eagle™ or Upcoming - to the place it represents.
|
4
|
+
|
5
|
+
The API is accessed via HTTP GET; the following examples can be cut-and-paste into a web browser to view the results:
|
6
|
+
|
7
|
+
Find the WOEID of a significant landmark:
|
8
|
+
http://where.yahooapis.com/v1/places.q('sydney%20opera%20house')
|
9
|
+
|
10
|
+
Resolve a WOEID to a place:
|
11
|
+
http://where.yahooapis.com/v1/place/2507854
|
12
|
+
|
13
|
+
Find the WOEID of a specific place:
|
14
|
+
http://where.yahooapis.com/v1/places.q('northfield%20mn%20usa')
|
15
|
+
|
16
|
+
Obtain a range of WOEIDs that match a given place, ordered by the most likely:
|
17
|
+
http://where.yahooapis.com/v1/places.q('springfield');start=0;count=5
|
18
|
+
|
19
|
+
Find the parent of a given WOEID (and return a detailed record):
|
20
|
+
http://where.yahooapis.com/v1/place/638242/parent?select=long
|
21
|
+
|
22
|
+
Return the Placename for a given WOEID in a specific language (where it exists):
|
23
|
+
http://where.yahooapis.com/v1/places.q('usa')?lang=fr
|
24
|
+
|
25
|
+
To obtain the representation of a place in JSON format:
|
26
|
+
http://where.yahooapis.com/v1/place/2487956?format=json
|
27
|
+
|
28
|
+
To obtain a list of geographies that neighbor a specific WOEID:
|
29
|
+
http://where.yahooapis.com/v1/place/12795711/neighbors
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rake"
|
3
|
+
require "echoe"
|
4
|
+
|
5
|
+
Echoe.new('yilp', '0.1') do |p|
|
6
|
+
p.description = "Ruby wrapper arround Yahoo Internet Location Platform"
|
7
|
+
# p.url = "http://github.com/sabman/yilp"
|
8
|
+
p.url = "http://yilp.rubyforge.org"
|
9
|
+
p.author = "Shoaib Burq & David Troy"
|
10
|
+
p.email = "shoaib@nomad-labs.com"
|
11
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
12
|
+
p.development_dependencies = ["active_support"]
|
13
|
+
end
|
14
|
+
|
15
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
@@ -0,0 +1,12 @@
|
|
1
|
+
appid:
|
2
|
+
fallback:
|
3
|
+
RKxL3NrV34Fwy2Xx2IRhxKz_cy4ESJWC9QUyr45ZMdnj85FXjIGs.yrUdBTQyXWFZu8-
|
4
|
+
|
5
|
+
test:
|
6
|
+
RKxL3NrV34Fwy2Xx2IRhxKz_cy4ESJWC9QUyr45ZMdnj85FXjIGs.yrUdBTQyXWFZu8-
|
7
|
+
|
8
|
+
development:
|
9
|
+
RKxL3NrV34Fwy2Xx2IRhxKz_cy4ESJWC9QUyr45ZMdnj85FXjIGs.yrUdBTQyXWFZu8-
|
10
|
+
|
11
|
+
production:
|
12
|
+
RKxL3NrV34Fwy2Xx2IRhxKz_cy4ESJWC9QUyr45ZMdnj85FXjIGs.yrUdBTQyXWFZu8-
|
data/lib/yilp.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require "open-uri"
|
3
|
+
require "active_support"
|
4
|
+
module YILP
|
5
|
+
class YILP
|
6
|
+
APP_ID = ENV["RAILS_ENV"].nil? ?
|
7
|
+
YAML::load_file("./config/yilp_appid.yml")["appid"]["fallback"] :
|
8
|
+
YAML::load_file("./config/yilp_appid.yml")["appid"][ENV["RAILS_ENV"]]
|
9
|
+
|
10
|
+
@@lang_hash = {
|
11
|
+
:French => 'fr',
|
12
|
+
:German => 'de',
|
13
|
+
:Italian => 'de',
|
14
|
+
:Dutch => 'nl',
|
15
|
+
:Greek => 'el',
|
16
|
+
:Spanish => 'es',
|
17
|
+
:Portuguese => 'pt',
|
18
|
+
:Arabic => 'ar',
|
19
|
+
:Hebrew => 'he',
|
20
|
+
:Russian => 'ru',
|
21
|
+
:Chinese => 'zh',
|
22
|
+
:Japanese => 'ja',
|
23
|
+
:Hindi => 'hi',
|
24
|
+
:Urdu => 'ur',
|
25
|
+
:Sanskrit => 'sa'
|
26
|
+
}
|
27
|
+
|
28
|
+
@@baseurl = "http://where.yahooapis.com/v1"
|
29
|
+
|
30
|
+
def self.find(query, options={})
|
31
|
+
if query.is_a?(Fixnum) # /place/{woeid}
|
32
|
+
valid_keys = [:neighbors, :parent, :ancestors, :belongtos, :siblings, :children]
|
33
|
+
options.assert_valid_keys(valid_keys)
|
34
|
+
url = "place/#{query}"
|
35
|
+
valid_keys.find { |k| url += "/#{k.to_s}" if options[k] }
|
36
|
+
url += "?appid=#{APP_ID}"
|
37
|
+
else # /places.q('query')
|
38
|
+
valid_keys = [:lang]
|
39
|
+
options.assert_valid_keys(valid_keys)
|
40
|
+
url = "places.q(#{URI.encode(query)})"
|
41
|
+
url += "?appid=#{APP_ID}"
|
42
|
+
url += "&lang=#{lang(options[:lang])}" if options[:lang]
|
43
|
+
end
|
44
|
+
Hash.from_xml(open("#{@@baseurl}/#{url}"))
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.placetypes
|
48
|
+
# http://where.yahooapis.com/v1/placetypes?appid=RKxL3NrV34Fwy2Xx2IRhxKz_cy4ESJWC9QUyr45ZMdnj85FXjIGs.yrUdBTQyXWFZu8-
|
49
|
+
url = "placetypes?appid=#{APP_ID}"
|
50
|
+
Hash.from_xml(open("#{@@baseurl}/#{url}"))
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.lang(lang)
|
54
|
+
language = @@lang_hash[lang.to_s.capitalize.to_sym]
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,2 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<places xmlns="http://where.yahooapis.com/v1/schema.rng" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:start="0" yahoo:count="1" yahoo:total="1"><place yahoo:uri="http://where.yahooapis.com/v1/place/1105779" xml:lang="en"><woeid>1105779</woeid><placeTypeName code="7">Town</placeTypeName><name>Sydney</name><country type="Country" code="AU">Australia</country><admin1 type="State" code="AU-NSW">New South Wales</admin1><admin2></admin2><admin3></admin3><locality1>Sydney</locality1><locality2></locality2><postal></postal><centroid><latitude>-33.869629</latitude><longitude>151.206955</longitude></centroid><boundingBox><southWest><latitude>-34.18961</latitude><longitude>150.517166</longitude></southWest><northEast><latitude>-33.57814</latitude><longitude>151.342575</longitude></northEast></boundingBox></place></places>
|
@@ -0,0 +1,2 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<placeTypes xmlns="http://where.yahooapis.com/v1/schema.rng" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:start="0" yahoo:count="32" yahoo:total="32"><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/0" xml:lang="en"><placeTypeName code="0">Undefined</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/1" xml:lang="en"><placeTypeName code="1">Geocoded Building</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/2" xml:lang="en"><placeTypeName code="2">Geocoded Segment</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/3" xml:lang="en"><placeTypeName code="3">Geocoded Nearby Building</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/4" xml:lang="en"><placeTypeName code="4">Geocoded Street</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/5" xml:lang="en"><placeTypeName code="5">Geocoded Intersection</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/6" xml:lang="en"><placeTypeName code="6">Street</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/7" xml:lang="en"><placeTypeName code="7">Town</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/8" xml:lang="en"><placeTypeName code="8">State</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/9" xml:lang="en"><placeTypeName code="9">County</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/10" xml:lang="en"><placeTypeName code="10">Local Admin</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/11" xml:lang="en"><placeTypeName code="11">Postal Code</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/12" xml:lang="en"><placeTypeName code="12">Country</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/13" xml:lang="en"><placeTypeName code="13">Island</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/14" xml:lang="en"><placeTypeName code="14">Airport</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/15" xml:lang="en"><placeTypeName code="15">Drainage</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/16" xml:lang="en"><placeTypeName code="16">Land Feature</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/17" xml:lang="en"><placeTypeName code="17">Miscellaneous</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/18" xml:lang="en"><placeTypeName code="18">Nationality</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/19" xml:lang="en"><placeTypeName code="19">Supername</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/20" xml:lang="en"><placeTypeName code="20">Point of Interest</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/21" xml:lang="en"><placeTypeName code="21">Region</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/22" xml:lang="en"><placeTypeName code="22">Suburb</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/23" xml:lang="en"><placeTypeName code="23">Sports Team</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/24" xml:lang="en"><placeTypeName code="24">Colloquial</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/25" xml:lang="en"><placeTypeName code="25">Zone</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/26" xml:lang="en"><placeTypeName code="26">Historical State</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/27" xml:lang="en"><placeTypeName code="27">Historical County</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/29" xml:lang="en"><placeTypeName code="29">Continent</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/31" xml:lang="en"><placeTypeName code="31">Time Zone</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/32" xml:lang="en"><placeTypeName code="32">Geocoded Nearby Intersection</placeTypeName></placeType><placeType yahoo:uri="http://where.yahooapis.com/v1/placetype/33" xml:lang="en"><placeTypeName code="33">Estate</placeTypeName></placeType></placeTypes>
|
@@ -0,0 +1,2 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<place xmlns="http://where.yahooapis.com/v1/schema.rng" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:uri="http://where.yahooapis.com/v1/place/1105779" xml:lang="en"><woeid>1105779</woeid><placeTypeName code="7">Town</placeTypeName><name>Sydney</name><country type="Country" code="AU">Australia</country><admin1 type="State" code="AU-NSW">New South Wales</admin1><admin2></admin2><admin3></admin3><locality1>Sydney</locality1><locality2></locality2><postal></postal><centroid><latitude>-33.869629</latitude><longitude>151.206955</longitude></centroid><boundingBox><southWest><latitude>-34.18961</latitude><longitude>150.517166</longitude></southWest><northEast><latitude>-33.57814</latitude><longitude>151.342575</longitude></northEast></boundingBox></place>
|
@@ -0,0 +1,2 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<places xmlns="http://where.yahooapis.com/v1/schema.rng" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:start="0" yahoo:count="3" yahoo:total="3"><place yahoo:uri="http://where.yahooapis.com/v1/place/2344700" xml:lang="en"><woeid>2344700</woeid><placeTypeName code="8">State</placeTypeName><name>New South Wales</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/23424748" xml:lang="en"><woeid>23424748</woeid><placeTypeName code="12">Country</placeTypeName><name>Australia</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/24865674" xml:lang="en"><woeid>24865674</woeid><placeTypeName code="29">Continent</placeTypeName><name>Pacific</name></place></places>
|
@@ -0,0 +1,2 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<places xmlns="http://where.yahooapis.com/v1/schema.rng" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:start="0" yahoo:count="9" yahoo:total="9"><place yahoo:uri="http://where.yahooapis.com/v1/place/23509401" xml:lang="en"><woeid>23509401</woeid><placeTypeName code="24">Colloquial</placeTypeName><name>South Coast NSW</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/2344700" xml:lang="en"><woeid>2344700</woeid><placeTypeName code="8">State</placeTypeName><name>New South Wales</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/28350885" xml:lang="en"><woeid>28350885</woeid><placeTypeName code="31">Time Zone</placeTypeName><name>Australia/Sydney</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/23424748" xml:lang="en"><woeid>23424748</woeid><placeTypeName code="12">Country</placeTypeName><name>Australia</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/24865674" xml:lang="en"><woeid>24865674</woeid><placeTypeName code="29">Continent</placeTypeName><name>Pacific</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/28289417" xml:lang="en"><woeid>28289417</woeid><placeTypeName code="19">Supername</placeTypeName><name>Oceania</name></place></places>
|
@@ -0,0 +1,2 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<places xmlns="http://where.yahooapis.com/v1/schema.rng" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:start="0" yahoo:count="10" yahoo:total="1450"><place yahoo:uri="http://where.yahooapis.com/v1/place/1093994" xml:lang="en"><woeid>1093994</woeid><placeTypeName code="22">Suburb</placeTypeName><name>Abbotsford</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1094076" xml:lang="en"><woeid>1094076</woeid><placeTypeName code="22">Suburb</placeTypeName><name>Annandale</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1094115" xml:lang="en"><woeid>1094115</woeid><placeTypeName code="22">Suburb</placeTypeName><name>Artarmon</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1094126" xml:lang="en"><woeid>1094126</woeid><placeTypeName code="22">Suburb</placeTypeName><name>Ashfield</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1094130" xml:lang="en"><woeid>1094130</woeid><placeTypeName code="22">Suburb</placeTypeName><name>Asquith</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1094146" xml:lang="en"><woeid>1094146</woeid><placeTypeName code="22">Suburb</placeTypeName><name>Avalon</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1094203" xml:lang="en"><woeid>1094203</woeid><placeTypeName code="22">Suburb</placeTypeName><name>Balgowlah</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1094215" xml:lang="en"><woeid>1094215</woeid><placeTypeName code="22">Suburb</placeTypeName><name>Balmain</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1094231" xml:lang="en"><woeid>1094231</woeid><placeTypeName code="22">Suburb</placeTypeName><name>Bangor</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1094233" xml:lang="en"><woeid>1094233</woeid><placeTypeName code="22">Suburb</placeTypeName><name>Banksmeadow</name></place></places>
|
@@ -0,0 +1,2 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<places xmlns="http://where.yahooapis.com/v1/schema.rng" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:start="0" yahoo:count="10" yahoo:total="67"><place yahoo:uri="http://where.yahooapis.com/v1/place/55863721" xml:lang="en"><woeid>55863721</woeid><placeTypeName code="7">Town</placeTypeName><name>Macdonaldtown</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/22721293" xml:lang="en"><woeid>22721293</woeid><placeTypeName code="7">Town</placeTypeName><name>Pleasure Point</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/28585730" xml:lang="en"><woeid>28585730</woeid><placeTypeName code="7">Town</placeTypeName><name>Ku-Ring-Gai Chase</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/55864471" xml:lang="en"><woeid>55864471</woeid><placeTypeName code="7">Town</placeTypeName><name>Chisholm Centre</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1096314" xml:lang="en"><woeid>1096314</woeid><placeTypeName code="7">Town</placeTypeName><name>Holsworthy</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1101796" xml:lang="en"><woeid>1101796</woeid><placeTypeName code="7">Town</placeTypeName><name>Dural</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1096586" xml:lang="en"><woeid>1096586</woeid><placeTypeName code="7">Town</placeTypeName><name>Kenthurst</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/22721374" xml:lang="en"><woeid>22721374</woeid><placeTypeName code="7">Town</placeTypeName><name>Lucas Heights</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1094387" xml:lang="en"><woeid>1094387</woeid><placeTypeName code="7">Town</placeTypeName><name>Berrilee</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1101412" xml:lang="en"><woeid>1101412</woeid><placeTypeName code="7">Town</placeTypeName><name>Cowan</name></place></places>
|
@@ -0,0 +1,2 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<place xmlns="http://where.yahooapis.com/v1/schema.rng" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:uri="http://where.yahooapis.com/v1/place/2344700" xml:lang="en"><woeid>2344700</woeid><placeTypeName code="8">State</placeTypeName><name>New South Wales</name></place>
|
@@ -0,0 +1,2 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<places xmlns="http://where.yahooapis.com/v1/schema.rng" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:start="0" yahoo:count="3" yahoo:total="3"><place yahoo:uri="http://where.yahooapis.com/v1/place/1104584" xml:lang="en"><woeid>1104584</woeid><placeTypeName code="7">Town</placeTypeName><name>Newcastle</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1105779" xml:lang="en"><woeid>1105779</woeid><placeTypeName code="7">Town</placeTypeName><name>Sydney</name></place><place yahoo:uri="http://where.yahooapis.com/v1/place/1106771" xml:lang="en"><woeid>1106771</woeid><placeTypeName code="7">Town</placeTypeName><name>Wollongong</name></place></places>
|
data/spec/specs.html
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
6
|
+
<head>
|
7
|
+
<title>RSpec results</title>
|
8
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
9
|
+
<meta http-equiv="Expires" content="-1" />
|
10
|
+
<meta http-equiv="Pragma" content="no-cache" />
|
11
|
+
<style type="text/css">
|
12
|
+
body {
|
13
|
+
margin: 0;
|
14
|
+
padding: 0;
|
15
|
+
background: #fff;
|
16
|
+
font-size: 80%;
|
17
|
+
}
|
18
|
+
</style>
|
19
|
+
</head>
|
20
|
+
<body>
|
21
|
+
<div class="rspec-report">
|
22
|
+
<script type="text/javascript">
|
23
|
+
// <![CDATA[
|
24
|
+
function moveProgressBar(percentDone) {
|
25
|
+
document.getElementById("rspec-header").style.width = percentDone +"%";
|
26
|
+
}
|
27
|
+
function makeRed(element_id) {
|
28
|
+
document.getElementById(element_id).style.background = '#C40D0D';
|
29
|
+
document.getElementById(element_id).style.color = '#FFFFFF';
|
30
|
+
}
|
31
|
+
|
32
|
+
function makeYellow(element_id) {
|
33
|
+
if (element_id == "rspec-header" && document.getElementById(element_id).style.background != '#C40D0D')
|
34
|
+
{
|
35
|
+
document.getElementById(element_id).style.background = '#FAF834';
|
36
|
+
document.getElementById(element_id).style.color = '#000000';
|
37
|
+
}
|
38
|
+
else
|
39
|
+
{
|
40
|
+
document.getElementById(element_id).style.background = '#FAF834';
|
41
|
+
document.getElementById(element_id).style.color = '#000000';
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
// ]]>
|
46
|
+
</script>
|
47
|
+
<style type="text/css">
|
48
|
+
#rspec-header {
|
49
|
+
background: #65C400; color: #fff;
|
50
|
+
}
|
51
|
+
|
52
|
+
.rspec-report h1 {
|
53
|
+
margin: 0px 10px 0px 10px;
|
54
|
+
padding: 10px;
|
55
|
+
font-family: "Lucida Grande", Helvetica, sans-serif;
|
56
|
+
font-size: 1.8em;
|
57
|
+
}
|
58
|
+
|
59
|
+
#summary {
|
60
|
+
margin: 0; padding: 5px 10px;
|
61
|
+
font-family: "Lucida Grande", Helvetica, sans-serif;
|
62
|
+
text-align: right;
|
63
|
+
position: absolute;
|
64
|
+
top: 0px;
|
65
|
+
right: 0px;
|
66
|
+
}
|
67
|
+
|
68
|
+
#summary p {
|
69
|
+
margin: 0 0 0 2px;
|
70
|
+
}
|
71
|
+
|
72
|
+
#summary #totals {
|
73
|
+
font-size: 1.2em;
|
74
|
+
}
|
75
|
+
|
76
|
+
.example_group {
|
77
|
+
margin: 0 10px 5px;
|
78
|
+
background: #fff;
|
79
|
+
}
|
80
|
+
|
81
|
+
dl {
|
82
|
+
margin: 0; padding: 0 0 5px;
|
83
|
+
font: normal 11px "Lucida Grande", Helvetica, sans-serif;
|
84
|
+
}
|
85
|
+
|
86
|
+
dt {
|
87
|
+
padding: 3px;
|
88
|
+
background: #65C400;
|
89
|
+
color: #fff;
|
90
|
+
font-weight: bold;
|
91
|
+
}
|
92
|
+
|
93
|
+
dd {
|
94
|
+
margin: 5px 0 5px 5px;
|
95
|
+
padding: 3px 3px 3px 18px;
|
96
|
+
}
|
97
|
+
|
98
|
+
dd.spec.passed {
|
99
|
+
border-left: 5px solid #65C400;
|
100
|
+
border-bottom: 1px solid #65C400;
|
101
|
+
background: #DBFFB4; color: #3D7700;
|
102
|
+
}
|
103
|
+
|
104
|
+
dd.spec.failed {
|
105
|
+
border-left: 5px solid #C20000;
|
106
|
+
border-bottom: 1px solid #C20000;
|
107
|
+
color: #C20000; background: #FFFBD3;
|
108
|
+
}
|
109
|
+
|
110
|
+
dd.spec.not_implemented {
|
111
|
+
border-left: 5px solid #FAF834;
|
112
|
+
border-bottom: 1px solid #FAF834;
|
113
|
+
background: #FCFB98; color: #131313;
|
114
|
+
}
|
115
|
+
|
116
|
+
dd.spec.pending_fixed {
|
117
|
+
border-left: 5px solid #0000C2;
|
118
|
+
border-bottom: 1px solid #0000C2;
|
119
|
+
color: #0000C2; background: #D3FBFF;
|
120
|
+
}
|
121
|
+
|
122
|
+
.backtrace {
|
123
|
+
color: #000;
|
124
|
+
font-size: 12px;
|
125
|
+
}
|
126
|
+
|
127
|
+
a {
|
128
|
+
color: #BE5C00;
|
129
|
+
}
|
130
|
+
|
131
|
+
/* Ruby code, style similar to vibrant ink */
|
132
|
+
.ruby {
|
133
|
+
font-size: 12px;
|
134
|
+
font-family: monospace;
|
135
|
+
color: white;
|
136
|
+
background-color: black;
|
137
|
+
padding: 0.1em 0 0.2em 0;
|
138
|
+
}
|
139
|
+
|
140
|
+
.ruby .keyword { color: #FF6600; }
|
141
|
+
.ruby .constant { color: #339999; }
|
142
|
+
.ruby .attribute { color: white; }
|
143
|
+
.ruby .global { color: white; }
|
144
|
+
.ruby .module { color: white; }
|
145
|
+
.ruby .class { color: white; }
|
146
|
+
.ruby .string { color: #66FF00; }
|
147
|
+
.ruby .ident { color: white; }
|
148
|
+
.ruby .method { color: #FFCC00; }
|
149
|
+
.ruby .number { color: white; }
|
150
|
+
.ruby .char { color: white; }
|
151
|
+
.ruby .comment { color: #9933CC; }
|
152
|
+
.ruby .symbol { color: white; }
|
153
|
+
.ruby .regex { color: #44B4CC; }
|
154
|
+
.ruby .punct { color: white; }
|
155
|
+
.ruby .escape { color: white; }
|
156
|
+
.ruby .interp { color: white; }
|
157
|
+
.ruby .expr { color: white; }
|
158
|
+
|
159
|
+
.ruby .offending { background-color: gray; }
|
160
|
+
.ruby .linenum {
|
161
|
+
width: 75px;
|
162
|
+
padding: 0.1em 1em 0.2em 0;
|
163
|
+
color: #000000;
|
164
|
+
background-color: #FFFBD3;
|
165
|
+
}
|
166
|
+
|
167
|
+
</style>
|
168
|
+
|
169
|
+
<div id="rspec-header">
|
170
|
+
<h1>RSpec Results</h1>
|
171
|
+
|
172
|
+
<div id="summary">
|
173
|
+
<p id="totals"> </p>
|
174
|
+
<p id="duration"> </p>
|
175
|
+
</div>
|
176
|
+
</div>
|
177
|
+
|
178
|
+
<div class="results">
|
179
|
+
<div class="example_group">
|
180
|
+
<dl>
|
181
|
+
<dt id="example_group_1">YILP</dt>
|
182
|
+
<script type="text/javascript">moveProgressBar('10.0');</script>
|
183
|
+
<dd class="spec passed"><span class="passed_spec_name">should accept a query string and return a valid hash</span></dd>
|
184
|
+
<script type="text/javascript">moveProgressBar('20.0');</script>
|
185
|
+
<dd class="spec passed"><span class="passed_spec_name">should accept a numeric WOEID and return a valid hash</span></dd>
|
186
|
+
<script type="text/javascript">moveProgressBar('30.0');</script>
|
187
|
+
<dd class="spec passed"><span class="passed_spec_name">should accept a numeric WOEID, a parent option and return a valid hash</span></dd>
|
188
|
+
<script type="text/javascript">moveProgressBar('40.0');</script>
|
189
|
+
<dd class="spec passed"><span class="passed_spec_name">should accept a numeric woeid, an ancestors hash and return a valid hash</span></dd>
|
190
|
+
<script type="text/javascript">moveProgressBar('50.0');</script>
|
191
|
+
<dd class="spec passed"><span class="passed_spec_name">should accept a neighbors option</span></dd>
|
192
|
+
<script type="text/javascript">moveProgressBar('60.0');</script>
|
193
|
+
<dd class="spec passed"><span class="passed_spec_name">should accept a valid WOEID and a belongtos option and return a valid hash of a collection of places that contain a place</span></dd>
|
194
|
+
<script type="text/javascript">moveProgressBar('70.0');</script>
|
195
|
+
<dd class="spec passed"><span class="passed_spec_name">should accept a valid WOEID and a siblings option and return a collection of places that are siblings of a place</span></dd>
|
196
|
+
<script type="text/javascript">moveProgressBar('80.0');</script>
|
197
|
+
<dd class="spec passed"><span class="passed_spec_name">should accept a valid WOEID and a children option and return a collection of places that are children of a place.</span></dd>
|
198
|
+
<script type="text/javascript">moveProgressBar('90.0');</script>
|
199
|
+
<dd class="spec passed"><span class="passed_spec_name">should return placetypes</span></dd>
|
200
|
+
<script type="text/javascript">moveProgressBar('100.0');</script>
|
201
|
+
<dd class="spec passed"><span class="passed_spec_name">should have valid key-value pairs for language</span></dd>
|
202
|
+
</dl>
|
203
|
+
</div>
|
204
|
+
<script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>4.317402 seconds</strong>";</script>
|
205
|
+
<script type="text/javascript">document.getElementById('totals').innerHTML = "10 examples, 0 failures";</script>
|
206
|
+
</div>
|
207
|
+
</div>
|
208
|
+
</body>
|
209
|
+
</html>
|
data/spec/yilp_spec.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../lib/yilp.rb'
|
2
|
+
require "pp"
|
3
|
+
include YILP
|
4
|
+
|
5
|
+
describe YILP do
|
6
|
+
before do
|
7
|
+
@h = Hash.new
|
8
|
+
@valid_place = 'sydney'
|
9
|
+
@valid_woid = 1105777
|
10
|
+
@invalid_woid = "12dsag@!"
|
11
|
+
@invalid_place = "21gdssf32"
|
12
|
+
end
|
13
|
+
|
14
|
+
after(:each) do
|
15
|
+
@h.should_not be(nil)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should find the yilp api keys in ./config/yilp_appid.yml" do
|
19
|
+
@h = YILP::YILP::APP_ID
|
20
|
+
@h = YILP::YILP.find(@valid_place)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should accept a query string and return a valid hash" do
|
24
|
+
@h = YILP::YILP.find(@valid_place)
|
25
|
+
end
|
26
|
+
|
27
|
+
# /place/{woeid}
|
28
|
+
it "should accept a numeric WOEID and return a valid hash" do
|
29
|
+
@h = YILP::YILP.find(@valid_woid)
|
30
|
+
end
|
31
|
+
|
32
|
+
# /place/{woeid}/parent
|
33
|
+
it "should accept a numeric WOEID, a parent option and return a valid hash" do
|
34
|
+
@h = YILP::YILP.find(@valid_woid, :parent => true)
|
35
|
+
end
|
36
|
+
|
37
|
+
# /place/{woeid}/ancestors
|
38
|
+
it "should accept a numeric woeid, an ancestors hash and return a valid hash" do
|
39
|
+
@h = YILP::YILP.find(@valid_woid, :ancestors => true)
|
40
|
+
end
|
41
|
+
|
42
|
+
# /place/{woeid}/neighbors
|
43
|
+
it "should accept a neighbors option" do
|
44
|
+
@h = YILP::YILP.find(@valid_woid, :neighbors => true)
|
45
|
+
end
|
46
|
+
|
47
|
+
# /place/{woeid}/belongtos
|
48
|
+
it "should accept a valid WOEID and a belongtos option and return a valid hash of a collection of places that contain a place" do
|
49
|
+
@h = YILP::YILP.find(@valid_woid, :belongtos => true)
|
50
|
+
@h["places"]["place"].should_not be(nil)
|
51
|
+
end
|
52
|
+
|
53
|
+
# /place/{woeid}/siblings TODO: siblings may need a spec
|
54
|
+
it "should accept a valid WOEID and a siblings option and return a collection of places that are siblings of a place" do
|
55
|
+
@h = YILP::YILP.find(@valid_woid, :siblings => true)
|
56
|
+
@h["places"]["place"].should_not be(nil)
|
57
|
+
end
|
58
|
+
|
59
|
+
# /place/{woeid}/children
|
60
|
+
it "should accept a valid WOEID and a children option and return a collection of places that are children of a place." do
|
61
|
+
@h = YILP::YILP.find(@valid_woid, :children => true)
|
62
|
+
@h["places"]["place"].should_not be(nil)
|
63
|
+
end
|
64
|
+
|
65
|
+
# /placetypes
|
66
|
+
it "should return placetypes" do
|
67
|
+
@placetypes = YILP::YILP.placetypes
|
68
|
+
@placetypes.should_not be(nil)
|
69
|
+
@placetypes["place_types"]["place_type"].should_not be(nil)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should deal with internationalized placenames" do
|
73
|
+
@h = YILP::YILP.find('Moscow', :lang => :German)
|
74
|
+
@h["places"]["place"]["name"].should eql("Moskau")
|
75
|
+
@h = YILP::YILP.find('USA', :lang => :French)
|
76
|
+
@h["places"]["place"]["name"].should eql("États-Unis")
|
77
|
+
end
|
78
|
+
|
79
|
+
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
|
80
|
+
#TODO: it "should accept a valid lang option and return"
|
81
|
+
|
82
|
+
it "should have valid key-value pairs for language" do
|
83
|
+
YILP::YILP.lang(:French).should eql('fr')
|
84
|
+
YILP::YILP.lang(:German).should eql('de')
|
85
|
+
YILP::YILP.lang(:Italian).should eql('de')
|
86
|
+
YILP::YILP.lang(:Dutch).should eql('nl')
|
87
|
+
YILP::YILP.lang(:Greek).should eql('el')
|
88
|
+
YILP::YILP.lang(:Spanish).should eql('es')
|
89
|
+
YILP::YILP.lang(:Portuguese).should eql('pt')
|
90
|
+
YILP::YILP.lang(:Arabic).should eql('ar')
|
91
|
+
YILP::YILP.lang(:Hebrew).should eql('he')
|
92
|
+
YILP::YILP.lang(:Russian).should eql('ru')
|
93
|
+
YILP::YILP.lang(:Chinese).should eql('zh')
|
94
|
+
YILP::YILP.lang(:Japanese).should eql('ja')
|
95
|
+
YILP::YILP.lang(:Hindi).should eql('hi')
|
96
|
+
YILP::YILP.lang(:Urdu).should eql('ur')
|
97
|
+
YILP::YILP.lang(:Sanskrit).should eql('sa')
|
98
|
+
end
|
99
|
+
end
|
data/yilp.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{yilp}
|
5
|
+
s.version = "0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Shoaib Burq & David Troy"]
|
9
|
+
s.date = %q{2009-04-13}
|
10
|
+
s.description = %q{Ruby wrapper arround Yahoo Internet Location Platform}
|
11
|
+
s.email = %q{shoaib@nomad-labs.com}
|
12
|
+
s.extra_rdoc_files = ["lib/yilp.rb", "README.rdoc"]
|
13
|
+
s.files = ["config/yilp_appid.yml", "lib/yilp.rb", "Rakefile", "README.rdoc", "spec/fixtures/places_sydney.xml", "spec/fixtures/placetypes.xml", "spec/fixtures/woid_1105779.xml", "spec/fixtures/woid_1105779_ancestors.xml", "spec/fixtures/woid_1105779_belongto.xml", "spec/fixtures/woid_1105779_children.xml", "spec/fixtures/woid_1105779_neighbors.xml", "spec/fixtures/woid_1105779_parent.xml", "spec/fixtures/woid_1105779_siblings.xml", "spec/specs.html", "spec/yilp_spec.rb", "Manifest", "yilp.gemspec"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://yilp.rubyforge.org}
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Yilp", "--main", "README.rdoc"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{yilp}
|
19
|
+
s.rubygems_version = %q{1.3.1}
|
20
|
+
s.summary = %q{Ruby wrapper arround Yahoo Internet Location Platform}
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 2
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_development_dependency(%q<active_support>, [">= 0"])
|
28
|
+
else
|
29
|
+
s.add_dependency(%q<active_support>, [">= 0"])
|
30
|
+
end
|
31
|
+
else
|
32
|
+
s.add_dependency(%q<active_support>, [">= 0"])
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yilp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shoaib Burq & David Troy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-13 00:00:00 +10:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: active_support
|
17
|
+
type: :development
|
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: Ruby wrapper arround Yahoo Internet Location Platform
|
26
|
+
email: shoaib@nomad-labs.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- lib/yilp.rb
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- config/yilp_appid.yml
|
36
|
+
- lib/yilp.rb
|
37
|
+
- Rakefile
|
38
|
+
- README.rdoc
|
39
|
+
- spec/fixtures/places_sydney.xml
|
40
|
+
- spec/fixtures/placetypes.xml
|
41
|
+
- spec/fixtures/woid_1105779.xml
|
42
|
+
- spec/fixtures/woid_1105779_ancestors.xml
|
43
|
+
- spec/fixtures/woid_1105779_belongto.xml
|
44
|
+
- spec/fixtures/woid_1105779_children.xml
|
45
|
+
- spec/fixtures/woid_1105779_neighbors.xml
|
46
|
+
- spec/fixtures/woid_1105779_parent.xml
|
47
|
+
- spec/fixtures/woid_1105779_siblings.xml
|
48
|
+
- spec/specs.html
|
49
|
+
- spec/yilp_spec.rb
|
50
|
+
- Manifest
|
51
|
+
- yilp.gemspec
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://yilp.rubyforge.org
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options:
|
56
|
+
- --line-numbers
|
57
|
+
- --inline-source
|
58
|
+
- --title
|
59
|
+
- Yilp
|
60
|
+
- --main
|
61
|
+
- README.rdoc
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "1.2"
|
75
|
+
version:
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project: yilp
|
79
|
+
rubygems_version: 1.3.1
|
80
|
+
signing_key:
|
81
|
+
specification_version: 2
|
82
|
+
summary: Ruby wrapper arround Yahoo Internet Location Platform
|
83
|
+
test_files: []
|
84
|
+
|