Last active
August 29, 2015 14:00
-
-
Save ipmsteven/11042200 to your computer and use it in GitHub Desktop.
download all appfolio repo from github
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| require 'io/console' | |
| require 'net/http' | |
| require 'json' | |
| require 'cgi' | |
| $url = "https://api.github.com/orgs/appfolio/repos" | |
| puts "Enter your Github username:" | |
| $username = STDIN.gets.chomp | |
| puts "Enter your password:" | |
| $passwd = STDIN.noecho(&:gets).chomp | |
| def get_last_url | |
| cmd = "curl -I https://api.github.com/orgs/appfolio/repos -u '#{$username}:#{$passwd}'" | |
| linker = `#{cmd}` | |
| URI.extract(linker, /https/).last | |
| end | |
| num_of_pages = CGI.parse(URI.parse(get_last_url).query)['page'].first.to_i | |
| (1..num_of_pages).each do |n| | |
| page = `curl #{$url}?page=#{n} -u #{$username}:#{$passwd}` | |
| JSON.load(page).each {|repo| %x[git clone #{repo["clone_url"]} ]} | |
| end | |
| Dir['*'].select { |r| not Dir[r+"/*.gemspec"].empty? }.each {|gem| FileUtils.mv(gem, "./gems")} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment