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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5aec74f02a9856df9798317291e9fc587c07a6473f8c13639b878e8b6a10bf67
4
- data.tar.gz: 4aaea0730f59300c09c9ad5685f38cfa5e061df00f0d5c81e6aa4c386c04fa6d
3
+ metadata.gz: a41ea2a6df5c180fcae8b4196721e6923d6404652c01952646b406986d6dfbb5
4
+ data.tar.gz: ab7679782a12f7e54cd4575d40bef3788b254080d683335942f45b065ce2f6bd
5
5
  SHA512:
6
- metadata.gz: 36d42b1e5e2f74b5492e3cf6d32bf79e13ab131de92e2c9f683a44a8f975a3424bd2851d58947909665684d2c3772ab18a6330371c159351fd9f67cdf454eaaa
7
- data.tar.gz: aaffe9a0e03be688218b84aaa8a9005b3300f643b81d6e7cb5a19690ee8b539e7f32ee233e16e92874588f3fbe400da24c23ac97ea33b9483e9839f149c08d93
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
- rails g china_regions:regions
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
- bundle install
35
+ ```
36
+ bundle install
37
+ ```
26
38
 
27
39
  Run the generator:
28
40
 
29
- rails g china_regions:install
41
+ ```
42
+ rails g china_regions:install
43
+ ```
30
44
 
31
- Then you can see the changes that happened to the console:
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
- Create tables (provinces, cities, districts):
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
- rake db:migrate
50
+ Create tables (provinces, cities, districts):
38
51
 
39
- Copy Models [Province`, `City`, `District] into your project:
52
+ ```
53
+ rake db:migrate
54
+ ```
40
55
 
41
- please run `rails g` see the generator list.
56
+ Copy Models [`Province`, `City`, `District`] into your project:
42
57
 
43
- rails g china_regions:regions
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
- rake china_regions:all
70
+ ```
71
+ rake china_regions:all
54
72
 
55
- * 1. Downloading regions from `Administrative-divisions-of-China` to `db/regions` folder.
56
- - db/regions/pca-code.json
57
- * 2. Import the regions into provinces and cities, districts
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
- = form_for @article do |f|
87
+ ```
88
+ = form_for @article do |f|
64
89
 
65
- = f.region_select [:province, :city, :district]
90
+ = f.region_select [:province, :city, :district]
66
91
 
67
- # form_tag
68
- = region_select :article, :province_id
69
- = region_select :article, :city_id
70
- = region_select :article, :district_id
92
+ # form_tag
93
+ = region_select :article, :province_id
94
+ = region_select :article, :city_id
95
+ = region_select :article, :district_id
71
96
 
72
- OR
97
+ OR
73
98
 
74
- = region_select :article, :province
75
- = region_select :article, :city
76
- = region_select :article, :district
99
+ = region_select :article, :province
100
+ = region_select :article, :city
101
+ = region_select :article, :district
77
102
 
78
- = f.submit class: 'btn'
103
+ = f.submit class: 'btn'
104
+ ```
79
105
 
80
106
  Add prefix name:
81
107
 
82
- = form_for @article do |f|
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
- = form_for @article do |f|
117
+ ```
118
+ = form_for @article do |f|
119
+ = f.region_select [:province, :city, :district], province: "chongqing"
91
120
 
92
- = f.region_select [:province, :city, :district], province: "chongqing"
121
+ OR
93
122
 
94
- OR
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
- = form_for @article do |f|
101
-
102
- = f.region_select [:province, :city, :district], priority: { province: ["重庆市"], district: %w(巴南区 北碚区 渝北区) }
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 © 2018-07 Encore Shao. See LICENSE for details.
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
- rails g china_regions:regions
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
- bundle install
33
+ ```
34
+ bundle install
35
+ ```
24
36
 
25
37
  #### 开始构建城市数据
26
38
 
27
39
  复制所需文件到你的项目中:
28
40
 
29
- rails g china_regions:install
41
+ ```
42
+ rails g china_regions:install
43
+ ```
30
44
 
31
- 随后你可以看到控制台发生的变化:
32
- * 复制 `db/migrate/xxxxxxxxxxx_create_china_regions_tables.rb` 文件到 `db/migrate` 目录中
33
- * 复制 `regions.en.yml` 和 `regions.zh.yml` 配置文件到 `config/locales` 目录中
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
- rake db:migrate
51
+ ```
52
+ rake db:migrate
53
+ ```
38
54
 
39
55
  将所需的模型(Models) [`Province`, `City`, `District`] 到您的应用程式中:
40
56
 
41
- 你可以执行 `rails g` 查看到 `generator` 列表.
42
-
43
- rails g china_regions:regions
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
- rake china_regions:all
69
+ ```
70
+ rake china_regions:all
71
+
72
+ OR
54
73
 
55
- * 1. 从 `Administrative-divisions-of-China` 下载最新的地区信息到 `db/regions` 目录中.
56
- - db/regions/pca-code.json
57
- * 2. 将下载后的地区信息导入数据库中
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
- = form_for @article do |f|
86
+ ```
87
+ = form_for @article do |f|
64
88
 
65
- = f.region_select [:province, :city, :district]
89
+ = f.region_select [:province, :city, :district]
66
90
 
67
- # form_tag
68
- = region_select :article, :province_id
69
- = region_select :article, :city_id
70
- = region_select :article, :district_id
91
+ # form_tag
92
+ = region_select :article, :province_id
93
+ = region_select :article, :city_id
94
+ = region_select :article, :district_id
71
95
 
72
- OR
96
+ OR
73
97
 
74
- = region_select :article, :province
75
- = region_select :article, :city
76
- = region_select :article, :district
98
+ = region_select :article, :province
99
+ = region_select :article, :city
100
+ = region_select :article, :district
77
101
 
78
- = f.submit class: 'btn'
102
+ = f.submit class: 'btn'
103
+ ```
79
104
 
80
105
  添加前缀名:
81
106
 
82
- = form_for @article do |f|
83
-
84
- = f.region_select [:province, :city, :district], :prefix => "home"
85
- = f.region_select [:province, :city, :district], :prefix => "work"
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
- = form_for @article do |f|
115
+ ```
116
+ = form_for @article do |f|
91
117
 
92
- = f.region_select [:province, :city, :district], province: "chongqing"
118
+ = f.region_select [:province, :city, :district], province: "chongqing"
93
119
 
94
- OR
120
+ OR
95
121
 
96
- = f.region_select [:province, :city, :district], province: "重庆市"
122
+ = f.region_select [:province, :city, :district], province: "重庆市"
123
+ ```
97
124
 
98
125
  优先选择:
99
126
 
100
- = form_for @article do |f|
101
-
102
- = f.region_select [:province, :city, :district], priority: { province: ["重庆市"], district: %w(巴南区 北碚区 渝北区) }
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 © 2018-07 Encore Shao. See LICENSE for details.
145
+ Copyright © 2020-02 Encore Shao. See LICENSE for details.
119
146
 
@@ -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'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChinaRegions
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
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.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-08 00:00:00.000000000 Z
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: