china_regions 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +70 -41
- data/README.zh.md +69 -42
- data/china_regions.gemspec +1 -1
- data/lib/china_regions/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a41ea2a6df5c180fcae8b4196721e6923d6404652c01952646b406986d6dfbb5
|
4
|
+
data.tar.gz: ab7679782a12f7e54cd4575d40bef3788b254080d683335942f45b065ce2f6bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de1e99b860db09eba4a5be416c519cfbbed6ad64e1ed916e088aab22eb1eb10c011e53dbf8db02a487661aae8c275586f835d0a1176db8cfb5618beaaaadfb64
|
7
|
+
data.tar.gz: 5c495307768bceb1b04f5f25c1960d1d380e9a7d55b1c83a7c0065dd9d7dc46ca55b078a6549ed4cd2d70aa65f2c0b27c7e1d35afd8d37a7d97600380c2cabeb
|
data/README.md
CHANGED
@@ -1,16 +1,26 @@
|
|
1
1
|
# ChinaRegions
|
2
2
|
|
3
|
-
Chinese provinces, cities, regions [prefecture-level cities] Ruby on Rails code, Ruby (> 1.9.x) And Rails (> 4.0)
|
4
|
-
|
5
3
|
[![Gem Version](https://badge.fury.io/rb/crunchbase-ruby-library.svg)](https://badge.fury.io/rb/crunchbase-ruby-library)
|
6
4
|
[![Build Status](https://travis-ci.org/encoreshao/crunchbase-ruby-library.svg?branch=master)](https://travis-ci.org/encoreshao/crunchbase-ruby-library)
|
7
5
|
[![Coverage Status](https://coveralls.io/repos/github/encoreshao/crunchbase-ruby-library/badge.svg)](https://coveralls.io/github/encoreshao/crunchbase-ruby-library)
|
8
6
|
|
7
|
+
ChinaRegions provides Ruby on Rails code for provinces, cities, and districts [prefecture-level cities] in China. The code version requires Ruby (> 1.9.x) and Rails (> 4.0).
|
8
|
+
|
9
|
+
### Data Sources
|
10
|
+
|
11
|
+
* Ministry of Civil Affairs, National Bureau of Statistics:
|
12
|
+
* [State Statistics Bureau of the People's Republic of China-Statistical Divisions and Urban-Rural Division Codes](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/)
|
13
|
+
* [State Statistics Bureau of the People's Republic of China-Statistical Division Codes and Urban-rural Division Codes Compilation Rules](http://www.stats.gov.cn/tjsj/tjbz/200911/t20091125_8667.html)
|
14
|
+
* This item has been updated to:
|
15
|
+
* [2018 zoning code and urban-rural division code for statistics (cut-off time: 2018-10-31, release time: 2019-01-31)](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2018/index.html)
|
16
|
+
|
9
17
|
### How to update data
|
10
18
|
|
11
19
|
If you are using ChinaRegions version 0.1.x be sure to run:
|
12
20
|
|
13
|
-
|
21
|
+
```
|
22
|
+
rails g china_regions:regions
|
23
|
+
```
|
14
24
|
|
15
25
|
to have the javascript file copied over into your project.
|
16
26
|
|
@@ -22,25 +32,32 @@ Add it to your Gemfile:
|
|
22
32
|
|
23
33
|
Run the following command to install it:
|
24
34
|
|
25
|
-
|
35
|
+
```
|
36
|
+
bundle install
|
37
|
+
```
|
26
38
|
|
27
39
|
Run the generator:
|
28
40
|
|
29
|
-
|
41
|
+
```
|
42
|
+
rails g china_regions:install
|
43
|
+
```
|
30
44
|
|
31
|
-
|
32
|
-
* Copy `db/migrate/xxxxxxxxxxx_create_china_regions_tables.rb` to `db/migrate` folder.
|
33
|
-
* Copy `regions.en.yml` and `regions.zh.yml` files to `config/locales` folders
|
45
|
+
Then you can see the changes that happened to the console:
|
34
46
|
|
35
|
-
|
47
|
+
- Copy `db/migrate/xxxxxxxxxxx_create_china_regions_tables.rb` to `db/migrate` folder.
|
48
|
+
- Copy `regions.en.yml` and `regions.zh.yml` files to `config/locales` folders
|
36
49
|
|
37
|
-
|
50
|
+
Create tables (provinces, cities, districts):
|
38
51
|
|
39
|
-
|
52
|
+
```
|
53
|
+
rake db:migrate
|
54
|
+
```
|
40
55
|
|
41
|
-
|
56
|
+
Copy Models [`Province`, `City`, `District`] into your project:
|
42
57
|
|
43
|
-
|
58
|
+
```
|
59
|
+
rails g china_regions:regions
|
60
|
+
```
|
44
61
|
|
45
62
|
Newly added models:
|
46
63
|
|
@@ -50,56 +67,68 @@ Newly added models:
|
|
50
67
|
|
51
68
|
Download and import the latest regions to your project:
|
52
69
|
|
53
|
-
|
70
|
+
```
|
71
|
+
rake china_regions:all
|
54
72
|
|
55
|
-
|
56
|
-
|
57
|
-
|
73
|
+
OR
|
74
|
+
|
75
|
+
rake china_regions:download
|
76
|
+
rake china_regions:import
|
77
|
+
```
|
78
|
+
|
79
|
+
- 1. Downloading regions from `Administrative-divisions-of-China` to `db/regions` folder.
|
80
|
+
- db/regions/pca-code.json
|
81
|
+
- 2. Import the regions into provinces and cities, districts
|
58
82
|
|
59
83
|
### Usage
|
60
84
|
|
61
85
|
Example:
|
62
86
|
|
63
|
-
|
87
|
+
```
|
88
|
+
= form_for @article do |f|
|
64
89
|
|
65
|
-
|
90
|
+
= f.region_select [:province, :city, :district]
|
66
91
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
92
|
+
# form_tag
|
93
|
+
= region_select :article, :province_id
|
94
|
+
= region_select :article, :city_id
|
95
|
+
= region_select :article, :district_id
|
71
96
|
|
72
|
-
|
97
|
+
OR
|
73
98
|
|
74
|
-
|
75
|
-
|
76
|
-
|
99
|
+
= region_select :article, :province
|
100
|
+
= region_select :article, :city
|
101
|
+
= region_select :article, :district
|
77
102
|
|
78
|
-
|
103
|
+
= f.submit class: 'btn'
|
104
|
+
```
|
79
105
|
|
80
106
|
Add prefix name:
|
81
107
|
|
82
|
-
|
83
|
-
|
84
|
-
= f.region_select [:province, :city, :district], :prefix => "home"
|
85
|
-
= f.region_select [:province, :city, :district], :prefix => "work"
|
108
|
+
```
|
109
|
+
= form_for @article do |f|
|
86
110
|
|
111
|
+
= f.region_select [:province, :city, :district], :prefix => "home"
|
112
|
+
= f.region_select [:province, :city, :district], :prefix => "work"
|
113
|
+
```
|
87
114
|
|
88
115
|
Pre-selected province:
|
89
116
|
|
90
|
-
|
117
|
+
```
|
118
|
+
= form_for @article do |f|
|
119
|
+
= f.region_select [:province, :city, :district], province: "chongqing"
|
91
120
|
|
92
|
-
|
121
|
+
OR
|
93
122
|
|
94
|
-
|
95
|
-
|
96
|
-
= f.region_select [:province, :city, :district], province: "重庆市"
|
123
|
+
= f.region_select [:province, :city, :district], province: "重庆市"
|
124
|
+
```
|
97
125
|
|
98
126
|
Prior choice:
|
99
127
|
|
100
|
-
|
101
|
-
|
102
|
-
|
128
|
+
```
|
129
|
+
= form_for @article do |f|
|
130
|
+
= f.region_select [:province, :city, :district], priority: { province: ["重庆市"], district: %w(巴南区 北碚区 渝北区) }
|
131
|
+
```
|
103
132
|
|
104
133
|
|
105
134
|
### Other languages
|
@@ -115,5 +144,5 @@ https://github.com/encoreshao/china_regions/graphs/contributors
|
|
115
144
|
|
116
145
|
### License
|
117
146
|
|
118
|
-
Copyright ©
|
147
|
+
Copyright © 2020-02 Encore Shao. See LICENSE for details.
|
119
148
|
|
data/README.zh.md
CHANGED
@@ -1,16 +1,26 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
中国省份,城市,地区[地级市]Ruby on Rails 程式代码, Ruby (> 1.9.x) And Rails (> 4.0)
|
1
|
+
# ChinaRegions
|
4
2
|
|
5
3
|
[![Gem Version](https://badge.fury.io/rb/china-regions.svg)](https://badge.fury.io/rb/china-regions)
|
6
4
|
[![Build Status](https://travis-ci.org/encoreshao/china-regions.svg?branch=master)](https://travis-ci.org/encoreshao/china-regions)
|
7
5
|
[![Coverage Status](https://coveralls.io/repos/github/encoreshao/china-regions/badge.svg)](https://coveralls.io/github/encoreshao/china-regions)
|
8
6
|
|
7
|
+
ChinaRegions 提供中国的省,市,区[地级市]的 Ruby on Rails的程式代码,代码版本要求 Ruby(> 1.9.x)和Rails(> 4.0).
|
8
|
+
|
9
|
+
### 数据来源
|
10
|
+
|
11
|
+
* 民政部、国家统计局:
|
12
|
+
* [中华人民共和国国家统计局-统计用区划和城乡划分代码](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/)
|
13
|
+
* [中华人民共和国国家统计局-统计用区划代码和城乡划分代码编制规则](http://www.stats.gov.cn/tjsj/tjbz/200911/t20091125_8667.html)
|
14
|
+
* 本项目已更新至:
|
15
|
+
* [2018年统计用区划代码和城乡划分代码(截止时间:2018-10-31,发布时间:2019-01-31)](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2018/index.html)
|
16
|
+
|
9
17
|
### 如何更新数据文件
|
10
18
|
|
11
19
|
复制所需文件到你的项目中:
|
12
20
|
|
13
|
-
|
21
|
+
```
|
22
|
+
rails g china_regions:regions
|
23
|
+
```
|
14
24
|
|
15
25
|
### 如何引入china_regions到你的项目
|
16
26
|
|
@@ -20,27 +30,33 @@
|
|
20
30
|
|
21
31
|
安装:
|
22
32
|
|
23
|
-
|
33
|
+
```
|
34
|
+
bundle install
|
35
|
+
```
|
24
36
|
|
25
37
|
#### 开始构建城市数据
|
26
38
|
|
27
39
|
复制所需文件到你的项目中:
|
28
40
|
|
29
|
-
|
41
|
+
```
|
42
|
+
rails g china_regions:install
|
43
|
+
```
|
30
44
|
|
31
|
-
|
32
|
-
|
33
|
-
|
45
|
+
随后你可以看到控制台发生的变化:
|
46
|
+
- 复制 `db/migrate/xxxxxxxxxxx_create_china_regions_tables.rb` 文件到 `db/migrate` 目录中
|
47
|
+
- 复制 `regions.en.yml` 和 `regions.zh.yml` 配置文件到 `config/locales` 目录中
|
34
48
|
|
35
49
|
创建所需的表 (provinces, cities, districts):
|
36
50
|
|
37
|
-
|
51
|
+
```
|
52
|
+
rake db:migrate
|
53
|
+
```
|
38
54
|
|
39
55
|
将所需的模型(Models) [`Province`, `City`, `District`] 到您的应用程式中:
|
40
56
|
|
41
|
-
|
42
|
-
|
43
|
-
|
57
|
+
```
|
58
|
+
rails g china_regions:regions
|
59
|
+
```
|
44
60
|
|
45
61
|
查看 app/models:
|
46
62
|
|
@@ -50,57 +66,68 @@
|
|
50
66
|
|
51
67
|
下载并导入最新数据到你的项目中:
|
52
68
|
|
53
|
-
|
69
|
+
```
|
70
|
+
rake china_regions:all
|
71
|
+
|
72
|
+
OR
|
54
73
|
|
55
|
-
|
56
|
-
|
57
|
-
|
74
|
+
rake china_regions:download
|
75
|
+
rake china_regions:import
|
76
|
+
```
|
77
|
+
|
78
|
+
- 1. 从 `Administrative-divisions-of-China` 下载最新的地区信息到 `db/regions` 目录中.
|
79
|
+
- db/regions/pca-code.json
|
80
|
+
- 2. 将下载后的地区信息导入数据库中
|
58
81
|
|
59
82
|
### 如何在View中使用
|
60
83
|
|
61
84
|
范例:
|
62
85
|
|
63
|
-
|
86
|
+
```
|
87
|
+
= form_for @article do |f|
|
64
88
|
|
65
|
-
|
89
|
+
= f.region_select [:province, :city, :district]
|
66
90
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
91
|
+
# form_tag
|
92
|
+
= region_select :article, :province_id
|
93
|
+
= region_select :article, :city_id
|
94
|
+
= region_select :article, :district_id
|
71
95
|
|
72
|
-
|
96
|
+
OR
|
73
97
|
|
74
|
-
|
75
|
-
|
76
|
-
|
98
|
+
= region_select :article, :province
|
99
|
+
= region_select :article, :city
|
100
|
+
= region_select :article, :district
|
77
101
|
|
78
|
-
|
102
|
+
= f.submit class: 'btn'
|
103
|
+
```
|
79
104
|
|
80
105
|
添加前缀名:
|
81
106
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
107
|
+
```
|
108
|
+
= form_for @article do |f|
|
109
|
+
= f.region_select [:province, :city, :district], :prefix => "home"
|
110
|
+
= f.region_select [:province, :city, :district], :prefix => "work"
|
111
|
+
```
|
87
112
|
|
88
113
|
预选则省份:
|
89
114
|
|
90
|
-
|
115
|
+
```
|
116
|
+
= form_for @article do |f|
|
91
117
|
|
92
|
-
|
118
|
+
= f.region_select [:province, :city, :district], province: "chongqing"
|
93
119
|
|
94
|
-
|
120
|
+
OR
|
95
121
|
|
96
|
-
|
122
|
+
= f.region_select [:province, :city, :district], province: "重庆市"
|
123
|
+
```
|
97
124
|
|
98
125
|
优先选择:
|
99
126
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
127
|
+
```
|
128
|
+
= form_for @article do |f|
|
129
|
+
= f.region_select [:province, :city, :district], priority: { province: ["重庆市"], district: %w(巴南区 北碚区 渝北区) }
|
130
|
+
```
|
104
131
|
|
105
132
|
### 其它语言
|
106
133
|
|
@@ -115,5 +142,5 @@ https://github.com/encoreshao/china_regions/graphs/contributors
|
|
115
142
|
|
116
143
|
### 许可
|
117
144
|
|
118
|
-
Copyright ©
|
145
|
+
Copyright © 2020-02 Encore Shao. See LICENSE for details.
|
119
146
|
|
data/china_regions.gemspec
CHANGED
@@ -6,7 +6,7 @@ require File.expand_path('lib/china_regions/version', __dir__)
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.authors = ['Encore Shao']
|
8
8
|
gem.email = ['encore.shao@gmail.com']
|
9
|
-
gem.description = 'China Regions is Ruby on rails interface'
|
9
|
+
gem.description = 'China Regions is a Ruby on rails interface'
|
10
10
|
gem.summary = 'Rails 4+ version of dropdowns for all provinces, cities,
|
11
11
|
and districts in China.'
|
12
12
|
gem.homepage = 'http://github.com/encoreshao'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: china_regions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Encore Shao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: down
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description: China Regions is Ruby on rails interface
|
83
|
+
description: China Regions is a Ruby on rails interface
|
84
84
|
email:
|
85
85
|
- encore.shao@gmail.com
|
86
86
|
executables:
|