Sha256: 9b9ef13b6be3ec11daa24773a1968a2b09492a4737fc4d8aa42969ce025130d0

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 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.first(2).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

1 entries across 1 versions & 1 rubygems

Version Path
git-ready-0.8.0 lib/git-ready/github.rb