Class: GithubBackup::Backup
- Inherits:
-
Object
- Object
- GithubBackup::Backup
- Defined in:
- lib/github-backup/backup.rb
Instance Attribute Summary collapse
-
#backup_root ⇒ Object
readonly
Returns the value of attribute backup_root.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#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, options = {}) ⇒ Backup
constructor
A new instance of Backup.
Constructor Details
#initialize(username, backup_root, options = {}) ⇒ Backup
Returns a new instance of Backup.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/github-backup/backup.rb', line 5 def initialize(username, backup_root, = {}) @username = username @backup_root = backup_root @options = @debug = false unless .key?(:token) config = read_gitconfig if config.key?('github') [:token] = config['github'].fetch('token', nil) end end if [:token] @client = Octokit::Client.new(:access_token => [:token]) else @client = Octokit::Client.new end end |
Instance Attribute Details
#backup_root ⇒ Object (readonly)
Returns the value of attribute backup_root.
3 4 5 |
# File 'lib/github-backup/backup.rb', line 3 def backup_root @backup_root end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/github-backup/backup.rb', line 3 def client @client end |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
3 4 5 |
# File 'lib/github-backup/backup.rb', line 3 def debug @debug end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
3 4 5 |
# File 'lib/github-backup/backup.rb', line 3 def username @username end |
Instance Method Details
#execute ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/github-backup/backup.rb', line 25 def execute backup_all rescue Octokit::Unauthorized puts "Github API authentication failed." puts "Please add a [github] section to your ~/.gitconfig" puts " See: http://github.com/guides/tell-git-your-user-name-and-email-address" puts "Or, use the arguments to authenticate with your username and API token." end |