From 8591b37eb9fc5687bafb13c9031f4a46ec67b720 Mon Sep 17 00:00:00 2001 From: Liu Lantao Date: Mon, 20 Nov 2017 07:08:09 +0800 Subject: [PATCH] rename script Signed-off-by: Liu Lantao --- {_META => .scripts}/fetch-samplecode.sh | 6 +++--- _META/samplecode.csv => _projects.csv | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename {_META => .scripts}/fetch-samplecode.sh (64%) rename _META/samplecode.csv => _projects.csv (100%) diff --git a/_META/fetch-samplecode.sh b/.scripts/fetch-samplecode.sh similarity index 64% rename from _META/fetch-samplecode.sh rename to .scripts/fetch-samplecode.sh index d74d9de3..2961e2d6 100755 --- a/_META/fetch-samplecode.sh +++ b/.scripts/fetch-samplecode.sh @@ -1,11 +1,11 @@ #!/bin/bash -curl 'https://developer.apple.com/search/search_data.php?q=swift%203&results=500' -s -e developer.apple.com -o search_result.json +curl 'https://developer.apple.com/search/search_data.php?q=swift%203&results=500' -s -e developer.apple.com -o /tmp/search_result.json ruby -e "require 'json'; require 'csv'; -CSV.open('samplecode.csv', 'wb') do |csv| - JSON.parse(File.open('search_result.json').read)['results'].keep_if {|v| +CSV.open('_projects.csv', 'wb') do |csv| + JSON.parse(File.open('/tmp/search_result.json').read)['results'].keep_if {|v| v['type'] == 'sample_code' }.sort_by {|x| x['title']}.each{|sc| csv << [sc['url'].match('\/samplecode\/([^\/]*)\/')[1], 'https://developer.apple.com' + sc['url'] + 'Introduction/Intro.html', sc['title']] diff --git a/_META/samplecode.csv b/_projects.csv similarity index 100% rename from _META/samplecode.csv rename to _projects.csv