4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/detector/region.rb', line 4
def detect_region(host, geo)
return nil unless host || geo
hostname = host.to_s.downcase
aws_region = detect_aws_region(hostname)
return aws_region if aws_region
azure_region = detect_azure_region(hostname)
return azure_region if azure_region
gcp_region = detect_gcp_region(hostname)
return gcp_region if gcp_region
return nil unless geo
city_region = detect_region_by_city(geo&.data&.dig('city')&.downcase)
return city_region if city_region
geo_region = detect_region_by_geography(geo&.data&.dig('region'), geo&.data&.dig('country'))
return geo_region if geo_region
geo&.data&.dig('region') || geo&.data&.dig('country_code')&.downcase
end
|