Sha256: a73539a8a5cdacccd2077fe91e31288605a56e4bdd1a029d9dd3116c7e890b18

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require 'octokit'

require_relative 'performers/github_repository'
require_relative 'performers/github_wiki'
require_relative 'performers/github_gist'

module BackupRepos
  class BackupGithub
    class << self
      def process
        new.process
      end
    end

    def process
      process_repositories
      process_wiki
      process_gist
    end

    def repos
      @repos ||= client.repos
    end

    def client
      @client ||= Octokit::Client.new(access_token: access_token)
    end

    private

    def access_token
      BackupRepos.config.github_access_token
    end

    def process_repositories
      repos.each do |repo_params|
        Performers::GithubRepository.new(repo_params).backup
      end
    end

    def process_wiki
      repos.select(&:has_wiki?).each do |repo_params|
        Performers::GithubWiki.new(repo_params).backup
      end
    end

    def process_gist
      client.gists.each do |gist_params|
        Performers::GithubGist.new(gist_params).backup
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
backup_repos-0.1.0 lib/backup_repos/backup_github.rb