class MirrorGithub::Base
Public Class Methods
new(args = nil)
click to toggle source
# File lib/mirror_github/base.rb, line 5 def initialize(args = nil) parse_arguments(args) end
Public Instance Methods
config()
click to toggle source
# File lib/mirror_github/base.rb, line 28 def config @config ||= Configuration.new end
github_connection()
click to toggle source
# File lib/mirror_github/base.rb, line 32 def github_connection @github_connection ||= Github.new(config.username, config.password, config.org) end
mirror(repository)
click to toggle source
Creates a new mirroir repository at the target directory (if necessary) and fetches any updates.
# File lib/mirror_github/base.rb, line 22 def mirror(repository) git = Git.new(config.backup_directory, repository) git.create_mirror unless git.mirror_exists? git.update_mirror end
mirror_all()
click to toggle source
Backs up all repositories from the organization defined in the config.
# File lib/mirror_github/base.rb, line 10 def mirror_all puts "Mirroring #{github_connection.repositories.size} repositories..." github_connection.repositories.each do |repo| puts "Beginning #{repo.name}" mirror repo puts "Finished #{repo.name}" puts "" end end
parse_arguments(args)
click to toggle source
# File lib/mirror_github/base.rb, line 36 def parse_arguments(args) args.each do |arg| option, value = arg.split('=').map { |v| v.chomp.strip } next unless option && value case option when "--config-file" then Configuration.config_file_path = value when "--backup-dir" then config.backup_directory = value end end end