Skip to content

Commit 39d4f6a

Browse files
authored
Merge pull request #19 from coderdojo-japan/automate-to-update-profile-upon-dojo-stats
📊 Automate to update profile upon dojo stats
2 parents 4f0bac7 + 36e1a6b commit 39d4f6a

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

_data/stats.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
active_dojos: 180

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ <h3 class="headline rich_font">DecaDojo とは?</h3>
199199

200200
<h3 class="headline rich_font" style='margin-top: 70px;'>CoderDojo とは?</h3>
201201
<div class="desc">
202-
<p>CoderDojo は7〜17歳を対象とした非営利のプログラミング道場です。2011年にアイルランドで始まり、世界では100カ国・2,000の道場、<a href='https://coderdojo.jp/'>日本には180以上の道場</a>があります。</p>
202+
<p>CoderDojo は7〜17歳を対象とした非営利のプログラミング道場です。2011年にアイルランドで始まり、世界では100カ国・2,000の道場、<a href='https://coderdojo.jp/'>日本には{{ site.data.stats['active_dojos'] }}以上の道場</a>があります。</p>
203203
</div>
204204
</div>
205205
</div>

update_profile.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'net/http'
4+
require 'json'
5+
require 'yaml'
6+
7+
BASE_URL = 'https://coderdojo.jp'
8+
DOJO_STATS = JSON.parse Net::HTTP.get(URI.parse "#{BASE_URL}/stats.json"), symbolize_names: true
9+
STATS_PATH = '_data/stats.yml'
10+
11+
stats = YAML.load_file(STATS_PATH)
12+
stats['active_dojos'] = DOJO_STATS[:active_dojos]
13+
YAML.dump stats, File.open(STATS_PATH, 'w')

0 commit comments

Comments
 (0)