chinese_regions_rails 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -4
- data/README.md +14 -1
- data/lib/chinese_regions_rails.rb +2 -1
- data/lib/chinese_regions_rails/json_data_source.rb +21 -0
- data/lib/chinese_regions_rails/version.rb +1 -1
- data/lib/dump_json.rb +11 -0
- data/lib/regions.json +33192 -0
- data/lib/tasks/seed.rake +1 -1
- data/spec/chinese_regions_rails/db_spec.rb +1 -1
- data/spec/chinese_regions_rails/json_data_source_spec.rb +16 -0
- metadata +14 -28
data/lib/tasks/seed.rake
CHANGED
@@ -17,7 +17,7 @@ namespace :db do
|
|
17
17
|
args[:model_class] = 'region'
|
18
18
|
region_class = args[:model_class].classify.constantize
|
19
19
|
|
20
|
-
ChineseRegionsRails::
|
20
|
+
ChineseRegionsRails::JsonDataSource.query_regions do |region_param|
|
21
21
|
region_class.create(region_param)
|
22
22
|
end
|
23
23
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "helper"
|
2
|
+
require "chinese_regions_rails/json_data_source"
|
3
|
+
|
4
|
+
describe ChineseRegionsRails::JsonDataSource do
|
5
|
+
it 'query_regions' do
|
6
|
+
ChineseRegionsRails::JsonDataSource.query_regions do |region_param|
|
7
|
+
expect(region_param).to be_truthy
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'regions' do
|
12
|
+
regions = ChineseRegionsRails::JsonDataSource.regions
|
13
|
+
expect(regions.size > 0).to be_truthy
|
14
|
+
expect(regions.first.keys).to contain_exactly(*%w[code parent_code name alias pinyin abbr zip level])
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chinese_regions_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Basten Gao
|
@@ -14,37 +14,17 @@ dependencies:
|
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
|
-
- - <
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '5'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '3.2'
|
30
|
-
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '5'
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: sqlite3
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ~>
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '1.3'
|
40
|
-
type: :runtime
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - ~>
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '1.3'
|
47
|
-
description: 中国省市区县数据库,包含 行政编码,邮政编码,地区拼音和简拼。 数据来源 https://github.com/xixilive/chinese_regions_db
|
27
|
+
description: "中国省市区县数据库,包含 行政编码,邮政编码,地区拼音和简拼。 数据来源 https://github.com/xixilive/chinese_regions_db"
|
48
28
|
email: bastengao@gmail.com
|
49
29
|
executables: []
|
50
30
|
extensions: []
|
@@ -55,12 +35,16 @@ files:
|
|
55
35
|
- Rakefile
|
56
36
|
- lib/chinese_regions_rails.rb
|
57
37
|
- lib/chinese_regions_rails/db.rb
|
38
|
+
- lib/chinese_regions_rails/json_data_source.rb
|
58
39
|
- lib/chinese_regions_rails/railtie.rb
|
59
40
|
- lib/chinese_regions_rails/version.rb
|
41
|
+
- lib/dump_json.rb
|
60
42
|
- lib/generators/chinese_regions/install_generator.rb
|
61
43
|
- lib/regions.db
|
44
|
+
- lib/regions.json
|
62
45
|
- lib/tasks/seed.rake
|
63
46
|
- spec/chinese_regions_rails/db_spec.rb
|
47
|
+
- spec/chinese_regions_rails/json_data_source_spec.rb
|
64
48
|
- spec/helper.rb
|
65
49
|
homepage: https://github.com/bastengao/chinese_regions_rails
|
66
50
|
licenses:
|
@@ -72,20 +56,22 @@ require_paths:
|
|
72
56
|
- lib
|
73
57
|
required_ruby_version: !ruby/object:Gem::Requirement
|
74
58
|
requirements:
|
75
|
-
- -
|
59
|
+
- - ">="
|
76
60
|
- !ruby/object:Gem::Version
|
77
61
|
version: 1.9.3
|
78
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
63
|
requirements:
|
80
|
-
- -
|
64
|
+
- - ">="
|
81
65
|
- !ruby/object:Gem::Version
|
82
66
|
version: 1.8.11
|
83
67
|
requirements: []
|
84
68
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
69
|
+
rubygems_version: 2.4.8
|
86
70
|
signing_key:
|
87
71
|
specification_version: 4
|
88
|
-
summary: 中国省市区县数据库
|
72
|
+
summary: "中国省市区县数据库"
|
89
73
|
test_files:
|
90
74
|
- spec/chinese_regions_rails/db_spec.rb
|
75
|
+
- spec/chinese_regions_rails/json_data_source_spec.rb
|
91
76
|
- spec/helper.rb
|
77
|
+
has_rdoc:
|