项目作者: gonzalo-bulnes

项目描述 :
A Ruby representation of the chilean cities as described by the Chilean Subsecretaría de Desarrollo Regional y Administrativo.
高级语言: Ruby
项目地址: git://github.com/gonzalo-bulnes/chilean_cities.git
创建时间: 2013-02-12T13:19:09Z
项目社区:https://github.com/gonzalo-bulnes/chilean_cities

开源协议:GNU General Public License v3.0

下载


Comunas de Chile

Gem Version
Build Status
Code Climate
Inline docs

A Ruby representation of the Chilean administrative areas as described by the SUBDERE.

Disclaimer

This library is not developed, supported nor endorsed in any way by the Chilean Subsecretaría de Desarrollo Regional y Administrativo (SUBDERE), nor any related institution.

Data Sources

This library is based on the publicly available information from the SUBDERE related to the Codificación Única Territorial. The sources quoted by the document on which this library is based are:

  • Decreto Supremo No 1439, del Ministerio del Interior, publicado en el Diario Oficial del 8 de Mayo de 2000
  • Decreto Supremo No 1352, del Ministerio del Interior, publicado en el Diario Oficial del 23 de Agosto de 2008
  • Decreto Exento No 910, del Ministerio del Interior, publicado en el Diario Oficial del 14 de Junio de 2007
  • Decreto Exento No 817, del Ministerio del Interior, publicado en el Diario Oficial del 26 de Marzo de 2010

Usage

Add the gem to your Gemfile:

  1. # Gemfile
  2. gem 'chilean_cities', '~> 1.0' # see semver.org

Then generate the chilean administrative areas:

  1. require 'chilean_cities'
  2. chile = ChileanCities::Factory.instance
  3. chile.generate!
  4. # and use them as you want : )
  5. chile.regiones.select{ |region| region.iso_3166_2 == 'CL-LL' }.first.name
  6. # => "Región de los Lagos"
  7. chile.provincias.select{ |provincia| provincia.name =~ /Magallanes/ }.first.comunas.map{ |comuna| comuna.name }
  8. # => ["Punta Arenas", "Laguna Blanca", "Río Verde", "San Gregorio"]

Schema.org

The generated administrative areas representations do partially enforce the Place schema (see schema.org and the schemas specs for details):

  1. # comunas, provincias and regiones do implement the `contained_in` method:
  2. chile.comunas.select{ |comuna| comuna.name == 'Quellón' }.first.contained_in.name
  3. # => "Chiloé"

Note about the previous version (v0.1.0)

If you were using this gem in the past and are looking for its ancient behaviour, please modify your Gemfile to checkout the v0.1.0 tag (it’s been a few years, so this is not recommended):

  1. # Gemfile
  2. gem 'chilean_cities', git: 'https://github.com/gonzalo-bulnes/chilean_cities.git', tag: 'v0.1.0'

The same tag does also point to the corresponding documentation.

Code of Conduct

Please note that by participating in this project, you agree to abide by its code of conduct. That is true for pull requests, and also when participating in issues.

See Also

Credits

Part of this gem was crafted during my 10% free focus work time at Acid Labs. Thanks @acidlabs!

License

  1. ChileanCities provides a Ruby representation of the Chilean _administrative areas_.
  2. Copyright (C) 2013, 2020 Gonzalo Bulnes Guilpain
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses></http:>.