Skip to content

Commit

Permalink
Merge pull request #19 from coderdojo-japan/automate-to-update-profil…
Browse files Browse the repository at this point in the history
…e-upon-dojo-stats

📊 Automate to update profile upon dojo stats
  • Loading branch information
yasulab committed Nov 17, 2023
2 parents 4f0bac7 + 36e1a6b commit 39d4f6a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions _data/stats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
active_dojos: 180
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ <h3 class="headline rich_font">DecaDojo とは?</h3>
<h3 class="headline rich_font" style='margin-top: 70px;'>CoderDojo とは?</h3>
<div class="desc">
<p>CoderDojo は7〜17歳を対象とした非営利のプログラミング道場です。2011年にアイルランドで始まり、世界では100カ国・2,000の道場、<a href='https://coderdojo.jp/'>日本には180以上の道場</a>があります。</p>
<p>CoderDojo は7〜17歳を対象とした非営利のプログラミング道場です。2011年にアイルランドで始まり、世界では100カ国・2,000の道場、<a href='https://coderdojo.jp/'>日本には{{ site.data.stats['active_dojos'] }}以上の道場</a>があります。</p>
</div>
</div>
</div>
Expand Down
13 changes: 13 additions & 0 deletions update_profile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env ruby

require 'net/http'
require 'json'
require 'yaml'

BASE_URL = 'https://coderdojo.jp'
DOJO_STATS = JSON.parse Net::HTTP.get(URI.parse "#{BASE_URL}/stats.json"), symbolize_names: true
STATS_PATH = '_data/stats.yml'

stats = YAML.load_file(STATS_PATH)
stats['active_dojos'] = DOJO_STATS[:active_dojos]
YAML.dump stats, File.open(STATS_PATH, 'w')

0 comments on commit 39d4f6a

Please sign in to comment.