Permalink
Browse files

Let's try that, YET AGAIN...

  • Loading branch information...
1 parent 23a6401 commit 63eb10f6379edc686dd09958409caab77a158c22 @duckinator committed Apr 29, 2011
Showing with 15 additions and 18 deletions.
  1. +15 −18 config.ru
View
33 config.ru
@@ -12,28 +12,25 @@ class Site
end
def getinfo(ip)
- unless $cache[ip]
- tmp = @g.country(ip)
- data = {
- :raw => tmp,
- :city => tmp[7] || "unknown",
- :region => tmp[6] || "unknown",
- :country => tmp[4] || "unknown",
- :area_code => tmp[12] || "unknown",
- :time_zone => tmp[13] || "unknown"
- }
- data[:time_zone].gsub!('_',' ')
- $cache[ip] = data
- end
- $cache[ip]
+ return $cache[ip] if $cache.keys.include?(ip)
+ tmp = @g.country(ip)
+ data = {
+ :raw => tmp,
+ :city => tmp[7] || "unknown",
+ :region => tmp[6] || "unknown",
+ :country => tmp[4] || "unknown",
+ :area_code => tmp[12] || "unknown",
+ :time_zone => tmp[13] || "unknown"
+ }
+ data[:time_zone].gsub!('_',' ')
+ $cache[ip] = data
end
def getua(raw_useragent)
- unless $useragents[raw_useragent]
- $useragents[raw_useragent] = parse_useragent(raw_useragent)
- end
- $useragents[raw_useragent]
+ return $useragents[raw_useragent] if $useragents.keys.include?(raw_useragent)
+ $useragents[raw_useragent] = parse_useragent(raw_useragent)
end
+
def call(env)
ip = env['REMOTE_ADDR'] # Normal
raw_ua = env['HTTP_USER_AGENT']

0 comments on commit 63eb10f

Please sign in to comment.