File tree Expand file tree Collapse file tree 7 files changed +50
-0
lines changed
Expand file tree Collapse file tree 7 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 5454 - name : ☯️ Cache dojo logos in Japan
5555 run : |
5656 bundle exec ruby cache_dojo_logos.rb
57+ bundle exec rake cache_data_as_yaml
5758
5859 - name : 📍 Generate DojoMap from Earth/Japan data
5960 run : |
@@ -65,13 +66,24 @@ jobs:
6566 git config --global user.name "Yohei Yasukawa"
6667 git config --global user.email "yohei@yasslab.jp"
6768 git checkout main
69+
70+ # Gems may update automatically
6871 git add Gemfile.lock
72+
73+ # Cache responses from Japan/Clubs APIs
6974 git add dojos_earth.json
7075 git add dojos_japan.json
7176 git add events_japan.json
7277 git add images/dojos
78+ git add _data/earth.yml
79+
80+ # Save GeoJSON data to render DojoMap
7381 git add dojos.geojson
82+
83+ # Commit changed files above
7484 git commit -m '🤖 Upsert Earth/Japan data for DojoMap'
85+
86+ # Git pull/push the commit to deploy
7587 git pull origin main
7688 git push origin main
7789 fi
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ desc 'Get CoderDojo data on the Earth via Raspberry Pi Clubs API'
55task ( :get_data_from_earth ) { ruby 'get_data_from_earth.rb' }
66task ( :get_data_from_japan ) { ruby 'get_data_from_japan.rb' }
77task ( :cache_dojo_logos ) { ruby 'cache_dojo_logos.rb' }
8+ task ( :cache_data_as_yaml ) { ruby 'cache_data_as_yaml.rb' }
89task ( :upsert_dojos_geojson ) { ruby 'upsert_dojos_geojson.rb' }
910
1011# GitHub - gjtorikian/html-proofer
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env ruby
2+ require 'json'
3+ require 'yaml'
4+ require 'fileutils'
5+
6+ # This script caches the Clubs API's data as YAML format.
7+ # Earth data: from RasPi's Clubs API: https://clubs-api.raspberrypi.org
8+ EARTH_YAML_PATH = '_data/earth.yml'
9+
10+ # Ensure _data directory exists
11+ FileUtils . mkdir_p ( '_data' )
12+
13+ # Load Earth data (use string keys, not symbols)
14+ dojos_earth = JSON . load ( File . read ( 'dojos_earth.json' ) ,
15+ nil ,
16+ symbolize_names : false ,
17+ create_additions : false )
18+
19+ # Save all Earth data as YAML
20+ IO . write ( EARTH_YAML_PATH , dojos_earth . to_yaml )
21+ puts "✅ Cached #{ dojos_earth . size . to_s . rjust ( 4 ) } Earth dojos to #{ EARTH_YAML_PATH } "
22+
23+ # Count Japan dojos for information
24+ dojos_japan = dojos_earth . select { |dojo | dojo [ 'countryCode' ] == 'JP' }
25+ puts " (Incl. #{ dojos_japan . size . to_s . rjust ( 4 ) } Japan's active/inactive dojos)"
26+
27+ puts
28+ puts "Finished caching JSON data as YAML."
29+ puts
Original file line number Diff line number Diff line change 1+ ---
2+ layout: none
3+ ---
4+ {{ site.data.earth | jsonify }}
Original file line number Diff line number Diff line change 1+ ---
2+ layout: none
3+ ---
4+ {{ site.data.earth | where: "countryCode", "JP" | jsonify }}
You can’t perform that action at this time.
0 commit comments