
Security News
Scaling Socket from Zero to 10,000+ Organizations
Socket CEO Feross Aboukhadijeh shares lessons from scaling a developer security startup to 10,000+ organizations in this founder interview.
region-spotter
Advanced tools
Robustly identify countries, states, islands, cities and whatnot from text. This is still BETA. Although it supports most countries and states, it still lacks regions and cities for the most part of the world.
What if I ask you: "What region is 'ontario'", or "where is 'ca'"? I would answer: Ontario is a state in Canada as well as a city in California. CA is the ISO abbreviation for Canada, and also the abbreviation for California.
The goal of this gem is such: Given a string, do your very best to identify all possible locations, and order them by significance. Provide as much information as possible; What kind of region is this? Country? City? Island? Continent?
require 'spotter'
spotter = Spotter.new
results = spotter.identify('new york')
puts results.first.to_s # => "United States, New York"
puts results.first.regions[0].name # => "United States"
puts results.first.regions[0].type # => "country"
puts results.first.regions[1].name # => "New York"
puts results.first.regions[1].type # => "state"
It can handle text in different cases, spellings, etc.
spotter.identify('ontARIO, california').first.to_s
# => "United States, California, San Bernardino, Ontario"
spotter.identify('ŃĐžŃХиЯ').first.to_s # => 'Russia'
spotter.identify('ruSSia').first.to_s # => 'Russia'
It returns all matches found:
results = spotter.identify('canada')
puts results[0].to_s # => 'Canada'
puts results[1].to_s # => 'United States, Kansas, Canada'
It works with abbreviations too:
puts spotter.identify('se').first.to_s # => 'Sweden'
You can also use the gem with the rake task identify as such:
rake identify['new york']
FAQs
Unknown package
We found that region-spotter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh shares lessons from scaling a developer security startup to 10,000+ organizations in this founder interview.

Research
Socket Threat Research maps a rare inside look at OtterCookieâs npm-Vercel-GitHub chain, adding 197 malicious packages and evidence of North Korean operators.

Research
Socket researchers identified a malicious Chrome extension that manipulates Raydium swaps to inject an undisclosed SOL transfer, quietly routing fees to an attacker wallet.