Class: Github::Backup
Instance Attribute Summary collapse
-
#backup_root ⇒ Object
readonly
Returns the value of attribute backup_root.
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(username, backup_root) ⇒ Backup
constructor
A new instance of Backup.
Constructor Details
#initialize(username, backup_root) ⇒ Backup
Returns a new instance of Backup.
12 13 14 15 16 |
# File 'lib/github-backup.rb', line 12 def initialize(username, backup_root) @username = username @backup_root = backup_root @debug = false end |
Instance Attribute Details
#backup_root ⇒ Object (readonly)
Returns the value of attribute backup_root.
10 11 12 |
# File 'lib/github-backup.rb', line 10 def backup_root @backup_root end |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
10 11 12 |
# File 'lib/github-backup.rb', line 10 def debug @debug end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
10 11 12 |
# File 'lib/github-backup.rb', line 10 def username @username end |
Instance Method Details
#execute ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/github-backup.rb', line 18 def execute FileUtils::mkdir_p(backup_root) authenticated do |api| repositories = User.find(username).repositories.sort_by { |r| r.name } repositories.each do |repository| puts "Backing up: #{repository.name}" backup_repository repository end end rescue Errno::ENOENT puts "Please install git and create a ~/.gitconfig" puts " See: http://github.com/guides/tell-git-your-user-name-and-email-address" rescue NoMethodError puts "Please add a [github] section to your ~/.gitconfig" puts " See: http://github.com/guides/tell-git-your-user-name-and-email-address" end |