jnewland-fireeagle 0.7.1.0

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.
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'