Class: GithubBackup::Repository

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

Direct Known Subclasses

Gist, Wiki

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sawyer_resource, opts = {}) ⇒ Repository

Returns a new instance of Repository.



5
6
7
8
# File 'lib/github-backup/repository.rb', line 5

def initialize(sawyer_resource, opts = {})
  @sawyer_resource = sawyer_resource
  @shell = opts[:shell] || Shell.new
end

Instance Attribute Details

#sawyer_resourceObject (readonly)

Returns the value of attribute sawyer_resource.



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

def sawyer_resource
  @sawyer_resource
end

#shellObject (readonly)

Returns the value of attribute shell.



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

def shell
  @shell
end

Instance Method Details

#backup(backup_root) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/github-backup/repository.rb', line 10

def backup(backup_root)
  full_backup_path = File.join(backup_root, backup_path)

  puts "Backing up #{ full_backup_path }"

  if File.exist?(full_backup_path)
    backup_repository_incremental(full_backup_path)
  else
    backup_repository_initial(full_backup_path)
  end
end

#backup_pathObject



26
27
28
# File 'lib/github-backup/repository.rb', line 26

def backup_path
  "#{ sawyer_resource.full_name }.git"
end

#clone_urlObject



22
23
24
# File 'lib/github-backup/repository.rb', line 22

def clone_url
  sawyer_resource.ssh_url
end