jnewland-fireeagle 0.7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +33 -0
- data/License.txt +20 -0
- data/Manifest.txt +21 -0
- data/README.txt +52 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +18 -0
- data/lib/fireeagle/client.rb +283 -0
- data/lib/fireeagle/location.rb +70 -0
- data/lib/fireeagle/response.rb +31 -0
- data/lib/fireeagle/user.rb +33 -0
- data/lib/fireeagle/version.rb +10 -0
- data/lib/fireeagle.rb +66 -0
- data/setup.rb +1585 -0
- data/spec/fireeagle_location_spec.rb +60 -0
- data/spec/fireeagle_response_spec.rb +65 -0
- data/spec/fireeagle_spec.rb +190 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +359 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +32 -0
- metadata +104 -0
data/lib/fireeagle.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'time'
|
2
|
+
require 'net/https'
|
3
|
+
require 'rubygems'
|
4
|
+
gem 'oauth', ">= 0.2.4"
|
5
|
+
require 'oauth/helper'
|
6
|
+
require 'oauth/client/helper'
|
7
|
+
require 'oauth/request_proxy/net_http'
|
8
|
+
require 'hpricot'
|
9
|
+
require 'geo_ruby'
|
10
|
+
|
11
|
+
class FireEagle
|
12
|
+
API_SERVER = "https://fireeagle.yahooapis.com"
|
13
|
+
AUTH_SERVER = "https://fireeagle.yahoo.net"
|
14
|
+
REQUEST_TOKEN_PATH = "/oauth/request_token"
|
15
|
+
ACCESS_TOKEN_PATH = "/oauth/access_token"
|
16
|
+
AUTHORIZATION_URL = "#{AUTH_SERVER}/oauth/authorize"
|
17
|
+
MOBILE_AUTH_URL = "#{AUTH_SERVER}/oauth/mobile_auth/"
|
18
|
+
USER_API_PATH = "/api/0.1/user"
|
19
|
+
LOOKUP_API_PATH = "/api/0.1/lookup"
|
20
|
+
UPDATE_API_PATH = "/api/0.1/update"
|
21
|
+
RECENT_API_PATH = "/api/0.1/recent"
|
22
|
+
WITHIN_API_PATH = "/api/0.1/within"
|
23
|
+
FORMAT_XML = "xml"
|
24
|
+
UPDATE_PARAMS = :lat, :lon, :woeid, :place_id, :address, :mnc, :mcc, :lac, :cellid, :postal, :city, :state, :country, :q, :label
|
25
|
+
# not yet supported
|
26
|
+
#,:geom, :upcoming_venue_id, :yahoo_local_id, :plazes_id
|
27
|
+
|
28
|
+
class Error < RuntimeError #:nodoc:
|
29
|
+
end
|
30
|
+
|
31
|
+
class ArgumentError < Error #:nodoc:
|
32
|
+
end
|
33
|
+
|
34
|
+
class FireEagleException < Error #:nodoc:
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# FireEagle additions to the <code>Hash</code> class
|
39
|
+
class Hash
|
40
|
+
# Returns <code>true</code> if the ALL or NONE of the given keys are present in <i>my_keys</i>.
|
41
|
+
def has_all_or_none_keys?(*my_keys)
|
42
|
+
size = my_keys.length
|
43
|
+
false_count = 0
|
44
|
+
my_keys.each do |k|
|
45
|
+
false_count += 1 unless keys.include?(k)
|
46
|
+
end
|
47
|
+
false_count == 0 or false_count == size
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# FireEagle addition to the <code>OAuth::Consumer</code> class
|
52
|
+
class OAuth::Consumer
|
53
|
+
alias_method :create_http_with_verify, :create_http
|
54
|
+
# Monkey patch to silence the SSL warnings
|
55
|
+
def create_http_without_verify #:nodoc:
|
56
|
+
http_object = create_http_with_verify
|
57
|
+
http_object.verify_mode = OpenSSL::SSL::VERIFY_NONE if uri.scheme=="https"
|
58
|
+
http_object
|
59
|
+
end
|
60
|
+
alias_method :create_http, :create_http_without_verify
|
61
|
+
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'
|