end
end
+ # Raised when a rate limit is exceeded
+ class APIRateLimitExceeded < APIError
+ def initialize
+ super "Rate limit exceeded"
+ end
+
+ def status
+ :too_many_requests
+ end
+ end
+
# Helper methods for going to/from mercator and lat/lng.
class Mercator
include Math
end
# Construct a random token of a given length
- def self.make_token(length = 30)
- chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
- token = ""
-
- length.times do
- token += chars[(rand * chars.length).to_i].chr
- end
-
- token
+ def self.make_token(length = 24)
+ SecureRandom.urlsafe_base64(length)
end
# Return an SQL fragment to select a given area of the globe