Skip to content

Commit a0fcb49

Browse files
committed
Get upcoming events from Japan DB
1 parent 96c133f commit a0fcb49

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

get_dojos_from_japan.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,28 @@
33
require 'net/http'
44
require 'json'
55

6-
DOJOS_URL = 'https://coderdojo.jp/dojos.json'
7-
DOJOS_DATA = JSON.parse Net::HTTP.get(URI.parse DOJOS_URL), symbolize_names: true
8-
DOJOS_JSON = JSON.pretty_generate DOJOS_DATA.sort_by{|dojo| dojo[:id]}
6+
BASE_URL = 'https://coderdojo.jp'
7+
DOJOS_DATA = JSON.parse Net::HTTP.get(URI.parse "#{BASE_URL}/dojos.json"), symbolize_names: true
8+
DOJOS_JSON = JSON.pretty_generate DOJOS_DATA.sort_by{|dojo| dojo[:id]}
9+
EVENTS_DATA = JSON.parse Net::HTTP.get(URI.parse "#{BASE_URL}/events.json"), symbolize_names: true
10+
EVENTS_JSON = JSON.pretty_generate EVENTS_DATA.sort_by{|dojo| dojo[:id]}
911

1012
File.open("dojos_japan.json", "w") do |file|
1113
file.write(DOJOS_JSON)
1214
end
1315

16+
File.open("events_japan.json", "w") do |file|
17+
file.write(EVENTS_JSON)
18+
end
19+
1420
# Show next step for developers
1521
puts DOJOS_JSON
1622
puts ''
1723
puts 'Check out JSON data you fetched by:'
1824
puts '$ cat dojos_japan.json'
25+
puts ''
26+
puts EVENTS_JSON
27+
puts ''
28+
puts 'Check out JSON data you fetched by:'
29+
puts '$ cat events_japan.json'
30+
puts ''

0 commit comments

Comments
 (0)