Class: Gitignores::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/gitignores/fetcher.rb

Overview

Encapsulate Git commands in this helper class in order to help mock the command line

Instance Method Summary collapse

Instance Method Details

#clone(repository, directory) ⇒ Object

Raises:



40
41
42
43
# File 'lib/gitignores/fetcher.rb', line 40

def clone(repository, directory)
  system('git', 'clone', repository, directory)
  raise GitCloneError, "Failed to clone #{repository}" unless $?.success?
end

#pull(directory) ⇒ Object



45
46
47
48
49
50
# File 'lib/gitignores/fetcher.rb', line 45

def pull(directory) 
  Dir.chdir(directory) {
    system('git', 'pull')
    raise GitPullError, "Failed to pull in #{directory}" unless $?.success?
  }
end