geo_states 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1d0aedae067e7276a505d4a23c6bf594c9db0cf9f1e23d3713b0a82923512b65
4
+ data.tar.gz: 9f4a6960b3e6334a579af5f5d4e7a2da36c284d4753625a87288ded90eb5e54e
5
+ SHA512:
6
+ metadata.gz: 22945f22f63d71c653d2a900bdf5ea4396cb763c07ca8046d39823ec1915e01a7229f6b69bffe2b61380860ba4612f03a7341e26231454b975dfe246538e9732
7
+ data.tar.gz: 3cffe4fa3fe31b687956a6008ffbb133f305194a9fd56dfad3e2d5149407741bee62dbfad358b309e0eb70b4967f5bdb08657ca97344da120f07f9c2773acf2b
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Albert Osbal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # GeoStates
2
+
3
+ Ruby gem that lists countries and their states (or provinces, regions) from **bundled data**. No external services at runtime.
4
+
5
+ ## Installation
6
+
7
+ Add the gem to your Gemfile:
8
+
9
+ ```ruby
10
+ gem "geo_states"
11
+ ```
12
+
13
+ Or install directly:
14
+
15
+ ```bash
16
+ gem install geo_states
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ require "geo_states"
23
+
24
+ # List all countries
25
+ GeoStates.all_countries
26
+ # => [{:country=>"Mexico", :iso2=>"MX", :iso3=>"MEX", :states=>[...]}, ...]
27
+
28
+ # Find country by ISO 3166-1 alpha-2 code
29
+ GeoStates.find_country("MX")
30
+ # => {:country=>"Mexico", :m49=>nil, :iso3=>"MEX", :iso2=>"MX", :currency=>"MXN", ...}
31
+
32
+ # Find by ISO3, M49, or name
33
+ GeoStates.find_country_by_iso3("MEX")
34
+ GeoStates.find_country_by_m49("484") # Mexico
35
+ GeoStates.find_country_by_name("Mexico")
36
+
37
+ # Get states for a country (by iso2, iso3, m49, or name)
38
+ GeoStates.states_for("MX")
39
+ # => [{:name=>"Aguascalientes", :state_code=>"AGU", :iso3=>"AGU", :iso2=>"AG"}, ...]
40
+ ```
41
+
42
+ ### Country format
43
+
44
+ Each country is a Hash with:
45
+
46
+ - `:country` — country name
47
+ - `:m49` — UN M49 numeric code (optional, nil if not in source)
48
+ - `:iso3` — ISO 3166-1 alpha-3
49
+ - `:iso2` — ISO 3166-1 alpha-2
50
+ - `:currency`, `:currency_symbol`, `:phone_code`, `:flag` — optional
51
+ - `:states` — array of states
52
+
53
+ Each state has:
54
+
55
+ - `:name` — name
56
+ - `:state_code` — code (e.g. "AGU")
57
+ - `:iso3` — same as state_code if not provided
58
+ - `:iso2` — derived from state_code if not provided
59
+
60
+ ## Data sources
61
+
62
+ The bundled data in `lib/geo_states/data/countries.json` is the single source. It includes:
63
+
64
+ - **Countries and subdivisions** — names and codes (ISO 3166-1 alpha-2/alpha-3, UN M49).
65
+ - **Flag URLs** — point to [Wikimedia Commons](https://commons.wikimedia.org/) (the gem does not fetch them; they are stored as strings).
66
+
67
+ No external APIs are called at runtime.
68
+
69
+ ## Development
70
+
71
+ ```bash
72
+ bin/setup # install dependencies
73
+ rake spec # run tests
74
+ bin/console # interactive console
75
+ ```
76
+
77
+ ## Author
78
+
79
+ Created by [@elosnaya](https://github.com/elosnaya).
80
+
81
+ ## License
82
+
83
+ MIT.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ Dir.glob("lib/tasks/**/*.rake").each { |r| load r }
9
+
10
+ task default: :spec