Class: GithubBackup::Backup

Inherits:
Object
  • Object
show all
Defined in:
lib/github-backup/backup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, options = {}) ⇒ Backup

Returns a new instance of Backup.



5
6
7
8
9
10
11
12
13
# File 'lib/github-backup/backup.rb', line 5

def initialize(username, options = {})
  @username      = username
  @debug         = false
  @gists         = options.delete(:gists)
  @starred_gists = options.delete(:starred_gists)
  @wikis         = options.delete(:wikis)
  @config        = Config.new(options)
  @client        = Octokit::Client.new(:access_token => config.token)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/github-backup/backup.rb', line 3

def client
  @client
end

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/github-backup/backup.rb', line 3

def config
  @config
end

#debugObject (readonly)

Returns the value of attribute debug.



3
4
5
# File 'lib/github-backup/backup.rb', line 3

def debug
  @debug
end

#gistsObject (readonly)

Returns the value of attribute gists.



3
4
5
# File 'lib/github-backup/backup.rb', line 3

def gists
  @gists
end

#starred_gistsObject (readonly)

Returns the value of attribute starred_gists.



3
4
5
# File 'lib/github-backup/backup.rb', line 3

def starred_gists
  @starred_gists
end

#usernameObject (readonly)

Returns the value of attribute username.



3
4
5
# File 'lib/github-backup/backup.rb', line 3

def username
  @username
end

#wikisObject (readonly)

Returns the value of attribute wikis.



3
4
5
# File 'lib/github-backup/backup.rb', line 3

def wikis
  @wikis
end

Instance Method Details

#executeObject



15
16
17
18
19
20
21
22
# File 'lib/github-backup/backup.rb', line 15

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