mojodna-fireeagle 0.8.0.0 → 0.8.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,14 +7,27 @@ README.txt
7
7
  Rakefile
8
8
  lib/fireeagle.rb
9
9
  lib/fireeagle/client.rb
10
+ lib/fireeagle/error.rb
10
11
  lib/fireeagle/location.rb
12
+ lib/fireeagle/location_hierarchy.rb
13
+ lib/fireeagle/locations.rb
11
14
  lib/fireeagle/response.rb
12
15
  lib/fireeagle/user.rb
13
16
  lib/fireeagle/version.rb
14
17
  setup.rb
15
- spec/fireeagle_location_spec.rb
16
18
  spec/fireeagle_response_spec.rb
17
19
  spec/fireeagle_spec.rb
20
+ spec/location_spec.rb
21
+ spec/locations_spec.rb
22
+ spec/responses/error.xml
23
+ spec/responses/exact_location_chunk.xml
24
+ spec/responses/location_chunk.xml
25
+ spec/responses/location_chunk_with_query.xml
26
+ spec/responses/locations_chunk.xml
27
+ spec/responses/lookup.xml
28
+ spec/responses/recent.xml
29
+ spec/responses/user.xml
30
+ spec/responses/within.xml
18
31
  spec/spec.opts
19
32
  spec/spec_helper.rb
20
33
  tasks/environment.rake
@@ -58,7 +58,7 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
58
58
 
59
59
  # == Optional
60
60
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
61
- p.extra_deps = [ ['oauth', '>= 0.2.1'], ['hpricot', '>= 0.6'], ['GeoRuby', '>= 1.3.2'] ] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
61
+ p.extra_deps = [ ['oauth', '>= 0.3.1'], ['happymapper', '>= 0.2.1'], ['GeoRuby', '>= 1.3.2'] ] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
62
62
 
63
63
  #p.spec_extras = {} # A hash of extra values to set in the gemspec.
64
64
 
@@ -5,8 +5,16 @@ gem 'oauth', ">= 0.2.4"
5
5
  require 'oauth/helper'
6
6
  require 'oauth/client/helper'
7
7
  require 'oauth/request_proxy/net_http'
8
- require 'hpricot'
9
8
  require 'geo_ruby'
9
+ require 'happymapper'
10
+
11
+ require File.dirname(__FILE__) + '/fireeagle/client'
12
+ require File.dirname(__FILE__) + '/fireeagle/location'
13
+ require File.dirname(__FILE__) + '/fireeagle/locations'
14
+ require File.dirname(__FILE__) + '/fireeagle/location_hierarchy'
15
+ require File.dirname(__FILE__) + '/fireeagle/user'
16
+ require File.dirname(__FILE__) + '/fireeagle/error'
17
+ require File.dirname(__FILE__) + '/fireeagle/response'
10
18
 
11
19
  module FireEagle
12
20
  API_SERVER = "https://fireeagle.yahooapis.com"
@@ -25,13 +33,10 @@ module FireEagle
25
33
  # not yet supported
26
34
  #,:geom, :upcoming_venue_id, :yahoo_local_id, :plazes_id
27
35
 
28
- class Error < RuntimeError #:nodoc:
29
- end
30
-
31
- class ArgumentError < Error #:nodoc:
36
+ class ArgumentError < StandardError #:nodoc:
32
37
  end
33
38
 
34
- class FireEagleException < Error #:nodoc:
39
+ class FireEagleException < StandardError #:nodoc:
35
40
  end
36
41
  end
37
42
 
@@ -59,8 +64,3 @@ class OAuth::Consumer
59
64
  end
60
65
  alias_method :create_http, :create_http_without_verify
61
66
  end
62
-
63
- require File.dirname(__FILE__) + '/fireeagle/client'
64
- require File.dirname(__FILE__) + '/fireeagle/location'
65
- require File.dirname(__FILE__) + '/fireeagle/user'
66
- require File.dirname(__FILE__) + '/fireeagle/response'
@@ -155,7 +155,7 @@ module FireEagle
155
155
  def lookup(params)
156
156
  raise FireEagle::ArgumentError, "OAuth Access Token Required" unless @access_token
157
157
  response = get(FireEagle::LOOKUP_API_PATH, :params => params)
158
- FireEagle::Response.new(response.body).locations
158
+ FireEagle::Response.parse(response.body).locations
159
159
  end
160
160
 
161
161
  # Sets a User's current Location using using a Place ID hash or a set of Location parameters. If the User
@@ -187,14 +187,14 @@ module FireEagle
187
187
  raise FireEagle::ArgumentError, "OAuth Access Token Required" unless @access_token
188
188
  location = sanitize_location_hash(location)
189
189
  response = post(FireEagle::UPDATE_API_PATH, :params => location)
190
- FireEagle::Response.new(response.body)
190
+ FireEagle::Response.parse(response.body)
191
191
  end
192
192
 
193
193
  # Returns the Location of a User.
194
194
  def user
195
195
  raise FireEagle::ArgumentError, "OAuth Access Token Required" unless @access_token
196
196
  response = get(FireEagle::USER_API_PATH)
197
- FireEagle::Response.new(response.body).users.first
197
+ FireEagle::Response.parse(response.body).users.first
198
198
  end
199
199
  alias_method :location, :user
200
200
 
@@ -210,7 +210,7 @@ module FireEagle
210
210
  raise FireEagle::ArgumentError, "OAuth Access Token Required" unless @access_token
211
211
  params = { :count => count, :start => start, :time => time }
212
212
  response = get(FireEagle::RECENT_API_PATH, :params => params)
213
- FireEagle::Response.new(response.body).users
213
+ FireEagle::Response.parse(response.body).users
214
214
  end
215
215
 
216
216
  # Takes a Place ID or a Location and returns a list of users of your application who are within the bounding box of that Location.
@@ -238,7 +238,7 @@ module FireEagle
238
238
  location = sanitize_location_hash(location)
239
239
  params = { :count => count, :start => start }.merge(location)
240
240
  response = get(FireEagle::WITHIN_API_PATH, :params => params)
241
- FireEagle::Response.new(response.body).users
241
+ FireEagle::Response.parse(response.body).users
242
242
  end
243
243
 
244
244
  protected
@@ -0,0 +1,9 @@
1
+ module FireEagle
2
+ class Error
3
+ include HappyMapper
4
+
5
+ tag "err"
6
+ attribute :code, String
7
+ attribute :message, String, :tag => "msg"
8
+ end
9
+ end
@@ -1,85 +1,55 @@
1
- #Describes a location
2
1
  module FireEagle
3
- class Location
4
-
5
- #Initialize a Location from an XML response
6
- def initialize(doc)
7
- doc = Hpricot(doc) unless doc.is_a?(Hpricot::Doc || Hpricot::Elem)
8
- @doc = doc
9
- end
10
-
11
- def label
12
- @label ||= @doc.at("/location/label").innerText rescue nil
13
- end
2
+ class StringWithExactMatch < String
3
+ attr_writer :exact_match
14
4
 
15
- #Level of granularity for this Location
16
- def level
17
- @level ||= @doc.at("/location/level").innerText.to_i rescue nil
18
- end
19
-
20
- #Name of the level of granularity for this Location
21
- def level_name
22
- @level_name ||= @doc.at("/location/level-name").innerText rescue nil
23
- end
5
+ def initialize(value = "")
6
+ node = XML::Parser.string(value).parse.root
7
+ str = super(node.content)
8
+ str.exact_match = node.attributes.to_h["exact-match"] == "true"
9
+ node = nil
24
10
 
25
- #Human Name for this Location
26
- def name
27
- @name ||= @doc.at("/location/name").innerText rescue nil
11
+ str
28
12
  end
29
- alias_method :to_s, :name
30
13
 
31
- #Unique identifier for this place. Pro-tip: This is the same place_id used by Flickr.
32
- def place_id
33
- @place_id ||= @doc.at("/location/place-id").innerText rescue nil
34
- end
35
-
36
- #Numeric unique identifier for this place.
37
- def woeid
38
- @woeid ||= @doc.at("/location/woeid").innerText rescue nil
39
- end
40
-
41
- #The Time at which the User last updated in this Location
42
- def located_at
43
- @located_at ||= Time.parse(@doc.at("/location/located-at").innerText) rescue nil
14
+ def exact_match?
15
+ @exact_match
44
16
  end
17
+ end
45
18
 
46
- #The coordinates of the lower corner of a bounding box surrounding this Location
47
- def lower_corner
48
- @georss ||= @doc.at("/location//georss:box").innerText.split.map{ |l| l.to_f } rescue nil
49
- @lower_corner ||= @georss[0..1] rescue nil
50
- end
19
+ # Represents a location
20
+ class Location
21
+ include HappyMapper
22
+
23
+ tag "location"
24
+ attribute :best_guess, Boolean, :tag => "best-guess"
25
+ element :label, String
26
+ element :level, Integer
27
+ element :level_name, String, :tag => "level-name"
28
+ element :located_at, Time, :tag => "located-at"
29
+ element :name, String
30
+ element :normal_name, String, :tag => "normal-name"
31
+ element :place_id, StringWithExactMatch, :tag => "place-id", :parser => :new, :raw => true
32
+ element :query, String
33
+ element :woeid, StringWithExactMatch, :parser => :new, :raw => true
34
+
35
+ element :_box, GeoRuby::SimpleFeatures::Geometry, :tag => "box",
36
+ :namespace => "georss", :parser => :from_georss, :raw => true
37
+ element :_point, GeoRuby::SimpleFeatures::Geometry, :tag => "point",
38
+ :namespace => "georss", :parser => :from_georss, :raw => true
51
39
 
52
- # The actual query that the user used so that it can be geocoded by the
53
- # consumer since the Yahoo! geocoder is a little flaky, especially when it
54
- # comes to intersections etc.
55
- #
56
- # Turns something like this:
57
- #
58
- # <query> "q=333%20W%20Harbor%20Dr,%20San%20Diego,%20CA" </query>
59
- #
60
- # into
61
- #
62
- # 333 W Harbor Dr, San Diego, CA
63
- def query
64
- @query ||= CGI::unescape((@doc.at("/location/query").innerText).gsub('"', '').split('=')[1]).strip rescue nil
40
+ def best_guess?
41
+ best_guess == true
65
42
  end
66
43
 
67
44
  # The GeoRuby[http://georuby.rubyforge.org/] representation of this location
68
45
  def geom
69
- if @doc.at("/location//georss:box")
70
- @geo ||= GeoRuby::SimpleFeatures::Geometry.from_georss(@doc.at("/location//georss:box").to_s)
71
- elsif @doc.at("/location//georss:point")
72
- @geo ||= GeoRuby::SimpleFeatures::Geometry.from_georss(@doc.at("/location//georss:point").to_s)
73
- else
74
- return nil
75
- end
46
+ _point || _box
76
47
  end
48
+
77
49
  alias_method :geo, :geom
78
-
79
- #Is this Location FireEagle's best guess?
80
- def best_guess?
81
- @best_guess ||= @doc.at("/location").attributes["best-guess"] == "true" rescue false
82
- end
83
50
 
51
+ def to_s
52
+ name
53
+ end
84
54
  end
85
55
  end
@@ -0,0 +1,10 @@
1
+ module FireEagle
2
+ class LocationHierarchy
3
+ include HappyMapper
4
+
5
+ tag "location-hierarchy"
6
+ attribute :string, String
7
+ attribute :timezone, String
8
+ has_many :locations, Location
9
+ end
10
+ end
@@ -0,0 +1,36 @@
1
+ module FireEagle
2
+ class Locations
3
+ include Enumerable
4
+ include HappyMapper
5
+
6
+ tag "locations"
7
+ attribute :count, Integer
8
+ attribute :start, Integer
9
+ attribute :total, Integer
10
+ has_many :locations, Location, :single => false
11
+
12
+ def [](*args)
13
+ locations[*args]
14
+ end
15
+
16
+ alias_method :slice, :[]
17
+
18
+ def each(&block)
19
+ locations.each(&block)
20
+ end
21
+
22
+ def first
23
+ locations.first
24
+ end
25
+
26
+ def last
27
+ locations.last
28
+ end
29
+
30
+ def length
31
+ locations.length
32
+ end
33
+
34
+ alias_method :size, :length
35
+ end
36
+ end
@@ -1,31 +1,33 @@
1
1
  module FireEagle
2
2
  class Response
3
+ include HappyMapper
3
4
 
4
- #Parses the XML response from FireEagle
5
- def initialize(doc)
6
- doc = Hpricot(doc) unless doc.is_a?(Hpricot::Doc || Hpricot::Elem)
7
- @doc = doc
8
- raise FireEagle::FireEagleException, @doc.at("/rsp/err").attributes["msg"] if !success?
9
- end
5
+ tag "rsp"
6
+ attribute :status, String, :tag => "stat"
7
+ element :querystring, String
8
+ has_one :error, Error
9
+ has_one :locations, Locations
10
+ has_many :users, User
10
11
 
11
- #does the response indicate success?
12
- def success?
13
- @doc.at("/rsp").attributes["stat"] == "ok" rescue false
12
+ def self.parse(xml, opts = {})
13
+ rsp = super(xml, opts)
14
+
15
+ raise FireEagleException, rsp.error.message if rsp.fail?
16
+
17
+ rsp
14
18
  end
15
19
 
16
- #An array of of User-specific tokens and their Location at all levels the Client can see and larger.
17
- def users
18
- @users ||= @doc.search("/rsp//user").map do |user|
19
- FireEagle::User.new(user.to_s)
20
- end
20
+ def fail?
21
+ status == "fail"
21
22
  end
22
23
 
23
- #A Location array.
24
- def locations
25
- @locations ||= @doc.search("/rsp/locations/location").map do |location|
26
- FireEagle::Location.new(location.to_s)
27
- end
24
+ # does the response indicate success?
25
+ def success?
26
+ status == "ok"
28
27
  end
29
28
 
29
+ def user
30
+ users[0]
31
+ end
30
32
  end
31
33
  end
@@ -1,37 +1,20 @@
1
1
  module FireEagle
2
2
  class User
3
- #Parses the XML response from FireEagle.
4
- def initialize(doc)
5
- doc = Hpricot(doc) unless doc.is_a?(Hpricot::Doc || Hpricot::Elem)
6
- @doc = doc
7
- end
8
-
9
- #The User-specific token for this Client.
10
- def token
11
- @token ||= @doc.at("/user").attributes["token"] rescue nil
12
- end
3
+ include HappyMapper
13
4
 
14
- #The time at which this user was last located
15
- def located_at
16
- @located_at ||= Time.parse(@doc.at("/user").attributes["located-at"]) rescue nil
17
- end
5
+ tag "user"
6
+ attribute :located_at, Time, :tag => "located-at"
7
+ attribute :readable, Boolean
8
+ attribute :token, String
9
+ attribute :writable, Boolean
10
+ has_one :location_hierarchy, LocationHierarchy, :tag => "location-hierarchy"
18
11
 
19
- #FireEagle's "best guess" form this User's Location. This best guess is derived as the most accurate
20
- #level of the hierarchy with a timestamp in the last half an hour <b>or</b> as the most accurate
21
- #level of the hierarchy with the most recent timestamp.
22
12
  def best_guess
23
- @best_guess ||= locations.select { |location| location.best_guess? }.first rescue nil
13
+ @best_guess ||= locations.select { |loc| loc.best_guess? }.first
24
14
  end
25
15
 
26
- #An Array containing all Location granularity that the Client has been allowed to
27
- #see for the User. The Location elements returned are arranged in hierarchy order consisting of:
28
- #Country, State, County, Large Cities, Neighbourhoods/Local Area, Postal Code and exact location.
29
- #The Application should therefore be prepared to receive a response that may consist of (1) only
30
- #country, or (2) country & state or (3) country, state & county and so forth.
31
16
  def locations
32
- @locations ||= @doc.search("/user/location-hierarchy/location").map do |location|
33
- FireEagle::Location.new(location.to_s)
34
- end
17
+ location_hierarchy && location_hierarchy.locations
35
18
  end
36
19
  end
37
20
  end
@@ -3,7 +3,7 @@ module FireEagle #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 8
5
5
  TINY = 0
6
- TEENY = 0
6
+ TEENY = 1
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, TEENY].join('.')
9
9
  end
@@ -1,11 +1,11 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe "FireEagle Response" do
3
+ describe FireEagle::Response do
4
4
 
5
5
  describe "user / location parsing" do
6
6
 
7
7
  before(:each) do
8
- @response = FireEagle::Response.new(XML_LOCATION_RESPONSE)
8
+ @response = FireEagle::Response.parse(XML_LOCATION_RESPONSE)
9
9
  end
10
10
 
11
11
  it "should indicate success" do
@@ -33,7 +33,7 @@ describe "FireEagle Response" do
33
33
  describe "location parsing" do
34
34
 
35
35
  before(:each) do
36
- @response = FireEagle::Response.new(XML_LOOKUP_RESPONSE)
36
+ @response = FireEagle::Response.parse(XML_LOOKUP_RESPONSE)
37
37
  end
38
38
 
39
39
  it "should indicate success" do
@@ -57,7 +57,7 @@ describe "FireEagle Response" do
57
57
  describe "error handling" do
58
58
 
59
59
  it "should raise an exception when returned xml with a status of fail" do
60
- lambda { FireEagle::Response.new(XML_ERROR_RESPONSE) }.should raise_error(FireEagle::FireEagleException, "Something bad happened")
60
+ lambda { FireEagle::Response.parse(XML_ERROR_RESPONSE) }.should raise_error(FireEagle::FireEagleException, "Something bad happened")
61
61
  end
62
62
 
63
63
  end
@@ -171,10 +171,6 @@ describe "FireEagle" do
171
171
  it "should return an array of Users" do
172
172
  @client.within(:woe => "12796255").should have(2).users
173
173
  end
174
-
175
- it "should return an array of Locations for each" do
176
- @client.within(:woe => "12796255").first.should have(5).locations
177
- end
178
174
  end
179
175
 
180
176
  describe "recent method" do
@@ -1,12 +1,10 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe "FireEagle Location" do
3
+ describe FireEagle::Location do
4
4
 
5
5
  before(:each) do
6
- location = Hpricot.XML(XML_LOCATION_CHUNK)
7
- @location = FireEagle::Location.new(location)
8
- location_with_query = Hpricot.XML(XML_QUERY_LOCATION_CHUNK)
9
- @location_with_query = FireEagle::Location.new(location_with_query)
6
+ @location = FireEagle::Location.parse(responses(:location_chunk))
7
+ @location_with_query = FireEagle::Location.parse(responses(:location_chunk_with_query))
10
8
  end
11
9
 
12
10
  it "should know if this is a best guess" do
@@ -25,42 +23,56 @@ describe "FireEagle Location" do
25
23
  @location.name.should == 'Davis, CA'
26
24
  end
27
25
 
28
- it "should represent the location place id" do
26
+ it "should represent the raw name" do
27
+ @location.normal_name.should == "Davis"
28
+ end
29
+
30
+ it "should represent the location's place id" do
29
31
  @location.place_id.should == 'u4L9ZOObApTdx1q3'
30
32
  end
31
33
 
34
+ it "should represent whether the location's place id is an exact match" do
35
+ @location.place_id.should be_an_exact_match
36
+ end
37
+
38
+ it "should represent the location's WOEID" do
39
+ @location.woeid.should == "2389646"
40
+ end
41
+
42
+ it "should represent whether the location's WOEID is an exact match" do
43
+ @location.woeid.should be_an_exact_match
44
+ end
45
+
32
46
  it "should represent the location's timestamp" do
33
47
  @location.located_at.should == Time.parse("2008-01-22T14:23:11-08:00")
34
48
  end
35
49
 
50
+ it "should represent the label" do
51
+ @location.label.should == "Home of UC Davis"
52
+ end
53
+
36
54
  it "should use the name for #to_s" do
37
55
  @location.to_s.should == @location.name
38
56
  end
39
57
 
40
- it "should return the actual query string" do
41
- @location_with_query.query.should == "333 W Harbor Dr, San Diego, CA"
58
+ it "should represent the querystring" do
59
+ @location_with_query.query.should == "q=333%20W%20Harbor%20Dr,%20San%20Diego,%20CA"
42
60
  end
43
61
 
44
62
  describe "GeoRuby support" do
45
-
46
63
  it "should represent a bounding box as a GeoRuby Envelope" do
47
- location = Hpricot.XML(XML_LOCATION_CHUNK)
48
- @location = FireEagle::Location.new(location)
64
+ @location = FireEagle::Location.parse(responses(:location_chunk))
49
65
  @location.geom.should be_an_instance_of(GeoRuby::SimpleFeatures::Envelope)
50
66
  end
51
67
 
52
68
  it "should represent an exact point as a GeoRuby Point" do
53
- location = Hpricot.XML(XML_EXACT_LOCATION_CHUNK)
54
- @location = FireEagle::Location.new(location)
69
+ @location = FireEagle::Location.parse(responses(:exact_location_chunk))
55
70
  @location.geom.should be_an_instance_of(GeoRuby::SimpleFeatures::Point)
56
71
  end
57
72
 
58
73
  it "should be aliased as 'geo'" do
59
- location = Hpricot.XML(XML_EXACT_LOCATION_CHUNK)
60
- @location = FireEagle::Location.new(location)
74
+ @location = FireEagle::Location.parse(responses(:exact_location_chunk))
61
75
  @location.geo.should be_an_instance_of(GeoRuby::SimpleFeatures::Point)
62
76
  end
63
-
64
77
  end
65
-
66
78
  end
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe FireEagle::Locations do
4
+ before :each do
5
+ @instance = FireEagle::Locations.parse(responses(:locations_chunk))
6
+ end
7
+
8
+ it "should be Enumerable" do
9
+ @instance.should be_a_kind_of(Enumerable)
10
+ end
11
+
12
+ it "should have a length" do
13
+ @instance.length.should == 9
14
+ end
15
+
16
+ it "should have a size" do
17
+ @instance.size.should == 9
18
+ end
19
+
20
+ it "should be indexable" do
21
+ @instance[0].should_not be_nil
22
+ end
23
+
24
+ it "should be indexable by Range" do
25
+ @instance[0..2].length.should == 3
26
+ end
27
+
28
+ it "should be indexable by 'start' and 'length'" do
29
+ @instance[0, 2].length.should == 2
30
+ end
31
+
32
+ it "should be sliceable" do
33
+ @instance.should respond_to(:slice)
34
+ end
35
+
36
+ it "should have a first element" do
37
+ @instance.first.should == @instance[0]
38
+ end
39
+
40
+ it "should have a last element" do
41
+ @instance.last.should == @instance[-1]
42
+ end
43
+ end
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <rsp stat="fail">
3
+ <err code="11" msg="Something bad happened" />
4
+ </rsp>
@@ -0,0 +1,3 @@
1
+ <location xmlns:georss="http://www.georss.org/georss">
2
+ <georss:point>38.5351715088 -121.7948684692</georss:point>
3
+ </location>
@@ -0,0 +1,11 @@
1
+ <location best-guess="false" xmlns:georss="http://www.georss.org/georss">
2
+ <georss:box>38.5351715088 -121.7948684692 38.575668335 -121.6747894287</georss:box>
3
+ <level>3</level>
4
+ <level-name>city</level-name>
5
+ <located-at>2008-01-22T14:23:11-08:00</located-at>
6
+ <name>Davis, CA</name>
7
+ <normal-name>Davis</normal-name>
8
+ <woeid exact-match="true">2389646</woeid>
9
+ <place-id exact-match="true">u4L9ZOObApTdx1q3</place-id>
10
+ <label>Home of UC Davis</label>
11
+ </location>
@@ -0,0 +1,9 @@
1
+ <location best-guess="true" xmlns:georss="http://www.georss.org/georss">
2
+ <id>111541</id>
3
+ <georss:point>32.7093315125 -117.1650772095</georss:point>
4
+ <level>0</level>
5
+ <level-name>exact</level-name>
6
+ <located-at>2008-03-03T09:05:16-08:00</located-at>
7
+ <name>333 W Harbor Dr, San Diego, CA</name>
8
+ <query>q=333%20W%20Harbor%20Dr,%20San%20Diego,%20CA</query>
9
+ </location>
@@ -0,0 +1,38 @@
1
+ <locations start="0" total="9" count="9">
2
+ <location>
3
+ <name>Alpharetta, GA 30022</name>
4
+ <place-id>IrhZMHuYA5s1fFi4Qw</place-id>
5
+ </location>
6
+ <location>
7
+ <name>Hannover, Region Hannover, Deutschland</name>
8
+ <place-id>88Hctc2bBZlhvlwbUg</place-id>
9
+ </location>
10
+ <location>
11
+ <name>N&#238;mes, Gard, France</name>
12
+ <place-id>Sut8q82bBZkF0s1eTg</place-id>
13
+ </location>
14
+ <location>
15
+ <name>Ceggia, Venezia, Italia</name>
16
+ <place-id>s9ulRieYA5TkNK9otw</place-id>
17
+ </location>
18
+ <location>
19
+ <name>Comit&#225;n de Dom&#237;nguez, Comitan de Dominguez, M&#233;xico</name>
20
+ <place-id>.51HvYKbBZnSAeNHWw</place-id>
21
+ </location>
22
+ <location>
23
+ <name>Platanos Aitoloakarnanias, Etolia Kai Akarnania, Greece</name>
24
+ <place-id>CmfJ2H.YA5QKpS56HQ</place-id>
25
+ </location>
26
+ <location>
27
+ <name>Krak&#243;w, Krak&#243;w, Polska</name>
28
+ <place-id>9bYc0l.bA5vPTGscQg</place-id>
29
+ </location>
30
+ <location>
31
+ <name>Nakuru, Kenya</name>
32
+ <place-id>VDprypWYA5sujnZphA</place-id>
33
+ </location>
34
+ <location>
35
+ <name>Fez, Al Magreb</name>
36
+ <place-id>BxOaGgSYA5R40Nm1RA</place-id>
37
+ </location>
38
+ </locations>
@@ -0,0 +1,42 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <rsp stat="ok">
3
+ <querystring>q=30022</querystring>
4
+ <locations start="0" total="9" count="9">
5
+ <location>
6
+ <name>Alpharetta, GA 30022</name>
7
+ <place-id>IrhZMHuYA5s1fFi4Qw</place-id>
8
+ </location>
9
+ <location>
10
+ <name>Hannover, Region Hannover, Deutschland</name>
11
+ <place-id>88Hctc2bBZlhvlwbUg</place-id>
12
+ </location>
13
+ <location>
14
+ <name>N&#238;mes, Gard, France</name>
15
+ <place-id>Sut8q82bBZkF0s1eTg</place-id>
16
+ </location>
17
+ <location>
18
+ <name>Ceggia, Venezia, Italia</name>
19
+ <place-id>s9ulRieYA5TkNK9otw</place-id>
20
+ </location>
21
+ <location>
22
+ <name>Comit&#225;n de Dom&#237;nguez, Comitan de Dominguez, M&#233;xico</name>
23
+ <place-id>.51HvYKbBZnSAeNHWw</place-id>
24
+ </location>
25
+ <location>
26
+ <name>Platanos Aitoloakarnanias, Etolia Kai Akarnania, Greece</name>
27
+ <place-id>CmfJ2H.YA5QKpS56HQ</place-id>
28
+ </location>
29
+ <location>
30
+ <name>Krak&#243;w, Krak&#243;w, Polska</name>
31
+ <place-id>9bYc0l.bA5vPTGscQg</place-id>
32
+ </location>
33
+ <location>
34
+ <name>Nakuru, Kenya</name>
35
+ <place-id>VDprypWYA5sujnZphA</place-id>
36
+ </location>
37
+ <location>
38
+ <name>Fez, Al Magreb</name>
39
+ <place-id>BxOaGgSYA5R40Nm1RA</place-id>
40
+ </location>
41
+ </locations>
42
+ </rsp>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <rsp xmlns:georss="http://www.georss.org/georss" stat="ok">
3
+ <users>
4
+ <user located-at="2008-07-31T22:31:37+12:00" token="5pyl1xip0uh6"/>
5
+ <user located-at="2008-07-31T21:49:03+12:00" token="i71yc3myixg3"/>
6
+ <user located-at="2008-07-30T21:40:54+12:00" token="q1jm8nubnpsi"/>
7
+ </users>
8
+ </rsp>
@@ -0,0 +1,40 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <rsp stat="ok" xmlns:georss="http://www.georss.org/georss">
3
+ <user token="16w3z6ysudxt" located-at="2008-12-09T17:14:50-08:00" readable="true" writable="true">
4
+ <location-hierarchy timezone="America/Los_Angeles">
5
+ <location best-guess="false">
6
+ <georss:box>38.5351715088 -121.7948684692 38.575668335 -121.6747894287</georss:box>
7
+ <label>Home of UC Davis</label>
8
+ <level>3</level>
9
+ <level-name>city</level-name>
10
+ <located-at>2008-01-22T14:23:11-08:00</located-at>
11
+ <name>Davis, CA</name>
12
+ <place-id>u4L9ZOObApTdx1q3</place-id>
13
+ </location>
14
+ <location best-guess="true">
15
+ <georss:box>38.3131217957 -122.4230804443 38.9261016846 -121.5012969971</georss:box>
16
+ <level>4</level>
17
+ <level-name>region</level-name>
18
+ <located-at>2008-01-22T18:45:26-08:00</located-at>
19
+ <name>Yolo County, California</name>
20
+ <place-id>YUYMh9CbBJ61mgFe</place-id>
21
+ </location>
22
+ <location best-guess="false">
23
+ <georss:box>32.5342788696 -124.4150238037 42.0093803406 -114.1308135986</georss:box>
24
+ <level>5</level>
25
+ <level-name>state</level-name>
26
+ <located-at>2008-01-22T18:45:26-08:00</located-at>
27
+ <name>California</name>
28
+ <place-id>SVrAMtCbAphCLAtP</place-id>
29
+ </location>
30
+ <location best-guess="false">
31
+ <georss:box>18.9108390808 -167.2764129639 72.8960571289 -66.6879425049</georss:box>
32
+ <level>6</level>
33
+ <level-name>country</level-name>
34
+ <located-at>2008-01-22T18:45:26-08:00</located-at>
35
+ <name>United States</name>
36
+ <place-id>4KO02SibApitvSBieQ</place-id>
37
+ </location>
38
+ </location-hierarchy>
39
+ </user>
40
+ </rsp>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <rsp xmlns:georss="http://www.georss.org/georss" stat="ok">
3
+ <users>
4
+ <user located-at="2008-07-31T22:31:37+12:00" token="5pyl1xip0uh6"/>
5
+ <user located-at="2008-07-31T21:49:03+12:00" token="i71yc3myixg3"/>
6
+ </users>
7
+ </rsp>
@@ -7,54 +7,18 @@ rescue LoadError
7
7
  end
8
8
  require 'time'
9
9
 
10
- XML_ERROR_RESPONSE = <<-RESPONSE
11
- <?xml version="1.0" encoding="utf-8"?>
12
- <rsp stat="fail">
13
- <err code="11" msg="Something bad happened" />
14
- </rsp>
15
- RESPONSE
10
+ module ResponseHelper
11
+ def responses(key)
12
+ File.read(File.join(File.dirname(__FILE__), "responses", "#{key}.xml"))
13
+ end
14
+ end
16
15
 
17
- XML_LOCATION_RESPONSE = <<-RESPONSE
18
- <?xml version="1.0" encoding="utf-8"?>
19
- <rsp stat="ok" xmlns:georss="http://www.georss.org/georss">
20
- <user token="16w3z6ysudxt">
21
- <location-hierarchy>
22
- <location best-guess="false">
23
- <georss:box>38.5351715088 -121.7948684692 38.575668335 -121.6747894287</georss:box>
24
- <level>3</level>
25
- <level-name>city</level-name>
26
- <located-at>2008-01-22T14:23:11-08:00</located-at>
27
- <name>Davis, CA</name>
28
- <place-id>u4L9ZOObApTdx1q3</place-id>
29
- </location>
30
- <location best-guess="true">
31
- <georss:box>38.3131217957 -122.4230804443 38.9261016846 -121.5012969971</georss:box>
32
- <level>4</level>
33
- <level-name>region</level-name>
34
- <located-at>2008-01-22T18:45:26-08:00</located-at>
35
- <name>Yolo County, California</name>
36
- <place-id>YUYMh9CbBJ61mgFe</place-id>
37
- </location>
38
- <location best-guess="false">
39
- <georss:box>32.5342788696 -124.4150238037 42.0093803406 -114.1308135986</georss:box>
40
- <level>5</level>
41
- <level-name>state</level-name>
42
- <located-at>2008-01-22T18:45:26-08:00</located-at>
43
- <name>California</name>
44
- <place-id>SVrAMtCbAphCLAtP</place-id>
45
- </location>
46
- <location best-guess="false">
47
- <georss:box>18.9108390808 -167.2764129639 72.8960571289 -66.6879425049</georss:box>
48
- <level>6</level>
49
- <level-name>country</level-name>
50
- <located-at>2008-01-22T18:45:26-08:00</located-at>
51
- <name>United States</name>
52
- <place-id>4KO02SibApitvSBieQ</place-id>
53
- </location>
54
- </location-hierarchy>
55
- </user>
56
- </rsp>
57
- RESPONSE
16
+ Spec::Runner.configure do |config|
17
+ include ResponseHelper
18
+ end
19
+
20
+ XML_ERROR_RESPONSE = File.read(File.join(File.dirname(__FILE__), "responses", "error.xml"))
21
+ XML_LOCATION_RESPONSE = File.read(File.join(File.dirname(__FILE__), "responses", "user.xml"))
58
22
 
59
23
  XML_SUCCESS_RESPONSE = <<-RESPONSE
60
24
  <?xml version="1.0" encoding="utf-8"?>
@@ -63,80 +27,7 @@ XML_SUCCESS_RESPONSE = <<-RESPONSE
63
27
  </rsp>
64
28
  RESPONSE
65
29
 
66
- XML_LOCATION_CHUNK = <<-RESPONSE
67
- <location best-guess="false">
68
- <georss:box>38.5351715088 -121.7948684692 38.575668335 -121.6747894287</georss:box>
69
- <level>3</level>
70
- <level-name>city</level-name>
71
- <located-at>2008-01-22T14:23:11-08:00</located-at>
72
- <name>Davis, CA</name>
73
- <place-id>u4L9ZOObApTdx1q3</place-id>
74
- </location>
75
- RESPONSE
76
-
77
- XML_QUERY_LOCATION_CHUNK = <<-RESPONSE
78
- <location best-guess="true">
79
- <id>111541</id>
80
- <georss:point>32.7093315125 -117.1650772095</georss:point>
81
- <level>0</level>
82
- <level-name>exact</level-name>
83
- <located-at>2008-03-03T09:05:16-08:00</located-at>
84
- <name>333 W Harbor Dr, San Diego, CA</name>
85
- <query> "q=333%20W%20Harbor%20Dr,%20San%20Diego,%20CA" </query>
86
- </location>
87
- RESPONSE
88
-
89
-
90
- XML_EXACT_LOCATION_CHUNK = <<-RESPONSE
91
- <location>
92
- <georss:point>38.5351715088 -121.7948684692</georss:box>
93
- </location>
94
- RESPONSE
95
-
96
- XML_LOOKUP_RESPONSE = <<-RESPONSE
97
- <?xml version="1.0" encoding="UTF-8"?>
98
- <rsp stat="ok">
99
- <querystring>q=30022</querystring>
100
- <locations start="0" total="9" count="9">
101
- <location>
102
- <name>Alpharetta, GA 30022</name>
103
- <place-id>IrhZMHuYA5s1fFi4Qw</place-id>
104
- </location>
105
- <location>
106
- <name>Hannover, Region Hannover, Deutschland</name>
107
- <place-id>88Hctc2bBZlhvlwbUg</place-id>
108
- </location>
109
- <location>
110
- <name>N&#238;mes, Gard, France</name>
111
- <place-id>Sut8q82bBZkF0s1eTg</place-id>
112
- </location>
113
- <location>
114
- <name>Ceggia, Venezia, Italia</name>
115
- <place-id>s9ulRieYA5TkNK9otw</place-id>
116
- </location>
117
- <location>
118
- <name>Comit&#225;n de Dom&#237;nguez, Comitan de Dominguez, M&#233;xico</name>
119
- <place-id>.51HvYKbBZnSAeNHWw</place-id>
120
- </location>
121
- <location>
122
- <name>Platanos Aitoloakarnanias, Etolia Kai Akarnania, Greece</name>
123
- <place-id>CmfJ2H.YA5QKpS56HQ</place-id>
124
- </location>
125
- <location>
126
- <name>Krak&#243;w, Krak&#243;w, Polska</name>
127
- <place-id>9bYc0l.bA5vPTGscQg</place-id>
128
- </location>
129
- <location>
130
- <name>Nakuru, Kenya</name>
131
- <place-id>VDprypWYA5sujnZphA</place-id>
132
- </location>
133
- <location>
134
- <name>Fez, Al Magreb</name>
135
- <place-id>BxOaGgSYA5R40Nm1RA</place-id>
136
- </location>
137
- </locations>
138
- </rsp>
139
- RESPONSE
30
+ XML_LOOKUP_RESPONSE = File.read(File.join(File.dirname(__FILE__), "responses", "lookup.xml"))
140
31
 
141
32
  XML_FAIL_LOOKUP_RESPONSE = <<-RESPONSE
142
33
  <?xml version="1.0" encoding="utf-8"?>
@@ -145,143 +36,8 @@ XML_FAIL_LOOKUP_RESPONSE = <<-RESPONSE
145
36
  </rsp>
146
37
  RESPONSE
147
38
 
148
- XML_WITHIN_RESPONSE = <<-RESPONSE
149
- <?xml version="1.0" encoding="UTF-8"?>
150
- <rsp stat="ok">
151
- <users>
152
- <user token="MQdDrJgXMNJi">
153
- <location-hierarchy>
154
- <location best-guess="true">
155
- <id>111541</id>
156
- <georss:point>32.7093315125 -117.1650772095</georss:point>
157
- <level>0</level>
158
- <level-name>exact</level-name>
159
- <located-at>2008-03-03T09:05:16-08:00</located-at>
160
- <name>333 W Harbor Dr, San Diego, CA</name>
161
- </location>
162
- <location best-guess="false">
163
- <id>111551</id>
164
- <georss:box>
165
- 32.6916618347 -117.2174377441 32.744140625 -117.1458892822
166
- </georss:box>
167
- <level>1</level>
168
- <level-name>postal</level-name>
169
- <located-at>2008-03-03T09:05:16-08:00</located-at>
170
- <name>San Diego, CA 92101</name>
171
- <place-id>NpiXqwmYA5viX3K3Ew</place-id>
172
- <woeid>12796255</woeid>
173
- </location>
174
- <location best-guess="false">
175
- <id>111561</id>
176
- <georss:box>
177
- 32.5349388123 -117.2884292603 33.1128082275 -116.9142913818
178
- </georss:box>
179
- <level>3</level>
180
- <level-name>city</level-name>
181
- <located-at>2008-03-03T09:05:16-08:00</located-at>
182
- <name>San Diego, CA</name>
183
- <place-id>Nm4O.DebBZTYKUsu</place-id>
184
- <woeid>2487889</woeid>
185
- </location>
186
- <location best-guess="false">
187
- <id>111571</id>
188
- <georss:box>
189
- 32.5342788696 -124.4150238037 42.0093803406 -114.1308135986
190
- </georss:box>
191
- <level>5</level>
192
- <level-name>state</level-name>
193
- <located-at>2008-03-03T09:05:16-08:00</located-at>
194
- <name>California</name>
195
- <place-id>SVrAMtCbAphCLAtP</place-id>
196
- <woeid>2347563</woeid>
197
- </location>
198
- <location best-guess="false">
199
- <id>111581</id>
200
- <georss:box>
201
- 18.9108390808 -167.2764129639 72.8960571289 -66.6879425049
202
- </georss:box>
203
- <level>6</level>
204
- <level-name>country</level-name>
205
- <located-at>2008-03-03T09:05:16-08:00</located-at>
206
- <name>United States</name>
207
- <place-id>4KO02SibApitvSBieQ</place-id>
208
- <woeid>23424977</woeid>
209
- </location>
210
- </location-hierarchy>
211
- </user>
212
- <user token="MQdDrJgXMNJi">
213
- <location-hierarchy>
214
- <location best-guess="true">
215
- <id>111541</id>
216
- <georss:point>32.7093315125 -117.1650772095</georss:point>
217
- <level>0</level>
218
- <level-name>exact</level-name>
219
- <located-at>2008-03-03T09:05:16-08:00</located-at>
220
- <name>333 W Harbor Dr, San Diego, CA</name>
221
- </location>
222
- <location best-guess="false">
223
- <id>111551</id>
224
- <georss:box>
225
- 32.6916618347 -117.2174377441 32.744140625 -117.1458892822
226
- </georss:box>
227
- <level>1</level>
228
- <level-name>postal</level-name>
229
- <located-at>2008-03-03T09:05:16-08:00</located-at>
230
- <name>San Diego, CA 92101</name>
231
- <place-id>NpiXqwmYA5viX3K3Ew</place-id>
232
- <woeid>12796255</woeid>
233
- </location>
234
- <location best-guess="false">
235
- <id>111561</id>
236
- <georss:box>
237
- 32.5349388123 -117.2884292603 33.1128082275 -116.9142913818
238
- </georss:box>
239
- <level>3</level>
240
- <level-name>city</level-name>
241
- <located-at>2008-03-03T09:05:16-08:00</located-at>
242
- <name>San Diego, CA</name>
243
- <place-id>Nm4O.DebBZTYKUsu</place-id>
244
- <woeid>2487889</woeid>
245
- </location>
246
- <location best-guess="false">
247
- <id>111571</id>
248
- <georss:box>
249
- 32.5342788696 -124.4150238037 42.0093803406 -114.1308135986
250
- </georss:box>
251
- <level>5</level>
252
- <level-name>state</level-name>
253
- <located-at>2008-03-03T09:05:16-08:00</located-at>
254
- <name>California</name>
255
- <place-id>SVrAMtCbAphCLAtP</place-id>
256
- <woeid>2347563</woeid>
257
- </location>
258
- <location best-guess="false">
259
- <id>111581</id>
260
- <georss:box>
261
- 18.9108390808 -167.2764129639 72.8960571289 -66.6879425049
262
- </georss:box>
263
- <level>6</level>
264
- <level-name>country</level-name>
265
- <located-at>2008-03-03T09:05:16-08:00</located-at>
266
- <name>United States</name>
267
- <place-id>4KO02SibApitvSBieQ</place-id>
268
- <woeid>23424977</woeid>
269
- </location>
270
- </location-hierarchy>
271
- </user>
272
- </users>
273
- </rsp>
274
- RESPONSE
39
+ XML_WITHIN_RESPONSE = File.read(File.join(File.dirname(__FILE__), "responses", "within.xml"))
275
40
 
276
- XML_RECENT_RESPONSE = <<-RESPONSE
277
- <?xml version="1.0" encoding="UTF-8"?>
278
- <rsp xmlns:georss="http://www.georss.org/georss" stat="ok">
279
- <users>
280
- <user located-at="2008-07-31T22:31:37+12:00" token="5pyl1xip0uh6"/>
281
- <user located-at="2008-07-31T21:49:03+12:00" token="i71yc3myixg3"/>
282
- <user located-at="2008-07-30T21:40:54+12:00" token="q1jm8nubnpsi"/>
283
- </users>
284
- </rsp>
285
- RESPONSE
41
+ XML_RECENT_RESPONSE = File.read(File.join(File.dirname(__FILE__), "responses", "recent.xml"))
286
42
 
287
43
  require File.dirname(__FILE__) + '/../lib/fireeagle'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mojodna-fireeagle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0.0
4
+ version: 0.8.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Newland
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-29 00:00:00 -07:00
12
+ date: 2009-02-03 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -19,16 +19,16 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.2.4
22
+ version: 0.3.1
23
23
  version:
24
24
  - !ruby/object:Gem::Dependency
25
- name: hpricot
25
+ name: happymapper
26
26
  version_requirement:
27
27
  version_requirements: !ruby/object:Gem::Requirement
28
28
  requirements:
29
29
  - - ">="
30
30
  - !ruby/object:Gem::Version
31
- version: "0.6"
31
+ version: 0.2.1
32
32
  version:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: GeoRuby
@@ -39,6 +39,15 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.3.2
41
41
  version:
42
+ - !ruby/object:Gem::Dependency
43
+ name: hoe
44
+ version_requirement:
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 1.8.0
50
+ version:
42
51
  description: Ruby wrapper for Yahoo!'s FireEagle
43
52
  email:
44
53
  - jnewland@gmail.com
@@ -61,14 +70,27 @@ files:
61
70
  - Rakefile
62
71
  - lib/fireeagle.rb
63
72
  - lib/fireeagle/client.rb
73
+ - lib/fireeagle/error.rb
64
74
  - lib/fireeagle/location.rb
75
+ - lib/fireeagle/location_hierarchy.rb
76
+ - lib/fireeagle/locations.rb
65
77
  - lib/fireeagle/response.rb
66
78
  - lib/fireeagle/user.rb
67
79
  - lib/fireeagle/version.rb
68
80
  - setup.rb
69
- - spec/fireeagle_location_spec.rb
70
81
  - spec/fireeagle_response_spec.rb
71
82
  - spec/fireeagle_spec.rb
83
+ - spec/location_spec.rb
84
+ - spec/locations_spec.rb
85
+ - spec/responses/error.xml
86
+ - spec/responses/exact_location_chunk.xml
87
+ - spec/responses/location_chunk.xml
88
+ - spec/responses/location_chunk_with_query.xml
89
+ - spec/responses/locations_chunk.xml
90
+ - spec/responses/lookup.xml
91
+ - spec/responses/recent.xml
92
+ - spec/responses/user.xml
93
+ - spec/responses/within.xml
72
94
  - spec/spec.opts
73
95
  - spec/spec_helper.rb
74
96
  - tasks/environment.rake