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
guard/guard
https://github.com/guard/guard
spec/lib/guard/jobs/sleep_spec.rb
Ruby
mit
6,479
master
1,328
# frozen_string_literal: true require "guard/jobs/sleep" RSpec.describe Guard::Jobs::Sleep, :stub_ui do include_context "with engine" subject { described_class.new(engine) } describe "#foreground" do it "sleeps" do status = "unknown" Thread.new do sleep 0.1 status = Thread.mai...
github
guard/guard
https://github.com/guard/guard
spec/lib/guard/jobs/pry_wrapper_spec.rb
Ruby
mit
6,479
master
5,993
# frozen_string_literal: true require "guard/jobs/pry_wrapper" RSpec.describe Guard::Jobs::PryWrapper, :stub_ui do include_context "with engine" let(:pry_hooks) { double("pry_hooks", add_hook: true) } let(:pry_config) do double("pry_config", "history_file=" => true, command_prefix: true, "prompt=" => true,...
github
guard/guard
https://github.com/guard/guard
spec/lib/guard/ui/logger_config_spec.rb
Ruby
mit
6,479
master
526
# frozen_string_literal: true require "guard/ui/logger_config" RSpec.describe Guard::UI::LoggerConfig do describe "defaults" do it "flushes device by default" do expect(subject[:flush_seconds]).to eq(0) end end describe "#level=" do context "with a valid value" do before do subj...
github
guard/guard
https://github.com/guard/guard
spec/lib/guard/ui/config_spec.rb
Ruby
mit
6,479
master
614
# frozen_string_literal: true require "guard/ui/config" RSpec.describe Guard::UI::Config do describe "#device" do context "when not set" do context "when accessed as a method" do it "returns $stderr" do expect(subject.device).to be($stderr) end end context "when acce...
github
guard/guard
https://github.com/guard/guard
spec/support/gems_helper.rb
Ruby
mit
6,479
master
273
# frozen_string_literal: true def growl_installed? require "growl" true rescue LoadError false end def libnotify_installed? require "libnotify" true rescue LoadError false end def rbnotifu_installed? require "rb-notifu" true rescue LoadError false end
github
guard/guard
https://github.com/guard/guard
spec/support/platform_helper.rb
Ruby
mit
6,479
master
217
# frozen_string_literal: true def mac? RbConfig::CONFIG["target_os"] =~ /darwin/i end def linux? RbConfig::CONFIG["target_os"] =~ /linux/i end def windows? RbConfig::CONFIG["target_os"] =~ /mswin|mingw/i end
github
guard/guard
https://github.com/guard/guard
features/support/aruba_adapter.rb
Ruby
mit
6,479
master
1,553
# frozen_string_literal: true require "guard/cli" require "guard/ui" # @private class ArubaAdapter def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) @argv = argv @stdin = stdin @stdout = stdout @stderr = stderr @kernel = kernel if ENV["I...
github
guard/guard
https://github.com/guard/guard
features/support/env.rb
Ruby
mit
6,479
master
890
# frozen_string_literal: true require "aruba" require "aruba/cucumber" require "aruba/processes/in_process" require "aruba/processes/spawn_process" require_relative "aruba_adapter" Before("@spawn") do aruba.config.command_launcher = :spawn gemfile_path = expand_path("Gemfile") set_environment_variable "BUNDLE...
github
guard/guard
https://github.com/guard/guard
features/step_definitions/guard_steps.rb
Ruby
mit
6,479
master
1,782
# frozen_string_literal: true Given(/^my Guardfile contains:$/) do |contents| write_file("Guardfile", contents) end Given(/^my Rakefile contains:$/) do |contents| write_file("Rakefile", contents) end Given(/^my Gemfile includes "([^"]*)"$/) do |gem| (@gems ||= []) << gem end Given(/^Guard is bundled using sou...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
geocoder.gemspec
Ruby
mit
6,440
master
1,262
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require 'date' require "geocoder/version" Gem::Specification.new do |s| s.name = "geocoder" s.required_ruby_version = '>= 2.5.0' s.version = Geocoder::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Alex Reisner"]...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
Gemfile
Ruby
mit
6,440
master
761
source "https://rubygems.org" group :development, :test do gem 'benchmark' # needed for Ruby >=4.0 gem 'bigdecimal' gem 'geoip' gem 'ip2location_ruby' gem 'logger' gem 'mongoid' gem 'ostruct' gem 'rails', '~>5.1.0' gem 'rake' gem 'rdoc' # needed for Ruby >=4.0 gem 'rubyzip' gem 'test-unit' # ne...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
Rakefile
Ruby
mit
6,440
master
1,989
require 'bundler' Bundler::GemHelper.install_tasks ACCEPTED_DB_VALUES = %w(sqlite postgres mysql) DATABASE_CONFIG_FILE = 'test/database.yml' def config require 'yaml' YAML.load(File.open(DATABASE_CONFIG_FILE)) end namespace :db do task :create do if ACCEPTED_DB_VALUES.include? ENV['DB'] Rake::Task["d...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder.rb
Ruby
mit
6,440
master
1,279
require "geocoder/configuration" require "geocoder/logger" require "geocoder/kernel_logger" require "geocoder/query" require "geocoder/calculations" require "geocoder/exceptions" require "geocoder/cache" require "geocoder/request" require "geocoder/lookup" require "geocoder/ip_address" require "geocoder/models/active_r...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/maxmind_database.rb
Ruby
mit
6,440
master
3,483
require 'csv' require 'net/http' module Geocoder module MaxmindDatabase extend self def download(package, dir = "tmp") filepath = File.expand_path(File.join(dir, "#{archive_edition(package)}.zip")) open(filepath, 'wb') do |file| uri = URI.parse(base_url(package)) Net::HTTP.start(...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/easting_northing.rb
Ruby
mit
6,440
master
4,891
module Geocoder class EastingNorthing attr_reader :easting, :northing, :lat_lng def initialize(opts) @easting = opts[:easting] @northing = opts[:northing] @lat_lng = to_WGS84(to_osgb_36) end private def to_osgb_36 osgb_fo = 0.9996012717 northing0 = -100_000.0 ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/sql.rb
Ruby
mit
6,440
master
4,567
module Geocoder module Sql extend self ## # Distance calculation for use with a database that supports POWER(), # SQRT(), PI(), and trigonometric functions SIN(), COS(), ASIN(), # ATAN2(). # # Based on the excellent tutorial at: # http://www.scribd.com/doc/2569355/Geo-Distance-Search...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/exceptions.rb
Ruby
mit
6,440
master
533
require 'timeout' module Geocoder class Error < StandardError end class ConfigurationError < Error end class OverQueryLimitError < Error end class ResponseParseError < Error attr_reader :response def initialize(response) @response = response end end class RequestDenied < Error...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/configuration.rb
Ruby
mit
6,440
master
4,100
require 'singleton' require 'geocoder/configuration_hash' require 'geocoder/util' module Geocoder ## # Configuration options should be set by passing a hash: # # Geocoder.configure( # :timeout => 5, # :lookup => :yandex, # :api_key => "2a9fsa983jaslfj982fjasd", # :units => :km...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/query.rb
Ruby
mit
6,440
master
2,830
module Geocoder class Query attr_accessor :text, :options def initialize(text, options = {}) self.text = text self.options = options end def execute lookup.search(text, options) end def to_s text end def sanitized_text if coordinates? if text.i...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/calculations.rb
Ruby
mit
6,440
master
13,873
module Geocoder module Calculations extend self ## # Compass point names, listed clockwise starting at North. # # If you want bearings named using more, fewer, or different points # override Geocoder::Calculations.COMPASS_POINTS with your own array. # COMPASS_POINTS = %w[N NE E SE S S...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/esri_token.rb
Ruby
mit
6,440
master
975
module Geocoder class EsriToken attr_accessor :value, :expires_at def initialize(value, expires_at) @value = value @expires_at = expires_at end def to_s @value end def active? @expires_at > Time.now end def self.generate_token(client_id, client_secret, exp...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/cli.rb
Ruby
mit
6,440
master
3,955
require 'geocoder' require 'optparse' module Geocoder class Cli def self.run(args, out = STDOUT) show_url = false show_json = false # remove arguments that are probably coordinates so they are not # processed as arguments (eg: -31.96047031,115.84274631) coords = args.select{ |i| ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/util.rb
Ruby
mit
6,440
master
1,028
# frozen_string_literal: true module Geocoder module Util # # Recursive version of Hash#merge! # # Adds the contents of +h2+ to +h1+, # merging entries in +h1+ with duplicate keys with those from +h2+. # # Compared with Hash#merge!, this method supports nested hashes. # When both +h1+...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/cache.rb
Ruby
mit
6,440
master
1,749
Dir["#{__dir__}/cache_stores/*.rb"].each {|file| require file } module Geocoder class Cache def initialize(store, config) @class = (Geocoder::CacheStore.const_get("#{store.class}", false) rescue Geocoder::CacheStore::Generic) @store_service = @class.new(store, config) end ## # Read from...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/ip_address.rb
Ruby
mit
6,440
master
745
require 'resolv' module Geocoder class IpAddress < String PRIVATE_IPS = [ '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', ].map { |ip| IPAddr.new(ip) }.freeze def initialize(ip) ip = ip.to_string if ip.is_a?(IPAddr) if ip.is_a?(Hash) super(**ip) else s...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/kernel_logger.rb
Ruby
mit
6,440
master
583
module Geocoder class KernelLogger include Singleton def add(level, message) return unless log_message_at_level?(level) case level when ::Logger::DEBUG, ::Logger::INFO puts message when ::Logger::WARN warn message when ::Logger::ERROR raise me...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/request.rb
Ruby
mit
6,440
master
4,440
require 'ipaddr' module Geocoder module Request # The location() method is vulnerable to trivial IP spoofing. # Don't use it in authorization/authentication code, or any # other security-sensitive application. Use safe_location # instead. def location @location ||= Geocoder.search(g...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/logger.rb
Ruby
mit
6,440
master
1,124
require 'logger' module Geocoder def self.log(level, message) Logger.instance.log(level, message) end class Logger include Singleton SEVERITY = { debug: ::Logger::DEBUG, info: ::Logger::INFO, warn: ::Logger::WARN, error: ::Logger::ERROR, fatal: ::Logger::FATAL } ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookup.rb
Ruby
mit
6,440
master
3,638
require "geocoder/lookups/test" module Geocoder module Lookup extend self ## # Array of valid Lookup service names. # def all_services street_services + ip_services end ## # Array of valid Lookup service names, excluding :test. # def all_services_except_test all_...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/railtie.rb
Ruby
mit
6,440
master
608
require 'geocoder/models/active_record' module Geocoder if defined? Rails::Railtie require 'rails' class Railtie < Rails::Railtie initializer 'geocoder.insert_into_active_record', before: :load_config_initializers do ActiveSupport.on_load :active_record do Geocoder::Railtie.insert ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/configuration_hash.rb
Ruby
mit
6,440
master
251
module Geocoder class ConfigurationHash < Hash def method_missing(meth, *args, &block) has_key?(meth) ? self[meth] : super end def respond_to_missing?(meth, include_private = false) has_key?(meth) || super end end end
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/db_ip_com.rb
Ruby
mit
6,440
master
960
require 'geocoder/results/base' module Geocoder::Result class DbIpCom < Base def coordinates ['latitude', 'longitude'].map{ |coordinate_name| @data[coordinate_name] } end def city @data['city'] end def district @data['district'] end def state_code @data['stateP...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/maxmind.rb
Ruby
mit
6,440
master
2,700
require 'geocoder/results/base' module Geocoder::Result class Maxmind < Base ## # Hash mapping service names to names of returned fields. # def self.field_names { :country => [ :country_code, :error ], :city => [ :country_code, :...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/smarty_streets.rb
Ruby
mit
6,440
master
2,808
require 'geocoder/lookups/base' module Geocoder::Result class SmartyStreets < Base def coordinates result = %w(latitude longitude).map do |i| zipcode_endpoint? ? zipcodes.first[i] : metadata[i] end if result.compact.empty? nil else result end end de...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/ip2location_lite.rb
Ruby
mit
6,440
master
892
require 'geocoder/results/base' module Geocoder::Result class Ip2locationLite < Base def coordinates [@data[:latitude], @data[:longitude]] end def city @data[:city] end def state @data[:region] end def state_code "" # Not available in Maxmind's database end...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/maxmind_local.rb
Ruby
mit
6,440
master
655
require 'geocoder/results/base' module Geocoder::Result class MaxmindLocal < Base def coordinates [@data[:latitude], @data[:longitude]] end def city @data[:city_name] end def state @data[:region_name] end def state_code "" # Not available in Maxmind's database ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/melissa_street.rb
Ruby
mit
6,440
master
752
require 'geocoder/results/base' module Geocoder::Result class MelissaStreet < Base def address(format = :full) @data['FormattedAddress'] end def street_address @data['AddressLine1'] end def suffix @data['ThoroughfareTrailingType'] end def number @data['PremisesN...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/postcodes_io.rb
Ruby
mit
6,440
master
587
require 'geocoder/results/base' module Geocoder::Result class PostcodesIo < Base def coordinates [@data['latitude'].to_f, @data['longitude'].to_f] end def quality @data['quality'] end def postal_code @data['postcode'] end alias address postal_code def city ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/ipdata_co.rb
Ruby
mit
6,440
master
623
require 'geocoder/results/base' module Geocoder::Result class IpdataCo < Base def city @data['city'] end def state @data['region'] end def state_code @data['region_code'] end def country @data['country_name'] end def country_code @data['country_c...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/google_places_details.rb
Ruby
mit
6,440
master
601
require "geocoder/results/google" module Geocoder module Result class GooglePlacesDetails < Google def place_id @data["place_id"] end def types @data["types"] || [] end def reviews @data["reviews"] || [] end def rating @data["rating"] ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/latlon.rb
Ruby
mit
6,440
master
1,211
require 'geocoder/results/base' module Geocoder::Result class Latlon < Base def city address_components["city"] end def coordinates [@data['lat'].to_f, @data['lon'].to_f] end def country "United States" # LatLon.io only supports the US end def country_code "US"...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/pc_miler.rb
Ruby
mit
6,440
master
2,282
require 'geocoder/results/base' module Geocoder::Result class PcMiler < Base # sample response: # https://singlesearch.alk.com/na/api/search?authToken=<TOKEN>&include=Meta&query=Feasterville # # { # "Err": 0, # "ErrString": "OK", # "QueryConfidence": 1, # "TimeInMill...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/ipinfo_io.rb
Ruby
mit
6,440
master
749
require 'geocoder/results/base' module Geocoder::Result class IpinfoIo < Base def address(format = :full) "#{city} #{postal_code}, #{country}".sub(/^[ ,]*/, "") end def coordinates @data['loc'].to_s.split(",").map(&:to_f) end def city @data['city'] end def state ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/mapbox.rb
Ruby
mit
6,440
master
1,665
require 'geocoder/results/base' module Geocoder::Result class Mapbox < Base def coordinates data['geometry']['coordinates'].reverse.map(&:to_f) end def place_name data['place_name'] end def street data['properties']['address'] end def city data_part('place') ||...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/ban_data_gouv_fr.rb
Ruby
mit
6,440
master
7,301
# encoding: utf-8 require 'geocoder/results/base' module Geocoder::Result class BanDataGouvFr < Base STATE_CODE_MAPPINGS = { "Guadeloupe" => "01", "Martinique" => "02", "Guyane" => "03", "La Réunion" => "04", "Mayotte" => "06", "Île-de-France" => "11", "Centre-Val de Lo...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/geoip2.rb
Ruby
mit
6,440
master
1,432
require 'geocoder/results/base' module Geocoder module Result class Geoip2 < Base def coordinates %w[latitude longitude].map do |l| data.fetch('location', {}).fetch(l, 0.0) end end def city fetch_name( data.fetch('city', {}).fetch('names', {}) ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/esri.rb
Ruby
mit
6,440
master
1,588
require 'geocoder/results/base' module Geocoder::Result class Esri < Base def address address_key = reverse_geocode? ? 'Address' : 'Match_addr' attributes[address_key] end def city if !reverse_geocode? && is_city? place_name else attributes['City'] end ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/postcode_anywhere_uk.rb
Ruby
mit
6,440
master
851
require 'geocoder/results/base' module Geocoder::Result class PostcodeAnywhereUk < Base def coordinates [@data['Latitude'].to_f, @data['Longitude'].to_f] end def blank_result '' end alias_method :state, :blank_result alias_method :state_code, :blank_result alias_method :post...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/geoapify.rb
Ruby
mit
6,440
master
3,971
# frozen_string_literal: true require 'geocoder/results/base' module Geocoder module Result # https://apidocs.geoapify.com/docs/geocoding/api class Geoapify < Base def address(_format = :full) properties['formatted'] end def address_line1 properties['address_line1'] ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/ipinfo_io_lite.rb
Ruby
mit
6,440
master
315
require 'geocoder/results/base' module Geocoder::Result class IpinfoIoLite < Base def self.response_attributes %w(ip asn as_name as_domain country country_code continent continent_code) end response_attributes.each do |a| define_method a do @data[a] end end end end
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/nominatim.rb
Ruby
mit
6,440
master
2,179
require 'geocoder/results/base' module Geocoder::Result class Nominatim < Base def poi return address_data[place_type] if address_data.key?(place_type) return nil end def house_number address_data['house_number'] end def address @data['display_name'] end def st...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/osmnames.rb
Ruby
mit
6,440
master
972
require 'geocoder/results/base' module Geocoder::Result class Osmnames < Base def address @data['display_name'] end def coordinates [@data['lat'].to_f, @data['lon'].to_f] end def viewport west, south, east, north = @data['boundingbox'].map(&:to_f) [south, west, north, ea...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/ipregistry.rb
Ruby
mit
6,440
master
5,596
require 'geocoder/results/base' module Geocoder::Result class Ipregistry < Base def initialize(data) super @data = flatten_hash(data) end def coordinates [@data['location_latitude'], @data['location_longitude']] end def flatten_hash(hash) hash.each_with_object({}) do |...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/google_places_search.rb
Ruby
mit
6,440
master
617
require "geocoder/results/google" module Geocoder module Result class GooglePlacesSearch < Google def types @data["types"] || [] end def rating @data["rating"] end def photos @data["photos"] end def city "" end def state ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/pointpin.rb
Ruby
mit
6,440
master
724
require 'geocoder/results/base' module Geocoder::Result class Pointpin < Base def address [ city_name, state, postal_code, country ].select{ |i| i.to_s != "" }.join(", ") end def city @data['city_name'] end def state @data['region_name'] end def state_code @dat...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/abstract_api.rb
Ruby
mit
6,440
master
2,554
require 'geocoder/results/base' module Geocoder module Result class AbstractApi < Base ## # Geolocation def state @data['region'] end def state_code @data['region_iso_code'] end def city @data["city"] end def city_geoname_id ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/uk_ordnance_survey_names.rb
Ruby
mit
6,440
master
1,021
require 'geocoder/results/base' require 'easting_northing' module Geocoder::Result class UkOrdnanceSurveyNames < Base def coordinates @coordinates ||= Geocoder::EastingNorthing.new( easting: data['GEOMETRY_X'], northing: data['GEOMETRY_Y'], ).lat_lng end def city is_po...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/photon.rb
Ruby
mit
6,440
master
2,044
require 'geocoder/results/base' module Geocoder::Result class Photon < Base def name properties['name'] end def address(_format = :full) parts = [] parts << name if name parts << street_address if street_address parts << city parts << state if state parts << pos...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/ipgeolocation.rb
Ruby
mit
6,440
master
1,162
require 'geocoder/results/base' module Geocoder::Result class Ipgeolocation < Base def coordinates [@data['latitude'].to_f, @data['longitude'].to_f] end def address(format = :full) "#{city}, #{state} #{postal_code}, #{country_name}".sub(/^[ ,]*/, "") end def state @data['stat...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/ipapi_com.rb
Ruby
mit
6,440
master
739
require 'geocoder/results/base' module Geocoder::Result class IpapiCom < Base def coordinates [lat, lon] end def address "#{city}, #{state_code} #{postal_code}, #{country}".sub(/^[ ,]*/, "") end def state region_name end def state_code region end def p...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/amazon_location_service.rb
Ruby
mit
6,440
master
895
require 'geocoder/results/base' module Geocoder::Result class AmazonLocationService < Base def initialize(result) @place = result.place super end def coordinates [@place.geometry.point[1], @place.geometry.point[0]] end def address @place.label end def neighborho...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/nationaal_georegister_nl.rb
Ruby
mit
6,440
master
905
require 'geocoder/results/base' module Geocoder::Result class NationaalGeoregisterNl < Base def response_attributes @data end def coordinates @data['centroide_ll'][6..-2].split(' ').map(&:to_f).reverse end def formatted_address @data['weergavenaam'] end alias_method ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/ip2location.rb
Ruby
mit
6,440
master
593
require 'geocoder/results/base' module Geocoder::Result class Ip2location < Base def address(format = :full) "#{city_name} #{zip_code}, #{country_name}".sub(/^[ ,]*/, '') end def self.response_attributes %w[country_code country_name region_name city_name latitude longitude zip_code ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/here.rb
Ruby
mit
6,440
master
1,355
require 'geocoder/results/base' module Geocoder::Result class Here < Base ## # A string in the given format. # def address(format = :full) address_data["label"] end ## # A two-element array: [lat, lon]. # def coordinates fail unless d = @data["position"] [d["la...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/baidu.rb
Ruby
mit
6,440
master
1,437
require 'geocoder/results/base' module Geocoder::Result class Baidu < Base def coordinates ['lat', 'lng'].map{ |i| @data['location'][i] } end def province @data['addressComponent'] and @data['addressComponent']['province'] or "" end alias_method :state, :province def city ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/twogis.rb
Ruby
mit
6,440
master
1,700
require 'geocoder/results/base' module Geocoder::Result class Twogis < Base def coordinates ['lat', 'lon'].map{ |i| @data['point'][i] } if @data['point'] end def address(_format = :full) @data['full_address_name'] || '' end def city return '' unless @data['adm_div'] @dat...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/maxmind_geoip2.rb
Ruby
mit
6,440
master
411
require 'geocoder/results/geoip2' module Geocoder::Result class MaxmindGeoip2 < Geoip2 # MindmindGeoip2 has the same results as Geoip2 because both are from MaxMind's GeoIP2 Precision Services # See http://dev.maxmind.com/geoip/geoip2/web-services/ The difference being that Maxmind calls the service # di...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/pdok_nl.rb
Ruby
mit
6,440
master
889
require 'geocoder/results/base' module Geocoder::Result class PdokNl < Base def response_attributes @data end def coordinates @data['centroide_ll'][6..-2].split(' ').map(&:to_f).reverse end def formatted_address @data['weergavenaam'] end alias_method :address, :forma...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/ipstack.rb
Ruby
mit
6,440
master
1,315
require 'geocoder/results/base' module Geocoder::Result class Ipstack < Base def address(format = :full) s = region_code.empty? ? "" : ", #{region_code}" "#{city}#{s} #{zip}, #{country_name}".sub(/^[ ,]*/, "") end def state @data['region_name'] end def state_code @data[...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/geocodio.rb
Ruby
mit
6,440
master
1,478
require 'geocoder/results/base' module Geocoder::Result class Geocodio < Base def number address_components["number"] end def street address_components["street"] end def suffix address_components["suffix"] end def street_address [number, address_components["form...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/amap.rb
Ruby
mit
6,440
master
1,772
require 'geocoder/results/base' module Geocoder::Result class Amap < Base def coordinates location = @data['location'] || @data['roadinters'].try(:first).try(:[], 'location') \ || address_components.try(:[], 'streetNumber').try(:[], 'location') location.to_s.split(",").reverse.map(&:to_f) ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/geocoder_ca.rb
Ruby
mit
6,440
master
1,440
require 'geocoder/results/base' module Geocoder::Result class GeocoderCa < Base def coordinates [@data['latt'].to_f, @data['longt'].to_f] end def address(format = :full) "#{street_address}, #{city}, #{state} #{postal_code}, #{country}".sub(/^[ ,]*/, "") end def street_address ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/bing.rb
Ruby
mit
6,440
master
857
require 'geocoder/results/base' module Geocoder::Result class Bing < Base def address(format = :full) @data['address']['formattedAddress'] end def city @data['address']['locality'] end def state_code @data['address']['adminDistrict'] end alias_method :state, :state_c...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/google.rb
Ruby
mit
6,440
master
3,241
require 'geocoder/results/base' module Geocoder::Result class Google < Base def coordinates ['lat', 'lng'].map{ |i| geometry['location'][i] } end def address(format = :full) formatted_address end def neighborhood if neighborhood = address_components_of_type(:neighborhood).fir...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/geoportail_lu.rb
Ruby
mit
6,440
master
1,233
require 'geocoder/results/base' module Geocoder::Result class GeoportailLu < Base def coordinates geomlonlat['coordinates'].reverse if geolocalized? end def address full_address end def city try_to_extract 'locality', detailled_address end def state 'Luxembourg...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/pelias.rb
Ruby
mit
6,440
master
893
require 'geocoder/results/base' module Geocoder::Result class Pelias < Base def address(format = :full) properties['label'] end def city locality end def coordinates geometry['coordinates'].reverse end def country_code properties['country_a'] end def po...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/mapquest.rb
Ruby
mit
6,440
master
811
require 'geocoder/results/base' module Geocoder::Result class Mapquest < Base def coordinates %w[lat lng].map{ |l| @data["latLng"][l] } end def city @data['adminArea5'] end def street @data['street'] end def state @data['adminArea3'] end def county ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/ipqualityscore.rb
Ruby
mit
6,440
master
1,364
require 'geocoder/results/base' module Geocoder module Result class Ipqualityscore < Base def self.key_method_mappings { 'request_id' => :request_id, 'success' => :success?, 'message' => :message, 'city' => :city, 'region' => :state, 'cou...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/baidu_ip.rb
Ruby
mit
6,440
master
811
require 'geocoder/results/base' module Geocoder::Result class BaiduIp < Base def coordinates [point['y'].to_f, point['x'].to_f] end def address @data['address'] end def state province end def province address_detail['province'] end def city addres...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/tencent.rb
Ruby
mit
6,440
master
1,753
require 'geocoder/results/base' module Geocoder::Result class Tencent < Base def coordinates ['lat', 'lng'].map{ |i| @data['location'][i] } end def address "#{province}#{city}#{district}#{street}#{street_number}" #@data['title'] or @data['address'] end # NOTE: The Tencent re...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/azure.rb
Ruby
mit
6,440
master
1,251
require 'geocoder/results/base' module Geocoder::Result class Azure < Base def address @data['address']['freeformAddress'] end def building_number @data['address']['buildingNumber'] end def city @data['address']['municipality'] end def coordinates if @data['posi...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/opencagedata.rb
Ruby
mit
6,440
master
2,104
require 'geocoder/results/base' module Geocoder::Result class Opencagedata < Base def poi %w[stadium bus_stop tram_stop].each do |key| return @data['components'][key] if @data['components'].key?(key) end return nil end def house_number @data['components']['house_number']...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/telize.rb
Ruby
mit
6,440
master
610
require 'geocoder/results/base' module Geocoder::Result class Telize < Base def city @data['city'] end def state @data['region'] end def state_code @data['region_code'] end def country @data['country'] end def country_code @data['country_code'] ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/yandex.rb
Ruby
mit
6,440
master
7,975
require 'geocoder/results/base' module Geocoder::Result class Yandex < Base # Yandex result has difficult tree structure, # and presence of some nodes depends on exact search case. # Also Yandex lacks documentation about it. # See https://tech.yandex.com/maps/doc/geocoder/desc/concepts/response_stru...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/ipbase.rb
Ruby
mit
6,440
master
733
require 'geocoder/results/base' module Geocoder::Result class Ipbase < Base def ip @data["data"]['ip'] end def country_code @data["data"]["location"]["country"]["alpha2"] end def country @data["data"]["location"]["country"]["name"] end def state_code @data["data...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/freegeoip.rb
Ruby
mit
6,440
master
586
require 'geocoder/results/base' module Geocoder::Result class Freegeoip < Base def city @data['city'] end def state @data['region_name'] end def state_code @data['region_code'] end def country @data['country_name'] end def country_code @data['cou...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/ip2location_io.rb
Ruby
mit
6,440
master
482
require 'geocoder/results/base' module Geocoder::Result class Ip2locationIo < Base def address(format = :full) "#{city_name} #{zip_code}, #{country_name}".sub(/^[ ,]*/, '') end def self.response_attributes %w[ip country_code country_name region_name city_name latitude longitude zip_...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/test.rb
Ruby
mit
6,440
master
790
require 'geocoder/results/base' module Geocoder module Result class Test < Base def self.add_result_attribute(attr) begin remove_method(attr) if method_defined?(attr) rescue NameError # method defined on superclass end define_method(attr) do @data[attr....
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/results/base.rb
Ruby
mit
6,440
master
1,596
module Geocoder module Result class Base # data (hash) fetched from geocoding service attr_accessor :data # true if result came from cache, false if from request to geocoding # service; nil if cache is not configured attr_accessor :cache_hit ## # Takes a hash of data f...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/models/mongo_base.rb
Ruby
mit
6,440
master
1,891
module Geocoder ## # Methods for invoking Geocoder in a model. # module Model module MongoBase ## # Set attribute names and include the Geocoder module. # def geocoded_by(address_attr, options = {}, &block) geocoder_init( :geocode => true, :user_ad...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/models/active_record.rb
Ruby
mit
6,440
master
1,627
require 'geocoder/models/base' module Geocoder module Model module ActiveRecord include Base ## # Set attribute names and include the Geocoder module. # def geocoded_by(address_attr, options = {}, &block) geocoder_init( :geocode => true, :user_addr...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/models/base.rb
Ruby
mit
6,440
master
845
module Geocoder ## # Methods for invoking Geocoder in a model. # module Model module Base def geocoder_options if defined?(@geocoder_options) @geocoder_options elsif superclass.respond_to?(:geocoder_options) superclass.geocoder_options || { } else ...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/models/mongo_mapper.rb
Ruby
mit
6,440
master
674
require 'geocoder/models/base' require 'geocoder/models/mongo_base' module Geocoder module Model module MongoMapper include Base include MongoBase def self.included(base); base.extend(self); end private # -------------------------------------------------------------- def geocoder...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/models/mongoid.rb
Ruby
mit
6,440
master
877
require 'geocoder/models/base' require 'geocoder/models/mongo_base' module Geocoder module Model module Mongoid include Base include MongoBase def self.included(base); base.extend(self); end private # -------------------------------------------------------------- def geocoder_fil...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/stores/base.rb
Ruby
mit
6,440
master
3,713
module Geocoder module Store module Base ## # Is this object geocoded? (Does it have latitude and longitude?) # def geocoded? to_coordinates.compact.size == 2 end ## # Coordinates [lat,lon] of the object. # def to_coordinates [:latitude, :lon...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/stores/mongoid.rb
Ruby
mit
6,440
master
235
require 'geocoder/stores/base' require 'geocoder/stores/mongo_base' module Geocoder::Store module Mongoid include Base include MongoBase def self.included(base) MongoBase.included_by_model(base) end end end
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/stores/mongo_mapper.rb
Ruby
mit
6,440
master
239
require 'geocoder/stores/base' require 'geocoder/stores/mongo_base' module Geocoder::Store module MongoMapper include Base include MongoBase def self.included(base) MongoBase.included_by_model(base) end end end
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/stores/mongo_base.rb
Ruby
mit
6,440
master
1,525
module Geocoder::Store module MongoBase def self.included_by_model(base) base.class_eval do scope :geocoded, lambda { where(geocoder_options[:coordinates].ne => nil) } scope :not_geocoded, lambda { where(geocoder_options[:coordinates] => nil) } en...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/stores/active_record.rb
Ruby
mit
6,440
master
12,471
# -*- coding: utf-8 -*- require 'geocoder/sql' require 'geocoder/stores/base' ## # Add geocoding functionality to any ActiveRecord object. # module Geocoder::Store module ActiveRecord include Base ## # Implementation of 'included' hook method. # def self.included(base) base.extend ClassMet...
github
alexreisner/geocoder
https://github.com/alexreisner/geocoder
lib/geocoder/lookups/ip2location_lite.rb
Ruby
mit
6,440
master
943
require 'geocoder/lookups/base' require 'geocoder/results/ip2location_lite' module Geocoder module Lookup class Ip2locationLite < Base attr_reader :gem_name def initialize unless configuration[:file].nil? begin @gem_name = 'ip2location_ruby' require @gem_nam...