Class: Baya::Adapters::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/baya/adapters/git.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Git

Returns a new instance of Git.



7
8
9
10
# File 'lib/baya/adapters/git.rb', line 7

def initialize(config)
  @config = config
  check_config
end

Instance Method Details

#archive(root) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/baya/adapters/git.rb', line 12

def archive(root)
  destination = root + '/' + @config['destination']
  if File.directory?(destination)
    begin
      g = ::Git.open(destination)
      g.pull
    rescue ArgumentError => e
      raise "Folder exists and is not a Git repository: #{destination}"
    end
  else
    ::Git.clone(@config['origin'], destination)
  end
end