-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Continent data #133
Comments
I spent a little time thinking about how to accomplish this a while back, but didn't start writing any code for it. The challenge is deciding if the current YAML file structure is extended an additional level, or if it is worth special-casing continents to avoid doing so. I would be interested in what you were thinking, as this would be a nice addition to the library. |
👍 This would be useful. Adding another YAML level is probably the best approach. |
I am thinking of putting continent list and continent code in each of the country in world.yml world.yml ---
- alpha_2_code: AU
alpha_3_code: AUS
numeric_code: "001"
continent_code: OC
type: country
- alpha_2_code: FO
alpha_3_code: FRO
numeric_code: "002"
continent_code: EU
type: country
- alpha_2_code: EE
alpha_3_code: EST
continent_code: EU
numeric_code: "003"
type: country
- continent_code: EU
type: continent
- continent_code: OC
type: continent
- continent_code: AS
type: continent
|
@emptyflask what do you mean by adding another YAML level? |
👍 I'm in a similar boat of either extending carmen's functionality to include this or rolling my own solution. Looks like this is kind of an old issue; would love to hear if any of you have pursued this further. |
FWIW I'll give my 2c on previous comments. The complication behind extending the yaml structure to another level is that you would need to read multiple files to get a full list of countries (we don't need have this complication for subregions because we only ever care about a single country's subregions). My gut feeling is that @wizztjh's solution is simpler. Would we just have another yml alongside Just to feel out what an API would be like:
Missing anything? |
By the way sorry for my lack of comments. I opened the issue saying I could work on this but truth is I didn’t end up having enough time. Feel free to get this started, anyone! I think the API you suggest makes sense @joekur. With added aliases for |
I've dug into it a little more. Adding another layer would actually be more elegant because it would follow the tree structure that's already in place. Ideally the structure would be |
Adding another YAML layer for continents would probably be OK. Breaking other user's YAML overrides is not a big deal as long as this was clearly stated in the docs and the version number is bumped accordingly. The implementations of I haven't had much time to work on this library recently, so thank you to everyone for working together to address this feature request! |
After I added a continent to the spec_data, the overlay spec failed because the data type is I think all data in the Country.all should be country. I will change the spec_data of overlay data
the commit dddc9d2 |
Any update on this @wizztjh? :) |
Hi Dain,
|
Thanks for the status @wizztjh. Will leave it open for the time being :) |
I found https://github.com/beefsack/ruby-continent It seems to match properly with every Carmen country countries = Carmen::Country.all
countries.map {|c| Continent.by_alpha_2_code(c.code) || nil }.compact.size == countries.size
# true |
It would be good if the above made it to the documentation. I didn't know you can |
Would it make sense to include information about continents in Carmen?
Geonames has a nice database of countries with their corresponding continent code (parseable file). I ran a little script and it turns out all
Carmen::Country.all.map(&:code)
are included.These APIs would be useful:
I could work on this.
The text was updated successfully, but these errors were encountered: