source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/smarty_streets.rb
Ruby
mit
6,440
master
1,776
require 'geocoder/lookups/base' require 'geocoder/results/smarty_streets' module Geocoder::Lookup class SmartyStreets < Base def name "SmartyStreets" end def required_api_key_parts %w(auth-id auth-token) end # required by API as of 26 March 2015 def supported_protocols [:h...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/amazon_location_service.rb
Ruby
mit
6,440
master
1,622
require 'geocoder/lookups/base' require 'geocoder/results/amazon_location_service' module Geocoder::Lookup class AmazonLocationService < Base def results(query) params = query.options.dup # index_name is required # Aws::ParamValidator raises ArgumentError on missing required keys params....
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/uk_ordnance_survey_names.rb
Ruby
mit
6,440
master
1,157
require 'geocoder/lookups/base' require 'geocoder/results/uk_ordnance_survey_names' module Geocoder::Lookup class UkOrdnanceSurveyNames < Base def name 'Ordance Survey Names' end def supported_protocols [:https] end def base_query_url(query) "#{protocol}://api.os.uk/search/na...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/mapbox.rb
Ruby
mit
6,440
master
1,634
require 'geocoder/lookups/base' require "geocoder/results/mapbox" module Geocoder::Lookup class Mapbox < Base def name "Mapbox" end private # --------------------------------------------------------------- def base_query_url(query) "#{protocol}://api.mapbox.com/geocoding/v5/#{dataset}/...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/geocodio.rb
Ruby
mit
6,440
master
1,221
require 'geocoder/lookups/base' require "geocoder/results/geocodio" module Geocoder::Lookup class Geocodio < Base def name "Geocodio" end def results(query) return [] unless doc = fetch_data(query) return doc["results"] if doc['error'].nil? if doc['error'] == 'Invalid API...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/ipregistry.rb
Ruby
mit
6,440
master
1,491
require 'geocoder/lookups/base' require 'geocoder/results/ipregistry' module Geocoder::Lookup class Ipregistry < Base ERROR_CODES = { 400 => Geocoder::InvalidRequest, 401 => Geocoder::InvalidRequest, 402 => Geocoder::OverQueryLimitError, 403 => Geocoder::InvalidApiKey, 451 => Geoco...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/nationaal_georegister_nl.rb
Ruby
mit
6,440
master
857
require 'geocoder/lookups/base' require "geocoder/results/nationaal_georegister_nl" module Geocoder::Lookup class NationaalGeoregisterNl < Base def name 'Nationaal Georegister Nederland' end private # --------------------------------------------------------------- def cache_key(query) ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/melissa_street.rb
Ruby
mit
6,440
master
1,008
require 'geocoder/lookups/base' require "geocoder/results/melissa_street" module Geocoder::Lookup class MelissaStreet < Base def name "MelissaStreet" end def results(query) return [] unless doc = fetch_data(query) if doc["TransmissionResults"] == "GE05" raise_error(Geocoder::...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/latlon.rb
Ruby
mit
6,440
master
1,393
require 'geocoder/lookups/base' require 'geocoder/results/latlon' module Geocoder::Lookup class Latlon < Base def name "LatLon.io" end def required_api_key_parts ["api_key"] end private # --------------------------------------------------------------- def base_query_url(query)...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/ipgeolocation.rb
Ruby
mit
6,440
master
1,294
require 'geocoder/lookups/base' require 'geocoder/results/ipgeolocation' module Geocoder::Lookup class Ipgeolocation < Base ERROR_CODES = { 400 => Geocoder::RequestDenied, # subscription is paused 401 => Geocoder::InvalidApiKey, # missing/invalid API key 403 => Geocoder::InvalidRequest, # inv...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/test.rb
Ruby
mit
6,440
master
923
require 'geocoder/lookups/base' require 'geocoder/results/test' module Geocoder module Lookup class Test < Base def name "Test" end def self.add_stub(query_text, results) stubs[query_text] = results end def self.set_default_stub(results) @default_stub = re...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/google_places_details.rb
Ruby
mit
6,440
master
1,313
require "geocoder/lookups/google" require "geocoder/results/google_places_details" module Geocoder module Lookup class GooglePlacesDetails < Google def name "Google Places Details" end def required_api_key_parts ["key"] end def supported_protocols [:https] ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/ip2location.rb
Ruby
mit
6,440
master
2,241
require 'geocoder/lookups/base' require 'geocoder/results/ip2location' module Geocoder::Lookup class Ip2location < Base def name "IP2LocationApi" end def required_api_key_parts ['key'] end def supported_protocols [:http, :https] end private # ------------------------...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/base.rb
Ruby
mit
6,440
master
10,870
require 'net/http' require 'net/https' require 'uri' unless defined?(ActiveSupport::JSON) begin require 'json' rescue LoadError raise LoadError, "Please install the 'json' or 'json_pure' gem to parse geocoder results." end end module Geocoder module Lookup class Base def initialize ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/maxmind.rb
Ruby
mit
6,440
master
2,368
require 'geocoder/lookups/base' require 'geocoder/results/maxmind' require 'csv' module Geocoder::Lookup class Maxmind < Base def name "MaxMind" end private # --------------------------------------------------------------- def base_query_url(query) "#{protocol}://geoip.maxmind.com/#{se...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/ipinfo_io_lite.rb
Ruby
mit
6,440
master
925
require 'geocoder/lookups/base' require 'geocoder/results/ipinfo_io_lite' module Geocoder::Lookup class IpinfoIoLite < Base def name 'Ipinfo.io Lite' end private # --------------------------------------------------------------- def base_query_url(query) url = "#{protocol}://api.ipinfo.i...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/freegeoip.rb
Ruby
mit
6,440
master
1,466
require 'geocoder/lookups/base' require 'geocoder/results/freegeoip' module Geocoder::Lookup class Freegeoip < Base def name "FreeGeoIP" end def supported_protocols if configuration[:host] [:https] else # use https for default host [:https] end end ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/baidu_ip.rb
Ruby
mit
6,440
master
555
require 'geocoder/lookups/baidu' require 'geocoder/results/baidu_ip' module Geocoder::Lookup class BaiduIp < Baidu def name "Baidu IP" end private # --------------------------------------------------------------- def base_query_url(query) "#{protocol}://api.map.baidu.com/location/ip?" ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/photon.rb
Ruby
mit
6,440
master
2,244
require 'geocoder/lookups/base' require 'geocoder/results/photon' module Geocoder::Lookup class Photon < Base def name 'Photon' end private # --------------------------------------------------------------- def supported_protocols [:https] end def base_query_url(query) hos...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/maxmind_local.rb
Ruby
mit
6,440
master
2,251
require 'ipaddr' require 'geocoder/lookups/base' require 'geocoder/results/maxmind_local' module Geocoder::Lookup class MaxmindLocal < Base def initialize if !configuration[:file].nil? begin gem = RUBY_PLATFORM == 'java' ? 'jgeoip' : 'geoip' require gem rescue LoadError...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/ban_data_gouv_fr.rb
Ruby
mit
6,440
master
4,295
# encoding: utf-8 require 'geocoder/lookups/base' require 'geocoder/results/ban_data_gouv_fr' module Geocoder::Lookup class BanDataGouvFr < Base def name "Base Adresse Nationale Française" end def map_link_url(coordinates) "https://www.openstreetmap.org/#map=19/#{coordinates.join('/')}" ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/amap.rb
Ruby
mit
6,440
master
1,678
require 'geocoder/lookups/base' require "geocoder/results/amap" module Geocoder::Lookup class Amap < Base def name "AMap" end def required_api_key_parts ["key"] end def supported_protocols [:http] end private # --------------------------------------------------------...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/mapquest.rb
Ruby
mit
6,440
master
1,691
require 'cgi' require 'geocoder/lookups/base' require "geocoder/results/mapquest" module Geocoder::Lookup class Mapquest < Base def name "Mapquest" end def required_api_key_parts ["key"] end private # --------------------------------------------------------------- def base_que...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/bing.rb
Ruby
mit
6,440
master
2,839
require 'geocoder/lookups/base' require "geocoder/results/bing" module Geocoder::Lookup class Bing < Base def name "Bing" end def map_link_url(coordinates) "http://www.bing.com/maps/default.aspx?cp=#{coordinates.join('~')}" end def required_api_key_parts ["key"] end ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/google_premier.rb
Ruby
mit
6,440
master
1,618
require 'openssl' require 'base64' require 'geocoder/lookups/google' require 'geocoder/results/google_premier' module Geocoder::Lookup class GooglePremier < Google def name "Google Premier" end def required_api_key_parts ["private key"] end def query_url(query) path = "/maps/...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/opencagedata.rb
Ruby
mit
6,440
master
1,920
require 'geocoder/lookups/base' require 'geocoder/results/opencagedata' module Geocoder::Lookup class Opencagedata < Base def name "OpenCageData" end def required_api_key_parts ["key"] end private # ---------------------------------------------------------------- def base_quer...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/location_iq.rb
Ruby
mit
6,440
master
1,355
require 'geocoder/lookups/nominatim' require "geocoder/results/location_iq" module Geocoder::Lookup class LocationIq < Nominatim def name "LocationIq" end def required_api_key_parts ["api_key"] end def supported_protocols [:https] end private # -----------------------...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/pickpoint.rb
Ruby
mit
6,440
master
879
require "geocoder/lookups/nominatim" require "geocoder/results/pickpoint" module Geocoder::Lookup class Pickpoint < Nominatim def name "Pickpoint" end def supported_protocols [:https] end def required_api_key_parts ["api_key"] end private # ---------------------------...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/geoip2.rb
Ruby
mit
6,440
master
1,171
require 'geocoder/lookups/base' require 'geocoder/results/geoip2' module Geocoder module Lookup class Geoip2 < Base attr_reader :gem_name def initialize unless configuration[:file].nil? begin @gem_name = configuration[:lib] || 'maxminddb' require @gem_name ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/azure.rb
Ruby
mit
6,440
master
1,086
require 'geocoder/lookups/base' require 'geocoder/results/azure' module Geocoder::Lookup class Azure < Base def name 'Azure' end def required_api_key_parts ['api_key'] end def supported_protocols [:https] end private def base_query_url(query) host = 'atlas....
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/postcode_anywhere_uk.rb
Ruby
mit
6,440
master
1,648
require 'geocoder/lookups/base' require 'geocoder/results/postcode_anywhere_uk' module Geocoder::Lookup class PostcodeAnywhereUk < Base # API documentation: http://www.postcodeanywhere.co.uk/Support/WebService/Geocoding/UK/Geocode/2/ DAILY_LIMIT_EXEEDED_ERROR_CODES = ['8', '17'] # api docs say these two code...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/esri.rb
Ruby
mit
6,440
master
3,355
require 'geocoder/lookups/base' require "geocoder/results/esri" require 'geocoder/esri_token' module Geocoder::Lookup class Esri < Base def name "Esri" end def supported_protocols [:https] end private # --------------------------------------------------------------- def ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/maxmind_geoip2.rb
Ruby
mit
6,440
master
1,860
require 'geocoder/lookups/base' require 'geocoder/results/maxmind_geoip2' module Geocoder::Lookup class MaxmindGeoip2 < Base def name "MaxMind GeoIP2" end # Maxmind's GeoIP2 Precision Services only supports HTTPS, # otherwise a `404 Not Found` HTTP response will be returned def supported_...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/google_places_search.rb
Ruby
mit
6,440
master
1,744
require "geocoder/lookups/google" require "geocoder/results/google_places_search" module Geocoder module Lookup class GooglePlacesSearch < Google def name "Google Places Search" end def required_api_key_parts ["key"] end def supported_protocols [:https] ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/ipinfo_io.rb
Ruby
mit
6,440
master
908
require 'geocoder/lookups/base' require 'geocoder/results/ipinfo_io' module Geocoder::Lookup class IpinfoIo < Base def name "Ipinfo.io" end private # --------------------------------------------------------------- def base_query_url(query) url = "#{protocol}://ipinfo.io/#{query.sanitiz...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/google.rb
Ruby
mit
6,440
master
3,076
require 'geocoder/lookups/base' require "geocoder/results/google" module Geocoder::Lookup class Google < Base def name "Google" end def map_link_url(coordinates) "http://maps.google.com/maps?q=#{coordinates.join(',')}" end def supported_protocols # Google requires HTTPS if an...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/ipstack.rb
Ruby
mit
6,440
master
1,555
require 'geocoder/lookups/base' require 'geocoder/results/ipstack' module Geocoder::Lookup class Ipstack < Base ERROR_CODES = { 404 => Geocoder::InvalidRequest, 101 => Geocoder::InvalidApiKey, 102 => Geocoder::Error, 103 => Geocoder::InvalidRequest, 104 => Geocoder::OverQueryLimitE...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/db_ip_com.rb
Ruby
mit
6,440
master
1,288
require 'geocoder/lookups/base' require 'geocoder/results/db_ip_com' module Geocoder::Lookup class DbIpCom < Base def name 'DB-IP.com' end def supported_protocols [:https, :http] end def required_api_key_parts ['api_key'] end private # -------------------------------...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/pc_miler.rb
Ruby
mit
6,440
master
2,353
require 'geocoder/lookups/base' require "geocoder/results/pc_miler" require 'cgi' unless defined?(CGI) && defined?(CGI.escape) module Geocoder::Lookup class PcMiler < Base # https://developer.trimblemaps.com/restful-apis/location/single-search/single-search-api/#test-the-api-now def valid_region_codes ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/twogis.rb
Ruby
mit
6,440
master
1,466
require 'geocoder/lookups/base' require "geocoder/results/twogis" module Geocoder::Lookup class Twogis < Base def name "2gis" end def required_api_key_parts ["key"] end def map_link_url(coordinates) "https://2gis.ru/?m=#{coordinates.join(',')}" end def supported_prot...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/pdok_nl.rb
Ruby
mit
6,440
master
865
require 'geocoder/lookups/base' require "geocoder/results/pdok_nl" module Geocoder::Lookup class PdokNl < Base def name 'pdok NL' end def supported_protocols [:https] end private # --------------------------------------------------------------- def cache_key(query) base_...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/postcodes_io.rb
Ruby
mit
6,440
master
663
require 'geocoder/lookups/base' require 'geocoder/results/postcodes_io' module Geocoder::Lookup class PostcodesIo < Base def name 'Postcodes.io' end def query_url(query) "#{protocol}://api.postcodes.io/postcodes/#{query.sanitized_text.gsub(/\s/, '')}" end def supported_protocols ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/here.rb
Ruby
mit
6,440
master
1,804
require 'geocoder/lookups/base' require 'geocoder/results/here' module Geocoder::Lookup class Here < Base def name "Here" end def required_api_key_parts ['api_key'] end def supported_protocols [:https] end private # ---------------------------------------------------...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/ipdata_co.rb
Ruby
mit
6,440
master
1,593
require 'geocoder/lookups/base' require 'geocoder/results/ipdata_co' module Geocoder::Lookup class IpdataCo < Base def name "ipdata.co" end def supported_protocols [:https] end def query_url(query) # Ipdata.co requires that the API key be sent as a query parameter. # It...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/pointpin.rb
Ruby
mit
6,440
master
1,905
require 'geocoder/lookups/base' require 'geocoder/results/pointpin' module Geocoder::Lookup class Pointpin < Base def name "Pointpin" end def required_api_key_parts ["key"] end def query_url(query) "#{protocol}://geo.pointp.in/#{configuration.api_key}/json/#{query.sanitized_t...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/ipapi_com.rb
Ruby
mit
6,440
master
2,020
require 'geocoder/lookups/base' require 'geocoder/results/ipapi_com' module Geocoder::Lookup class IpapiCom < Base def name "ip-api.com" end def supported_protocols if configuration.api_key [:http, :https] else [:http] end end private # -----------------...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/osmnames.rb
Ruby
mit
6,440
master
1,317
require 'cgi' require 'geocoder/lookups/base' require 'geocoder/results/osmnames' module Geocoder::Lookup class Osmnames < Base def name 'OSM Names' end def required_api_key_parts configuration[:host] ? [] : ['key'] end def supported_protocols [:https] end private ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/ipqualityscore.rb
Ruby
mit
6,440
master
1,349
# encoding: utf-8 require 'geocoder/lookups/base' require 'geocoder/results/ipqualityscore' module Geocoder::Lookup class Ipqualityscore < Base def name "IPQualityScore" end def required_api_key_parts ['api_key'] end private # ------------------------------------------------------...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/baidu.rb
Ruby
mit
6,440
master
1,756
require 'geocoder/lookups/base' require "geocoder/results/baidu" module Geocoder::Lookup class Baidu < Base def name "Baidu" end def required_api_key_parts ["key"] end # HTTP only def supported_protocols [:http] end private # -------------------------------------...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/ipbase.rb
Ruby
mit
6,440
master
1,120
require 'geocoder/lookups/base' require 'geocoder/results/ipbase' module Geocoder::Lookup class Ipbase < Base def name "ipbase.com" end def supported_protocols [:https] end private # --------------------------------------------------------------- def base_query_url(query) ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/geoapify.rb
Ruby
mit
6,440
master
2,034
# frozen_string_literal: true require 'geocoder/lookups/base' require 'geocoder/results/geoapify' module Geocoder module Lookup # https://apidocs.geoapify.com/docs/geocoding/api class Geoapify < Base def name 'Geoapify' end def required_api_key_parts ['api_key'] end ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/geocoder_ca.rb
Ruby
mit
6,440
master
1,317
require 'geocoder/lookups/base' require "geocoder/results/geocoder_ca" module Geocoder::Lookup class GeocoderCa < Base def name "Geocoder.ca" end private # --------------------------------------------------------------- def base_query_url(query) "#{protocol}://geocoder.ca/?" end ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/tencent.rb
Ruby
mit
6,440
master
1,612
require 'geocoder/lookups/base' require "geocoder/results/tencent" module Geocoder::Lookup class Tencent < Base def name "Tencent" end def required_api_key_parts ["key"] end def supported_protocols [:https] end private # ----------------------------------------------...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/yandex.rb
Ruby
mit
6,440
master
1,708
require 'geocoder/lookups/base' require "geocoder/results/yandex" module Geocoder::Lookup class Yandex < Base def name "Yandex" end def map_link_url(coordinates) "http://maps.yandex.ru/?ll=#{coordinates.reverse.join(',')}" end def supported_protocols [:https] end pri...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/telize.rb
Ruby
mit
6,440
master
1,704
require 'geocoder/lookups/base' require 'geocoder/results/telize' module Geocoder::Lookup class Telize < Base def name "Telize" end def required_api_key_parts configuration[:host] ? [] : ["key"] end def query_url(query) if configuration[:host] "#{protocol}://#{configu...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/ip2location_io.rb
Ruby
mit
6,440
master
1,456
require 'geocoder/lookups/base' require 'geocoder/results/ip2location_io' module Geocoder::Lookup class Ip2locationIo < Base def name "IP2LocationIOApi" end def required_api_key_parts ['key'] end def supported_protocols [:http, :https] end private # -----------------...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/nominatim.rb
Ruby
mit
6,440
master
1,655
require 'geocoder/lookups/base' require "geocoder/results/nominatim" module Geocoder::Lookup class Nominatim < Base def name "Nominatim" end def map_link_url(coordinates) "https://www.openstreetmap.org/?lat=#{coordinates[0]}&lon=#{coordinates[1]}&zoom=15&layers=M" end private # ---...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/geoportail_lu.rb
Ruby
mit
6,440
master
1,530
require 'geocoder/lookups/base' require "geocoder/results/geoportail_lu" module Geocoder module Lookup class GeoportailLu < Base def name "Geoportail.lu" end private # --------------------------------------------------------------- def base_query_url(query) if query.rev...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/pelias.rb
Ruby
mit
6,440
master
1,706
require 'geocoder/lookups/base' require 'geocoder/results/pelias' module Geocoder::Lookup class Pelias < Base def name 'Pelias' end def endpoint configuration[:endpoint] || 'localhost' end def required_api_key_parts ['search-XXXX'] end private # ----------------------...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/abstract_api.rb
Ruby
mit
6,440
master
876
# encoding: utf-8 require 'geocoder/lookups/base' require 'geocoder/results/abstract_api' module Geocoder::Lookup class AbstractApi < Base def name "Abstract API" end def required_api_key_parts ['api_key'] end def supported_protocols [:https] end private # ---------...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/cache_stores/redis.rb
Ruby
mit
6,440
master
657
require 'geocoder/cache_stores/base' module Geocoder::CacheStore class Redis < Base def initialize(store, options) super @expiration = options[:expiration] end def write(url, value, expire = @expiration) if expire.present? store.set key_for(url), value, ex: expire else ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/cache_stores/base.rb
Ruby
mit
6,440
master
765
module Geocoder::CacheStore class Base def initialize(store, options) @store = store @config = options @prefix = config[:prefix] end ## # Array of keys with the currently configured prefix # that have non-nil values. def keys store.keys.select { |k| k.match(/^#{prefix}...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/cache_stores/generic.rb
Ruby
mit
6,440
master
711
require 'geocoder/cache_stores/base' module Geocoder::CacheStore class Generic < Base def write(url, value) case when store.respond_to?(:[]=) store[key_for(url)] = value when store.respond_to?(:set) store.set key_for(url), value when store.respond_to?(:write) store...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/tasks/maxmind.rake
Ruby
mit
6,440
master
1,962
require 'maxmind_database' namespace :geocoder do namespace :maxmind do namespace :geolite do desc "Download and load/refresh MaxMind GeoLite City data" task load: [:download, :extract, :insert] desc "Download MaxMind GeoLite City data" task :download do p = MaxmindTask.check_fo...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/tasks/geocoder.rake
Ruby
mit
6,440
master
1,572
require "geocoder/models/mongoid" namespace :geocode do desc "Geocode all objects without coordinates." task :all => :environment do class_name = ENV['CLASS'] || ENV['class'] sleep_timer = ENV['SLEEP'] || ENV['sleep'] batch = ENV['BATCH'] || ENV['batch'] reverse = ENV['REVERSE'] || ENV['reverse'] ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/generators/geocoder/migration_version.rb
Ruby
mit
6,440
master
281
module Geocoder module Generators module MigrationVersion def rails_5? Rails::VERSION::MAJOR == 5 end def migration_version if rails_5? "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" end end end end end
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/generators/geocoder/maxmind/geolite_city_generator.rb
Ruby
mit
6,440
master
973
require 'rails/generators/migration' require 'generators/geocoder/migration_version' module Geocoder module Generators module Maxmind class GeoliteCityGenerator < Rails::Generators::Base include Rails::Generators::Migration include Generators::MigrationVersion source_root File.expa...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/generators/geocoder/maxmind/geolite_country_generator.rb
Ruby
mit
6,440
master
982
require 'rails/generators/migration' require 'generators/geocoder/migration_version' module Geocoder module Generators module Maxmind class GeoliteCountryGenerator < Rails::Generators::Base include Rails::Generators::Migration include Generators::MigrationVersion source_root File.e...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/generators/geocoder/maxmind/templates/migration/geolite_city.rb
Ruby
mit
6,440
master
1,138
class GeocoderMaxmindGeoliteCity < ActiveRecord::Migration<%= migration_version %> def self.up create_table :maxmind_geolite_city_blocks, id: false do |t| t.column :start_ip_num, :bigint, null: false t.column :end_ip_num, :bigint, null: false t.column :loc_id, :bigint, null: false end ad...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/generators/geocoder/maxmind/templates/migration/geolite_country.rb
Ruby
mit
6,440
master
572
class GeocoderMaxmindGeoliteCountry < ActiveRecord::Migration<%= migration_version %> def self.up create_table :maxmind_geolite_country, id: false do |t| t.column :start_ip, :string t.column :end_ip, :string t.column :start_ip_num, :bigint, null: false t.column :end_ip_num, :bigint, null: ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/generators/geocoder/config/config_generator.rb
Ruby
mit
6,440
master
409
require 'rails/generators' module Geocoder class ConfigGenerator < Rails::Generators::Base source_root File.expand_path("../templates", __FILE__) desc "This generator creates an initializer file at config/initializers, " + "with the default configuration options for Geocoder." def add_initializ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/generators/geocoder/config/templates/initializer.rb
Ruby
mit
6,440
master
1,123
Geocoder.configure( # Geocoding options # timeout: 3, # geocoding service timeout (secs) # lookup: :nominatim, # name of geocoding service (symbol) # ip_lookup: :ipinfo_io, # name of IP address geocoding service (symbol) # language: :en, # ISO-639 language code # us...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
examples/reverse_geocode_job.rb
Ruby
mit
6,440
master
1,000
# This class implements an ActiveJob job for performing reverse-geocoding # asynchronously. Example usage: # if @location.save && @location.address.blank? # ReverseGeocodeJob.perform_later(@location) # end # Be sure to configure the queue adapter in config/application.rb: # config.active_job.queue_adapter = :sideki...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
examples/app_defined_lookup_services.rb
Ruby
mit
6,440
master
982
# To extend the Geocoder with additional lookups that come from the application, # not shipped with the gem, define a "child" lookup in your application, based on existing one. # This is required because the Geocoder::Configuration is a Singleton and stores one api key per lookup. # in app/libs/geocoder/lookup/my_prec...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
examples/cache_bypass.rb
Ruby
mit
6,440
master
1,000
# This class allows you to configure how Geocoder should treat errors that occur when # the cache is not available. # Configure it like this # config/initializers/geocoder.rb # Geocoder.configure( # :cache => Geocoder::CacheBypass.new(Redis.new) # ) # # Depending on the value of @bypass this will either # raise the ex...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/mongoid_test_helper.rb
Ruby
mit
6,440
master
2,323
require 'rubygems' require 'test/unit' require 'test_helper' require 'mongoid' require 'geocoder/models/mongoid' $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) if (::Mongoid::VERSION >= "3") Mongoid.logger = Logger.new($stderr, :debug) else Mongoid.co...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/test_helper.rb
Ruby
mit
6,440
master
19,801
# encoding: utf-8 require 'rubygems' require 'test/unit' $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'yaml' configs = YAML.load_file('test/database.yml') if configs.keys.include? ENV['DB'] require 'active_record' # Establish a database co...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/https_test.rb
Ruby
mit
6,440
master
276
# encoding: utf-8 require 'test_helper' class HttpsTest < GeocoderTestCase def test_uses_https_for_secure_query Geocoder.configure(:use_https => true) g = Geocoder::Lookup::Google.new assert_match(/^https:/, g.query_url(Geocoder::Query.new("test"))) end end
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/result_test.rb
Ruby
mit
6,440
master
2,721
# encoding: utf-8 require 'test_helper' class ResultTest < GeocoderTestCase def test_forward_geocoding_result_has_required_attributes Geocoder::Lookup.all_services_except_test.each do |l| next if [ :ip2location, # has pay-per-attribute pricing model :ip2location_io, # has pay-per-attribute...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/ip_address_test.rb
Ruby
mit
6,440
master
2,687
# encoding: utf-8 require 'test_helper' class IpAddressTest < GeocoderTestCase def test_valid assert Geocoder::IpAddress.new("232.65.123.94").valid? assert Geocoder::IpAddress.new(IPAddr.new("232.65.123.94")).valid? assert !Geocoder::IpAddress.new("666.65.123.94").valid? assert Geocoder::IpAddress.n...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/lookup_test.rb
Ruby
mit
6,440
master
6,952
# encoding: utf-8 require 'test_helper' class LookupTest < GeocoderTestCase def test_responds_to_name_method Geocoder::Lookup.all_services.each do |l| lookup = Geocoder::Lookup.get(l) assert lookup.respond_to?(:name), "Lookup #{l} does not respond to #name method." end end def test_s...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/request_test.rb
Ruby
mit
6,440
master
4,633
# encoding: utf-8 require 'test_helper' class RequestTest < GeocoderTestCase class MockRequest < Rack::Request include Geocoder::Request def initialize(headers={}, ip="") super_env = headers super_env.merge!({'REMOTE_ADDR' => ip}) unless ip == "" super(super_env) end end def setup ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/mongoid_test.rb
Ruby
mit
6,440
master
1,977
# encoding: utf-8 require 'mongoid_test_helper' class MongoidTest < GeocoderTestCase def test_geocoded_check p = PlaceUsingMongoid.new(*geocoded_object_params(:msg)) p.location = [40.750354, -73.993371] assert p.geocoded? end def test_geocoded_check_single_coord p = PlaceUsingMongoid.new(*geocod...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/logger_test.rb
Ruby
mit
6,440
master
1,768
# encoding: utf-8 require 'test_helper' require 'logger' require 'tempfile' class LoggerTest < GeocoderTestCase def setup @tempfile = Tempfile.new("log") @logger = Logger.new(@tempfile.path) Geocoder.configure(logger: @logger) end def teardown @logger.close @tempfile.close end def test...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/geocoder_test.rb
Ruby
mit
6,440
master
2,662
# encoding: utf-8 require 'test_helper' class GeocoderTest < GeocoderTestCase def test_distance_to_returns_float v = Place.new(*geocoded_object_params(:msg)) v.latitude, v.longitude = [40.750354, -73.993371] assert (v.distance_to([30, -94])).is_a?(Float) end def test_coordinates_method_returns_arra...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/test_mode_test.rb
Ruby
mit
6,440
master
2,335
# encoding: utf-8 require 'test_helper' class TestModeTest < GeocoderTestCase def setup @_original_lookup = Geocoder.config.lookup Geocoder.configure(:lookup => :test) end def teardown Geocoder::Lookup::Test.reset Geocoder.configure(:lookup => @_original_lookup) end def test_search_with_kn...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/near_test.rb
Ruby
mit
6,440
master
4,432
# encoding: utf-8 require 'test_helper' require 'arel' class NearTest < GeocoderTestCase def test_near_scope_options_includes_bounding_box_condition omit("Not applicable to unextended SQLite") if using_unextended_sqlite? result = PlaceWithCustomResultsHandling.send(:near_scope_options, 1.0, 2.0, 5) tab...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/proxy_test.rb
Ruby
mit
6,440
master
1,209
# encoding: utf-8 require 'test_helper' class ProxyTest < GeocoderTestCase def test_uses_proxy_when_specified Geocoder.configure(:http_proxy => 'localhost') Geocoder.configure(:use_https => false) lookup = Geocoder::Lookup::Bing.new assert lookup.send(:http_client).proxy_class? end def test_doe...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/model_test.rb
Ruby
mit
6,440
master
1,405
# encoding: utf-8 require 'test_helper' class ModelTest < GeocoderTestCase def test_geocode_with_block_runs_block e = PlaceWithCustomResultsHandling.new(*geocoded_object_params(:msg)) e.geocode assert_match(/[0-9\.,\-]+/, e.coords_string) end def test_geocode_with_block_doesnt_auto_assign_coordinat...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/calculations_test.rb
Ruby
mit
6,440
master
7,701
# encoding: utf-8 require 'test_helper' class CalculationsTest < GeocoderTestCase def setup Geocoder.configure( :units => :mi, :distances => :linear ) end # --- degree distance --- def test_longitude_degree_distance_at_equator assert_equal 69, Geocoder::Calculations.longitude_degree_d...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/query_test.rb
Ruby
mit
6,440
master
3,750
# encoding: utf-8 require 'test_helper' class QueryTest < GeocoderTestCase def test_detect_ipv4 assert Geocoder::Query.new("232.65.123.94").ip_address? ip = IPAddr.new("232.65.123.94") assert Geocoder::Query.new(ip).ip_address? end def test_detect_ipv6 assert Geocoder::Query.new("3ffe:0b00:0000...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/configuration_test.rb
Ruby
mit
6,440
master
1,898
# encoding: utf-8 require 'test_helper' class ConfigurationTest < GeocoderTestCase def setup Geocoder::Configuration.set_defaults end def test_exception_raised_on_bad_lookup_config Geocoder.configure(:lookup => :stoopid) assert_raises Geocoder::ConfigurationError do Geocoder.search "something ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/active_record_test.rb
Ruby
mit
6,440
master
476
# encoding: utf-8 require 'test_helper' class ActiveRecordTest < GeocoderTestCase def test_exclude_condition_when_model_has_a_custom_primary_key venue = PlaceWithCustomPrimaryKey.new(*geocoded_object_params(:msg)) # just call private method directly so we don't have to stub .near scope conditions = ven...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/method_aliases_test.rb
Ruby
mit
6,440
master
669
# encoding: utf-8 require 'test_helper' class MethodAliasesTest < GeocoderTestCase def test_distance_from_is_alias_for_distance_to v = Place.new(*geocoded_object_params(:msg)) v.latitude, v.longitude = [40.750354, -73.993371] assert_equal v.distance_from([30, -94]), v.distance_to([30, -94]) end def...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/cache_test.rb
Ruby
mit
6,440
master
2,458
# encoding: utf-8 require 'test_helper' class CacheTest < GeocoderTestCase def setup @tempfile = Tempfile.new("log") @logger = Logger.new(@tempfile.path) Geocoder.configure(logger: @logger) end def teardown Geocoder.configure(logger: :kernel) @logger.close @tempfile.close end def te...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/error_handling_test.rb
Ruby
mit
6,440
master
2,571
# encoding: utf-8 require 'test_helper' class ErrorHandlingTest < GeocoderTestCase def teardown Geocoder.configure(:always_raise => []) end def test_does_not_choke_on_timeout silence_warnings do Geocoder::Lookup.all_services_with_http_requests.each do |l| Geocoder.configure(:lookup => l) ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/util_test.rb
Ruby
mit
6,440
master
399
# frozen_string_literal: true require 'test_helper' class UtilTest < GeocoderTestCase def test_recursive_hash_merge h1 = { 'a' => 100, 'b' => 200, 'c' => { 'c1' => 12, 'c2' => 14 } } h2 = { 'b' => 254, 'c' => { 'c1' => 16, 'c3' => 94 } } Geocoder::Util.recursive_hash_merge(h1, h2) assert h1 == { 'a'...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/lookups/pc_miler_test.rb
Ruby
mit
6,440
master
4,889
# encoding: utf-8 require 'test_helper' class TrimbleMapsTest < GeocoderTestCase def setup super Geocoder.configure(lookup: :pc_miler) end def test_query_for_geocode query = Geocoder::Query.new('wall drug') lookup = Geocoder::Lookup.get(:pc_miler) res = lookup.query_url(query) assert_eq...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/lookups/esri_test.rb
Ruby
mit
6,440
master
7,718
# encoding: utf-8 require 'test_helper' require 'geocoder/esri_token' class EsriTest < GeocoderTestCase def setup super Geocoder.configure(lookup: :esri) end def test_query_for_geocode query = Geocoder::Query.new("Bluffton, SC") lookup = Geocoder::Lookup.get(:esri) res = lookup.query_url(qu...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
test/unit/lookups/pickpoint_test.rb
Ruby
mit
6,440
master
1,110
require 'test_helper' class PickpointTest < GeocoderTestCase def setup super Geocoder.configure(lookup: :pickpoint) set_api_key!(:pickpoint) end def test_result_components result = Geocoder.search("Madison Square Garden, New York, NY").first assert_equal "10001", result.postal_code asse...