Sha256: 76bf7658d00888774eaa06ed7b946ac408a143daa4cd3f74c89c66f620f5d7ca

Contents?: true

Size: 702 Bytes

Versions: 6

Compression:

Stored size: 702 Bytes

Contents

require 'contracts'
require 'octokit'
require 'progress_bar'
require_relative 'settings'

module GitHub
  include Contracts

  Contract String => ArrayOf[({ upstream: Sawyer::Resource, origin: Sawyer::Resource })]
  def self.fork_all(organization)
    repositories = %w(public, private).flat_map do |type|
      api.org_repos(organization, type: type)
    end
    progress = ProgressBar.new repositories.length
    repositories.flat_map do |repository|
      progress.increment!
      { upstream: repository, origin: api.fork(repository[:full_name]) }
    end
  end

  Contract nil => Octokit::Client
  def self.api
    @api ||= Octokit::Client.new access_token: Settings.github_access_token
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
git-ready-0.8.6 lib/git-ready/github.rb
git-ready-0.8.5 lib/git-ready/github.rb
git-ready-0.8.4 lib/git-ready/github.rb
git-ready-0.8.3 lib/git-ready/github.rb
git-ready-0.8.2 lib/git-ready/github.rb
git-ready-0.8.1 lib/git-ready/github.rb