List of cities in a state

for those whom it may concern, I created a simple ruby gem called
“city-state” that returns a list of states in a country and also a list
of
cities/towns in a state. It simple like that:

CS.states(:us)

=> {:AK=>“Alaska”, :AL=>“Alabama”, :AR=>“Arkansas”, :AZ=>“Arizona”,

:CA=>“California”, :CO=>“Colorado”, :CT=>“Connecticut”, :DC=>“District
of
Columbia”, :DE=>“Delaware”, :FL=>“Florida”, :GA=>“Georgia”,
:HI=>“Hawaii”,
:IA=>“Iowa”, :ID=>“Idaho”, :IL=>“Illinois”, :IN=>“Indiana”,
:KS=>“Kansas”,
:KY=>“Kentucky”, :LA=>“Louisiana”, :MA=>“Massachusetts”,
:MD=>“Maryland”,
:ME=>“Maine”, :MI=>“Michigan”, :MN=>“Minnesota”, :MO=>“Missouri”,
:MS=>“Mississippi”, :MT=>“Montana”, :NC=>“North Carolina”, :ND=>“North
Dakota”, :NE=>“Nebraska”, :NH=>“New Hampshire”, :NJ=>“New Jersey”,
:NM=>“New Mexico”, :NV=>“Nevada”, :NY=>“New York”, :OH=>“Ohio”,
:OK=>“Oklahoma”, :OR=>“Oregon”, :PA=>“Pennsylvania”, :RI=>“Rhode
Island”,
:SC=>“South Carolina”, :SD=>“South Dakota”, :TN=>“Tennessee”,
:TX=>“Texas”,
:UT=>“Utah”, :VA=>“Virginia”, :VT=>“Vermont”, :WA=>“Washington”,
:WI=>“Wisconsin”, :WV=>“West Virginia”, :WY=>“Wyoming”}

CS.cities(:ak, :us)

=> [“Adak”, “Akhiok”, “Akiachak”, “Akiak”, “Akutan”, “Alakanuk”,

“Ambler”, “Anchor Point”, “Anchorage”, “Angoon”, “Atqasuk”, “Barrow”,
“Bell
Island Hot Springs”, “Bethel”, “Big Lake”, “Buckland”, “Chefornak”,
“Chevak”, “Chicken”, “Chugiak”, “Coffman Cove”, “Cooper Landing”,
“Copper
Center”, “Cordova”, “Craig”, “Deltana”, “Dillingham”, “Douglas”, “Dutch
Harbor”, “Eagle River”, “Eielson Air Force Base”, “Fairbanks”,
“Fairbanks
North Star Borough”, “Fort Greely”, “Fort Richardson”, “Galena”,
“Girdwood”, “Goodnews Bay”, “Haines”, “Homer”, “Hooper Bay”, “Juneau”,
“Kake”, “Kaktovik”, “Kalskag”, “Kenai”, “Ketchikan”, “Kiana”, “King
Cove”,
“King Salmon”, “Kipnuk”, “Klawock”, “Kodiak”, “Kongiganak”, “Kotlik”,
“Koyuk”, “Kwethluk”, “Levelock”, “Manokotak”, “May Creek”, “Mekoryuk”,
“Metlakatla”, “Mountain Village”, “Nabesna”, “Naknek”, “Nazan Village”,
“Nenana”, “New Stuyahok”, “Nikiski”, “Ninilchik”, “Noatak”, “Nome”,
“Nondalton”, “Noorvik”, “North Pole”, “Northway”, “Old Kotzebue”,
“Palmer”,
“Pedro Bay”, “Petersburg”, “Pilot Station”, “Point Hope”, “Point Lay”,
“Prudhoe Bay”, “Russian Mission”, “Sand Point”, “Scammon Bay”,
“Selawik”,
“Seward”, “Shungnak”, “Sitka”, “Skaguay”, “Soldotna”, “Stebbins”,
“Sterling”, “Sutton”, “Talkeetna”, “Teller”, “Thorne Bay”, “Togiak”,
“Tok”,
“Toksook Bay”, “Tuntutuliak”, “Two Rivers”, “Unalakleet”, “Unalaska”,
“Valdez”, “Wainwright”, “Wasilla”]

It works with every country of the world and can be easily updated with
a
CS.update command.

I know this is a ridiculously simple, but:

  1. IDK in another countries, but in mine, it’s common to ask to the
    users
    this type of information in forms
  2. I never find a gem that do this, so I have to hardcode a list of
    states
    every time that I need for a project

If you find a bug you can notify me in the page of the project:

Thanks for the attention.

On Feb 8, 2015, at 7:23 PM, Daniel L. [email protected]
wrote:

I know this is a ridiculously simple, but:

  1. IDK in another countries, but in mine, it’s common to ask to the users this
    type of information in forms
  2. I never find a gem that do this, so I have to hardcode a list of states every
    time that I need for a project

Have you seen this one? GitHub - realadeel/carmen-rails: Rails adapter for Carmen (provides country_select and subregion_select) I’ve
used it a couple of times, but I will give yours a try as well.

Thanks!

Walter

The big scary comment from the carmen repo owner makes me a bit leery of
using carmen, though with 200+ forks, it looks like it won’t be going
away
anytime soon, either.

I’ve used MaxMind’s database with other languages (perl) and I know it’s
good, too. I’m happier letting someone else manage the collection and
dissemination of geographic data that I can update, than needing to
update
a gem for data updates.

I think the biggest wins, by far, are the cities and the update
mechanism.

On Sun, Feb 8, 2015 at 7:22 PM, Daniel L. [email protected]

Em domingo, 8 de fevereiro de 2015 22:27:38 UTC-2, Walter Lee D.
wrote:

Have you seen this one? GitHub - realadeel/carmen-rails: Rails adapter for Carmen (provides country_select and subregion_select) I’ve
used it a couple of times, but I will give yours a try as well.

Ouch, that awkward moment that you realize that someone already done
what
you just made - this would save me some time :stuck_out_tongue:

I think the carmen interface is better than mine, but in my defense,
carmen
doesn’t provide a list of cities nor have a update mechanism. In my
country
new cities are created weekly, so its necessary to maintain the base
updated. But its good to know this gem, and I will be glad if you know
if
there’s a gem that provides a list of cities too.

Thanks.

Hi greetings,
Great gem. It was working great since last couple of years.

But recently encountered the following thing,

I am not able to add custom states. For example for singapore, No states are showing. I tried updating. Adding states.sg using custom file. But not able to get states. Any idea?