Skip to content

Commit f4e76bc

Browse files
committed
Transform dojos_earth's keys from string into symbol
1 parent caf093c commit f4e76bc

File tree

3 files changed

+48
-19
lines changed

3 files changed

+48
-19
lines changed

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source "https://rubygems.org"
2+
3+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4+
5+
gem 'activesupport'

Gemfile.lock

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
activesupport (7.0.4)
5+
concurrent-ruby (~> 1.0, >= 1.0.2)
6+
i18n (>= 1.6, < 2)
7+
minitest (>= 5.1)
8+
tzinfo (~> 2.0)
9+
concurrent-ruby (1.1.10)
10+
i18n (1.12.0)
11+
concurrent-ruby (~> 1.0)
12+
minitest (5.16.3)
13+
tzinfo (2.0.5)
14+
concurrent-ruby (~> 1.0)
15+
16+
PLATFORMS
17+
arm64-darwin-21
18+
19+
DEPENDENCIES
20+
activesupport
21+
22+
BUNDLED WITH
23+
2.3.22

convert.rb

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/usr/bin/env ruby
22
require 'json'
3+
require 'active_support/core_ext/hash/keys'
34

45
dojos_earth = []
56
dojos_japan = []
67

78
File.open("dojos_earth.json") do |file|
8-
dojos_earth = JSON.load(file)
9+
dojos_earth = JSON.load(file).map{|data| data.deep_transform_keys!(&:to_sym) }
910
end
1011

1112
File.open("dojos_japan.json") do |file|
@@ -27,34 +28,34 @@
2728
# 2: Register ahead
2829
# 3: 満員
2930
# 4: 活動していません
30-
if dojo["geoPoint"] && dojo["stage"] != 4
31+
if dojo[:geoPoint] && dojo[:stage] != 4
3132

3233
# 細かな名寄せ for Proof of Concept (PoC)
33-
dojo['name'].gsub!('Chofu', '調布')
34-
dojo['name'].gsub!('Gifu', '岐阜')
35-
dojo['name'].gsub!('Eniwa', '恵庭')
36-
dojo['name'].gsub!('muroran@kuru', '室蘭')
37-
dojo['name'].gsub!('SapporoEast', '札幌東')
38-
dojo['name'].gsub!('Sapporo', '札幌')
39-
dojo['name'].gsub!('Ebetsu, Hokkaido', '江別')
40-
dojo['name'].gsub!('Nara, Nara', '奈良')
41-
dojo['name'].gsub!('Ikoma, Nara', '生駒')
42-
dojo['name'].gsub!('天白,名古屋,愛知', '天白')
43-
dojo['name'].gsub!('shikatsu', '師勝')
44-
dojo['name'].gsub!('Tondabayashi, Osaka', '富田林')
45-
dojo['name'].gsub!('Osakasayama, Osaka', '大阪狭山')
34+
dojo[:name].gsub!('Chofu', '調布')
35+
dojo[:name].gsub!('Gifu', '岐阜')
36+
dojo[:name].gsub!('Eniwa', '恵庭')
37+
dojo[:name].gsub!('muroran@kuru', '室蘭')
38+
dojo[:name].gsub!('SapporoEast', '札幌東')
39+
dojo[:name].gsub!('Sapporo', '札幌')
40+
dojo[:name].gsub!('Ebetsu, Hokkaido', '江別')
41+
dojo[:name].gsub!('Nara, Nara', '奈良')
42+
dojo[:name].gsub!('Ikoma, Nara', '生駒')
43+
dojo[:name].gsub!('天白,名古屋,愛知', '天白')
44+
dojo[:name].gsub!('shikatsu', '師勝')
45+
dojo[:name].gsub!('Tondabayashi, Osaka', '富田林')
46+
dojo[:name].gsub!('Osakasayama, Osaka', '大阪狭山')
4647

47-
dojo['name'].gsub!('富山@長江', '富山')
48-
dojo['name'].gsub!('Kanazawa, Ishikawa @ HackforPlay', '金沢')
48+
dojo[:name].gsub!('富山@長江', '富山')
49+
dojo[:name].gsub!('Kanazawa, Ishikawa @ HackforPlay', '金沢')
4950

5051
features << {
5152
"type" => "Feature",
5253
"geometry" => {
5354
"type" => "Point",
54-
"coordinates" => [dojo["geoPoint"]["lon"], dojo["geoPoint"]["lat"]]
55+
"coordinates" => [dojo[:geoPoint][:lon], dojo[:geoPoint][:lat]]
5556
},
5657
"properties" => {
57-
"description" => "#{dojo['name']}<br />#{name2text[dojo['name']]}<a target='_blank' href='http://zen.coderdojo.com/dojos/#{dojo['urlSlug']}'>連絡先を見る</a>"
58+
"description" => "#{dojo[:name]}<br />#{name2text[dojo[:name]]}<a target='_blank' href='http://zen.coderdojo.com/dojos/#{dojo[:urlSlug]}'>連絡先を見る</a>"
5859
}
5960
}
6061
end

0 commit comments

Comments
 (0)