group_logins.each do |group_login| group_repos = fetch "#{base}/groups/#{group_login}/repos" group_repos["data"].each do |repo| repo["name"].gsub! "/","%2F" Dir.mkdir("./markdown/#{repo['name']}") unlessFile.exists? "./markdown/#{repo['name']}" Dir.mkdir("./json/#{repo['name']}") unlessFile.exists? "./json/#{repo['name']}"
puts "new repo for #{login}, name:#{repo['name']},namespace:#{repo['namespace']},id:#{repo['id']}" repo_docs = fetch "#{base}/repos/#{repo['id']}/docs" repo_docs['data'].each do |doc| puts "\t title:#{doc['title']},slug:#{doc['slug']}" doc_resp = fetch "#{base}/repos/#{repo['namespace']}/docs/#{doc['slug']}" doc = doc_resp["data"] doc["title"].gsub! "/","%2F" File.open "./markdown/#{repo['name']}/#{doc['title']}.md","w"do |file| file.puts doc["body"] end File.open "./json/#{repo['name']}/#{doc["slug"]}.json","w"do |file| file.puts JSON.dump(doc) end end end end