taiwan_city_dists_helper 0.91 → 0.93
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/Rakefile +0 -0
- data/lib/generators/taiwan_city_dists_helper/table/table_generator.rb +0 -0
- data/lib/generators/taiwan_city_dists_helper/table/templates/migration.rb +0 -0
- data/lib/taiwan_city_dists_helper/engine.rb +0 -0
- data/lib/taiwan_city_dists_helper/helper.rb +0 -0
- data/lib/taiwan_city_dists_helper/version.rb +1 -1
- data/lib/taiwan_city_dists_helper.rb +0 -0
- data/lib/tasks/taiwan_city_dists_helper.rake +29 -4
- data/taiwan_city_dists_helper.gemspec +0 -0
- data/vendor/assets/javascripts/taiwan_city_dists_helper.js +0 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NzYwM2I4ZTQ5OTg1NzFlYWVlZjM3MjJmMDdmMmJjNjljZmE4OWI1Ng==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a3abe3b0a7302375b9b266062e1bebd8d7071d1e
|
4
|
+
data.tar.gz: f1a1cdb1df008df6809adac4b8656ad6d9116206
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MzQ4ODc1NDk4ZjM1NTMyZTFkODMzZmRjNWY3NjI1OThkNDk5MDhiYjQ5ZjAw
|
11
|
-
MWEyNTRlZTFiNzc0MDU4MWU3ODg2MTk0ZWYzNDI4MDBkMTk2ZDE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MjNhODA2ZGM0YWI2Mjg4Y2E1N2VjYzQ3ZmMwNjUxODY5NzkxYTI5ZTQ0MDhh
|
14
|
-
ZjdkMjkxZjk5NDc0Y2NhMGI5M2JjMjFlNmM5NzU3YTQwMmU0MWI3NTU4NGJl
|
15
|
-
ZjEyMWU3NmQxNzc3OGNlYzUxOTU4YmJjNjEwZWJiMTBiMjRkOTg=
|
6
|
+
metadata.gz: 25d8397ed40af440fdf8e95d1fd4395318e2913d1f27e9006f26cf2703c7feed682f8fd8c842fa967ea215f11da24cc1cb575fa6fe70850bc2cd82fa4d083be3
|
7
|
+
data.tar.gz: 84e57ad82dbd85262c05f7a3d5ffa6e8eb5869ba180fa9bf231f92d23537493810fe47b191b7c49a530086f576ff72bd3a87f633990295aa1910271eee6fa11a
|
data/.gitignore
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -16,11 +16,36 @@ namespace :taiwan_city_dists_helper do
|
|
16
16
|
|
17
17
|
desc "Grab cities and dists from wikipedia"
|
18
18
|
task :get_cities_and_dists => :environment do
|
19
|
-
url = "
|
19
|
+
url = "https://zh.wikipedia.org/wiki/%E4%B8%AD%E8%8F%AF%E6%B0%91%E5%9C%8B%E8%87%BA%E7%81%A3%E5%9C%B0%E5%8D%80%E9%84%89%E9%8E%AE%E5%B8%82%E5%8D%80%E5%88%97%E8%A1%A8"
|
20
20
|
begin
|
21
21
|
doc = Nokogiri::HTML(open(url))
|
22
22
|
puts "We got data from wikipedia, now processing ..."
|
23
|
-
|
23
|
+
#直轄市
|
24
|
+
doc.search("//table[@class='wikitable'][3]//tr").each do |tr|
|
25
|
+
city_name = tr.search("td[1]").text
|
26
|
+
if city_name != ""
|
27
|
+
@city = City.create(:name => "#{city_name}")
|
28
|
+
dist_string = tr.search("td[3]").text
|
29
|
+
dists = dist_string.split("、")
|
30
|
+
dists.each do |dist_name|
|
31
|
+
Dist.create(:name => "#{dist_name}", :city_id => @city.id)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
#市
|
36
|
+
doc.search("//table[@class='wikitable'][4]//tr").each do |tr|
|
37
|
+
city_name = tr.search("td[1]").text
|
38
|
+
if city_name != ""
|
39
|
+
@city = City.create(:name => "#{city_name}")
|
40
|
+
dist_string = tr.search("td[3]").text
|
41
|
+
dists = dist_string.split("、")
|
42
|
+
dists.each do |dist_name|
|
43
|
+
Dist.create(:name => "#{dist_name}", :city_id => @city.id)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
#縣
|
48
|
+
doc.search("//table[@class='wikitable'][5]//tr").each do |tr|
|
24
49
|
city_name = tr.search("td[1]").text
|
25
50
|
if city_name != ""
|
26
51
|
@city = City.create(:name => "#{city_name}")
|
@@ -32,8 +57,8 @@ namespace :taiwan_city_dists_helper do
|
|
32
57
|
end
|
33
58
|
end
|
34
59
|
rescue Exception => e
|
35
|
-
puts "Please check your network connection, we can't
|
36
|
-
puts "maybe try later
|
60
|
+
puts "Please check your network connection, we can't connect wikipedia :("
|
61
|
+
puts "maybe try later ?"
|
37
62
|
end
|
38
63
|
|
39
64
|
end
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taiwan_city_dists_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.93'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- unayung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: Generate Taiwan cities and dists model and provide dynamic select box
|
@@ -32,7 +32,7 @@ executables: []
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
-
- .gitignore
|
35
|
+
- ".gitignore"
|
36
36
|
- Gemfile
|
37
37
|
- LICENSE.txt
|
38
38
|
- README.md
|
@@ -57,17 +57,17 @@ require_paths:
|
|
57
57
|
- lib
|
58
58
|
required_ruby_version: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- -
|
65
|
+
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
69
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
70
|
+
rubygems_version: 2.5.1
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: This gem is a test
|