Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1f37e74

Browse filesBrowse files
committed
Split get_dojo_list script into .rb and .txt files #1433
1 parent 39a4e92 commit 1f37e74
Copy full SHA for 1f37e74

File tree

3 files changed

+44
-20
lines changed
Filter options

3 files changed

+44
-20
lines changed

‎get_dojo_linked_text.rb

Copy file name to clipboardExpand all lines: get_dojo_linked_text.rb
-20Lines changed: 0 additions & 20 deletions
This file was deleted.

‎get_dojo_list.rb

Copy file name to clipboard
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'net/http'
4+
require 'json'
5+
require 'pry'
6+
7+
# Google Spreadsheet などから対象となった Dojo 名の列をコピーし、
8+
# get_dojo_list.txt にペースト後、本スクリプトを実行すると、
9+
# お知らせ記事などで使える HTML のリスト一覧が出力されます。
10+
#
11+
# 詳細: https://github.com/coderdojo-japan/coderdojo.jp/pull/1433
12+
13+
TEXT = IO.readlines('./get_dojo_list.txt')
14+
DOJOS = JSON.parse(Net::HTTP.get URI.parse('https://coderdojo.jp/dojos.json'))
15+
result = "<ul>\n"
16+
17+
# CoderDojo の名前を使って、Dojo 一覧からデータを検索
18+
dojo_name =''
19+
not_found = []
20+
TEXT.each do |line|
21+
next if line.start_with?('#') || line.strip.empty?
22+
dojo_name = line.split[1..].join
23+
dojo_data = DOJOS.find {|dojo| dojo['name'].start_with? dojo_name}
24+
not_found << dojo_name && next if dojo_data.nil?
25+
result << " <li>#{dojo_data['linked_text']}</li>\n"
26+
#result << " <li>#{d['linked_text']}</li>\n"
27+
end
28+
result << "</ul>\n"
29+
puts result
30+
31+
# 検索して見つからなかった Dojo 一覧があれば出力
32+
puts '---' if not_found.nil?
33+
not_found.each {|dojo_name| puts "Not found: #{dojo_name}" }

‎get_dojo_list.txt

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Google Spreadsheet などから対象となった Dojo 名の列をコピーし、
2+
# 本 TXT ファイルの以下にペースト後、get_dojo_list.rb を実行すると、
3+
# お知らせ記事などで使える HTML のリスト一覧が出力されます。
4+
#
5+
# 詳細: https://github.com/coderdojo-japan/coderdojo.jp/pull/1433
6+
7+
CoderDojo 札幌
8+
CoderDojo 札幌東
9+
CoderDojo 室蘭
10+
CoderDojo 八戸
11+
CoderDojo 陸前高田

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.