-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split get_dojo_list script into .rb and .txt files #1433
- Loading branch information
Showing
3 changed files
with
44 additions
and
20 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'net/http' | ||
require 'json' | ||
require 'pry' | ||
|
||
# Google Spreadsheet などから対象となった Dojo 名の列をコピーし、 | ||
# get_dojo_list.txt にペースト後、本スクリプトを実行すると、 | ||
# お知らせ記事などで使える HTML のリスト一覧が出力されます。 | ||
# | ||
# 詳細: https://github.com/coderdojo-japan/coderdojo.jp/pull/1433 | ||
|
||
TEXT = IO.readlines('./get_dojo_list.txt') | ||
DOJOS = JSON.parse(Net::HTTP.get URI.parse('https://coderdojo.jp/dojos.json')) | ||
result = "<ul>\n" | ||
|
||
# CoderDojo の名前を使って、Dojo 一覧からデータを検索 | ||
dojo_name ='' | ||
not_found = [] | ||
TEXT.each do |line| | ||
next if line.start_with?('#') || line.strip.empty? | ||
dojo_name = line.split[1..].join | ||
dojo_data = DOJOS.find {|dojo| dojo['name'].start_with? dojo_name} | ||
not_found << dojo_name && next if dojo_data.nil? | ||
result << " <li>#{dojo_data['linked_text']}</li>\n" | ||
#result << " <li>#{d['linked_text']}</li>\n" | ||
end | ||
result << "</ul>\n" | ||
puts result | ||
|
||
# 検索して見つからなかった Dojo 一覧があれば出力 | ||
puts '---' if not_found.nil? | ||
not_found.each {|dojo_name| puts "Not found: #{dojo_name}" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Google Spreadsheet などから対象となった Dojo 名の列をコピーし、 | ||
# 本 TXT ファイルの以下にペースト後、get_dojo_list.rb を実行すると、 | ||
# お知らせ記事などで使える HTML のリスト一覧が出力されます。 | ||
# | ||
# 詳細: https://github.com/coderdojo-japan/coderdojo.jp/pull/1433 | ||
|
||
CoderDojo 札幌 | ||
CoderDojo 札幌東 | ||
CoderDojo 室蘭 | ||
CoderDojo 八戸 | ||
CoderDojo 陸前高田 |