File tree 1 file changed +15
-3
lines changed
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 3
3
require 'net/http'
4
4
require 'json'
5
5
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 ] }
9
11
10
12
File . open ( "dojos_japan.json" , "w" ) do |file |
11
13
file . write ( DOJOS_JSON )
12
14
end
13
15
16
+ File . open ( "events_japan.json" , "w" ) do |file |
17
+ file . write ( EVENTS_JSON )
18
+ end
19
+
14
20
# Show next step for developers
15
21
puts DOJOS_JSON
16
22
puts ''
17
23
puts 'Check out JSON data you fetched by:'
18
24
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 ''
You can’t perform that action at this time.
0 commit comments