Skip to content

Instantly share code, notes, and snippets.

@ipmsteven
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save ipmsteven/11042200 to your computer and use it in GitHub Desktop.

Select an option

Save ipmsteven/11042200 to your computer and use it in GitHub Desktop.
download all appfolio repo from github
#!/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